@@ -7,6 +7,23 @@ reg_full <- regress("mean", y ~ x + z, data = dat, robustSE = FALSE)
77lm_null <- stats :: lm(y ~ x , data = dat )
88lm_full <- stats :: lm(y ~ x + z , data = dat )
99
10+ dat_miss <- dat
11+ dat_miss $ x [sample(1 : 100 , 10 )] <- NA
12+ reg_full_miss <- regress(" mean" , y ~ x + z , data = dat_miss )
13+ reg_null_miss <- regress(" mean" , y ~ z , data = dat_miss )
14+
15+ test_that(" anova.uRegress() throws an error if models are fit on different sample sizes" , {
16+ expect_error(anova(reg_null_miss , reg_full_miss ),
17+ paste0(" The full and reduced models are fit on data with different " ,
18+ " sample sizes, but the test is only valid when performed on the " ,
19+ " same dataset. This error often occurs when there is missing " ,
20+ " data in a variable that is included in the full model but not in the reduced model." ))
21+ })
22+
23+ test_that(" anova.uRegress() does not throw an error if models are fit on same sample size" , {
24+ expect_no_error(anova(reg_null , reg_full , robustSE = FALSE ))
25+ })
26+
1027
1128test_that(" anova.uRegress() throws an error if at least one of the two input
1229 objects is not of class uRegress" , {
@@ -36,7 +53,6 @@ hazard_reg_null <- regress("hazard", Surv(obstime, death)~age, data=mri)
3653hazard_reg_full <- regress(" hazard" , Surv(obstime , death )~ age + height + weight , data = mri )
3754rate_reg_full <- regress(" rate" , obstime ~ age + height + weight , data = mri , robustSE = FALSE )
3855
39-
4056test_that(" anova.uRegress() throws an error if the two input objects are
4157 regressions with different fnctls" , {
4258 expect_error(anova(hazard_reg_null , reg_full , robustSE = FALSE ),
0 commit comments