Running ‘0-01_preliminaries.R’ [2s/2s]
  Comparing ‘0-01_preliminaries.Rout’ to ‘0-01_preliminaries.Rout.save’ ... OK
  Running ‘1-01_distfreereg_function.R’ [21s/24s]
  Running ‘1-02_distfreereg_lm.R’ [12s/14s]
  Comparing ‘1-02_distfreereg_lm.Rout’ to ‘1-02_distfreereg_lm.Rout.save’ ... OK
  Running ‘1-03_distfreereg_nls.R’ [2s/3s]
  Running ‘1-04_distfreereg_glm.R’ [18s/21s]
  Comparing ‘1-04_distfreereg_glm.Rout’ to ‘1-04_distfreereg_glm.Rout.save’ ... OK
  Running ‘1-05_distfreereg_lmerMod.R’ [16s/19s]
  Comparing ‘1-05_distfreereg_lmerMod.Rout’ to ‘1-05_distfreereg_lmerMod.Rout.save’ ... OK
  Running ‘1-06_other.R’ [2s/2s]
  Comparing ‘1-06_other.Rout’ to ‘1-06_other.Rout.save’ ... OK
  Running ‘2-01_compare.R’ [39s/53s]
Running the tests in ‘tests/1-01_distfreereg_function.R’ failed.
Complete output:
  > library(distfreereg)
  > 
  > all.equal.distfreereg <- distfreereg:::all.equal.distfreereg
  > test_dfr_functions <- distfreereg:::test_dfr_functions
  > 
  > fcl <- function(need, covlist)
  +   distfreereg:::fill_covariance_list(need = need, covariance_list = covlist,
  +                                      matsqrt_tol = distfreereg:::default_distfreereg_tol()[["matsqrt_tol"]],
  +                                      solve_tol = distfreereg:::default_distfreereg_tol()[["solve_tol"]])
  > 
  > n <- 1e2
  > func <- function(X, theta) theta[1] + theta[2]*X[,1] + theta[3]*X[,2]
  > set.seed(20250516)
  > Sig_list <- lapply(seq_len(n/2), function(i) rWishart(n/2, df = 2, Sigma = diag(2))[,,i])
  > 
  > set.seed(20250516)
  > Sig <- rWishart(1, df = n, Sigma = diag(n))[,,1]
  > P <- fcl(need = "P", list(Sigma = Sig))[["P"]]
  > SqrtSigma <- fcl(need = "SqrtSigma", list(P = P))[["SqrtSigma"]]
  > Q <- fcl(need = "Q", list(SqrtSigma = SqrtSigma))[["Q"]]
  > 
  > X <- matrix(rexp(2*n, rate = 1), nrow = n)
  > colnames(X) <- c("a", "b")
  > 
  > theta <- c(2,5,1)
  > Y <- distfreereg:::f2ftheta(f = func, X)(theta) +
  +   as.vector(distfreereg:::rmvnorm(n = n, reps = 1, mean = rep(0,n), SqrtSigma = distfreereg:::matsqrt(Sig)))
  > 
  > set.seed(20250516)
  > dfr_func <- distfreereg(Y = Y, X = X, test_mean = func,
  +                         covariance = list(Sigma = Sig),
  +                         theta_init = c(1,1,1), verbose = FALSE,
  +                         control = list(return_on_error = FALSE),
  +                         stat = c("KS", "CvM", "KSmax", "KSmin"))
  > dfr_func
  Number of observations: 100
  Length of EPSP: 100 
  Monte Carlo simulations: 10000 
  
  Estimated parameter values:
     theta1    theta2    theta3 
  1.559e+00 5.363e+00 1.136e+00 
  
  Observed statistics:
   Stat      Value  Pr(>Value)       MCSE 
     KS  6.440e-01   6.885e-01  4.631e-03 
    CvM  6.841e-02   7.406e-01  4.383e-03 
  KSmax  6.440e-01   3.628e-01  4.808e-03 
  KSmin  1.973e-01   8.753e-01  3.304e-03 
  ---
  `MCSE' is the Monte Carlo standard error of the estimated p-value.
  
  > print(dfr_func, show_params = FALSE)
  Number of observations: 100
  Length of EPSP: 100 
  Monte Carlo simulations: 10000 
  
  Observed statistics:
   Stat      Value  Pr(>Value)       MCSE 
     KS  6.440e-01   6.885e-01  4.631e-03 
    CvM  6.841e-02   7.406e-01  4.383e-03 
  KSmax  6.440e-01   3.628e-01  4.808e-03 
  KSmin  1.973e-01   8.753e-01  3.304e-03 
  ---
  `MCSE' is the Monte Carlo standard error of the estimated p-value.
  
  > update(dfr_func, override = list(theta_hat = rep(1, length(dfr_func[["theta_hat"]]))))
  Number of observations: 100
  Length of EPSP: 100 
  Monte Carlo simulations: 10000 
  
  Estimated parameter values:
     theta1    theta2    theta3 
  1.000e+00 1.000e+00 1.000e+00 
  
  Observed statistics:
   Stat       Value  Pr(>Value)  MCSE 
     KS   3.725e+01  <1.000e-04    NA 
    CvM   4.675e+02  <1.000e-04    NA 
  KSmax  -4.815e-01  >9.999e-01    NA 
  KSmin   3.725e+01  <1.000e-04    NA 
  ---
  `MCSE' is the Monte Carlo standard error of the estimated p-value.
  
  > 
  > dfr_func_mod <- dfr_func
  > dfr_func_mod[["p"]][["value"]] <- c(0,1,0,1)
  > names(dfr_func_mod[["p"]][["value"]]) <- names(dfr_func[["p"]][["value"]])
  > dfr_func_mod
  Number of observations: 100
  Length of EPSP: 100 
  Monte Carlo simulations: 10000 
  
  Estimated parameter values:
     theta1    theta2    theta3 
  1.559e+00 5.363e+00 1.136e+00 
  
  Observed statistics:
   Stat      Value  Pr(>Value)       MCSE 
     KS  6.440e-01  <1.000e-04  4.631e-03 
    CvM  6.841e-02  >9.999e-01  4.383e-03 
  KSmax  6.440e-01  <1.000e-04  4.808e-03 
  KSmin  1.973e-01  >9.999e-01  3.304e-03 
  ---
  `MCSE' is the Monte Carlo standard error of the estimated p-value.
  
  > 
  > set.seed(20250516)
  > dfr_func_ungrouped <- distfreereg(Y = Y, X = X, test_mean = func, group = FALSE,
  +                                   covariance = list(Sigma = Sig),
  +                                   theta_init = c(1,1,1), verbose = FALSE,
  +                                   control = list(return_on_error = FALSE),
  +                                   stat = c("KS", "CvM", "KSmax", "KSmin"))
  > 
  > set.seed(20250516)
  > dfr_func_no_X <- distfreereg(Y = Y, test_mean = function(theta) theta,
  +                              covariance = list(Sigma = Sig),
  +                              theta_init = 1, verbose = FALSE,
  +                              control = list(return_on_error = FALSE))
  > 
  > set.seed(20250516)
  > dfr_func_verbose <- distfreereg(Y = matrix(Y), X = rnorm(n),
  +                                 test_mean = function(X, theta) theta*X[,1],
  +                                 covariance = list(Sigma = Sig),
  +                                 theta_init = 1,
  +                                 override = list(J = dfr_func[["J"]],
  +                                                 fitted_values = dfr_func[["fitted_values"]],
  +                                                 theoretical_stats = dfr_func[["theoretical_stats"]]),
  +                                 control = list(return_on_error = FALSE,
  +                                                theta_hat_name = "hello"),
  +                                 stat = c("KS", "CvM", "KSmax", "KSmin"))
  Coercing Y to vector...
  Coercing X to matrix...
  Using supplied covariance structure...
  Calculating the inverse square root of the covariance matrix...
  Estimating parameters...
  Using supplied fitted values...
  Using supplied Jacobian...
  Calculating mu...
  Ordering observations by simplex method...
  Calculating transformation anchors...
  Calculating r_tilde...
  Calculating residuals...
  All covariate observations are unique; no grouping done...
  Calculating empirical partial sum process...
  Calculating observed statistic(s)...
  Using supplied Monte Carlo simulation results...
  Warning message:
  In validate_args_distfreereg(test_mean = test_mean, ordering = ordering,  :
    No alternative optimization function specified; using optim() by default, ignoring 'fun_to_optimize_arg', 'theta_init_arg', and 'theta_hat_name'.
  > 
  > set.seed(20250516)
  > dfr_func_J_for_r <- distfreereg(Y = Y, X = X, test_mean = func,
  +                                 covariance = list(Sigma =Sig),
  +                                 theta_init = c(1,1,1), verbose = FALSE,
  +                                 override = list(r = dfr_func[["mu"]][order(order(dfr_func[["res_order"]])), ]),
  +                                 control = list(return_on_error = FALSE))
  Warning messages:
  1: In k2(r_tilde[, i], mu[, j], r_tilde[, j], k2_tol = k2_tol) :
    Matching columns found in mu and r_tilde that have scalar product nearly equal to 1
  2: In k2(r_tilde[, i], mu[, j], r_tilde[, j], k2_tol = k2_tol) :
    Matching columns found in mu and r_tilde that have scalar product nearly equal to 1
  3: In k2(r_tilde[, i], mu[, j], r_tilde[, j], k2_tol = k2_tol) :
    Matching columns found in mu and r_tilde that have scalar product nearly equal to 1
  4: In k2(output, r_tilde[, i], mu[, i], k2_tol = k2_tol) :
    Matching columns found in mu and r_tilde that have scalar product nearly equal to 1
  5: In k2(output, r_tilde[, i], mu[, i], k2_tol = k2_tol) :
    Matching columns found in mu and r_tilde that have scalar product nearly equal to 1
  6: In k2(output, r_tilde[, i], mu[, i], k2_tol = k2_tol) :
    Matching columns found in mu and r_tilde that have scalar product nearly equal to 1
  > 
  > set.seed(20250516)
  > dfr_func_list <- distfreereg(Y = Y, X = X, test_mean = func,
  +                              covariance = list(Sigma = Sig_list),
  +                              theta_init = c(1,1,1), verbose = FALSE,
  +                              control = list(return_on_error = FALSE),
  +                              stat = c("KS", "CvM", "KSmax", "KSmin"))
  > 
  > set.seed(20250516)
  > dfr_func_vec <- distfreereg(Y = Y, X = X, test_mean = func,
  +                             covariance = list(Sigma = runif(n, min = 1, max = 2)),
  +                             theta_init = c(1,1,1), verbose = FALSE,
  +                             control = list(return_on_error = FALSE),
  +                             stat = c("KS", "CvM", "KSmax", "KSmin"))
  > 
  > set.seed(20250516)
  > dfr_func_P <- distfreereg(Y = Y, X = X, test_mean = func,
  +                           covariance = list(P = P),
  +                           theta_init = c(1,1,1), verbose = FALSE,
  +                           control = list(return_on_error = FALSE),
  +                           stat = c("KS", "CvM", "KSmax", "KSmin"))
  > set.seed(20250516)
  > dfr_func_SqrtSigma <- distfreereg(Y = Y, X = X, test_mean = func,
  +                                   covariance = list(SqrtSigma = SqrtSigma),
  +                                   theta_init = c(1,1,1), verbose = FALSE,
  +                                   control = list(return_on_error = FALSE),
  +                                   stat = c("KS", "CvM", "KSmax", "KSmin"))
  > set.seed(20250516)
  > dfr_func_Q <- distfreereg(Y = Y, X = X, test_mean = func,
  +                           covariance = list(Q = Q),
  +                           theta_init = c(1,1,1), verbose = FALSE,
  +                           control = list(return_on_error = FALSE),
  +                           stat = c("KS", "CvM", "KSmax", "KSmin"))
  > 
  > stopifnot(all.equal(dfr_func, dfr_func_P))
  > stopifnot(all.equal(dfr_func, dfr_func_SqrtSigma))
  > stopifnot(all.equal(dfr_func, dfr_func_Q))
  > 
  > newdata_function <- matrix(rexp(2*10), nrow = 10)
  > test_dfr_functions(dfr_func, newdata = newdata_function)
  theta1 theta2 theta3 
    1.56   5.36   1.14 
         2.5 % 97.5 %
  theta1 0.725   2.39
  theta2 4.660   6.07
  theta3 0.832   1.44
    [1]  7.99  7.34 19.10 18.90  8.89  4.68  7.26  3.19  8.88  9.88  5.94  6.27
   [13]  3.84  4.08  6.66  5.92  5.64  3.76 12.00  9.06 11.90  6.93  3.69  7.21
   [25]  4.29  7.50  9.34  7.73  3.97  4.98 18.90 20.30  6.33 12.50 11.50  9.32
   [37]  5.73  5.48  5.10 12.00  3.73  1.88  2.87  2.74  4.33  4.55  5.14  5.60
   [49]  3.49 14.20  5.33 16.10  8.30 12.70 21.40  5.16  9.42  3.71  3.83  8.74
   [61] 17.70 10.80 10.20  3.38 10.90 14.50 12.40 11.30 15.70 11.70  7.22  5.52
   [73] 22.40 12.90  3.01 10.50  7.36  2.18 13.80  4.55  3.49  4.60  5.22  8.64
   [85]  2.87 10.50  3.30  4.55 11.20 14.00  2.28  8.63 11.40  2.01  7.31  5.70
   [97]  9.31  8.42 14.90  9.75
    [1]  7.99  7.34 19.10 18.90  8.89  4.68  7.26  3.19  8.88  9.88  5.94  6.27
   [13]  3.84  4.08  6.66  5.92  5.64  3.76 12.00  9.06 11.90  6.93  3.69  7.21
   [25]  4.29  7.50  9.34  7.73  3.97  4.98 18.90 20.30  6.33 12.50 11.50  9.32
   [37]  5.73  5.48  5.10 12.00  3.73  1.88  2.87  2.74  4.33  4.55  5.14  5.60
   [49]  3.49 14.20  5.33 16.10  8.30 12.70 21.40  5.16  9.42  3.71  3.83  8.74
   [61] 17.70 10.80 10.20  3.38 10.90 14.50 12.40 11.30 15.70 11.70  7.22  5.52
   [73] 22.40 12.90  3.01 10.50  7.36  2.18 13.80  4.55  3.49  4.60  5.22  8.64
   [85]  2.87 10.50  3.30  4.55 11.20 14.00  2.28  8.63 11.40  2.01  7.31  5.70
   [97]  9.31  8.42 14.90  9.75
   [1]  7.93  3.97  3.00  9.06 12.10  3.64 24.40  4.35  6.74  4.34
            theta1   theta2    theta3
  theta1  0.181000 -0.14500  0.000426
  theta2 -0.145000  0.12900 -0.002180
  theta3  0.000426 -0.00218  0.024000
  > 
  > plot(dfr_func, confband_args = NULL)
  > plot(dfr_func, which = "ecdf", confband_args = NULL)
  > plot(dfr_func, confband_args = FALSE)
  > plot(dfr_func, confband_args = list(m = 50,
  +                                     batch_len = 19,
  +                                     N = 1e3,
  +                                     conf.level = 0.9,
  +                                     q_probs = c(0.05, 0.95)))
  Warning message:
  In (function (x, w, func, m, batch_len, N, conf.level, q_probs,  :
    Batch length, 19, does not evenly divide data length, 10000
  > tryCatch(plot(dfr_func, confband_args = list(m = 50,
  +                                              batch_len = 19,
  +                                              N = 1e3,
  +                                              conf.level = 0.9,
  +                                              q_probs = c(0.5, 0.3))),
  +          error = function(e) warning(e))
  Warning message:
  In validate_args_plot.distfreereg(object = x, stat = stat, density_args = density_args,  :
    q_probs elements must be specified in increasing order.
  > 
  > plot(dfr_func, which = "residuals")
  > plot(dfr_func, which = "epsp")
  > 
  > 
  > cdfr_func <- asymptotics(dfr_func, reps = 5)
  Calculating required true covariance specification matrices...
  Generating errors...
  Running simulation...
  Repetition 1 of 5
  Repetition 2 of 5
  Repetition 3 of 5
  Repetition 4 of 5
  Repetition 5 of 5
  > signif(rejection(cdfr_func, alpha = c(0.1, 0.5))[,2:3], digits = 3)
    alpha rate
  1   0.1  0.0
  2   0.5  0.4
  3   0.1  0.0
  4   0.5  0.4
  5   0.1  0.2
  6   0.5  0.8
  7   0.1  0.0
  8   0.5  0.4
  > 
  > tryCatch(rejection(cdfr_func, alpha = c(0.1, "a")), error = function(e) warning(e))
  Warning message:
  In validate_numeric(alpha, min_len = 1, min_val = 0, max_val = 1) :
    alpha must be numeric; supplied value has class 'character'
  > tryCatch(rejection(cdfr_func, stat = "k"), error = function(e) warning(e))
  Warning message:
  In validate_args_rejection(object = object, alpha = alpha, stat = stat) :
    Some specified statistic(s) not found in object
  > 
  > 
  > predict(dfr_func, newdata = 1:3)
  [1] 9.194051
  Warning message:
  In predict.distfreereg(dfr_func, newdata = 1:3) :
    Vector supplied as 'newdata' converted into single row of newdata matrix...
  > 
  > 
  > 
  > 
  > 
  > # Update, smart versus dumb
  > 
  > set.seed(20250924)
  > dfr_1 <- distfreereg(Y = Y, X = X, test_mean = func,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = c(1,1,1), verbose = FALSE, B = 1e2)
  > 
  > set.seed(20250924)
  > dfr_update_smart <- update(dfr_1, theta_init = c(1,2,3))
  > set.seed(20250924)
  > dfr_update_dumb <- update(dfr_1, theta_init = c(1,2,3), smart = FALSE)
  > 
  > stopifnot(all.equal.distfreereg(dfr_update_smart, dfr_update_dumb))
  > 
  > 
  > # Orderings
  > 
  > dfr_func_asis <- update(dfr_func, ordering = "asis", verbose = TRUE)
  Using supplied covariance structure...
  Using supplied inverse square root of the covariance matrix...
  Using supplied parameter estimates...
  Using supplied fitted values...
  Using supplied Jacobian...
  Calculating mu...
  Leaving observation order as is...
  Calculating transformation anchors...
  Calculating r_tilde...
  Calculating residuals...
  All covariate observations are unique; no grouping done...
  Calculating empirical partial sum process...
  Calculating observed statistic(s)...
  Running Monte Carlo simulation...
  ...1000 of 10000
  ...2000 of 10000
  ...3000 of 10000
  ...4000 of 10000
  ...5000 of 10000
  ...6000 of 10000
  ...7000 of 10000
  ...8000 of 10000
  ...9000 of 10000
  ...10000 of 10000
  > dfr_func_optimal <- update(dfr_func, ordering = "optimal", verbose = TRUE)
  Using supplied covariance structure...
  Using supplied inverse square root of the covariance matrix...
  Using supplied parameter estimates...
  Using supplied fitted values...
  Using supplied Jacobian...
  Calculating mu...
  Ordering observations using optimal transport...
  - Creating distance matrix...
  - Solving linear sum assignment problem using the Hungarian method...
  Calculating transformation anchors...
  Calculating r_tilde...
  Calculating residuals...
  All covariate observations are unique; no grouping done...
  Calculating empirical partial sum process...
  Calculating observed statistic(s)...
  Running Monte Carlo simulation...
  ...1000 of 10000
  ...2000 of 10000
  ...3000 of 10000
  ...4000 of 10000
  ...5000 of 10000
  ...6000 of 10000
  ...7000 of 10000
  ...8000 of 10000
  ...9000 of 10000
  ...10000 of 10000
  > dfr_func_natural <- update(dfr_func, ordering = "natural", verbose = TRUE)
  Using supplied covariance structure...
  Using supplied inverse square root of the covariance matrix...
  Using supplied parameter estimates...
  Using supplied fitted values...
  Using supplied Jacobian...
  Calculating mu...
  Ordering observations by natural order...
  Calculating transformation anchors...
  Calculating r_tilde...
  Calculating residuals...
  All covariate observations are unique; no grouping done...
  Calculating empirical partial sum process...
  Calculating observed statistic(s)...
  Running Monte Carlo simulation...
  ...1000 of 10000
  ...2000 of 10000
  ...3000 of 10000
  ...4000 of 10000
  ...5000 of 10000
  ...6000 of 10000
  ...7000 of 10000
  ...8000 of 10000
  ...9000 of 10000
  ...10000 of 10000
  > dfr_func_colname <- update(dfr_func, ordering = list("a"), verbose = TRUE)
  Using supplied covariance structure...
  Using supplied inverse square root of the covariance matrix...
  Using supplied parameter estimates...
  Using supplied fitted values...
  Using supplied Jacobian...
  Calculating mu...
  Ordering observations by specified columns...
  Calculating transformation anchors...
  Calculating r_tilde...
  Calculating residuals...
  All covariate observations are unique; no grouping done...
  Calculating empirical partial sum process...
  Calculating observed statistic(s)...
  Running Monte Carlo simulation...
  ...1000 of 10000
  ...2000 of 10000
  ...3000 of 10000
  ...4000 of 10000
  ...5000 of 10000
  ...6000 of 10000
  ...7000 of 10000
  ...8000 of 10000
  ...9000 of 10000
  ...10000 of 10000
  > dfr_func_res_order <- update(dfr_func,
  +                              override = list(res_order = dfr_func[["res_order"]],
  +                                              r = dfr_func[["r"]]),
  +                              verbose = TRUE)
  Using supplied covariance structure...
  Using supplied inverse square root of the covariance matrix...
  Using supplied parameter estimates...
  Using supplied fitted values...
  Using supplied Jacobian...
  Calculating mu...
  Using supplied observation ordering...
  Using supplied transformation anchors...
  Calculating r_tilde...
  Calculating residuals...
  All covariate observations are unique; no grouping done...
  Calculating empirical partial sum process...
  Calculating observed statistic(s)...
  Running Monte Carlo simulation...
  ...1000 of 10000
  ...2000 of 10000
  ...3000 of 10000
  ...4000 of 10000
  ...5000 of 10000
  ...6000 of 10000
  ...7000 of 10000
  ...8000 of 10000
  ...9000 of 10000
  ...10000 of 10000
  > 
  > 
  > # Verify that ordering single column X with simplex results in natural ordering.
  > 
  > dfr_one_covariate_simplex <- distfreereg(test_mean = function(X, theta) theta*X[,1],
  +                                          Y = Y, X = X[,1,drop = FALSE],
  +                                          covariance = list(Sigma = 1),
  +                                          ordering = "simplex", B = 10,
  +                                          theta_init = 1, verbose = FALSE)
  > dfr_one_covariate_natural <- distfreereg(test_mean = function(X, theta) theta*X[,1],
  +                                          Y = Y, X = X[,1,drop = FALSE],
  +                                          covariance = list(Sigma = 1),
  +                                          ordering = "natural", B = 10,
  +                                          theta_init = 1, verbose = FALSE)
  > 
  > stopifnot(identical(dfr_one_covariate_simplex[["res_order"]],
  +                     dfr_one_covariate_natural[["res_order"]]))
  > 
  > 
  > 
  > 
  > ### default
  > 
  > set.seed(20250516)
  > dfr_default <- distfreereg(Y = Y, X = X, test_mean = NULL,
  +                            covariance = list(Sigma = Sig),
  +                            verbose = FALSE,
  +                            override = list(fitted_values = dfr_func[["fitted_values"]],
  +                                            J = dfr_func[["J"]]),
  +                            control = list(return_on_error = FALSE),
  +                            stat = c("KS", "CvM", "KSmax", "KSmin"))
  > dfr_default
  Number of observations: 100
  Length of EPSP: 100 
  Monte Carlo simulations: 10000 
  
  Observed statistics:
   Stat      Value  Pr(>Value)       MCSE 
     KS  6.440e-01   6.885e-01  4.631e-03 
    CvM  6.841e-02   7.406e-01  4.383e-03 
  KSmax  6.440e-01   3.628e-01  4.808e-03 
  KSmin  1.973e-01   8.753e-01  3.304e-03 
  ---
  `MCSE' is the Monte Carlo standard error of the estimated p-value.
  
  > 
  > dfr_default_verbose <- distfreereg(Y = as.matrix(Y), X = X[,1], test_mean = NULL,
  +                                    covariance = list(Sigma = Sig),
  +                                    override = list(fitted_values = dfr_func[["fitted_values"]],
  +                                                    J = dfr_func[["J"]]),
  +                                    control = list(return_on_error = FALSE),
  +                                    stat = c("KS", "CvM", "KSmax", "KSmin"))
  Coercing Y to vector...
  Coercing X to matrix...
  Using supplied covariance structure...
  Calculating the inverse square root of the covariance matrix...
  Estimating parameters...
  Using supplied fitted values...
  Using supplied Jacobian...
  Calculating mu...
  Ordering observations by simplex method...
  Calculating transformation anchors...
  Calculating r_tilde...
  Calculating residuals...
  All covariate observations are unique; no grouping done...
  Calculating empirical partial sum process...
  Calculating observed statistic(s)...
  Running Monte Carlo simulation...
  ...1000 of 10000
  ...2000 of 10000
  ...3000 of 10000
  ...4000 of 10000
  ...5000 of 10000
  ...6000 of 10000
  ...7000 of 10000
  ...8000 of 10000
  ...9000 of 10000
  ...10000 of 10000
  > 
  > test_dfr_functions(dfr_default, newdata = newdata_function)
  NULL
  NULL
    [1]  7.99  7.34 19.10 18.90  8.89  4.68  7.26  3.19  8.88  9.88  5.94  6.27
   [13]  3.84  4.08  6.66  5.92  5.64  3.76 12.00  9.06 11.90  6.93  3.69  7.21
   [25]  4.29  7.50  9.34  7.73  3.97  4.98 18.90 20.30  6.33 12.50 11.50  9.32
   [37]  5.73  5.48  5.10 12.00  3.73  1.88  2.87  2.74  4.33  4.55  5.14  5.60
   [49]  3.49 14.20  5.33 16.10  8.30 12.70 21.40  5.16  9.42  3.71  3.83  8.74
   [61] 17.70 10.80 10.20  3.38 10.90 14.50 12.40 11.30 15.70 11.70  7.22  5.52
   [73] 22.40 12.90  3.01 10.50  7.36  2.18 13.80  4.55  3.49  4.60  5.22  8.64
   [85]  2.87 10.50  3.30  4.55 11.20 14.00  2.28  8.63 11.40  2.01  7.31  5.70
   [97]  9.31  8.42 14.90  9.75
  NULL
  NULL
  NULL
  > 
  > stopifnot(all.equal(dfr_func, dfr_default))
  > 
  > 
  > # Orderings
  > 
  > dfr_default_asis <- update(dfr_default, ordering = "asis")
  > dfr_default_optimal <- update(dfr_default, ordering = "optimal")
  > dfr_default_natural <- update(dfr_default, ordering = "natural")
  > dfr_default_colname <- update(dfr_default, ordering = list("a"))
  > 
  > 
  > 
  > 
  > 
  > ### Warnings
  > 
  > 
  > # Partial Outputs
  > 
  > dfr_func_r_error <- distfreereg(Y = Y, X = X, test_mean = func,
  +                                 covariance = list(Sigma = Sig),
  +                                 theta_init = c(1,1,1),
  +                                 control = list(orth_tol = 1e-100))
  Using supplied covariance structure...
  Calculating the inverse square root of the covariance matrix...
  Estimating parameters...
  Calculating fitted values...
  Calculating Jacobian...
  Calculating mu...
  Warning message:
  Error encountered, partial results returned: Error in calc_mu(J = J_tilde, solve_tol = control[["solve_tol"]], orth_tol = control[["orth_tol"]]): crossprod(mu) is not equal to the identity matrix
   
  > names(dfr_func_r_error)
  [1] "call"                "test_mean"           "data"               
  [4] "covariance"          "optimization_output" "theta_hat"          
  [7] "fitted_values"       "J"                   ""                   
  > 
  > 
  > 
  > 
  > # fitted_values
  > 
  > set.seed(20250603)
  > func_fv <- function(X, theta) theta[1]*X
  > Sig_fv <- runif(n, min = 1, max = 3)
  > theta_fv <- 2
  > X_fv <- matrix(runif(n, min = 1, max = 5), nrow = n)
  > Y_fv <- theta_fv[1]*X_fv[,1] + rnorm(n, sd = sqrt(Sig_fv))
  > dfr_fv <- distfreereg(Y = Y_fv, X = X_fv, test_mean = func_fv,
  +                       covariance = list(Sigma = Sig_fv),
  +                       theta_init = 1, B = 1e3)
  Using supplied covariance structure...
  Calculating the inverse square root of the covariance matrix...
  Estimating parameters...
  Calculating fitted values...
  Calculating Jacobian...
  Calculating mu...
  Ordering observations by simplex method...
  Calculating transformation anchors...
  Calculating r_tilde...
  Calculating residuals...
  All covariate observations are unique; no grouping done...
  Calculating empirical partial sum process...
  Calculating observed statistic(s)...
  Running Monte Carlo simulation...
  ...100 of 1000
  ...200 of 1000
  ...300 of 1000
  ...400 of 1000
  ...500 of 1000
  ...600 of 1000
  ...700 of 1000
  ...800 of 1000
  ...900 of 1000
  ...1000 of 1000
  Warning message:
  In get_fitted_values.function(test_mean = test_mean, ftheta = ftheta,  :
    fitted_values being coerced to a vector...
  > 
  > 
  > 
  > 
  > 
  > 
  > ### Failures
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = NULL, group = FALSE,
  +                      covariance = list(Sigma = matrix(1:10, nrow = 5)), verbose = FALSE,
  +                      override = list(J = dfr_func[["J"]],
  +                                      fitted_values = dfr_func[["fitted_values"]]),
  +                      control = list(return_on_error = FALSE)),
  +          error = function(e) warning(e))
  Warning message:
  In validate_sqmat(covariance_list[[x]], n, message = c("Error in validating ",  :
    Error in validating covariance element Sigma (length>1): The dimensions of covariance_list[[x]] must be 100 by 100
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = NULL, group = FALSE,
  +                      covariance = list(Sigma = 1:10), verbose = FALSE,
  +                      override = list(J = dfr_func[["J"]],
  +                                      fitted_values = dfr_func[["fitted_values"]]),
  +                      control = list(return_on_error = FALSE)),
  +          error = function(e) warning(e))
  Warning message:
  In FUN(X[[i]], ...) : Invalid covariance vector length
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = NULL, group = FALSE,
  +                      covariance = list(Sigma = 1:10), verbose = FALSE,
  +                      override = list(J = dfr_func[["J"]],
  +                                      fitted_values = NA_real_),
  +                      control = list(return_on_error = FALSE)),
  +          error = function(e) warning(e))
  Warning message:
  In validate_numeric(override[["fitted_values"]], len = n, message = "override[['fitted_values']] failed numeric validation: ") :
    override[['fitted_values']] failed numeric validation: override[["fitted_values"]] cannot have NA values
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = NULL, group = FALSE,
  +                      covariance = list(Sigma = 1:10), verbose = FALSE,
  +                      override = list(J = dfr_func[["J"]],
  +                                      fitted_values = numeric()),
  +                      control = list(return_on_error = FALSE)),
  +          error = function(e) warning(e))
  Warning message:
  In validate_numeric(override[["fitted_values"]], len = n, message = "override[['fitted_values']] failed numeric validation: ") :
    override[['fitted_values']] failed numeric validation: override[["fitted_values"]] cannot be empty
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = NULL, group = FALSE,
  +                      covariance = list(Sigma = 1:10), verbose = FALSE,
  +                      override = list(J = dfr_func[["J"]],
  +                                      fitted_values = c(1, NaN)),
  +                      control = list(return_on_error = FALSE)),
  +          error = function(e) warning(e))
  Warning message:
  In validate_numeric(override[["fitted_values"]], len = n, message = "override[['fitted_values']] failed numeric validation: ") :
    override[['fitted_values']] failed numeric validation: override[["fitted_values"]] cannot have NaN values
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = NULL, group = FALSE,
  +                      covariance = list(Sigma = 1:10), verbose = FALSE,
  +                      override = list(J = dfr_func[["J"]],
  +                                      fitted_values = c(1, Inf)),
  +                      control = list(return_on_error = FALSE)),
  +          error = function(e) warning(e))
  Warning message:
  In validate_numeric(override[["fitted_values"]], len = n, message = "override[['fitted_values']] failed numeric validation: ") :
    override[['fitted_values']] failed numeric validation: override[["fitted_values"]] must be finite
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = NULL, group = FALSE,
  +                      covariance = list(Sigma = 1:10), verbose = FALSE,
  +                      override = list(J = dfr_func[["J"]],
  +                                      fitted_values = c(1, 2)),
  +                      control = list(return_on_error = FALSE)),
  +          error = function(e) warning(e))
  Warning message:
  In validate_numeric(override[["fitted_values"]], len = n, message = "override[['fitted_values']] failed numeric validation: ") :
    override[['fitted_values']] failed numeric validation: override[["fitted_values"]] must have length 100, not 2
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = NULL, group = FALSE,
  +                      covariance = list(Sigma = 1:10), verbose = FALSE,
  +                      override = list(J = dfr_func[["J"]],
  +                                      fitted_values = dfr_func[["fitted_values"]]),
  +                      control = list(return_on_error = FALSE,
  +                                     solve_tol = -1)),
  +          error = function(e) warning(e))
  Warning message:
  In FUN(X[[i]], ...) :
    Invalid tolerance specification: X[[i]] must be positive
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = function(a) a^2,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = c(1,1,1), verbose = FALSE,
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin")),
  +          error = function(e) warning(e))
  Warning message:
  In validate_mean_function_arg_names(f = test_mean) :
    Invalid argument specification of test_mean
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = func,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = c(1,1,1), verbose = FALSE,
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin"),
  +                      override = list(res_order = 1:4)),
  +          error = function(e) warning(e))
  Warning message:
  In validate_args_distfreereg(test_mean = test_mean, ordering = ordering,  :
    override[['res_order']] must be an ordering
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = func,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = c(1,1,1), verbose = FALSE,
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin"),
  +                      override = list(r = 1:5)),
  +          error = function(e) warning(e))
  Warning message:
  In validate_args_distfreereg(test_mean = test_mean, ordering = ordering,  :
    nrow(as.matrix(override[['r']])) must be equal to length(Y)
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = func,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = c(1,1,1), verbose = FALSE,
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin"),
  +                      override = list(J = 1:5)),
  +          error = function(e) warning(e))
  Warning message:
  In validate_args_distfreereg(test_mean = test_mean, ordering = ordering,  :
    nrow(as.matrix(override[['J']])) must be equal to length(Y)
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = func,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = c(1,1,1), verbose = FALSE,
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin"),
  +                      override = list(J = 1:5, r = 1:7)),
  +          error = function(e) warning(e))
  Warning message:
  In validate_args_distfreereg(test_mean = test_mean, ordering = ordering,  :
    nrow(as.matrix(override[['J']])) must be equal to length(Y)
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = func,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = c(1,1,1), verbose = FALSE,
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin"),
  +                      override = list(fitted_values = 1:5)),
  +          error = function(e) warning(e))
  Warning message:
  In validate_numeric(override[["fitted_values"]], len = n, message = "override[['fitted_values']] failed numeric validation: ") :
    override[['fitted_values']] failed numeric validation: override[["fitted_values"]] must have length 100, not 5
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = func,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = c(1,1,1), verbose = FALSE,
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin"),
  +                      override = list(J = c(1,2,NA))),
  +          error = function(e) warning(e))
  Warning message:
  In validate_numeric(override[["J"]], message = "override[['J']] failed numeric validation: ") :
    override[['J']] failed numeric validation: override[["J"]] cannot have NA values
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = func,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = c(1,1,1), verbose = FALSE,
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin"),
  +                      override = list(J = 1:5)),
  +          error = function(e) warning(e))
  Warning message:
  In validate_args_distfreereg(test_mean = test_mean, ordering = ordering,  :
    nrow(as.matrix(override[['J']])) must be equal to length(Y)
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = function(x) x,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = c(1,1,1), verbose = FALSE,
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin")),
  +          error = function(e) warning(e))
  Warning message:
  In validate_mean_function_arg_names(f = test_mean) :
    Invalid argument specification of test_mean
  > 
  > tryCatch(distfreereg(Y = Y, test_mean = function(x) x,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = c(1,1,1), verbose = FALSE,
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin")),
  +          error = function(e) warning(e))
  Warning message:
  In validate_mean_function_arg_names(f = test_mean) :
    Invalid argument specification of test_mean
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = function(theta) theta,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = c(1,1,1), verbose = FALSE,
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin")),
  +          error = function(e) warning(e))
  Warning message:
  In validate_args_distfreereg(test_mean = test_mean, ordering = ordering,  :
    'x' or 'X' must be an argument of test_mean when X is not NULL
  > 
  > tryCatch(distfreereg(Y = Y, X = X[1:5,], test_mean = function(theta) theta,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = 1, verbose = FALSE,
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin")),
  +          error = function(e) warning(e))
  Warning message:
  In validate_args_distfreereg(test_mean = test_mean, ordering = ordering,  :
    The number of rows in X must be the length of Y: nrow(X) is 5, but length(Y) is 100
  > 
  > tryCatch(distfreereg(Y = Y, X = NULL, test_mean = function(theta) theta,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = c(1,1,1), verbose = FALSE,
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin")),
  +          error = function(e) warning(e))
  Warning message:
  In validate_args_distfreereg(test_mean = test_mean, ordering = ordering,  :
    theta_init must have length 1 when X is NULL
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = func,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = c(1,1,1), verbose = FALSE,
  +                      control = list(return_on_error = FALSE,
  +                                     optimization_args = 4),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin")),
  +          error = function(e) warning(e))
  Warning message:
  In validate_args_distfreereg(test_mean = test_mean, ordering = ordering,  :
    control[['optimization_args']] must be a list.
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = func,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = c(1,1,1), verbose = FALSE,
  +                      control = list(return_on_error = FALSE,
  +                                     optimization_fun = "hello"),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin")),
  +          error = function(e) warning(e))
  Warning message:
  In validate_args_distfreereg(test_mean = test_mean, ordering = ordering,  :
    control[['optimization_fun']] must be a function
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = func,
  +                      covariance = list(Sigma = Sig),
  +                      theta_init = c(1,1,1), verbose = FALSE,
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin"),
  +                      ordering = c(1,2)),
  +          error = function(e) warning(e))
  Warning message:
  In validate_args_distfreereg(test_mean = test_mean, ordering = ordering,  :
    ordering method specification must have length one, or be a list of column specifications
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = NULL,
  +                      covariance = list(Sigma = Sig),
  +                      verbose = FALSE,
  +                      override = list(J = dfr_func[["J"]], dfr = "a",
  +                                      fitted_values = dfr_func[["fitted_values"]]),
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin")),
  +          error = function(e) warning(e))
  Warning message:
  In validate_named_list(override, valid_names = override_names) :
    override has the following bad names: dfr
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = NULL,
  +                      covariance = list(Sigma = Sig),
  +                      verbose = FALSE,
  +                      override = list(J = dfr_func[["J"]], res_order = 1:4,
  +                                      fitted_values = dfr_func[["fitted_values"]]),
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin")),
  +          error = function(e) warning(e))
  Warning message:
  In validate_args_distfreereg(test_mean = test_mean, ordering = ordering,  :
    override[['res_order']] must be an ordering
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = NULL,
  +                      covariance = list(Sigma = Sig),
  +                      verbose = FALSE,
  +                      override = list(J = dfr_func[["J"]], r = 1:5,
  +                                      fitted_values = dfr_func[["fitted_values"]]),
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin")),
  +          error = function(e) warning(e))
  Warning message:
  In validate_args_distfreereg(test_mean = test_mean, ordering = ordering,  :
    as.matrix(override[['J']]) and as.matrix(override[['r']]) must have the same dimensions
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = NULL,
  +                      covariance = list(Sigma = Sig),
  +                      verbose = FALSE,
  +                      override = list(J = dfr_func[["J"]], K = 1:5,
  +                                      fitted_values = dfr_func[["fitted_values"]]),
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin")),
  +          error = function(e) warning(e))
  Warning message:
  In validate_named_list(override, valid_names = override_names) :
    override has the following bad names: K
  > 
  > tryCatch(distfreereg(Y = Y, X = X[1:5,], test_mean = NULL,
  +                      covariance = list(Sigma = Sig),
  +                      verbose = FALSE,
  +                      override = list(J = dfr_func[["J"]],
  +                                      fitted_values = dfr_func[["fitted_values"]]),
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin")),
  +          error = function(e) warning(e))
  Warning message:
  In validate_args_distfreereg(test_mean = test_mean, ordering = ordering,  :
    The number of rows in X must be the length of Y: nrow(X) is 5, but length(Y) is 100
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = NULL,
  +                      covariance = list(Sigma = Sig),
  +                      verbose = FALSE,
  +                      override = list(J = dfr_func[["J"]],
  +                                      fitted_values = dfr_func[["fitted_values"]]),
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("KS", "CvM", "KSmax", "KSmin"),
  +                      ordering = c(1,4)),
  +          error = function(e) warning(e))
  Warning message:
  In validate_args_distfreereg(test_mean = test_mean, ordering = ordering,  :
    ordering method specification must have length one, or be a list of column specifications
  > 
  > tryCatch(distfreereg(Y = Y, X = X, test_mean = NULL,
  +                      covariance = list(Sigma = Sig),
  +                      verbose = FALSE,
  +                      override = list(J = dfr_func[["J"]],
  +                                      fitted_values = dfr_func[["fitted_values"]]),
  +                      control = list(return_on_error = FALSE),
  +                      stat = c("K")),
  +          error = function(e) warning(e))
  Warning message:
  In value[[3L]](cond) :*** buffer overflow detected ***: terminated
  Aborted
Running the tests in ‘tests/1-03_distfreereg_nls.R’ failed.
Complete output:
  > library(distfreereg)
  > 
  > all.equal.distfreereg <- distfreereg:::all.equal.distfreereg
  > test_dfr_functions <- distfreereg:::test_dfr_functions
  > 
  > n <- 1e2
  > func <- function(X, theta) theta[1] + theta[2]*X[,1] + theta[3]*X[,2]
  > set.seed(20250516)
  > Sig <- rWishart(1, df = n, Sigma = diag(n))[,,1]
  > X <- matrix(rexp(2*n, rate = 1), nrow = n)
  > theta <- c(2,5,1)
  > Y <- distfreereg:::f2ftheta(f = func, X)(theta) +
  +   as.vector(distfreereg:::rmvnorm(n = n, reps = 1, mean = rep(0,n), SqrtSigma = distfreereg:::matsqrt(Sig)))
  > 
  > df_nls <- as.data.frame(cbind(Y, X, rep(1:10, 10)))
  > names(df_nls) <- c("z", "x", "y", "g")
  > wt <- rexp(n) + 1
  > form_nls <- z ~ d + e*x + f*y
  > 
  > set.seed(20250516)
  > dfr_form_nls <- distfreereg(test_mean = form_nls, data = df_nls,
  +                             method_args = list(weights = wt),
  +                             method = "nls", verbose = FALSE,
  +                             control = list(return_on_error = FALSE))
  Warning message:
  In (function (formula, data = parent.frame(), start, control = nls.control(),  :*** buffer overflow detected ***: terminated
  Aborted
Running the tests in ‘tests/2-01_compare.R’ failed.
Complete output:
  > library(distfreereg)
  > all.equal.compare <- distfreereg:::all.equal.compare
  > 
  > 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),
  +                 reps = 3e2,
  +                 control = list(return_on_error = FALSE))
  Calculating required true covariance specification matrices...
  Generating errors...
  Running simulation...
  > 
  > cdfr
  'compare' object details:
  - Sample size: 60
  - Repetitions: 300
  - 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: 300
  - 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.943
  2  0.05 0.903
  3  0.10 0.937
  4  0.05 0.877
  > 
  > signif(ks.test(cdfr)[["p.value"]], digits = 3)
  [1] 7.67e-191
  > 
  > 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
  > 
  > 
  > 
  > # Override
  > 
  > smaller_n <- 1:(n/2)
  > cdfr_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),
  +                                 override = list(theta_hat = theta),
  +                                 reps = 10)
  Calculating required true covariance specification matrices...
  Generating errors...
  Running simulation...
  > 
  > 
  > 
  > 
  > # 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),
  +                          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 = length(smaller_n),
  +                   true_X = true_X[smaller_n,],
  +                   X = X[smaller_n,], keep = "all",
  +                   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),
  +                   # override = list(theta_hat = theta),
  +                   reps = 4e2)
  Calculating required true covariance specification matrices...
  Generating errors...
  Running simulation...
  > 
  > plot(x = cdfr, y = cdfr_n, confband_args = NULL)
  Warning messages:
  1: In plot.compare(x = cdfr, y = cdfr_n, confband_args = NULL) :
    Length of Y different for cdfr and cdfr_n
  2: In plot.compare(x = cdfr, y = cdfr_n, confband_args = NULL) :
    Length of empirical stats different for cdfr and cdfr_n
  > plot(x = cdfr, y = cdfr_n, confband_args = NULL, which = "dens")
  Warning messages:
  1: In plot.compare(x = cdfr, y = cdfr_n, confband_args = NULL, which = "dens") :
    Length of Y different for cdfr and cdfr_n
  2: In plot.compare(x = cdfr, y = cdfr_n, confband_args = NULL, which = "dens") :
    Length of empirical stats different for cdfr and cdfr_n
  > plot(x = cdfr, y = cdfr_n, confband_args = NULL, which = "qq")
  Warning messages:
  1: In plot.compare(x = cdfr, y = cdfr_n, confband_args = NULL, which = "qq") :
    Length of Y different for cdfr and cdfr_n
  2: In plot.compare(x = cdfr, y = cdfr_n, confband_args = NULL, which = "qq") :
    Length of empirical stats different for cdfr and cdfr_n
  > 
  > # 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_tilde, solve_tol = control[["solve_tol"]], orth_tol = control[["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"            
   [4] "true_mean"         "true_covariance"   "true_X"           
   [7] "true_data"         "test_mean"         "covariance"       
  [10] "X"                 "data"              "empirical_stats"  
  [13] "theoretical_stats" "p"                 "dfrs"             
  > 
  > 
  > 
  > ### Missing values in true_mean model object
  > 
  > true_data_missing <- true_data
  > missing_indices <- c(1, n+2)
  > is.na(true_data_missing)[missing_indices] <- TRUE
  > m_missing <- update(m, data = true_data_missing)
  > m_omitted <- update(m, data = true_data[-(missing_indices %% n), ])
  > 
  > tryCatch(compare(true_mean = m_missing, test_mean = m, reps = 10),
  +          error = function(e) warning(e))
  Warning message:
  In get_n(n = n, true_X = true_X, X = X, true_data = true_data, data = data,  :*** buffer overflow detected ***: terminated
  Aborted