[R] How can I use the predict function in R in a logistic regression fitted years ago?

S Ellison S.Ellison at lgcgroup.com
Wed Oct 9 14:22:07 CEST 2013



> Suppose that you have a logistic equation regression (binary model) from an
> old model that you estimated some years ago. Therefore you know the
> parameters âk (k = 1, 2, ..., p) because they were estimated in the
> past.
> But you don't have the data that were used to fit the model.
> 
> My question is: can I introduce this old estimated logistic model in R as
> an object (corresponding to a logistic regression model)?

You have not said how you fitted the model, so you could have anything from an lm() object to glm, passing through various max likelihood and optimisation routines on the way, so the answer is properly 'maybe'.

Having said that, for most practical purposes I think the answer is in practice 'no'. All the predict methods would require you to construct an object with the right class, containing as a minimum the parts of the object used by the relevant predict() method. For example, if you look at the code in predict.glm, one of the more common logistic modelling tools, that passes the fitted object to predict.lm and then uses an inverse link function to bring the predictions back into the binomial family space. So you will at least need to create enough of an object to keep predict.lm happy. That in turn will need things like the terms object, the contrasts, the call offset and so on. It also uses the object's residuals (for their length, if nothing else) and of course if you want standard errors on fit or prediction you'll need other things. Without the data that will all be very problematic and very tedious to invent.

It would be far quicker to write a simple function that does the prediction for you from the parameters.

S Ellison



*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list