View source: R/anova.glm_weightit.R
anova.glm_weightit | R Documentation |
glm_weightit()
objectsanova()
is used to compare nested models fit with glm_weightit()
, mutinom_weightit()
, ordinal_weightit()
, or coxph_weightit()
using a Wald test that incorporates uncertainty in estimating the weights (if any).
## S3 method for class 'glm_weightit'
anova(
object,
object2,
test = "Chisq",
method = "Wald",
tolerance = 1e-07,
vcov = NULL,
...
)
object , object2 |
an output from one of the above modeling functions. |
test |
the type of test statistic used to compare models. Currently only |
method |
the kind of test used to compare models. Currently only |
tolerance |
for the Wald test, the tolerance used to determine if models are symbolically nested. |
vcov |
either a string indicating the method used to compute the variance of the estimated parameters for |
... |
other arguments passed to the function used for computing the parameter variance matrix, if supplied as a string or function, e.g., |
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.
An object of class "anova"
inheriting from class "data.frame"
.
glm_weightit()
for the page documenting glm_weightit()
, lm_weightit()
, ordinal_weightit()
, multinom_weightit()
, and coxph_weightit()
. anova.glm()
for model comparison of glm
objects.
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)
# Using the usual maximum likelihood variance matrix
anova(fit1, fit2, vcov = "const")
# Using a bootstrapped variance matrix
anova(fit1, fit2, vcov = "BS", R = 100)
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.