Search code examples
rstatisticsglmmodelingauc

Is there a way to reuse a glm fit, if all I have is the model fit call and summary?


I'm working from a project built by a previous programmer. The call to glm() the programmer has in their documentation is

glm(formula = AVAL ~ AUC, family = binomial(), data = logreg.dat)

I have the output from that code, but none of the data used to build the model.

Deviance Residuals:
Min 1Q Median 3Q Max
-0.5991 -0.4784 -0.4220 -0.3028 2.7425

Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.62668 0.34738 -4.683 2.83e-06 ***
AUC -0.14730 0.07448 -1.978 0.048 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 119.87 on 193 degrees of freedom
Residual deviance: 113.23 on 192 degrees of freedom
AIC: 117.23

Number of Fisher Scoring iterations: 6

Is there a way to rebuild this fit? I'd like to use the fit to simulate out some new AVAL data based on a new AUC vector.


Solution

  • If I correctly understand, you want to simulate the model using the estimates of the fit for the parameters. You can do:

    # take the estimates from the output
    intercept <- -1.62668
    slope <- -0.14730 
    
    # new AUC values
    AUC <- c(1, 2, 3, 4, 5)
    
    # simulate AVAL values
    logit_probs <- intercept + slope * AUC
    probs <- 1 / (1 + exp(-logit_probs))
    n <- length(AUC)
    rbinom(n, 1, probs)