Wrappers to the add1 and drop1 methods for speedlm and speedglm objects
These are adviced to be used for speedlm
and speedglm
models fitted on moderately large data sets. It is also possible to use stepAIC function from package MASS
.
## S3 method for class 'speedlm' ## S3 method for class 'speedlm' add1(object, scope, scale = 0, test = c("none", "Chisq","F"), x = NULL, k = 2, data, ...) ## S3 method for class 'speedlm' drop1(object, scope, scale = 0, all.cols = TRUE, test = c("none","Chisq", "F"), k = 2, data, ...) ## S3 method for class 'speedlm' extractAIC(fit, scale = 0, k=2,...) ## S3 method for class 'speedlm' nobs(object, use.fallback = FALSE, ...) ## S3 method for class 'speedglm' ## S3 method for class 'speedglm' add1(object, scope, scale = 0, test = c("none", "Rao", "LRT", "Chisq", "F"), x = NULL, k = 2, weights=rep(1,object$n), ...) ## S3 method for class 'speedglm' drop1(object, scope, scale = 0, test = c("none", "Rao", "LRT", "Chisq", "F"), k = 2, weights=rep(1,object$n), ...) ## S3 method for class 'speedglm' extractAIC(fit, scale = 0, k=2,...) ## S3 method for class 'speedglm' nobs(object, use.fallback = FALSE, ...)
object |
a |
fit |
a |
scope |
see add1 from package |
scale |
see add1 from package |
all.cols |
see drop1 from package |
test |
see add1 from package |
x |
see add1 from package |
k |
see add1 from package |
data |
the data that the model was previously fitted to. If not provided, these will be searched in the parent environment. |
weights |
the model weights, if provided in the speedglm object |
use.fallback |
logical. Should fallback methods be used to try to guess the value? |
... |
further optional arguments. |
It is possible to use functions step() and stepAIC() for both speedlm and speedglm objects but objects fitted using updateWithMoreData()
Note that these functions have been poorly tested and need to be checked out more carefully.
Ronen Meiri and Marco Enea
## Not run: set.seed(10) n <- 1000 k <- 3 x <- round(matrix(rnorm(n * k), n, k), digits = 3) beta <- c(0.05,0.5,0.8,1.3,1.8) y <- drop(tcrossprod(cbind(1,x,x[,2]*x[,3]),t(beta))) + rnorm(n,,0.2) colnames(x) <- c("s1", "s2", "s3") da <- data.frame(y, x) m0 <- speedlm(y ~ 1, data = da,model=TRUE, y=TRUE) m0.1 <- add1(m0,scope=~(s1+s2+s3)^2, data = da) m1 <- step(m0,scope=~(s1+s2+s3)^3) m1 m2 <- speedglm(y ~ 1, data = da, model=TRUE, y=TRUE) m2.1 <- add1(m2,scope=~(s1+s2+s3)^2, data = da) m3 <- step(m2,scope=~(s1+s2+s3)^3) m3 ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.