speedglm (version 0.3-2)

add1.speedlm: Wrappers to the add1 and drop1 methods for speedlm and speedglm objects

Description

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.

Usage

## S3 method for class 'speedlm'
# S3 method for speedlm
add1(object, scope, scale = 0, test = c("none", "Chisq","F"), 
                       x = NULL, k = 2, data, ...)
# S3 method for speedlm
drop1(object, scope, scale = 0, all.cols = TRUE,
                        test = c("none","Chisq", "F"), k = 2, data, ...)
# S3 method for speedlm
extractAIC(fit, scale = 0, k=2,...)
# S3 method for speedlm
nobs(object, use.fallback = FALSE, ...)

## S3 method for class 'speedglm' # S3 method for 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 speedglm drop1(object, scope, scale = 0, test = c("none", "Rao", "LRT", "Chisq", "F"), k = 2, weights=rep(1,object$n), ...) # S3 method for speedglm extractAIC(fit, scale = 0, k=2,...) # S3 method for speedglm nobs(object, use.fallback = FALSE, ...)

Arguments

object

a speedlm or speedglm object for which model=TRUE was previously set to.

fit

a speedlm or speedglm object

scope

see add1 from package stats.

scale

see add1 from package stats.

all.cols

see drop1 from package stats.

test

see add1 from package stats.

x

see add1 from package stats.

k

see add1 from package stats.

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.

Warnings

Note that these functions have been poorly tested and need to be checked out more carefully.

Details

It is possible to use functions step() and stepAIC() for both speedlm and speedglm objects but objects fitted using updateWithMoreData()

Examples

Run this code
# 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
# }

Run the code above in your browser using DataCamp Workspace