Skip to content

predict.glm

3 messages · Maurice Charbit, Peter Ehlers, David Winsemius

#
Maurice,

The 'newdata' argument should be a data.frame with the
same names as used for your predictors in the glm formula.

For the data you quote below (after fixing the missing y1),
try:

yhat <- predict(reg1, newdata = data.frame(x1 = x2))
length(yhat)
[1] 200

A careful reading of ?predict would have told you that:

"newdata    optionally, a data frame in which to look for
             variables with which to predict."

If that is not your problem, perhaps you could give an
example with data and code that illustrates your problem.

  -Peter Ehlers
Maurice Charbit wrote:

  
    
#
On Jan 16, 2010, at 1:34 PM, Maurice Charbit wrote:

            
You are replying to a posting that is almost two years old. The  
posting back then was incomplete in that y1 was never defined. Why not  
post a more complete and updated question?