2
$\begingroup$

I want to recreate a regression model based on what was given in a scientific paper. They gave intercept and coefficient terms.

I know how to create regression models in R, but is this possible to do without the original database?

I would use these models on my own database to perform model comparison and test their predictive capabilities.

The special case here is that I am mostly interested in logistic regression. But I guess this question is scalable to all types of regression models.

So in other words: how can we create regression model objects (e.g. glm) using only beta values.

$\endgroup$
  • 1
    $\begingroup$ A working example of doing this with a logistic regression model, starting with the coefficients only, appears in the first block of code at stats.stackexchange.com/a/40609/919. An example with Poisson models is at stats.stackexchange.com/a/45789/919. Note that at a minimum you will also need somehow to specify the values of the independent variables. $\endgroup$ – whuber Aug 17 '16 at 18:41
  • $\begingroup$ Related SO question that didn't get any answer : stackoverflow.com/questions/56703403/…. Building the P(Y=1) function from coefficients is one thing but embedding it in a standard R object is another. I have reached the conclusion that it is not something you want to achieve. A standard R model object will allow you to use a lot of functions but most of them will give you bad results because the glm model contain a lot more informations : Std. Error, z value, Pr(>|z|) for coefficients. $\endgroup$ – lcrmorin Aug 20 '19 at 13:38
0
$\begingroup$

I think all you need to do is "score" (create a new column in your database that contains the predicted values for each record in your database) using the regression model coefficients and functional form of the model (for linear regression example, y = XB where y is the predicted value from the regression model, X is your database, and B is a vector with the model coefficients).

I'm not sure of the exact functional form of your regression model but in R you can write the equation from the command line:

y <- a + b*x

Hope this helps

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ statistics.ats.ucla.edu/stat/r/dae/logit.htm $\endgroup$ – Brian Griner Aug 17 '16 at 17:09
  • $\begingroup$ Link to R code in previous comment $\endgroup$ – Brian Griner Aug 17 '16 at 17:11
  • 1
    $\begingroup$ The question focuses on GLMs, for which this approach will not work. For linear regression your model is incomplete: you need to add random noise to y. Its variance is one more parameter of the model. $\endgroup$ – whuber Aug 17 '16 at 17:30
  • $\begingroup$ Agree if goal is simulating draws from model distribution. Prior post predicts model mean for a given set of covariates. $\endgroup$ – Brian Griner Aug 18 '16 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.