Please can some one help me check my R code ### Question 3 reg.data <- read.tabl
ID: 3378889 • Letter: P
Question
Please can some one help me check my R code
### Question 3
reg.data <- read.table("E:\Applied Multivariate Analysis\Assignments\HW 3\housing_1.txt",header=F)
names(reg.data) <- c("CRIM","ZN","INDUS","CHAS","NOX","RM","AGE","DIS","RAD","TAX","PTRATIO","B","LSTAT","MEDV")
attach (reg.data)
reg.data
#### summary Statistics
scores<-cbind(CRIM, NOX, RM, RAD, MEDV)
summary(scores)
#### Regression Model
attach (reg.data)
model1 <- lm(MEDV ~ CRIM + ZN + INDUS + CHAS + NOX + RM + AGE + DIS + RAD + TAX + PTRATIO + B + LSTAT)
anova(model1)
summary(model1)
summary.lm(model1)
# Y Predictions
pred.one <- predict(object = model1, newdata= reg.data)
pred.one
# Means Square Prediction error
mspr1 <- sum((reg.data$MEDV – pred.one)^2)
mspr1
Explanation / Answer
The R code is correct.
i am also providing some commands for linear regression along with an example.