Learn R Programming

speedglm (version 0.3-5)

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", "LRT", "Chisq", "F"), x = NULL, k = 2, ...) # S3 method for speedglm drop1(object, scope, scale = 0, test = c("none", "LRT", "Chisq", "F"), k = 2, ...) # S3 method for speedglm extractAIC(fit, scale = 0, k=2,...) # S3 method for speedglm nobs(object, use.fallback = FALSE, ...)

Value

An object of classes "anova" and "data.frame" summarizing the differences in fit between the models.

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. Currently, test "Rao" is not implemented.

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.

use.fallback

logical. Should fallback methods be used to try to guess the value?

...

further optional arguments.

Author

Ronen Meiri and Marco Enea

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

set.seed(10)
n <- 50
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, data = da)
m1 <- step(m0,scope=~s1+s2+s3)
m1

Run the code above in your browser using DataLab