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() and anova() methods are described at
anova.glm_weightit().
Usage
# S3 method for class 'glm_weightit'
summary(object, ci = FALSE, level = 0.95, transform = NULL, vcov = NULL, ...)
# S3 method for class 'multinom_weightit'
summary(object, ci = FALSE, level = 0.95, transform = NULL, vcov = NULL, ...)
# S3 method for class 'ordinal_weightit'
summary(
object,
ci = FALSE,
level = 0.95,
transform = NULL,
thresholds = TRUE,
vcov = NULL,
...
)
# S3 method for class 'coxph_weightit'
summary(object, ci = FALSE, level = 0.95, transform = NULL, vcov = 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, vcov = NULL, ...)
# S3 method for class 'multinom_weightit'
hatvalues(model, ...)
# S3 method for class 'ordinal_weightit'
hatvalues(model, ...)
# S3 method for class 'glm_weightit'
estfun(x, asympt = NULL, ...)
# S3 method for class 'glm_weightit'
update(object, formula. = NULL, ..., evaluate = TRUE)Arguments
- object, x
an output from one of the above modeling functions.
- ci
logical; whether to display Wald confidence intervals for estimated coefficients. Default isFALSE. (Note: this argument can also be supplied asconf.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 tomatch.fun()before being used on the coefficients. Whenci = 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.- vcov
a string indicating the method used to compute the variance of the estimated parameters for
object; see thevcovargument ofglm_weightit()for the allowable options. Default is to use the variance matrix already present inobject, unlesscluster,R, orfwb.argsis supplied through..., in which case the variance matrix is recomputed using the method used to fitobjectwith the new arguments. A variance matrix computed another way can be supplied to functions in other packages that accept one (e.g., through thevcovargument of marginaleffects functions). (Note: forvcov(), can also be supplied astype.)- ...
for
vcov()orsummary()orconfint()withvcovsupplied, other arguments used to compute the variance matrix depending on the method supplied tovcov, e.g.,cluster,R, orfwb.args. Forupdate(), additional arguments to the call or arguments with changed values. Seeglm_weightit()for details.- thresholds
logical; whether to include thresholds in thesummary()output forordinal_weightitobjects. Default isTRUE.- digits
the number of significant digits to be passed to
format(coef(x), .)whenprint()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 andcoef(.)containsNAs correspondingly. Whencomplete = TRUE,vcov()is compatible withcoef()also in this singular case.- model
for
hatvalues(), an output fromordinal_weightit()ormultinom_weightit().- asympt
logical; forestfun(), whether to use the asymptotic empirical estimating functions that account for estimation of the weights (whenMpartsis available). Set toFALSEto ignore estimation of the weights. The default follows the variance the model was fit with:FALSEwhenvcovwas"HC0"or"const"andTRUEotherwise, so thatsandwich::sandwich()andsandwich::vcovCL()agree withvcov(). Ignored whenMpartsis not available or no argument was supplied toweightitin the fitting function.- formula.
changes to the model formula, passed to the
newargument ofupdate.formula().- evaluate
logical; whether to evaluate the call (TRUE, the default) or just return it.
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 than for coxph
objects.
Otherwise, all methods return the same type of object as their generics.
Details
vcov() by default extracts the parameter covariance matrix already
computed by the fitting function, and summary() and confint() use this
covariance matrix to compute standard errors and Wald confidence intervals
(internally calling confint.lm()), respectively. Supplying vcov, or
cluster, R, or fwb.args through ..., will compute a new covariance
matrix; when vcov is not supplied, the method used to fit object is used.
If cluster was supplied to the original fitting function, it will be
incorporated into any newly computed covariance matrix unless cluster = NULL is specified in vcov(), summary(), or confint(). R and
fwb.args likewise default to the values used to fit object, or to the
defaults of glm_weightit() when the original fit was not bootstrapped. Note that for
vcov = "BS" and vcov = "FWB", the environment for the
fitting function is used, so any changes to that environment may affect
calculation. It is always safer to simply recompute the fitted object with a
new covariance matrix than to modify it with the vcov argument, but it can
be quicker to just request a new covariance matrix when refitting the model
is slow.
update() updates a fitted model object with new arguments, e.g., a new
model formula, dataset, or variance matrix. When only arguments that control
the computation of the variance are supplied, only the variance will be
recalculated (i.e., the parameters will not be re-estimated). When data is
supplied, weightit is not supplied, and a weightit object was originally
passed to the model fitting function, the weightit object will be re-fit
with the new dataset before the model is refit using the new weights and new
data. That is, calling update(obj, data = d) is equivalent to calling
update(obj, data = d, weightit = update(obj$weightit, data = d)) when a
weightit object was supplied to the model fitting function. Similarly,
supplying s.weights or weights passes the argument through to
weightit() to be refit. When s.weights or weights are supplied and no
weightit object is present, they are supplied to the weights argument of
the model fitting function, which treats them as fixed. Supplying weightit
replaces any weights supplied to the original call.
estfun() extracts the empirical estimating functions for the fitted model, optionally accounting for the estimation of the weights (if available). This, along with bread(), is used by sandwich::sandwich() to compute the robust covariance matrix of the estimated coefficients. See glm_weightit() and vcov() above for more details.
hatvalues() computes the generalized leverage of each unit for
ordinal_weightit and multinom_weightit objects, \(h_i =
\text{tr}(F^{-1} F_i)\), where \(F_i\) is the unit's contribution to the
expected information matrix \(F\) (including its weight). This is the trace
of the unit's block of the hat matrix of the model written as a vector
generalized linear model, i.e., the sum across columns of what hatvalues()
returns for vglm objects in VGAM, and it is equal to the usual hat
value when the outcome has two categories. The leverages sum to the number of
estimated coefficients, and units with a weight of 0 have a leverage of 0.
Unlike in a generalized linear model, a leverage can exceed 1, though it
cannot exceed the number of outcome categories minus 1. The leverages can be
used to compute an HC2 robust covariance matrix, which scales each unit's
estimating function by \(1/\sqrt{1 - h_i}\); note that with more than two
outcome categories, this is an approximation to the exact HC2 adjustment,
which applies a matrix correction to each unit's vector of residuals. For
glm_weightit objects, the hatvalues() method for glm objects is used.
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. anova.glm_weightit() for comparing models using a Wald test.
sandwich::estfun() and sandwich::bread() for the estfun() and bread() generics.
