Skip to contents

This page documents methods for objects returned by glm_weightit(), lm_weightit(), ordinal_weightit(), multinom_weightit(), and coxph_weightit(). predict() methods are described at predict.glm_weightit().

Usage

# S3 method for class 'glm_weightit'
summary(object, ci = FALSE, level = 0.95, transform = NULL, ...)

# S3 method for class 'multinom_weightit'
summary(object, ci = FALSE, level = 0.95, transform = NULL, ...)

# S3 method for class 'ordinal_weightit'
summary(
  object,
  ci = FALSE,
  level = 0.95,
  transform = NULL,
  thresholds = TRUE,
  ...
)

# S3 method for class 'coxph_weightit'
summary(object, ci = FALSE, level = 0.95, transform = NULL, ...)

# S3 method for class 'glm_weightit'
print(x, digits = max(3L, getOption("digits") - 3L), ...)

# S3 method for class 'glm_weightit'
vcov(object, complete = TRUE, ...)

# S3 method for class 'glm_weightit'
anova(object, object2, test = "Chisq", method = "Wald", tolerance = 1e-07, ...)

Arguments

object, object2, x

an output from one of the above modeling functions. For anova(), object2 is required.

ci

logical; whether to display Wald confidence intervals for estimated coefficients. Default is FALSE. (Note: this argument can also be supplied as conf.int.)

level

when ci = TRUE, the desired confidence level.

transform

the function used to transform the coefficients, e.g., exp (which can also be supplied as a string, e.g., "exp"); passed to match.fun() before being used on the coefficients. When ci = TRUE, this is also applied to the confidence interval bounds. If specified, the standard error will be omitted from the output. Default is no transformation.

...

ignored.

thresholds

logical; whether to include thresholds in the summary() output for ordinal_weightit objects. Default is TRUE.

digits

the number of significant digits to be passed to format(coef(x), .) when print()ing.

complete

logical; whether the full variance-covariance matrix should be returned also in case of an over-determined system where some coefficients are undefined and coef(.) contains NAs correspondingly. When complete = TRUE, vcov() is compatible with coef() also in this singular case.

test

the type of test statistic used to compare models. Currently only "Chisq" (the chi-square statistic) is allowed.

method

the kind of test used to compare models. Currently only "Wald" is allowed.

tolerance

for the Wald test, the tolerance used to determine if models are symbolically nested.

Value

summary() returns a summary.glm_weightit() object, which has its own print() method. For coxph_weightit() objects, the print() and summary() methods are more like those for glm objects then for coxph objects.

Otherwise, all methods return the same type of object as their generics.

Details

vcov() (which is called by summary()) simply extracts the covariance matrix already computed by the fitting function. confint() computes Wald confidence intervals (internally calling confint.lm()). The estfun() method for multinom_weightit and ordinal_weightit objects (which is used by function in the sandwich package to compute coefficient covariance matrices) simply extracts the gradient component of the object. For glm_weightit and coxph_weightit objects, the glm and coxph methods are dispatched instead.

anova() performs a Wald test to compare two fitted models. The models must be nested, but they don't have to be nested symbolically (i.e., the names of the coefficients of the smaller model do not have to be a subset of the names of the coefficients of the larger model). The larger model must be supplied to object and the smaller to object2. Both models must contain the same units, weights (if any), and outcomes. The variance-covariance matrix of the coefficients of the smaller model is not used, so it can be specified as "none" in the original model call. Otherwise, a warning be thrown if the covariances were computed using different methods.

See also

glm_weightit() for the page documenting glm_weightit(), lm_weightit(), ordinal_weightit(), multinom_weightit(), and coxph_weightit(). summary.glm(), vcov, confint() for the relevant methods pages. predict.glm_weightit() for computing predictions from the models.

Examples

## See more examples at ?glm_weightit

data("lalonde", package = "cobalt")

# Model comparison for any relationship between `treat`
# and `re78` (not the same as testing for the ATE)
fit1 <- glm_weightit(
  re78 ~ treat * (age + educ + race + married + nodegree +
                    re74 + re75), data = lalonde
)

fit2 <- glm_weightit(
  re78 ~ age + educ + race + married + nodegree +
    re74 + re75, data = lalonde
)

anova(fit1, fit2)
#> Wald test
#> 
#> Model 1: re78 ~ treat * (age + educ + race + married + nodegree + re74 + re75)
#> Model 2: re78 ~ age + educ + race + married + nodegree + re74 + re75
#>   Res.Df Df  Chisq Pr(>Chisq)  
#> 1    596                       
#> 2    605  9 17.563    0.04059 *
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

# Model comparison between spline model and linear
# model; note they are nested but not symbolically
# nested
fit_s <- glm_weightit(
  re78 ~ splines::ns(age, df = 4), data = lalonde
)

fit_l <- glm_weightit(
  re78 ~ age, data = lalonde
)

anova(fit_s, fit_l)
#> Wald test
#> 
#> Model 1: re78 ~ splines::ns(age, df = 4)
#> Model 2: re78 ~ age
#>   Res.Df Df  Chisq Pr(>Chisq)   
#> 1    609                        
#> 2    612  3 14.166   0.002688 **
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1