# what is the difference between using function predict() and coef() in prediction

5 messages
Open this post in threaded view
|

## what is the difference between using function predict() and coef() in prediction

 i do not know what is the difference between predict() and coef() i use the two function give me different result zz = predict(xy.lm,list(T8=T8)) ss = coef(xy.lm)[1]+(coef(xy.lm)[2])*T8 where is t8 is the data used in prediction did not use in the fitting in training sample where every sample is 15 value
Open this post in threaded view
|

## Re: what is the difference between using function predict() and coef() in prediction

 Hi Did you find any difference? The results shall be same (with only rounding error). Can you show us some example where you get substantial difference? Regards Petr > > i do not know what is the difference between predict() and coef() > i use the two function give me different result > zz = predict(xy.lm,list(T8=T8)) > ss = coef(xy.lm)[1]+(coef(xy.lm)[2])*T8 > where is t8 is the data used in prediction did not use in the fitting in > training sample where every sample is 15 value > > > -- > View this message in context: http://r.789695.n4.nabble.com/what-is-the-> difference-between-using-function-predict-and-coef-in-prediction- > tp4173961p4173961.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: what is the difference between using function predict() and coef() in prediction

 X8 = c(0.42808332,  0.14058333,  0.30558333,  0.09558333,  0.01808333, -0.09191666, -0.11441666, -0.12941666,  0.13808333, -0.31691666,  0.25308333 ,-0.20941666 ,0.02808333, -0.04441667, -0.43691666)   xy.lm =  lm(Y~X8) z = predict(xy.lm,list(X8=X8)) sz = coef(xy.lm)[1]+(coef(xy.lm)[2])*X8 is the same result in this step but when use the prediction as T8=c(-0.05691667, -0.09441666 , 0.31308333 ,-0.59941665 ,-0.33941666 ,-0.64441665,-0.55691665 ,-0.01191667  ,0.22558333, -0.30691666  ,0.97808331 , 0.49808332,-0.30941666  ,0.41808332 , 0.42308332) zz = predict(xy.lm,list(T8=T8)) ss = coef(xy.lm)[1]+(coef(xy.lm)[2])*T8 here gives me different  value and  zz = z = sz i do not know the reason for that what i understand about predict() act exactly like using coef() but now do not know  the difference thank you for respond   -- View this message in context: http://r.789695.n4.nabble.com/what-is-the-difference-between-using-function-predict-and-coef-in-prediction-tp4173961p4180577.htmlSent from the R help mailing list archive at Nabble.com. ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.