R Under development (unstable) (2024-11-14 r87333 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 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(20240215) > n <- 1e2 > p <- 6 > func <- function(x, theta) sum(x*theta) > Sig <- rWishart(1, df = n, Sigma = diag(n))[,,1] > theta <- runif(p, min = -10, max = 10) > X <- matrix(rexp(n*p, rate = 1), nrow = n) > Y <- distfreereg:::f2ftheta(f = func, X)(theta) + + as.vector(distfreereg:::rmvnorm(n = n, reps = 1, mean = rep(0,n), + SqrtSigma = distfreereg:::matsqrt(Sig))) > dfr <- distfreereg(Y = Y, X = X, test_mean = func, covariance = list(Sigma = Sig), + theta_init = rep(1,p), verbose = FALSE) > > mu <- dfr[["mu"]] > r <- dfr[["r"]] > > # All of the following should be TRUE > for(i in seq_len(p)){ + print(all.equal(r[,i], + distfreereg:::calc_k2_resid(mu[,i], r_tilde = dfr[["r_tilde"]], + mu = mu, k2_tol = sqrt(.Machine[["double.eps"]])))) + } [1] TRUE [1] TRUE [1] TRUE [1] TRUE [1] TRUE [1] TRUE > > proc.time() user system elapsed 0.56 0.07 0.62