Learn R Programming

bigFastlm (version 0.0.1)

bigLmPure: fast and memory efficient linear model fitting

Description

fast and memory efficient linear model fitting

Usage

bigLmPure(X, y, method = 0L)

Arguments

X
input model matrix. must be a big.matrix object (type = 8 for double)
y
numeric response vector of length nobs.
method
an integer scalar with value 0 for the LLT Cholesky or 1 for the LDLT Cholesky

Value

A list with the elements A list with the elements

Examples

Run this code

library(bigmemory)

nrows <- 50000
ncols <- 50
bkFile <- "bigmat2.bk"
descFile <- "bigmatk2.desc"
bigmat <- filebacked.big.matrix(nrow=nrows, ncol=ncols, type="double",
                                backingfile=bkFile, backingpath=".",
                                descriptorfile=descFile,
                                dimnames=c(NULL,NULL))

# Each column value with be the column number multiplied by
# samples from a standard normal distribution.
set.seed(123)
for (i in 1:ncols) bigmat[,i] = rnorm(nrows)*i

y <- rnorm(nrows) + bigmat[,1]

system.time(lmr1 <- bigLmPure(bigmat, y))

system.time(lmr2 <- lm.fit(x = bigmat[,], y = y))

max(abs(coef(lmr1) - coef(lmr2)))


Run the code above in your browser using DataLab