[R] glm predict issue

Giovanni Azua bravegag at gmail.com
Mon Dec 26 17:03:15 CET 2011


Hi Ben,

Yes thanks you are right, I was able to fix it but first I had to fix the data frame over which I built my model to use numeric for those and then making the grid values also numeric it finally worked thanks!

Thank you for your help!
Best regards,
Giovanni

On Dec 26, 2011, at 4:57 PM, Ben Bolker wrote:

> Giovanni Azua <bravegag <at> gmail.com> writes:
> 
>> 
>> Hello,
>> 
>> I have tried reading the documentation and googling for the answer but
> reviewing the online matches I end up
>> more confused than before.
>> 
>> My problem is apparently simple. I fit a glm model (2^k experiment), and then
> I would like to predict the
>> response variable (Throughput) for unseen factor levels.
>> 
>> When I try to predict I get the following error:
>>> throughput.pred <- predict(throughput.fit,experiments,type="response")
>> Error in model.frame.default(Terms, newdata, na.action = na.action, xlev =
> object$xlevels) : 
>>  factor 'No_databases' has new level(s) 200, 400, 600, 800, 1000
>> 
>> Of course these are new factor levels, it is exactly what I am trying to
> achieve i.e. extrapolate the values
>> of Throughput.
>> 
>> Can anyone please advice? Below I include all details.
> 
>  Any predictors that you want to treat as continuous
> (which would be the only way you can extrapolate to unobserved
> values) should be numeric, not factor variables -- use 
> 
> mydata <- transform(mydata, var=as.numeric(var))
> 
> for example.
> 
> ______________________________________________
> 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