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

2011-12-10 Thread tony333

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


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

2011-12-10 Thread tony333
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.6  , 887.6  ,3610.88333 ,  435.1 , 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.

__
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.


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

2011-12-10 Thread David Winsemius


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.


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

2011-12-09 Thread Petr PIKAL
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.
 
 __
 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.

__
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.


[R] what is the difference between using function predict() and coef() in prediction

2011-12-08 Thread tony333
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.

__
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.