[R] User error in calling predict/model.frame

Russell Pierce rpier001 at ucr.edu
Sat Jan 29 20:41:13 CET 2011


Thanks for your feedback. However, I think if you look at the mean of
your output (which, as a minor point, doesn't provide the same data to
predict as expand.grid(X1=c(-1,0,1),X2=c(-1,0,1)), you'll see it is
very different from the mean of dat$out.  Like Ista's previous answer,
I think in your case the predict function acts on xxA and xxB (as if
renaming the newdata to dat[1:2] in Ista's case) and acts as if they
were in their original scale, that is, it doesn't treat the predictors
as Z scores.  As a result, the yhat values are different from what
should be expected.

Russell S. Pierce, M.A.
Visual Cognition Lab
Department of Psychology
University of California, Riverside
900 University Avenue
Riverside, CA 92521
Lab Phone: (951) 827-7399

On Sat, Jan 29, 2011 at 11:10 AM, David Winsemius
<dwinsemius at comcast.net> wrote:
> ms.res <- glm(out ~ scale(xxA)*scale(xxB), data=dat)
> newdata <- predict(rms.res, newdata=data.frame(xxA=c(-1,0,1),xxB=c(-1,0,1)))

More information about the R-help mailing list