inst/tinytest/test_hierarchical_lm_drop.R

library(lmhelprs)

set.seed(1234)
x <- c("City A", "City B", "City C", "City A", "City B", "City C")
w <- rnorm(length(x))
y <- rnorm(length(x))
lm_tmp1 <- lm(y ~ x)
lm_tmp2 <- lm(y ~ x + w)

library(lmhelprs)
tmp <- hierarchical_lm(lm_tmp1, lm_tmp2)
expect_equal(summary(lm_tmp2)$r.squared - summary(lm_tmp1)$r.squared,
             tmp[2, "R.sq.change"])

Try the lmhelprs package in your browser

Any scripts or data that you put into this service are public.

lmhelprs documentation built on June 8, 2025, 1:48 p.m.