This function saves rms attributes with the fit object so that anova.rms, Predict, etc. can be used just as with ols and other fits. No validate or calibrate methods exist for Glm though.

Glm(
  formula,
  family = gaussian,
  data = environment(formula),
  weights,
  subset,
  na.action = na.delete,
  start = NULL,
  offset = NULL,
  control = glm.control(...),
  model = TRUE,
  method = "glm.fit",
  x = FALSE,
  y = TRUE,
  contrasts = NULL,
  ...
)

Arguments

formula, family, data, weights, subset, na.action, start, offset, control, model, method, x, y, contrasts

see stats::glm(); for print x is the result of Glm

...

ignored

Value

a fit object like that produced by stats::glm() but with rms attributes and a class of "rms", "Glm", "glm", and "lm". The g element of the fit object is the \(g\)-index.

Details

For the print method, format of output is controlled by the user previously running options(prType="lang") where lang is "plain" (the default), "latex", or "html".

See also

stats::glm(),Hmisc::GiniMd(), prModFit(), stats::residuals.glm

Examples


## Dobson (1990) Page 93: Randomized Controlled Trial :
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
f <- glm(counts ~ outcome + treatment, family=poisson())
f
#> 
#> Call:  glm(formula = counts ~ outcome + treatment, family = poisson())
#> 
#> Coefficients:
#> (Intercept)     outcome2     outcome3   treatment2   treatment3  
#>   3.045e+00   -4.543e-01   -2.930e-01    6.972e-16    8.237e-16  
#> 
#> Degrees of Freedom: 8 Total (i.e. Null);  4 Residual
#> Null Deviance:	    10.58 
#> Residual Deviance: 5.129 	AIC: 56.76
anova(f)
#> Analysis of Deviance Table
#> 
#> Model: poisson, link: log
#> 
#> Response: counts
#> 
#> Terms added sequentially (first to last)
#> 
#> 
#>           Df Deviance Resid. Df Resid. Dev Pr(>Chi)  
#> NULL                          8    10.5814           
#> outcome    2   5.4523         6     5.1291  0.06547 .
#> treatment  2   0.0000         4     5.1291  1.00000  
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
summary(f)
#> 
#> Call:
#> glm(formula = counts ~ outcome + treatment, family = poisson())
#> 
#> Coefficients:
#>               Estimate Std. Error z value Pr(>|z|)    
#> (Intercept)  3.045e+00  1.709e-01  17.815   <2e-16 ***
#> outcome2    -4.543e-01  2.022e-01  -2.247   0.0246 *  
#> outcome3    -2.930e-01  1.927e-01  -1.520   0.1285    
#> treatment2   6.972e-16  2.000e-01   0.000   1.0000    
#> treatment3   8.237e-16  2.000e-01   0.000   1.0000    
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> (Dispersion parameter for poisson family taken to be 1)
#> 
#>     Null deviance: 10.5814  on 8  degrees of freedom
#> Residual deviance:  5.1291  on 4  degrees of freedom
#> AIC: 56.761
#> 
#> Number of Fisher Scoring iterations: 4
#> 
f <- Glm(counts ~ outcome + treatment, family=poisson())
# could have had rcs( ) etc. if there were continuous predictors
f
#> General Linear Model
#> 
#> Glm(formula = counts ~ outcome + treatment, family = poisson())
#> 
#>                    Model Likelihood    
#>                          Ratio Test    
#>        Obs   9    LR chi2      5.45    
#> Residual d.f.4    d.f.            4    
#>        g 0.227    Pr(> chi2) 0.2440    
#> 
#>             Coef    S.E.   Wald Z Pr(>|Z|)
#> Intercept    3.0445 0.1709 17.81  <0.0001 
#> outcome=2   -0.4543 0.2022 -2.25  0.0246  
#> outcome=3   -0.2930 0.1927 -1.52  0.1285  
#> treatment=2  0.0000 0.2000  0.00  1.0000  
#> treatment=3  0.0000 0.2000  0.00  1.0000  
#> 
anova(f)
#>                 Wald Statistics          Response: counts 
#> 
#>  Factor     Chi-Square d.f. P     
#>  outcome    5.49       2    0.0643
#>  treatment  0.00       2    1.0000
#>  TOTAL      5.49       4    0.2409
summary(f, outcome=c('1','2','3'), treatment=c('1','2','3'))
#>              Effects              Response : counts 
#> 
#>  Factor          Low High Diff. Effect      S.E.    Lower 0.95 Upper 0.95
#>  outcome - 1:2   2   1    NA     4.5426e-01 0.20217 -0.10706   1.01560   
#>  outcome - 3:2   2   3    NA     1.6127e-01 0.21512 -0.43600   0.75854   
#>  treatment - 1:2 2   1    NA    -6.9715e-16 0.20000 -0.55529   0.55529   
#>  treatment - 3:2 2   3    NA     1.2657e-16 0.20000 -0.55529   0.55529   
#>