publish.glm: Tabulize regression coefficients with confidence intervals...

Description Usage Arguments Details Value Author(s) Examples

View source: R/publish.glm.R

Description

Tabulate the results of a generalized linear regression analysis.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## S3 method for class 'glm'
publish(
  object,
  confint.method,
  pvalue.method,
  digits = c(2, 4),
  print = TRUE,
  factor.reference = "extraline",
  intercept = ifelse((is.null(object$family) || object$family$family == "gaussian"),
    1L, 0L),
  units = NULL,
  ...
)

Arguments

object

A glm object.

confint.method

See regressionTable.

pvalue.method

See regressionTable.

digits

A vector of two integer values. These determine how to round numbers (first value) and p-values (second value). E.g., c(1,3) would mean 1 digit for all numbers and 3 digits for p-values. The actual rounding is done by summary.regressionTable.

print

If FALSE do not print results.

factor.reference

Style for showing results for categorical. See regressionTable.

intercept

See regressionTable.

units

See regressionTable.

...

passed to summary.regressionTable and also to labelUnits.

reference

Style for showing results for categorical variables. If "extraline" show an additional line for the reference category.

Details

The table shows changes in mean for linear regression and odds ratios for logistic regression (family = binomial).

Value

Table with regression coefficients, confidence intervals and p-values.

Author(s)

Thomas Alexander Gerds <tag@biostat.ku.dk>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
data(Diabetes)
## Linear regression
f = glm(bp.2s~frame+gender+age,data=Diabetes)
publish(f)
publish(f,factor.reference="inline")
publish(f,pvalue.stars=TRUE)
publish(f,ci.format="(l,u)")

### interaction
fit = glm(bp.2s~frame+gender*age,data=Diabetes)
summary(fit)
publish(fit)

Fit = glm(bp.2s~frame*gender+age,data=Diabetes)
publish(Fit)

## Logistic regression
Diabetes$hyper1 <- factor(1*(Diabetes$bp.1s>140))
lrfit <- glm(hyper1~frame+gender+age,data=Diabetes,family=binomial)
publish(lrfit)

### interaction
lrfit1 <- glm(hyper1~frame+gender*age,data=Diabetes,family=binomial)
publish(lrfit1)

lrfit2 <- glm(hyper1~frame*gender+age,data=Diabetes,family=binomial)
publish(lrfit2)

## Poisson regression
data(trace)
trace <- Units(trace,list("age"="years"))
fit <- glm(dead ~ smoking+sex+age+Time+offset(log(ObsTime)), family="poisson",data=trace)
rtf <- regressionTable(fit,factor.reference = "inline")
summary(rtf)
publish(fit)

## gls regression
if (requireNamespace("nlme",quietly=TRUE)){
    requireNamespace("lava",quietly=TRUE)
library(lava)
library(nlme)
m <- lvm(Y ~ X1 + gender + group + Interaction)
distribution(m, ~gender) <- binomial.lvm()
distribution(m, ~group) <- binomial.lvm(size = 2)
constrain(m, Interaction ~ gender + group) <- function(x){x[,1]*x[,2]}
d <- sim(m, 1e2)
d$gender <- factor(d$gender, labels = letters[1:2])
d$group <- factor(d$group)

e.gls <- gls(Y ~ X1 + gender*group, data = d,
             weights = varIdent(form = ~1|group))
publish(e.gls)

## lme
fm1 <- lme(distance ~ age*Sex, 
            random = ~1|Subject,
            data = Orthodont) 
res <- publish(fm1)
}

Example output

