Skip to content

Commit

Permalink
change
Browse files Browse the repository at this point in the history
  • Loading branch information
statlink committed Oct 16, 2023
1 parent 6106725 commit 6a32640
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion R/lm.parboot.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,22 @@ lm.parboot <- function(x, y, R = 1000) {
z <- Rfast::matrnorm(n, R)
booty <- sqrt(s) * z + est
xx %*% booty
}
}


#[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
}

0 comments on commit 6a32640

Please sign in to comment.