update_nested {petersenlab} | R Documentation |
Update Nested Models in Hierarchical Regression.
Description
Wrapper function to ensure the same observations are used for each updated model as were used in the first model.
Usage
update_nested(object, formula., ..., evaluate = TRUE)
Arguments
object |
model object to update |
formula. |
updated model formula |
... |
further parameters passed to the fitting function |
evaluate |
whether to evaluate the model. One of: |
Details
Convenience wrapper function to ensure the same observations are used for each updated model as were used in the first model, to ensure comparability of models.
Value
lm
model
See Also
https://stackoverflow.com/a/37341927
https://stackoverflow.com/a/37416336
https://stackoverflow.com/a/47195348
Other multipleRegression:
lmCombine()
,
plot2WayInteraction()
,
ppPlot()
Examples
# Prepare Data
data("mtcars")
dat <- mtcars
# Create some missing values in mtcars
dat[1, "wt"] <- NA
dat[5, "cyl"] <- NA
dat[7, "hp"] <- NA
m1 <- lm(mpg ~ wt + cyl + hp, data = dat)
m2 <- update_nested(m1, . ~ . - wt) # Remove wt
m3 <- update_nested(m1, . ~ . - cyl) # Remove cyl
m4 <- update_nested(m1, . ~ . - wt - cyl) # Remove wt and cyl
m5 <- update_nested(m1, . ~ . - wt - cyl - hp) # Remove all three variables
# (i.e., model with intercept only)
anova(m1, m2, m3, m4, m5)
[Package petersenlab version 1.0.0 Index]