fast.lm.df: no frills linear regression

Description Usage Arguments Value Author(s) See Also Examples

Description

a no frills version of lm. designed to return only the coefficients and nothing else. (and potentially some basic stats in a future version)

Usage

1
fast.lm.df(panel, right.hand.side, left.hand.sides)

Arguments

panel

a dataframe containing the relevant vectors

right.hand.side

a string referencing the column containing the observation vector of length n.

left.hand.sides

a vector of strings referencing the vectors to use as the design matrix (n * p).

Value

the length p coefficient vector.

Author(s)

Whit Armstrong

See Also

lm the standard lm method.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
NC <- 10
NR <- 1e5
A <- as.data.frame(asofdate=1:NR,matrix(rnorm(NR*NC),nrow=NR,ncol=NC))
colnames(A) <- letters[1:NC]
flm.time <- system.time(ans <- fast.lm.df(panel=A, right.hand.side="a",left.hand.sides=c("b","c","d","e")))
lm.time <- system.time(lm.ans <- as.vector(lm("a ~ 0 + b + c + d + e",data=A)$coefficients))
cat("all.equal:", all.equal(ans,lm.ans),"\n")

bmark.times <- rbind(flm.time,
                     lm.time,
                     lm.time/flm.time)
print(bmark.times)
ans.compare <- cbind(ans,lm.ans)

armstrtw/fast.lm documentation built on May 10, 2019, 1:42 p.m.