1 Replies - 498 Views - Last Post: 18 June 2017 - 02:22 PM Rate Topic: -----

#1 program94  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 19-April 14

Help with R Programming

Posted 18 June 2017 - 12:45 PM

I am working with the auto data in the ISLR library in R

1) Test on the test data using the predict function. Find the correlation between the predicted values and the mpg values in the test data. Comment on the results. Calculate the mse on the test results. Compare this to the mse for the training data

 

pred <- predict(lmlinreg, newdata = test)
cor(pred, test$mpg)




Error: Error in predict.lm(lmlinreg, newdata = test) : object 'test' not found

Is This A Good Question/Topic? 0
  • +

Replies To: Help with R Programming

#2 program94  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 19-April 14

Re: Help with R Programming

Posted 18 June 2017 - 02:22 PM

1 7. Create a second linear model with log(mpg) predicted by horsepower. Compare the summary statistic R^2 of the two models

lmlinreg1 <- lm(log(mpg) ~ horsepower, data = Auto)
summary(lmlinreg1)




I think I did 1 right but if you think I didnt please let me know

2 Plot the function with an abline(). Comment on how well the line fits the data.

 
plot.new()
plot(Auto$mpg, Auto$horsepower)
abline(reg = lmlinreg1, col = "red")



It is not right

3 Predict on the test data using lm2. Compare the correlation of the predictions with lm1. Calculate the MSE for the test data on lm2 and compare to lm1.

I have no idea about this please help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1