On Dec 10, 2011, at 11:48 AM, tony333 wrote:


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

The first "T8" should be..^^ .... "X8"

> zz = predict(xy.lm,data.frame(X8=T8))
> ss = coef(xy.lm)[1]+(coef(xy.lm)[2])*T8

> identical(unname(zz), ss)
[1] TRUE

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

If you give predict alist or data.fram whose name is different than that of the origianl variable ist will be ignored.

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.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org 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.

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org 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.

Reply via email to