[R] Use glm coefficients for other datasets
peter dalgaard
pdalgd at gmail.com
Wed Feb 9 16:17:07 CET 2011
On Feb 9, 2011, at 04:16 , maxsilva wrote:
>
> Thank you for your kindness, but ive done what you've said and the problem
> remains. What im doing is pretty straightforward,
>
...
>> model<-glm(data$response~data$pred1+datos$pred2,
> family=binomial(link="logit"))
Just in case what Dennis said didn't take: The above is your problem. You need to setup a model formula that applies both within "data" and "sdata", so drop the data$ prefix
glm(response ~ pred2 + pred2, data=data)
otherwise, predict() goes looking for data$pred1 etc. and finds the same ones that got used in the model.
... and of course, they have the wrong length:
>
>> pred<- predict(model, newdata=sdata,type="response")
> Mensajes de aviso perdidos
> 'newdata' had 5 rows but variable(s) found have 10 rows
--
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
More information about the R-help
mailing list