Loading required package: prodlim
    Variable  Units Coefficient           CI.95  p-value 
 (Intercept)             128.00 [112.52;143.48]   <1e-04 
       frame  large         Ref                          
             medium       -1.38    [-9.79;7.04]   0.7492 
              small       -1.61   [-12.71;9.48]   0.7765 
      gender female         Ref                          
               male       -1.50    [-8.80;5.79]   0.6867 
         age               0.52     [0.28;0.76]   <1e-04 
    Variable           Units Coefficient           CI.95  p-value 
 (Intercept)                      128.00 [112.52;143.48]   <1e-04 
       frame medium vs large       -1.38    [-9.79;7.04]   0.7492 
              small vs large       -1.61   [-12.71;9.48]   0.7765 
      gender  male vs female       -1.50    [-8.80;5.79]   0.6867 
         age                        0.52     [0.28;0.76]   <1e-04 
    Variable  Units Coefficient           CI.95  p-value signif 
 (Intercept)             128.00 [112.52;143.48]   <1e-04    *** 
       frame  large         Ref                                 
             medium       -1.38    [-9.79;7.04]   0.7492        
              small       -1.61   [-12.71;9.48]   0.7765        
      gender female         Ref                                 
               male       -1.50    [-8.80;5.79]   0.6867        
         age               0.52     [0.28;0.76]   <1e-04    *** 
    Variable  Units Coefficient           CI.95  p-value 
 (Intercept)             128.00 (112.52,143.48)   <1e-04 
       frame  large         Ref                          
             medium       -1.38    (-9.79,7.04)   0.7492 
              small       -1.61   (-12.71,9.48)   0.7765 
      gender female         Ref                          
               male       -1.50    (-8.80,5.79)   0.6867 
         age               0.52     (0.28,0.76)   <1e-04 

Call:
glm(formula = bp.2s ~ frame + gender * age, data = Diabetes)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-29.904  -13.246   -5.236   11.450   82.084  

Coefficients:
                Estimate Std. Error t value Pr(>|t|)    
(Intercept)    129.53581    9.40658  13.771  < 2e-16 ***
framemedium     -1.47393    4.31958  -0.341  0.73350    
framesmall      -1.78372    5.70929  -0.312  0.75523    
gendermale      -5.38769   13.30675  -0.405  0.68624    
age              0.49342    0.15279   3.229  0.00158 ** 
gendermale:age   0.07737    0.25448   0.304  0.76160    
---
Signif. codes:  0***0.001**0.01*0.05.’ 0.1 ‘ ’ 1

(Dispersion parameter for gaussian family taken to be 432.4405)

    Null deviance: 63881  on 133  degrees of freedom
Residual deviance: 55352  on 128  degrees of freedom
  (269 observations deleted due to missingness)
AIC: 1201.4

Number of Fisher Scoring iterations: 2

            Variable  Units Coefficient           CI.95    p-value 
         (Intercept)             129.54 [111.10;147.97]    < 1e-04 
               frame  large         Ref                            
                     medium       -1.47    [-9.94;6.99]   0.733496 
                      small       -1.78   [-12.97;9.41]   0.755227 
 age: gender(female)               0.49     [0.19;0.80]   0.001577 
   age: gender(male)               0.57     [0.17;0.97]   0.005949 
                               Variable Units Coefficient           CI.95  p-value 
                            (Intercept)            123.52 [105.43;141.60]   <1e-04 
                                    age              0.54     [0.30;0.78]   <1e-04 
   frame(large): gender(male vs female)              4.26   [-9.95;18.47]   0.5541 
  frame(medium): gender(male vs female)             -3.15   [-12.93;6.64]   0.5258 
   frame(small): gender(male vs female)             -5.19  [-23.44;13.07]   0.5748 
 gender(female): frame(medium vs large)              2.91   [-9.88;15.69]   0.6536 
  gender(female): frame(small vs large)              3.31  [-12.35;18.98]   0.6764 
   gender(male): frame(medium vs large)             -4.50   [-16.00;7.00]   0.4405 
    gender(male): frame(small vs large)             -6.14  [-23.08;10.81]   0.4750 
 Variable  Units OddsRatio       CI.95   p-value 
    frame  large       Ref                       
          medium      0.85 [0.49;1.48]   0.57161 
           small      0.45 [0.23;0.90]   0.02281 
   gender female       Ref                       
            male      0.85 [0.52;1.38]   0.51478 
      age             1.06 [1.04;1.07]   < 1e-04 
            Variable  Units OddsRatio       CI.95   p-value 
               frame  large       Ref                       
                     medium      0.80 [0.45;1.39]   0.42332 
                      small      0.41 [0.20;0.83]   0.01293 
 age: gender(female)             1.09 [1.06;1.11]   < 1e-04 
   age: gender(male)             1.02 [1.00;1.05]   0.05602 
                               Variable Units OddsRatio       CI.95   p-value 
                                    age            1.06 [1.04;1.07]   < 1e-04 
   frame(large): gender(male vs female)            0.55 [0.23;1.31]   0.17745 
  frame(medium): gender(male vs female)            1.02 [0.51;2.03]   0.95775 
   frame(small): gender(male vs female)            1.10 [0.37;3.25]   0.87006 
 gender(female): frame(medium vs large)            0.62 [0.28;1.35]   0.23035 
  gender(female): frame(small vs large)            0.32 [0.13;0.81]   0.01595 
   gender(male): frame(medium vs large)            1.14 [0.52;2.50]   0.74015 
    gender(male): frame(small vs large)            0.64 [0.22;1.81]   0.39616 
  Variable             Units HazardRatio       CI.95   p-value
