R Under development (unstable) (2025-06-30 r88369 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(distfreereg) > set.seed(20250509) > n <- 60 > Sig <- rWishart(1, df = n, Sigma = diag(n))[,,1] > theta <- c(2,3) > true_func <- function(theta, x) theta[1]*x[1] + theta[2]*x[2] > test_func <- function(theta, x) theta[1]*x[1] + theta[2]*x[2]^2 > true_data <- data.frame(a = rexp(n, rate = 1), b = rnorm(n)) > true_X <- as.matrix(true_data) > X <- true_X + rexp(length(true_X)) > m <- lm(b ~ a, data = true_data) > > cdfr <- compare(true_mean = true_func, + test_mean = test_func, + true_X = true_X, + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE)) Calculating required true covariance specification matrices... Generating errors... Running simulation... > > cdfr 'compare' object details: - Sample size: 60 - Repetitions: 1000 - Error-generating function: 'rmvnorm' (default) - 'distfreereg' objects saved: 1 > > edf <- function(n, reps) matrix(rnorm(n*reps), nrow = n) > > cdfr_edf <- update(cdfr, err_dist_fun = "edf") Calculating required true covariance specification matrices... Generating errors... Running simulation... > cdfr_edf 'compare' object details: - Sample size: 60 - Repetitions: 1000 - Error-generating function: 'edf' - 'distfreereg' objects saved: 1 > > signif(rejection(cdfr, alpha = c(0.1, 0.05))[,2:3], digits = 3) alpha rate 1 0.10 0.937 2 0.05 0.895 3 0.10 0.928 4 0.05 0.869 > > signif(ks.test(cdfr)[["p.value"]], digits = 3) [1] 0 > > plot(cdfr, confband_args = NULL) > plot(cdfr, confband_args = list(N = 1e3)) > plot(cdfr, which = "dens", confband_args = NULL) > plot(cdfr, which = "qq") > plot(cdfr, which = "qqp") > > > > # No reps, Y warning, custom tolerances > > cdfr_no_reps <- compare(true_mean = true_func, + test_mean = test_func, + true_X = true_X, + Y = rep(1, n), + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE, + matsqrt_tol = -1e-3, + solve_tol = 1e-3, + sym_tol = 1e-3, + sym_tol1 = 1e-3), + reps = 0) Calculating required true covariance specification matrices... Running simulation... Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : Y supplied to compare() is ignored > > > > # Global override > > smaller_n <- 1:30 > cdfr_global_override <- compare(true_mean = true_func, + test_mean = test_func, + true_X = true_X[smaller_n,], + # Y = rep(1, smaller_n), + X = X[smaller_n,], + true_covariance = list(Sigma = Sig[smaller_n,smaller_n]), + covariance = list(Sigma = Sig[smaller_n,smaller_n]), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE), + global_override = list(theta_hat = theta), + reps = 5e2) Calculating required true covariance specification matrices... Generating errors... Running simulation... > > > plot(x = cdfr, y = cdfr_global_override, confband_args = NULL) Warning messages: 1: In plot.compare(x = cdfr, y = cdfr_global_override, confband_args = NULL) : Length of Y different for cdfr and cdfr_global_override 2: In plot.compare(x = cdfr, y = cdfr_global_override, confband_args = NULL) : Length of observed stats different for cdfr and cdfr_global_override > plot(x = cdfr, y = cdfr_global_override, confband_args = NULL, which = "dens") Warning messages: 1: In plot.compare(x = cdfr, y = cdfr_global_override, confband_args = NULL, : Length of Y different for cdfr and cdfr_global_override 2: In plot.compare(x = cdfr, y = cdfr_global_override, confband_args = NULL, : Length of observed stats different for cdfr and cdfr_global_override > plot(x = cdfr, y = cdfr_global_override, confband_args = NULL, which = "qq") Warning messages: 1: In plot.compare(x = cdfr, y = cdfr_global_override, confband_args = NULL, : Length of Y different for cdfr and cdfr_global_override 2: In plot.compare(x = cdfr, y = cdfr_global_override, confband_args = NULL, : Length of observed stats different for cdfr and cdfr_global_override > > > > # Keep all > > cdfr_keep_all <- compare(true_mean = true_func, + test_mean = test_func, + true_X = true_X, + Y = rep(1, n), + X = X, keep = "all", + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE), + global_override = list(theta_hat = theta), + reps = 10) Calculating required true covariance specification matrices... Generating errors... Running simulation... Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : Y supplied to compare() is ignored > > stopifnot(length(cdfr_keep_all[["dfrs"]]) == 10) > > > # n supplied > > cdfr_n <- compare(true_mean = true_func, + test_mean = test_func, + n = n, + true_X = true_X, + X = X, keep = "all", + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE), + global_override = list(theta_hat = theta), + reps = 3) Calculating required true covariance specification matrices... Generating errors... Running simulation... > > > # List supplied for Sigma > > Sig_array <- rWishart(2, df = n/2, Sigma = diag(n/2)) > Sig_list <- list(Sig_array[,,1], Sig_array[,,2]) > > cdfr_list <- compare(true_mean = true_func, + test_mean = test_func, + true_X = true_X, + X = X, + true_covariance = list(Sigma = Sig_list), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, reps = 3, + control = list(return_on_error = FALSE)) Calculating required true covariance specification matrices... Generating errors... Running simulation... > > > > ### Partial outputs > > cdfr_partial <- compare(true_mean = true_func, + test_mean = test_func, + true_X = true_X, + Y = rep(1, n), + X = X, keep = "all", + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, + control = list(orth_tol = 1e-100), + reps = 10) Calculating required true covariance specification matrices... Generating errors... Running simulation... Warning messages: 1: In validate_args_compare(true_mean = true_mean, true_method = true_method, : Y supplied to compare() is ignored 2: Error encountered, partial results returned: Error in calc_mu(J = J_for_mu, solve_tol = solve_tol, orth_tol = orth_tol): crossprod(mu) is not equal to the identity matrix 3: In compare(true_mean = true_func, test_mean = test_func, true_X = true_X, : Error in repetition 1; exiting loop > names(cdfr_partial) [1] "call" "Y" "theta" "true_mean" [5] "true_covariance" "true_X" "true_data" "test_mean" [9] "covariance" "X" "data" "observed_stats" [13] "mcsim_stats" "p" "dfrs" > > > > > ### Failures > > tryCatch(plot(cdfr, confband_args = 3), error = function(e) warning(e)) Warning message: In validate_args_plot.compare(object = x, which = which, stat = stat, : confband_args must be NULL, FALSE, or a list > tryCatch(plot(cdfr, density_args = 3), error = function(e) warning(e)) Warning message: In validate_args_plot.compare(object = x, which = which, stat = stat, : 'density_args' must be NULL or a list > tryCatch(plot(cdfr, hlines = 3), error = function(e) warning(e)) Warning message: In validate_args_plot.compare(object = x, which = which, stat = stat, : 'hlines' must be NULL, FALSE, or a list > tryCatch(plot(cdfr, curve_args = 3), error = function(e) warning(e)) Warning message: In validate_args_plot.compare(object = x, which = which, stat = stat, : 'curve_args' must be NULL or a list > tryCatch(plot(cdfr, poly = 3), error = function(e) warning(e)) Warning message: In validate_args_plot.compare(object = x, which = which, stat = stat, : 'poly' must be NULL, FALSE, or a list > tryCatch(plot(cdfr, legend = 3), error = function(e) warning(e)) Warning message: In validate_args_plot.compare(object = x, which = which, stat = stat, : 'legend' must be NULL, FALSE, or a list > tryCatch(plot(cdfr, qqline = 3), error = function(e) warning(e)) Warning message: In validate_args_plot.compare(object = x, which = which, stat = stat, : 'qqline' must be NULL, FALSE, or a list > tryCatch(plot(cdfr, stat = "hello"), error = function(e) warning(e)) Warning message: In strict_match(arg = stat, choices = object) : 'hello' not found among statistics in compare object > > tryCatch(compare(true_mean = true_func, + true_X = true_X, + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE)), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : test_mean must be specified > > tryCatch(compare(true_mean = true_func, + test_mean = test_func, + true_X = true_X, + X = 1:10, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE)), + error = function(e) warning(e)) Warning message: In get_n(n = n, true_X = true_X, X = X, true_data = true_data, data = data, : All sets of covariates must have the same number of observations: - true_X: 60 - X: 10 > > tryCatch(compare(true_mean = function(a) a^2, + test_mean = test_func, + true_X = true_X, + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE)), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : true_mean must have 'x' or 'X' as an argument when true_X is not NULL > > tryCatch(compare(true_mean = true_func, + test_mean = test_func, + true_X = NULL, + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE)), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : true_mean must have neither 'x' nor 'X' as an argument when true_X is NULL > > tryCatch(compare(true_mean = true_func, + test_mean = test_func, + true_X = true_X, + n = 0, + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE)), + error = function(e) warning(e)) Warning message: In validate_numeric(x = n, pos_int = TRUE, len = 1) : as.integer(n) must be positive > > tryCatch(compare(true_mean = true_func, + test_mean = test_func, + true_X = true_X, + X = X, + true_covariance = NULL, + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE)), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : 'true_covariance' must be specified when 'true_mean' is a function or nls object, or 'true_method' is 'nls' > > tryCatch(compare(true_mean = function(x) x, + test_mean = test_func, + true_X = true_X, + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE)), + error = function(e) warning(e)) Warning message: In validate_mean_function_arg_names(f = true_mean) : Invalid argument specification of true_mean > > err_dist_fun_vec <- function() 1:10 > err_dist_fun_mat <- function() matrix(1:10) > > tryCatch(compare(true_mean = true_func, + test_mean = test_func, + true_X = true_X, + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + control = list(return_on_error = FALSE), + err_dist_fun = c("err_dist_fun_vec", "err_dist_fun_mat")), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : 'err_dist_fun' must be a character string of length 1 > > tryCatch(compare(true_mean = true_func, + test_mean = test_func, + true_X = true_X, + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + control = list(return_on_error = FALSE), + err_dist_fun = "pi"), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : 'err_dist_fun' must specify a function > > tryCatch(compare(true_mean = true_func, + test_mean = test_func, + true_X = true_X, + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + control = list(return_on_error = FALSE), + err_dist_args = "pi"), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : 'err_dist_args' must be a list > > tryCatch(compare(true_mean = true_func, + test_mean = test_func, + true_X = true_X, + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE), + err_dist_fun = "err_dist_fun_vec"), + error = function(e) warning(e)) Calculating required true covariance specification matrices... Generating errors... Warning message: In generate_error_matrix(..., n = n) : class of error_matrix is 'integer'; should be 'matrix' > > tryCatch(compare(true_mean = true_func, + test_mean = test_func, + true_X = true_X, + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE), + err_dist_fun = "err_dist_fun_mat"), + error = function(e) warning(e)) Calculating required true covariance specification matrices... Generating errors... Warning message: In generate_error_matrix(..., n = n) : dimension of error_matrix is 10, 1; should be 60, 1000 > > tryCatch(compare(true_mean = true_func, + test_mean = test_func, + true_X = true_X, + true_data = as.data.frame(true_X), + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE), + err_dist_fun = "err_dist_fun_mat"), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : true_data must not be supplied when true_mean is a function > > tryCatch(compare(true_mean = b ~ a, + true_method = "lm", + true_method_args = "4", + test_mean = test_func, + true_X = true_X, + true_data = as.data.frame(true_X), + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE), + err_dist_fun = "err_dist_fun_mat"), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : true_method_args must be NULL or a list > > tryCatch(compare(true_mean = b ~ a, + true_method = "lm", + test_mean = test_func, + true_X = true_X, + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE), + err_dist_fun = "err_dist_fun_mat"), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : true_data must be supplied when true_mean is a formula > > tryCatch(compare(true_mean = b ~ a, + true_method = "lm", + test_mean = test_func, + true_data = as.data.frame(true_X), + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE), + err_dist_fun = "err_dist_fun_mat"), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : theta must be NULL when true_mean is 'formula' > > tryCatch(compare(true_mean = true_func, + true_method = "lm", + test_mean = test_func, + true_X = true_X, + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE), + err_dist_fun = "err_dist_fun_mat"), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : true_method must be NULL when true_mean is not a formula > > tryCatch(compare(true_mean = true_func, + true_method_args = "lm", + test_mean = test_func, + true_X = true_X, + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE), + err_dist_fun = "err_dist_fun_mat"), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : true_method_args must be NULL when true_mean is not a formula > > tryCatch(compare(true_mean = true_func, + true_method_args = "lm", + test_mean = test_func, + true_X = true_X, + X = X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + theta = theta, prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE), + err_dist_fun = "err_dist_fun_mat"), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : true_method_args must be NULL when true_mean is not a formula > > tryCatch(compare(true_mean = b ~ a, + true_method = "lm", + test_mean = test_func, + true_data = as.data.frame(true_X), + data = 1:n, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE), + err_dist_fun = "err_dist_fun_mat"), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : data must be a data frame or a matrix > > tryCatch(compare(true_mean = b ~ a, + true_method = "lm", + test_mean = test_func, + true_data = as.data.frame(true_X), + data = data.frame(), + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE), + err_dist_fun = "err_dist_fun_mat"), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : data cannot be an empty matrix or data frame > > tryCatch(compare(true_mean = b ~ a, + true_method = "lm", + test_mean = test_func, + true_data = as.data.frame(true_X), + data = as.data.frame(true_X), + X = true_X, + true_covariance = list(Sigma = Sig), + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + prog = Inf, keep = 1, + manual = function(x) sum(x$theta_hat), + control = list(return_on_error = FALSE), + err_dist_fun = "err_dist_fun_mat"), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : data must be NULL when test_mean has no formula method > > tryCatch(compare(true_mean = m, + test_mean = test_func, + true_data = true_data, + data = true_X, + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + prog = Inf, keep = 1), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : true_data must be NULL when true_mean is a model object > > tryCatch(compare(true_mean = m, + test_mean = test_func, + theta = 1, + data = true_X, + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + prog = Inf, keep = 1), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : theta must be NULL when true_mean is a model object > > tryCatch(compare(true_mean = m, + test_mean = m, + data = true_X, + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + prog = Inf, keep = 1), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : data must be NULL when test_mean is a model object > > tryCatch(compare(true_mean = m, + test_mean = test_func, + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + prog = Inf, keep = 1), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : X must be specified when test_mean is a function with an 'x' argument > > tryCatch(compare(true_mean = m, + test_mean = test_func, + X = true_X, + data = true_X, + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + prog = Inf, keep = 1), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : data must be NULL when test_mean has no formula method > > tryCatch(compare(true_mean = m, + test_mean = b ~ a, + X = true_X, + data = true_X, + covariance = list(Sigma = Sig), + theta_init = rep(1, length(theta)), + prog = Inf, keep = 1), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : X must be NULL when test_mean has a formula method > > tryCatch(compare(true_mean = m, + test_mean = m, + true_covariance = list(Sigma = Sig), + prog = Inf, keep = 1), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : 'true_covariance' must be NULL when 'true_mean' is neither a function nor nls object, and 'true_method' is not 'nls' > > tryCatch(compare(true_mean = m, + test_mean = m, + prog = Inf, keep = "hello"), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : keep_all must be NULL, 'all', or a vector of positive integers > > tryCatch(compare(true_mean = m, + test_mean = m, + prog = Inf, manual = "hello"), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : 'manual' must be NULL or a function > > tryCatch(compare(true_mean = m, + test_mean = m, + prog = Inf, err_dist_fun = "hello"), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : 'err_dist_fun' must be NULL when class(true_mean) is lm > > tryCatch(compare(true_mean = m, + test_mean = m, + prog = Inf, err_dist_args = "hello"), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : 'err_dist_args' must be NULL when class(true_mean) is lm > > tryCatch(compare(true_mean = m, + test_mean = m, + prog = Inf, keep = rep(1, 2e4)), + error = function(e) warning(e)) Warning message: In validate_numeric(keep, pos_int = TRUE, min_len = 1, max_len = reps, : keep must have length at most 1000 > > tryCatch(compare(true_mean = m, + method = "lm", + test_mean = e ~ a, + data = true_X, + prog = Inf, keep = 1), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : Response variable 'e' not found in data > > tryCatch(plot(x = cdfr, y = cdfr), error = function(e) warning(e)) Warning message: In plot.compare(x = cdfr, y = cdfr) : The same object cannot be supplied to 'x' and 'y' > tryCatch(plot(x = cdfr, y = "cdfr"), error = function(e) warning(e)) Warning message: In plot.compare(x = cdfr, y = "cdfr") : y must have class 'compare' > tryCatch(plot(x = cdfr, y = cdfr_global_override, which = "qqp"), + error = function(e) warning(e)) Warning message: In plot.compare(x = cdfr, y = cdfr_global_override, which = "qqp") : Cannot create p-value Q-Q plot with two 'compare' objects > tryCatch(plot(x = cdfr, y = cdfr_global_override, which = "hello"), + error = function(e) warning(e)) Warning message: In strict_match(which, choices = c("cdf", "dens", "qq", "qqp")) : which must be exactly one of 'cdf', 'dens', 'qq', 'qqp'; it cannot be 'hello' > > tryCatch(rejection(cdfr, alpha = 1.1), error = function(e) warning(e)) Warning message: In validate_numeric(alpha, min_len = 1, min_val = 0, max_val = 1) : alpha must have value(s) less than or equal to 1 > tryCatch(rejection(cdfr, alpha = -1), error = function(e) warning(e)) Warning message: In validate_numeric(alpha, min_len = 1, min_val = 0, max_val = 1) : alpha must have value(s) greater than or equal to 0 > > tryCatch(plot(x = cdfr, which = "qqqq"), error = function(e) warning(e)) Warning message: In strict_match(which, choices = c("cdf", "dens", "qq", "qqp")) : which must be exactly one of 'cdf', 'dens', 'qq', 'qqp'; it cannot be 'qqqq' > > tryCatch(compare(true_mean = m, + method = "lm", + test_mean = b + e ~ a, + data = true_X, + prog = Inf, keep = 1), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : Response in test_mean object must be exactly one term > > tryCatch(compare(true_mean = m, + method = "lm", + test_mean = b ~ a, + prog = Inf, keep = 1), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : data must be supplied when test_mean is a formula > > tryCatch(compare(true_mean = m, + test_mean = m, + true_X = true_X, + prog = Inf, keep = 1), + error = function(e) warning(e)) Warning message: In validate_args_compare(true_mean = true_mean, true_method = true_method, : true_X must be NULL if true_mean is not a function > > tryCatch(compare(true_mean = true_func, + true_X = true_X, + true_covariance = list(Sigma = Sig), + theta = rep(1, length(theta) + 1), + test_mean = m, + prog = Inf, keep = 1), + error = function(e) warning(e)) Warning message: In validate_function_behavior(f = true_mean, X = true_X, n = n, : Element 3 of theta unnecessary for function evaluation. Recode true_mean, or shorten theta, and retry. > > > > > > > ########################### > > # These test various combinations of test mean specifications with compare(), > # specifically to test ordering options. > > rm(list=ls()) > > all.equal.compare <- distfreereg:::all.equal.compare > > set.seed(20250613) > n <- 20 > reps <- 10 > data <- data.frame(x1 = rnorm(n), x2 = rnorm(n), y = rnorm(n)) > > # lm > > form_lm <- y ~ x1 + x2 > m_lm_1 <- lm(y ~ x1 + x2, data = data) > m_lm_2 <- lm(form_lm, data = data) > > set.seed(20250614) > cdfr_lm_1 <- compare(true_mean = m_lm_1, test_mean = m_lm_1, reps = 10, prog = Inf) Running simulation... > set.seed(20250614) > cdfr_lm_2 <- compare(true_mean = m_lm_1, test_mean = m_lm_2, reps = 10, prog = Inf) Running simulation... > signif(cdfr_lm_1[["observed_stats"]], 3) KS CvM 1 0.901 0.1250 2 0.645 0.0839 3 1.070 0.2230 4 0.522 0.0482 5 0.623 0.1220 6 0.626 0.0716 7 0.621 0.0858 8 1.150 0.3860 9 0.686 0.2180 10 0.813 0.2410 > signif(cdfr_lm_1[["p"]][["KS"]], 3) [1] 0.1810 0.5130 0.0765 0.7240 0.5500 0.5440 0.5520 0.0463 0.4490 0.2730 > stopifnot(all.equal(cdfr_lm_1, cdfr_lm_2)) > > set.seed(20250614) > cdfr_lm_1_optimal <- update(cdfr_lm_1, ordering = "optimal") Running simulation... > set.seed(20250614) > cdfr_lm_2_optimal <- update(cdfr_lm_2, ordering = "optimal") Running simulation... > signif(cdfr_lm_1_optimal[["observed_stats"]], 3) KS CvM 1 0.631 0.1150 2 0.603 0.0883 3 0.634 0.1350 4 0.441 0.0297 5 1.090 0.3480 6 0.973 0.3530 7 0.663 0.0616 8 0.794 0.1020 9 0.732 0.1530 10 0.533 0.1050 > signif(cdfr_lm_1_optimal[["p"]][["KS"]], 3) [1] 0.5370 0.5820 0.5320 0.8560 0.0706 0.1300 0.4800 0.2940 0.3760 0.7080 > stopifnot(all.equal(cdfr_lm_1_optimal, cdfr_lm_2_optimal)) > > set.seed(20250614) > cdfr_lm_1_natural <- update(cdfr_lm_1, ordering = "natural") Running simulation... > set.seed(20250614) > cdfr_lm_2_natural <- update(cdfr_lm_2, ordering = "natural") Running simulation... > signif(cdfr_lm_1_natural[["observed_stats"]], 3) KS CvM 1 1.300 0.5550 2 0.730 0.1550 3 0.719 0.1650 4 0.339 0.0326 5 0.912 0.2470 6 0.838 0.1050 7 0.654 0.0919 8 0.430 0.0419 9 0.536 0.0506 10 0.948 0.2460 > signif(cdfr_lm_1_natural[["p"]][["KS"]], 3) [1] 0.0244 0.4060 0.4220 0.9730 0.1960 0.2710 0.5250 0.8910 0.7310 0.1670 > stopifnot(all.equal(cdfr_lm_1_natural, cdfr_lm_2_natural)) > > > # glm > > m_glm_1 <- glm(y ~ x1 + x2, data = data) > m_glm_2 <- glm(form_lm, data = data) > > set.seed(20250614) > cdfr_glm_1 <- compare(true_mean = m_glm_1, test_mean = m_glm_1, reps = 10, prog = Inf) Running simulation... > set.seed(20250614) > cdfr_glm_2 <- compare(true_mean = m_glm_1, test_mean = m_glm_2, reps = 10, prog = Inf) Running simulation... > signif(cdfr_glm_1[["observed_stats"]], 3) KS CvM 1 0.983 0.1490 2 0.715 0.1030 3 1.120 0.2460 4 0.556 0.0546 5 0.777 0.1890 6 0.761 0.1060 7 0.548 0.0667 8 1.150 0.3820 9 0.622 0.1790 10 0.840 0.2570 > signif(cdfr_glm_1[["p"]][["KS"]], 3) [1] 0.1210 0.4060 0.0573 0.6680 0.3200 0.3400 0.6810 0.0480 0.5510 0.2420 > stopifnot(all.equal(cdfr_glm_1, cdfr_glm_2)) > > set.seed(20250614) > cdfr_glm_1_optimal <- update(cdfr_glm_1, ordering = "optimal") Running simulation... > set.seed(20250614) > cdfr_glm_2_optimal <- update(cdfr_glm_2, ordering = "optimal") Running simulation... > signif(cdfr_glm_1_optimal[["observed_stats"]], 3) KS CvM 1 0.688 0.1370 2 0.668 0.1080 3 0.665 0.1490 4 0.469 0.0336 5 1.360 0.5420 6 1.180 0.5220 7 0.585 0.0479 8 0.789 0.1010 9 0.664 0.1260 10 0.551 0.1120 > signif(cdfr_glm_1_optimal[["p"]][["KS"]], 3) [1] 0.440 0.472 0.478 0.814 0.012 0.042 0.615 0.299 0.480 0.676 > stopifnot(all.equal(cdfr_glm_1_optimal, cdfr_glm_2_optimal)) > > set.seed(20250614) > cdfr_glm_1_natural <- update(cdfr_glm_1, ordering = "natural") Running simulation... > set.seed(20250614) > cdfr_glm_2_natural <- update(cdfr_glm_2, ordering = "natural") Running simulation... > signif(cdfr_glm_1_natural[["observed_stats"]], 3) KS CvM 1 1.420 0.6600 2 0.809 0.1900 3 0.754 0.1820 4 0.360 0.0369 5 1.140 0.3840 6 1.020 0.1550 7 0.577 0.0715 8 0.428 0.0415 9 0.487 0.0416 10 0.980 0.2620 > signif(cdfr_glm_1_natural[["p"]][["KS"]], 3) [1] 0.0124 0.3040 0.3720 0.9600 0.0625 0.1190 0.6600 0.8940 0.8120 0.1440 > stopifnot(all.equal(cdfr_glm_1_natural, cdfr_glm_2_natural)) > > > > # nls > > form_nls <- y ~ a*x1 + b*x2 > m_nls_1 <- nls(y ~ a*x1 + b*x2, data = data, start = c(a = 1, b = 1)) > m_nls_2 <- nls(form_nls, data = data, start = c(a = 1, b = 1)) > > set.seed(20250614) > cdfr_nls_1 <- compare(true_mean = m_nls_1, test_mean = m_nls_1, + true_covariance = list(Sigma = 1), reps = 10, prog = Inf) Calculating required true covariance specification matrices... Generating errors... Running simulation... > set.seed(20250614) > cdfr_nls_2 <- compare(true_mean = m_nls_1, test_mean = m_nls_2, + true_covariance = list(Sigma = 1), reps = 10, prog = Inf) Calculating required true covariance specification matrices... Generating errors... Running simulation... > signif(cdfr_nls_1[["observed_stats"]], 3) KS CvM 1 0.838 0.0971 2 0.680 0.1090 3 0.880 0.1510 4 0.600 0.0739 5 0.771 0.1450 6 0.753 0.0833 7 0.645 0.1140 8 1.430 0.6750 9 0.527 0.1150 10 0.650 0.1120 > signif(cdfr_nls_1[["p"]][["KS"]], 3) [1] 0.2820 0.5010 0.2350 0.6350 0.3690 0.3940 0.5580 0.0118 0.7550 0.5520 > stopifnot(all.equal(cdfr_nls_1, cdfr_nls_2)) > > set.seed(20250614) > cdfr_nls_1_optimal <- update(cdfr_nls_1, ordering = "optimal") Calculating required true covariance specification matrices... Generating errors... Running simulation... > set.seed(20250614) > cdfr_nls_2_optimal <- update(cdfr_nls_2, ordering = "optimal") Calculating required true covariance specification matrices... Generating errors... Running simulation... > signif(cdfr_nls_1_optimal[["observed_stats"]], 3) KS CvM 1 0.884 0.1760 2 0.640 0.0582 3 0.640 0.1300 4 0.673 0.1030 5 1.260 0.8030 6 0.844 0.1940 7 0.527 0.1190 8 0.947 0.3000 9 0.611 0.0663 10 0.901 0.1550 > signif(cdfr_nls_1_optimal[["p"]][["KS"]], 3) [1] 0.2250 0.5570 0.5560 0.5000 0.0328 0.2660 0.7520 0.1720 0.6080 0.2090 > stopifnot(all.equal(cdfr_nls_1_optimal, cdfr_nls_2_optimal)) > > set.seed(20250614) > cdfr_nls_1_natural <- update(cdfr_nls_1, ordering = "natural") Calculating required true covariance specification matrices... Generating errors... Running simulation... > set.seed(20250614) > cdfr_nls_2_natural <- update(cdfr_nls_2, ordering = "natural") Calculating required true covariance specification matrices... Generating errors... Running simulation... > signif(cdfr_nls_1_natural[["observed_stats"]], 3) KS CvM 1 0.613 0.0878 2 0.517 0.0922 3 0.352 0.0450 4 0.422 0.0468 5 0.596 0.0652 6 1.080 0.3860 7 0.751 0.1040 8 0.456 0.0882 9 0.493 0.0382 10 0.467 0.0680 > signif(cdfr_nls_1_natural[["p"]][["KS"]], 3) [1] 0.619 0.782 0.968 0.912 0.648 0.097 0.402 0.873 0.820 0.857 > stopifnot(all.equal(cdfr_nls_1_natural, cdfr_nls_2_natural)) > > > > > > # lmer > > if(require(lme4)){ + set.seed(20250614) + data$g <- factor(sample(1:2, size = n, replace = TRUE)) + + control_list <- list(action = "ignore", tol = 1) + control_spec <- lmerControl(check.conv.singular = control_list, + check.conv.grad = control_list, + check.conv.hess = control_list) + form_lmer <- y ~ x1 + x2 + (1 | g) + + suppressWarnings({ + m_lmer_1 <- lmer(y ~ x1 + x2 + (1 | g), data = data, control = control_spec) + m_lmer_2 <- lmer(form_lmer, data = data, control = control_spec) + + set.seed(20250614) + cdfr_lmer_1 <- compare(true_mean = m_lmer_1, test_mean = m_lmer_1, + reps = 10, prog = Inf) + set.seed(20250614) + cdfr_lmer_2 <- compare(true_mean = m_lmer_1, test_mean = m_lmer_2, + reps = 10, prog = Inf) + print(signif(cdfr_lmer_1[["observed_stats"]], 3)) + print(signif(cdfr_lmer_1[["p"]][["KS"]], 3)) + stopifnot(all.equal(cdfr_lmer_1, cdfr_lmer_2)) + + set.seed(20250614) + cdfr_lmer_1_optimal <- update(cdfr_lmer_1, ordering = "optimal") + set.seed(20250614) + cdfr_lmer_2_optimal <- update(cdfr_lmer_2, ordering = "optimal") + print(signif(cdfr_lmer_1_optimal[["observed_stats"]], 3)) + print(signif(cdfr_lmer_1_optimal[["p"]][["KS"]], 3)) + stopifnot(all.equal(cdfr_lmer_1_optimal, cdfr_lmer_2_optimal)) + + set.seed(20250614) + cdfr_lmer_1_natural <- update(cdfr_lmer_1, ordering = "natural") + set.seed(20250614) + cdfr_lmer_2_natural <- update(cdfr_lmer_2, ordering = "natural") + print(signif(cdfr_lmer_1_natural[["observed_stats"]], 3)) + print(signif(cdfr_lmer_1_natural[["p"]][["KS"]], 3)) + stopifnot(all.equal(cdfr_lmer_1_natural, cdfr_lmer_2_natural)) + }) + } Loading required package: lme4 Loading required package: Matrix Running simulation... Running simulation... KS CvM 1 0.645 0.0839 2 1.070 0.2230 3 0.522 0.0482 4 0.578 0.1360 5 0.805 0.1260 6 0.621 0.0858 7 1.150 0.3860 8 0.686 0.2180 9 0.813 0.2410 10 0.508 0.0658 [1] 0.5130 0.0765 0.7240 0.6260 0.2840 0.5520 0.0463 0.4490 0.2730 0.7480 Running simulation... Running simulation... KS CvM 1 0.603 0.0883 2 0.634 0.1350 3 0.441 0.0297 4 1.000 0.2940 5 0.900 0.2680 6 0.663 0.0616 7 0.794 0.1020 8 0.732 0.1530 9 0.533 0.1050 10 0.473 0.0654 [1] 0.582 0.532 0.856 0.112 0.185 0.480 0.294 0.376 0.708 0.808 Running simulation... Running simulation... KS CvM 1 0.730 0.1550 2 0.719 0.1650 3 0.339 0.0326 4 0.859 0.2110 5 0.774 0.0889 6 0.654 0.0919 7 0.430 0.0419 8 0.536 0.0506 9 0.948 0.2460 10 0.412 0.0333 [1] 0.406 0.422 0.973 0.248 0.346 0.525 0.891 0.731 0.167 0.912 > > proc.time() user system elapsed 127.89 3.42 131.42