From 6a326406716932d2790bad8fab9db1f79459dd83 Mon Sep 17 00:00:00 2001 From: Michail Tsagris Date: Mon, 16 Oct 2023 21:50:55 +0300 Subject: [PATCH] change --- R/lm.parboot.R | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/R/lm.parboot.R b/R/lm.parboot.R index 0472c2d..8364bcb 100644 --- a/R/lm.parboot.R +++ b/R/lm.parboot.R @@ -10,4 +10,22 @@ lm.parboot <- function(x, y, R = 1000) { z <- Rfast::matrnorm(n, R) booty <- sqrt(s) * z + est xx %*% booty -} \ No newline at end of file +} + + +#[export] +lm.nonparboot <- function (x, y, R = 1000) { + x <- model.matrix(y ~ ., data.frame(x)) + xx <- tcrossprod(Rfast::spdinv(crossprod(x)), x) + be <- xx %*% y + dm <- dim(x) + n <- dm[1] + p <- dm[2] + est <- as.vector(x %*% be) + res <- y - est + s <- Rfast::Var(res) * (n - 1)/(n - p) + z <- Rfast::rep_col(res, R) + z <- Rfast::colShuffle(z) + booty <- sqrt(s) * z + est + xx %*% booty +} \ No newline at end of file