1  smoking  Current vs Never        1.09 [1.01;1.19]   0.02863
2          Previous vs Never        1.08 [1.00;1.16]   0.04139
3      sex    Male vs Female        1.09 [1.02;1.16]   0.00632
4      age                          1.07 [1.07;1.08]   < 0.001
5     Time                          1.00 [1.00;1.00]   < 0.001
  Variable             Units HazardRatio       CI.95   p-value
1  smoking  Current vs Never        1.09 [1.01;1.19]   0.02863
2          Previous vs Never        1.08 [1.00;1.16]   0.04139
3      sex    Male vs Female        1.09 [1.02;1.16]   0.00632
4      age                          1.07 [1.07;1.08]   < 0.001
5     Time                          1.00 [1.00;1.00]   < 0.001
 Variable    Units HazardRatio       CI.95    p-value 
  smoking    Never         Ref                        
           Current        1.09 [1.01;1.19]   0.028634 
          Previous        1.08 [1.00;1.16]   0.041394 
      sex   Female         Ref                        
              Male        1.09 [1.02;1.16]   0.006317 
      age                 1.07 [1.07;1.08]    < 1e-04 
     Time                 1.00 [1.00;1.00]    < 1e-04 
Error in eval(parse(text = misscall), data) : object 'gender' not found
                 Variable Units Coefficient        CI.95   p-value 
              (Intercept)              0.09 [-0.45;0.63]   0.74973 
                       X1              0.86  [0.68;1.05]   < 1e-04 
 gender(a): group(1 vs 0)              0.71  [0.07;1.35]   0.02909 
 gender(a): group(2 vs 0)              2.06  [1.31;2.81]   < 1e-04 
 gender(b): group(1 vs 0)              2.34  [1.63;3.05]   < 1e-04 
 gender(b): group(2 vs 0)              4.04  [3.31;4.77]   < 1e-04 
 group(0): gender(b vs a)              0.80 [-0.01;1.62]   0.05294 
 group(1): gender(b vs a)              2.43  [1.95;2.92]   < 1e-04 
 group(2): gender(b vs a)              2.78  [2.12;3.45]   < 1e-04 
Error in eval(parse(text = misscall), data) : object 'age' not found
         Variable Units Coefficient         CI.95 p-value 
      (Intercept)             16.34 [14.39;18.29] < 1e-04 
   age: Sex(Male)              0.78   [0.63;0.94] < 1e-04 
 age: Sex(Female)              0.48   [0.30;0.66] < 1e-04 

Publish documentation built on Jan. 8, 2021, 5:37 p.m.