dear R experts---I am using the coef() function to pick off the coefficients from an lm() object. alas, I also need the standard errors and I need them fast. I know I can do a "summary()" on the object and pick them off this way, but this computes other stuff I do not need. Or, I can compute (X' X)^(-1) s^2 myself. Has someone written a fast se() function? incidentally, I think this would make a nice addition to the R base. I presume it is not uncommon for a statistician also to want to use the se of coef estimates. pointers appreciated. regards, /iaw ---- Ivo Welch (ivo.welch@brown.edu, ivo.welch@gmail.com) [[alternative HTML version deleted]]
You can get SE with this: coef(summary(your_model))[,'Std. Error'] On Fri, Jan 8, 2010 at 11:35 AM, ivo welch <ivowel at gmail.com> wrote:> dear R experts---I am using the coef() function to pick off the coefficients > from an lm() object. ?alas, I also need the standard errors and I need them > fast. ?I know I can do a "summary()" on the object and pick them off this > way, but this computes other stuff I do not need. ?Or, I can compute (X' > X)^(-1) s^2 myself. ?Has someone written a fast se() function? > > incidentally, I think this would make a nice addition to the R base. ?I > presume it is not uncommon for a statistician also to want to use the se of > coef estimates. > > pointers appreciated. > > regards, > > /iaw > ---- > Ivo Welch (ivo.welch at brown.edu, ivo.welch at gmail.com) > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O
From: ivo welch> > dear R experts---I am using the coef() function to pick off > the coefficients > from an lm() object. alas, I also need the standard errors > and I need them > fast. I know I can do a "summary()" on the object and pick > them off this > way, but this computes other stuff I do not need. Or, I can > compute (X' > X)^(-1) s^2 myself. Has someone written a fast se() function? > > incidentally, I think this would make a nice addition to the > R base. I > presume it is not uncommon for a statistician also to want to > use the se of > coef estimates.Not sure if this is much faster, but you can try sqrt(diag(vcov(lm.object))). Andy> pointers appreciated. > > regards, > > /iaw > ---- > Ivo Welch (ivo.welch at brown.edu, ivo.welch at gmail.com) > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >Notice: This e-mail message, together with any attachme...{{dropped:10}}
See ?display in the arm package. On Fri, Jan 8, 2010 at 8:35 AM, ivo welch <ivowel at gmail.com> wrote:> dear R experts---I am using the coef() function to pick off the coefficients > from an lm() object. ?alas, I also need the standard errors and I need them > fast. ?I know I can do a "summary()" on the object and pick them off this > way, but this computes other stuff I do not need. ?Or, I can compute (X' > X)^(-1) s^2 myself. ?Has someone written a fast se() function? > > incidentally, I think this would make a nice addition to the R base. ?I > presume it is not uncommon for a statistician also to want to use the se of > coef estimates. > > pointers appreciated. > > regards, > > /iaw > ---- > Ivo Welch (ivo.welch at brown.edu, ivo.welch at gmail.com) > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
On 8 January 2010 at 08:35, ivo welch wrote: | dear R experts---I am using the coef() function to pick off the coefficients | from an lm() object. alas, I also need the standard errors and I need them | fast. I know I can do a "summary()" on the object and pick them off this | way, but this computes other stuff I do not need. Or, I can compute (X' | X)^(-1) s^2 myself. Has someone written a fast se() function? Pages 72 and 73 of my most recent Intro to HPC tutorial [1] use Rcpp to access the GNU GSL to do just that: coefficients and covariance matrix of a standard y ~ X linear model. Pages 75 and 76 illustrate how the speed compares to both lm() and lm.fit() (hint: it is rather favourable). Page 74 tells you how to compile this if you use Rcpp (but you'd have to insert the slightly longer code from the tutorial document), this is now easier using the newest version of the inline package as detailed on my blog [2] but this has not yet been reflected in a new HPC tutorial. Hth, Dirk [1] http://dirk.eddelbuettel.com/papers/ismNov2009hpcTutorial.pdf [2] http://dirk.eddelbuettel.com/blog/2009/12/20#rcpp_inline_example -- Three out of two people have difficulties with fractions.