CRAN Package Check Results for Package glmMisrep

Last updated on 2025-07-04 19:50:20 CEST.

Flavor Version Tinstall Tcheck Ttotal Status Flags
r-devel-linux-x86_64-debian-clang 0.1.1 9.78 56.11 65.89 ERROR
r-devel-linux-x86_64-debian-gcc 0.1.1 5.84 37.95 43.79 OK
r-devel-linux-x86_64-fedora-clang 0.1.1 103.33 OK
r-devel-linux-x86_64-fedora-gcc 0.1.1 93.54 OK
r-devel-windows-x86_64 0.1.1 9.00 80.00 89.00 OK
r-patched-linux-x86_64 0.1.1 7.17 52.35 59.52 ERROR
r-release-linux-x86_64 0.1.1 8.80 52.61 61.41 OK
r-release-macos-arm64 0.1.1 33.00 OK
r-release-macos-x86_64 0.1.1 57.00 OK
r-release-windows-x86_64 0.1.1 9.00 81.00 90.00 OK
r-oldrel-macos-arm64 0.1.1 29.00 OK
r-oldrel-macos-x86_64 0.1.1 47.00 OK
r-oldrel-windows-x86_64 0.1.1 10.00 93.00 103.00 ERROR

Check Details

Version: 0.1.1
Check: tests
Result: ERROR Running ‘LN-testing.R’ [2s/2s] Running ‘NB-testing.R’ [2s/2s] Running ‘Norm-testing.R’ [1s/1s] Running ‘Pois-testing.R’ [3s/3s] Running ‘gamma-testing.R’ [3s/3s] Running the tests in ‘tests/Pois-testing.R’ failed. Complete output: > require(glmMisrep) Loading required package: glmMisrep > > data <- data.frame( Y = c(0, 0, 2, 0, 3, 0, 36, 0, 2, 1, 0, 2, 6, 9, 0, 0, 0, 0, 7, 1, 1, 2, 50, 4, 0, 0, 0, 1, + 0, 0, 0, 3, 0, 0, 1, 0, 1, 3, 176, 0, 0, 0, 0, 0, 2, 286, 0, 0, 0, 18), + X1 = c(0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1), + X2 = c(1.71870212, -0.55840901, 1.22589915, 0.53000107, 0.62571132, 0.02873955, 0.30989954, 1.35514993, 0.15587503, + 0.27987513, 0.48892178, 0.35218767, 0.52382778, 1.58126751, -0.07855081, -0.57128802, -0.92500953, -2.48543328, + 0.03810910, 0.39929906, -0.54854763, -0.10505694, 0.45120734, 0.32295222, -0.68595918, -0.66892486, 1.72253431, + -0.28425276, -0.67719912, -0.39644260, -0.16843500, 0.90540261, -1.38574804, 0.14456841, 0.44142810, -1.89442541, + -0.65961894, 2.13148776, 1.72410805, -1.60207312, -1.09525034, -1.31327168, -0.43378445, 1.33644956, 1.28938359, + 0.90232362, -0.94112768, -0.61851917, 0.37033085, -0.47019541), + X3 = c(0.6882029, 0.9934165, 0.9173388, 0.9406660, 0.5130041, 0.8590187, 0.4468488, 0.4186652, 0.5098278, 0.3339481, 0.6922477, + 0.6793977, 0.4983724, 0.6079911, 0.7763041, 0.8529067, 0.8287771, 0.9125900, 0.4802076, 0.8981448, 0.3570093, 0.9209584, + 0.4353817, 0.9426418, 0.9550002, 0.4869851, 0.9560156, 0.8247537, 0.1939687, 0.6103839, 0.7721900, 0.5980044, 0.8683831, + 0.7004518, 0.8577210, 0.3576712, 0.9540088, 0.9880046, 0.4304899, 0.7416618, 0.6656063, 0.8920356, 0.6097593, 0.8008748, + 0.8110432, 0.5967969, 0.6983106, 0.9471680, 0.9929186, 0.9059200), + Sex = c("Female", "Male", "Male", "Female", "Male", "Female", "Male", "Male", "Female", "Female", "Male", "Male", + "Male", "Female", "Male", "Male", "Female", "Female", "Male", "Female", "Female", "Male", "Female", "Male", + "Male", "Male", "Male", "Female", "Female", "Female", "Male", "Male", "Male", "Male", "Female", "Female", + "Female", "Female", "Male", "Male", "Male", "Male", "Male", "Male", "Female", "Male", "Male", "Female", + "Female", "Male"), + Race = c("Black", "White", "White", "White", "White", "White", "Black", "Black", "Black", "Black", "Black", "Black", "White", "Other", + "Black", "White", "Black", "White", "Other", "Black", "White", "Other", "Other", "White", "White", "White", "Black", "Other", + "White", "Other", "White", "Black", "Other", "Black", "Other", "Other", "Other", "Black", "Other", "Black", "White", "Other", + "Black", "White", "Black", "Other", "White", "Black", "Black", "Other"), + V_star = c(0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0)) > > data$Race <- as.factor(data$Race) > data$Sex <- as.factor(data$Sex) > > t1 <- tryCatch(poisRegMisrepEM(formula = y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6,0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # The response above is inappropriately specified (y, not Y) > stopifnot( + t1$message == "object 'y' not found" + ) > > > t2 <- tryCatch(poisRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_Star", + data = data, + lambda = c(0.6,0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # Argument to 'v_star' is misspelled > stopifnot( + t2$message == "variable V_Star not present in dataframe" + ) > > > data$V_star <- ifelse(data$V_star == 1, yes = "yes", no = "no") > > t3 <- tryCatch(poisRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6,0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > > # v* variable is type character (yes and no) > stopifnot( + t3$message == "v_star variable must be of class 'factor' or 'numeric'" + ) > > data$V_star <- ifelse(data$V_star == "yes", yes = 1, no = 0) > > > data$V_star[10] <- -1 > > > t4 <- tryCatch(poisRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6,0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # v* variable must be binary > stopifnot( + t4$message == "v_star variable must contain two unique values" + ) > > data$V_star[10] <- 0 > > > data$V_star <- ifelse(data$V_star == 1, yes = 1, no = 2) > > t5 <- tryCatch(poisRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6,0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # v* must be binary, but more specifically 0/1; > stopifnot( + t5$message == "v_star variable must be coded with ones and zeroes" + ) > > > > data$V_star <- ifelse(data$V_star == 1, yes = 1, no = 0) > > t6 <- tryCatch(poisRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.49, 0.52), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # Inappropriately specified lambda argument > stopifnot( + t6$message == "Lambda vector must sum to one" + ) > > > t7 <- tryCatch(poisRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(1/3, 1/3, 1/3), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # Inappropriately specified lambda argument > stopifnot( + t7$message == "Lambda vector must contain two elements" + ) > > > > data$X4 <- data$X2*0.3 > > t8 <- tryCatch(poisRegMisrepEM(formula = Y ~ X1 + X2 + X3 + X4 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6, 0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # Linearly dependent covariates/degenerate design matrix > stopifnot( + t8$message == "Linear dependencies exist in the covariates" + ) > > > t9 <- tryCatch(poisRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race, + v_star = "V_star", + data = data, + lambda = c(0.6, 0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > #V_star variable absent from formula > stopifnot( + t9$message == "v_star variable must be specified in 'formula'" + ) > > > > # EM algorithm should fail to converge within the specified number of attempts > t10 <- tryCatch( + capture.output(poisRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6, 0.4), + epsilon = 1e-08, + maxit = 2, + maxrestarts = 1)), + error = function(x) x + ) > > stopifnot( + t10$message == "NOT CONVERGENT! Failed to converge after 1 attempts" + ) > > > # On the first attempt, fails to converge, and restarts with new mixing props. > # Succeeds on the second attempt. > msg <- capture.output( + t11 <- poisRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6, 0.4), + epsilon = 1e-08, + maxit = 16, + maxrestarts = 4, verb = TRUE), + type = "message" + ) Execution halted Flavor: r-devel-linux-x86_64-debian-clang

Version: 0.1.1
Check: tests
Result: ERROR Running ‘LN-testing.R’ [2s/2s] Running ‘NB-testing.R’ [2s/2s] Running ‘Norm-testing.R’ [1s/1s] Running ‘Pois-testing.R’ [2s/2s] Running ‘gamma-testing.R’ [3s/3s] Running the tests in ‘tests/NB-testing.R’ failed. Complete output: > require(glmMisrep) Loading required package: glmMisrep > > data <- data.frame( Y = c(0, 0, 0, 0, 0, 5, 1, 0, 0, 0, 4, 2, 3, 3, 29, 0, 0, 12, 0, 6, 0, 0, 0, 1, 3, 17, 0, 25, 0, 0, 2, 0, 0, 0, 0, 0, 0, + 4, 2, 16, 0, 19, 0, 0, 2, 0, 0, 0, 0, 0), + X1 = c(0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0), + X2 = c(0.315223940, 0.203016819, -0.046615492, -0.040681413, 0.617273624, 0.813577139, 0.434980275, -1.868117146, + -0.027052575, 0.228288655, 1.380955283, 0.257543733, -0.353957121, 0.818737902, 0.525026487, -0.506164644, + -0.949480806, -0.107608844, 0.363661818, -0.295835692, 0.110056356, -0.205246487, -0.285092978, -0.639260383, + 1.576928404, 2.058907651, 0.823073891, -0.340826703, -1.324805151, 0.103545160, 0.497766445, 0.501280218, + -0.297921410, 1.056264736, -0.767076814, -0.212290592, -1.563216428, 1.026954673, -0.087597819, 1.334059105, + 0.955057522, 1.823380042, 1.082772308, -2.223962848, 1.433183408, -0.004531971, -1.029210193, 0.532295431, + -0.930908683, 0.391930241), + X3 = c(0.74306067, 0.67595394, 0.96320251, 0.57668303, 0.81643636, 0.78038200, 0.49999395, 0.99676766, 0.97642715, 0.88478779, + 0.53447733, 0.27009525, 0.64544670, 0.63666898, 0.14489153, 0.89359811, 0.70506987, 0.81595152, 0.78411313, 0.90301090, + 0.48920726, 0.75707194, 0.98999417, 0.85091229, 0.29074286, 0.73562357, 0.97903729, 0.96906234, 0.84957226, 0.55937779, + 0.49149558, 0.83789430, 0.66902416, 0.44173571, 0.81911265, 0.64182433, 0.34363554, 0.78838686, 0.78557154, 0.83241653, + 0.68691255, 0.20317013, 0.78619988, 0.09229911, 0.52779899, 0.79314940, 0.95612951, 0.95234203, 0.54259470, 0.81656990), + Sex = c("Male", "Male", "Female", "Male", "Male", "Female", "Female", "Female", "Female", "Male", "Male", "Female", + "Male", "Female", "Male", "Female", "Female", "Male", "Female", "Male", "Male", "Female", "Male", "Female", + "Female", "Male", "Male", "Male", "Male", "Female", "Male", "Female", "Female", "Female", "Male", "Female", + "Male", "Female", "Male", "Female", "Female", "Male", "Female", "Male", "Male", "Female", "Female", "Female", + "Female", "Male"), + Race = c("Black", "Black", "White", "White", "White", "White", "Black", "Other", "Other", "Other", "Black", "Other", "Other", "Other", "Other", "Other", "White", "Other", + "White", "Black", "White", "Other", "White", "White", "Other", "Other", "Black", "Other", "Other", "Black", "Black", "Black", "Other", "Black", "Black", "Other", + "White", "Other", "White", "White", "Other", "Other", "Other", "White", "White", "Black", "Black", "Black", "Other", "White"), + V_star = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) > > data$Race <- as.factor(data$Race) > data$Sex <- as.factor(data$Sex) > > t1 <- tryCatch(nbRegMisrepEM(formula = y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6,0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # The response above is inappropriately specified (y, not Y) > stopifnot( + t1$message == "object 'y' not found" + ) > > > t2 <- tryCatch(nbRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_Star", + data = data, + lambda = c(0.6,0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # Argument to 'v_star' is misspelled > stopifnot( + t2$message == "variable V_Star not present in dataframe" + ) > > > data$V_star <- ifelse(data$V_star == 1, yes = "yes", no = "no") > > t3 <- tryCatch(nbRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6,0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > > # v* variable is type character (yes and no) > stopifnot( + t3$message == "v_star variable must be of class 'factor' or 'numeric'" + ) > > data$V_star <- ifelse(data$V_star == "yes", yes = 1, no = 0) > > > data$V_star[10] <- -1 > > > t4 <- tryCatch(nbRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6,0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # v* variable must be binary > stopifnot( + t4$message == "v_star variable must contain two unique values" + ) > > data$V_star[10] <- 0 > > > data$V_star <- ifelse(data$V_star == 1, yes = 1, no = 2) > > t5 <- tryCatch(nbRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6,0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # v* must be binary, but more specifically 0/1; > stopifnot( + t5$message == "v_star variable must be coded with ones and zeroes" + ) > > > > data$V_star <- ifelse(data$V_star == 1, yes = 1, no = 0) > > t6 <- tryCatch(nbRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.49, 0.52), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # Inappropriately specified lambda argument > stopifnot( + t6$message == "Lambda vector must sum to one" + ) > > > t7 <- tryCatch(nbRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(1/3, 1/3, 1/3), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # Inappropriately specified lambda argument > stopifnot( + t7$message == "Lambda vector must contain two elements" + ) > > > > data$X4 <- data$X2*0.3 > > t8 <- tryCatch(nbRegMisrepEM(formula = Y ~ X1 + X2 + X3 + X4 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6, 0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # Linearly dependent covariates/degenerate design matrix > stopifnot( + t8$message == "Linear dependencies exist in the covariates" + ) > > # This is only to make sure the glm.nb() function can fit a model > # without throwing warnings messages/failing to converge. For purposes > # of testing our error handling, this should work. > > data$VS <- data$V_star > > t9 <- tryCatch(nbRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + VS, + v_star = "V_star", + data = data, + lambda = c(0.6, 0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # V_star variable is absent from formula ragument > stopifnot( + t9$message == "v_star variable must be specified in 'formula'" + ) > > > > # EM algorithm should fail to converge within the specified number of attempts > t10 <- tryCatch( + capture.output(nbRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6, 0.4), + epsilon = 1e-08, + maxit = 2, + maxrestarts = 1)), + error = function(x) x + ) > > stopifnot( + t10$message == "NOT CONVERGENT! Failed to converge after 1 attempts" + ) > > # On the first attempt, fails to converge, and restarts with new mixing props. > # Succeeds on the second attempt. > msg <- capture.output( + t11 <- nbRegMisrepEM(formula = Y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6, 0.4), + epsilon = 1e-08, + maxit = 9, + maxrestarts = 4, verb = TRUE), + type = "message" + ) Execution halted Flavor: r-patched-linux-x86_64

Version: 0.1.1
Check: tests
Result: ERROR Running 'LN-testing.R' [3s] Running 'NB-testing.R' [2s] Running 'Norm-testing.R' [1s] Running 'Pois-testing.R' [3s] Running 'gamma-testing.R' [5s] Running the tests in 'tests/LN-testing.R' failed. Complete output: > require(glmMisrep) Loading required package: glmMisrep > > data <- data.frame( Y = c(76.537552, 2528.253825, 742.661850, 275.771394, 422.115809, 994.273666, 27.363153, 107.370891, + 1133.422491, 42.577534, 21.222886, 82.130986, 254.636406, 116.754997, 96.768592, 238.197024, + 617.472558, 9.391864, 100.894256, 332.483705, 279.115849, 1101.826204, 599.726263, 218.041193, + 519.177473, 3529.107060, 1879.559865, 47.560367, 422.300405, 140.919276, 398.857500, 1003.204619, + 1518.945852, 638.622736, 1667.131817, 352.307789, 86.629404, 5524.732901, 372.118071, 3732.461629, + 4.532981, 147.234528, 41.538661, 10929.665862, 85.689014, 33.029995, 20.335263, 67.657641, + 388.829832, 8.608040), + X1 = c(1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), + X2 = c(0.49507310, -0.08883055, 0.12926013, 0.14710474, -0.51448308, -0.13046076, 2.08608211, -0.57426685, -0.90878741, + 1.23110221, 1.67853057, 1.55074616, -2.18659493, 1.41014900, 0.58587594, 0.04134293, -1.99370526, 0.09277679, + -0.76394655, -1.28839675, 0.41072563, -1.27177378, 0.08823336, 0.20571840, -0.82168230, 0.33441449, 0.28506237, + 0.04591112, -0.16366695, -1.45927411, -0.10830177, -1.29651305, 0.66361581, 2.00878945, -0.32495902, -1.13028382, + 0.74934344, -0.54082773, -0.22820110, -0.67195420, 0.57810617, 1.16271770, -0.97158214, 0.85486460, 0.93789922, + -0.80378906, 0.55046386, -0.03277486, 1.10168928, -1.47985902), + X3 = c(0.2357360, 0.9084012, 0.9510478, 0.9426464, 0.5130887, 0.9366523, 0.2776905, 0.8125779, 0.8742008, 0.7971722, 0.3337451, + 0.3999461, 0.8996933, 0.4550159, 0.4777070, 0.5786287, 0.9578764, 0.6710153, 0.6726491, 0.7067857, 0.9986008, 0.9106748, + 0.1215141, 0.9760379, 0.8532801, 0.5979620, 0.9679438, 0.8752609, 0.4202729, 0.6799168, 0.9755574, 0.9049099, 0.9187066, + 0.8170819, 0.5400875, 0.8945737, 0.1026229, 0.9990335, 0.7742958, 0.8731023, 0.3292357, 0.7081538, 0.6131705, 0.8676843, + 0.7707079, 0.9935447, 0.8271532, 0.7889369, 0.6950691, 0.5327706), + Sex = c("Female", "Male", "Female", "Male", "Male", "Male", "Female", "Male", "Male", "Female", "Male", "Female", + "Female", "Male", "Female", "Male", "Female", "Female", "Female", "Male", "Female", "Male", "Male", "Male", + "Male", "Female", "Female", "Male", "Female", "Male", "Female", "Female", "Male", "Female", "Male", "Female", + "Male", "Male", "Female", "Female", "Female", "Male", "Male", "Male", "Female", "Female", "Female", "Female", + "Male", "Female"), + Race = c("White", "Black", "Other", "White", "White", "Other", "Other", "White", "White", "White", "White", "Black", "Other", "White", + "White", "Other", "White", "Other", "Other", "Black", "Other", "Black", "Other", "Black", "Other", "Black", "Other", "Other", + "White", "White", "Other", "White", "Black", "Black", "Other", "Other", "White", "Other", "White", "Black", "Other", "Black", + "Black", "White", "Other", "Other", "Other", "White", "White", "Other"), + V_star = c(0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0)) > > data$Race <- as.factor(data$Race) > data$Sex <- as.factor(data$Sex) > > t1 <- tryCatch(LnRegMisrepEM(formula = y ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6,0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # The response above is inappropriately specified > stopifnot( + t1$message == "formula must be 'log(response) ~ terms'. See 'Details'" + ) > > > t2 <- tryCatch(LnRegMisrepEM(formula = log(y) ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6,0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > stopifnot( + t2$message == "object 'y' not found" + ) > > > > t3 <- tryCatch(LnRegMisrepEM(formula = log(Y) ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_Star", + data = data, + lambda = c(0.6,0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # Argument to 'v_star' is misspelled > stopifnot( + t3$message == "variable V_Star not present in dataframe" + ) > > > data$V_star <- ifelse(data$V_star == 1, yes = "yes", no = "no") > > t4 <- tryCatch(LnRegMisrepEM(formula = log(Y) ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6,0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > > # v* variable is type character (yes and no) > stopifnot( + t4$message == "v_star variable must be of class 'factor' or 'numeric'" + ) > > data$V_star <- ifelse(data$V_star == "yes", yes = 1, no = 0) > > > data$V_star[10] <- -1 > > > t5 <- tryCatch(LnRegMisrepEM(formula = log(Y) ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6,0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # v* variable must be binary > stopifnot( + t5$message == "v_star variable must contain two unique values" + ) > > data$V_star[10] <- 0 > > > data$V_star <- ifelse(data$V_star == 1, yes = 1, no = 2) > > t6 <- tryCatch(LnRegMisrepEM(formula = log(Y) ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6,0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # v* must be binary, but more specifically 0/1; > stopifnot( + t6$message == "v_star variable must be coded with ones and zeroes" + ) > > > > data$V_star <- ifelse(data$V_star == 1, yes = 1, no = 0) > > t7 <- tryCatch(LnRegMisrepEM(formula = log(Y) ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.49, 0.52), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # Inappropriately specified lambda argument > stopifnot( + t7$message == "Lambda vector must sum to one" + ) > > > t8 <- tryCatch(LnRegMisrepEM(formula = log(Y) ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(1/3, 1/3, 1/3), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # Inappropriately specified lambda argument > stopifnot( + t8$message == "Lambda vector must contain two elements" + ) > > > > data$X4 <- data$X2*0.3 > > t9 <- tryCatch(LnRegMisrepEM(formula = log(Y) ~ X1 + X2 + X3 + X4 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6, 0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # Linearly dependent covariates/degenerate design matrix > stopifnot( + t9$message == "Linear dependencies exist in the covariates" + ) > > > t10 <- tryCatch(LnRegMisrepEM(formula = log(Y) ~ X1 + X2 + X3 + Sex + Race, + v_star = "V_star", + data = data, + lambda = c(0.6, 0.4), + epsilon = 1e-08, + maxit = 10000, + maxrestarts = 20), + error = function(x) x ) > > # V_star variable is absent from formula argument > stopifnot( + t10$message == "v_star variable must be specified in 'formula'" + ) > > > # EM algorithm should fail to converge within the specified number of attempts > t11 <- tryCatch( + capture.output(LnRegMisrepEM(formula = log(Y) ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6, 0.4), + epsilon = 1e-08, + maxit = 2, + maxrestarts = 1)), + error = function(x) x + ) > > stopifnot( + t11$message == "NOT CONVERGENT! Failed to converge after 1 attempts" + ) > > > > # On the first attempt, fails to converge, and restarts with new mixing props. > # Succeeds on the second attempt. > msg <- capture.output( + t12 <- LnRegMisrepEM(formula = log(Y) ~ X1 + X2 + X3 + Sex + Race + V_star, + v_star = "V_star", + data = data, + lambda = c(0.6, 0.4), + epsilon = 1e-08, + maxit = 15, + maxrestarts = 4, verb = TRUE), + type = "message" + ) Execution halted Flavor: r-oldrel-windows-x86_64