How to predict a new value using simple linear reg

2019-07-11 06:07发布

问题:

How to predict a new given value of body using the ml2 model below, and interpret its output (new predicted output only, not model)

Using Animals dataset from MASS package to build a simple linear regression model

ml2<-lm(log(brain)~log(body),data=Animals)

predict a new given body of 468

pred_body<-data.frame(body=c(468))

predict(ml2,new, interval="confidence")

       fit      lwr      upr
1 5.604506 4.897498 6.311513

But i am not so sure predicted y(brain) =5.6 or log(brain)=5.6?

How could we get the predicted value with the same scale as it original?

回答1:

With a formula log(brain) ~ log(body), the response variable is log(brain). So when you make prediction using predict(), you get fitted values and prediction interval for log(brain).

To get corresponding results on original scale, do

exp(predict(ml2,new, interval="confidence"))