[R] what is the difference between using function predict() and coef() in prediction
tony333
tony333_6 at hotmail.com
Sat Dec 10 17:57:28 CET 2011
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)
Y =c(370.63333 , 887.63333 ,3610.88333 , 435.13333 , 1261.38333 ,
-741.11667,-3231.36667 ,-708.36667 ,-646.36667, -3652.86667 ,-2196.11667
,-5552.61667,-92.11667, -1635.86667 ,-3264.61667)
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-tp4173961p4180628.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list