How to predict a new value using simple linear regression log(y)=b0+b1*log(x)

随声附和 提交于 2019-12-24 00:24:22

问题


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"))


来源:https://stackoverflow.com/questions/44479952/how-to-predict-a-new-value-using-simple-linear-regression-logy-b0b1logx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!