R/bootreg.R

Defines functions bootreg

Documented in bootreg

bootreg <-
function(formula, data, nboot=1000){
    obj <- lm(formula, data=data)
    res <- resid(obj)
    hat <- fitted(obj)
    m <- length(coef(obj))
    bootmat <- matrix(0, nrow=nboot, ncol=m)
    rhs <- deparse(delete.response(terms(formula)))
    bootform <- as.formula(paste("yBoot", rhs))
    for(i in 1:nboot){
        resboot <- sample(res, replace=T)
        yBoot <- hat+resboot
        bootmat[i,] <- coef(lm(bootform, data=data))
    }
    colnames(bootmat) <- names(coef(obj))
    bootmat
}

Try the gamclass package in your browser

Any scripts or data that you put into this service are public.

gamclass documentation built on Aug. 21, 2023, 5:07 p.m.