[R] predict

Bill.Venables at csiro.au Bill.Venables at csiro.au
Thu Jul 30 06:17:22 CEST 2009


Your 'newdata' is a vector.  To us predict() the newdata supplied must be a data frame, with components having the same names as the predictors used in the model.  If some of the variables are factors, then the corresponding factors in the newdata data frame must have the same names and the same levels as the original factors used in fitting the model *even if* not all levels are needed for the prediction.

This is a precise sort of area.  You may need to study the help information in a bit more detail.  predict() does work, if only you use it correctly.


Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of serbring
Sent: Wednesday, 29 July 2009 11:31 PM
To: r-help at r-project.org
Subject: [R] predict


I have found a regression model, and i would like to predict value in
different points. I have tried to use predict function but it doesn't work.
I have used predict function like this:

newdata<-seq(from=0.1, to=0.32,by=0.02)
data<-predict(fm,newdata)

where fm is a regression model. The predict function return me that:

Error in eval(predvars, data, env) :   numeric argument 'envir' doesn't have
unitary length

where is the error?


-- 
View this message in context: http://www.nabble.com/predict-tp24719362p24719362.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at 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.




More information about the R-help mailing list