[R] Predictions with 'missing' variables

2011-01-25 Thread Axel Urbiz
Dear List,

I think I'm going crazy here...can anyone explain why do I get the same
predictions in train and test data sets below when the second has a missing
input?

y - rnorm(1000)
x1 - rnorm(1000)
x2 - rnorm(1000)
train - data.frame(y,x1,x2)
test - data.frame(x1)

myfit - glm(y ~ x1 + x2, data=train)
summary(myfit)
all(predict(myfit, test) == predict(myfit, train))

[1] TRUE



Thanks,

Axel.

[[alternative HTML version deleted]]

__
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] Predictions with 'missing' variables

2011-01-25 Thread Ista Zahn
See the note in the help page for ?predict.glm

Best,
Ista

On Tue, Jan 25, 2011 at 2:59 PM, Axel Urbiz axel.ur...@gmail.com wrote:
 Dear List,

 I think I'm going crazy here...can anyone explain why do I get the same
 predictions in train and test data sets below when the second has a missing
 input?

 y - rnorm(1000)
 x1 - rnorm(1000)
 x2 - rnorm(1000)
 train - data.frame(y,x1,x2)
 test - data.frame(x1)

 myfit - glm(y ~ x1 + x2, data=train)
 summary(myfit)
 all(predict(myfit, test) == predict(myfit, train))

 [1] TRUE



 Thanks,

 Axel.

        [[alternative HTML version deleted]]

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




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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