View source: R/update_nested.R
update_nested | R Documentation |
Wrapper function to ensure the same observations are used for each updated model as were used in the first model.
update_nested(object, formula., ..., evaluate = TRUE)
object |
model object to update |
formula. |
updated model formula |
... |
further parameters passed to the fitting function |
evaluate |
whether to evaluate the model. One of: |
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.
lm
model
https://stackoverflow.com/a/37341927
https://stackoverflow.com/a/37416336
https://stackoverflow.com/a/47195348
Other multipleRegression:
lmCombine()
,
plot2WayInteraction()
,
ppPlot()
,
semPlotInteraction()
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.