CS计算机代考程序代写 # BS1033 Lecture 1 Analysis Part 2

# BS1033 Lecture 1 Analysis Part 2
# Author: Chris Hansman
# Email: chansman@imperial.ac.uk
# Date : 07/01/20

# Installing Packages
#install.packages(“tidyverse”)

# Loading Libraries
library(tidyverse)

# Loading Ames Data
#Reading Data
ames_training<-read_csv("ames_training.csv") ames_testing<-read_csv("ames_testing.csv") #Scatter Plot ggplot(data = ames_training ) + geom_point(aes(x = Year.Built, y = log_price)) #Building Simple Linear Model ames_model_1 <- lm(log_price ~ Year.Built, data=ames_training) summary(ames_model_1) #Predicting and Computing Mean Squared Error log_price_pred1=predict(ames_model_1, newdata=ames_testing) model_1_mse <- mean((log_price_pred1-ames_testing$log_price)^2) #Scaling Variables # Scaling x ols_basics_scale <- ols_basics %>%
mutate(X_over_12=X/12) %>%
mutate(Y_times_1000=Y*1000)

# Basic Regression
ols_v1<-lm(Y~X, data= ols_basics) # Scaled X ols_v2<-lm(Y~X_over_12, data= ols_basics_scale) # Scaled Y ols_v3<-lm(Y_times_1000~X, data= ols_basics_scale) # Summarizing All summary(ols_v1) summary(ols_v2) summary(ols_v3)

Leave a Reply

Your email address will not be published. Required fields are marked *