r - How to use lm.fit instead on lm -
i want use lm.fit speed, second version gives nas
sum <- summary(lm(y~x)) slope <- sum$coefficients[2]
or
sum <- lm.fit(as.matrix(x,ncol=1),y) slope <- sum$coefficients[2]
edit 1
i see sum$coefficients has 1 value. why , it? doesn't explain this
it easier reproducible example.
however, guess missing intercept in second case. try lm.fit(cbind(1,x),y)
, see if gives comparison looking for.
other differences due other preprocessing lm
before calling lm.fit
, don't know without seeing x
. things removing missing values, expanding factor dummy variables result in differences.
Comments
Post a Comment