thanks everybody. I also just read Dirk E's high-performance computing
tutorial. now I wonder: would it be faster to compile a C version of
Gentleman's algorithm for WLS into R? before I waste a few days trying to
program this in and getting it all to work together, would the end result
lik
On Wed, Mar 25, 2009 at 5:15 PM, Gavin Simpson wrote:
> On Wed, 2009-03-25 at 16:28 -0400, ivo welch wrote:
>> Dear R experts:
>>
>> I just tried some simple test that told me that hand computing the OLS
>> coefficients is about 3-10 times as fast as using the built-in lm()
>> function. (code in
On Wed, 2009-03-25 at 22:11 +0100, Dimitris Rizopoulos wrote:
> check the following options:
>
> ols1 <- function (y, x) {
> coef(lm(y ~ x - 1))
> }
>
> ols2 <- function (y, x) {
> xy <- t(x)%*%y
> xxi <- solve(t(x)%*%x)
> b <- as.vector(xxi%*%xy)
> b
> }
>
> ols3 <- fun
On Wed, 25 Mar 2009, Ravi Varadhan wrote:
Yes, Bert. Any least-squares solution that forms X'X and then inverts it is
not to be recommended. If X is nearly rank-deficient, then X'X will be more
strongly so. The QR decomposition approach in my byhand.qr() function is
reliable and fast.
For
On Wed, 25 Mar 2009, ivo welch wrote:
thanks, dimitris. I also added Bill Dunlap's "solve(qr(x),y)"
function as ols5. here is what I get in terms of speed on a Mac Pro:
ols1 6.779 3.591 10.37 0 0
ols2 0.515 0.21 0.725 0 0
ols3 0.576 0.403 0.971 0 0
ols4 1.143 1.251 2.395 0 0
ols5 0.683 0.565
On Wed, 2009-03-25 at 16:28 -0400, ivo welch wrote:
> Dear R experts:
>
> I just tried some simple test that told me that hand computing the OLS
> coefficients is about 3-10 times as fast as using the built-in lm()
> function. (code included below.) Most of the time, I do not care,
> because I
09 6:03 pm
Subject: Re: [R] very fast OLS regression?
To: 'ivo welch' , 'Dimitris Rizopoulos'
Cc: 'r-help'
> lm is slow because it has to set up the design matrix (X) each time. See
> ?model.matrix and ?model.matrix.lm for how to do this once
> separately
.@r-project.org] On
Behalf Of ivo welch
Sent: Wednesday, March 25, 2009 2:30 PM
To: Dimitris Rizopoulos
Cc: r-help
Subject: Re: [R] very fast OLS regression?
thanks, dimitris. I also added Bill Dunlap's "solve(qr(x),y)"
function as ols5. here is what I get in terms of speed on a Ma
_
Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University
Ph. (410) 502-2619
email: rvarad...@jhmi.edu
- Original Message -
From: ivo welch
Date: Wednesday, March 25, 2009 4:31 pm
Subject: [R] very fast
thanks, dimitris. I also added Bill Dunlap's "solve(qr(x),y)"
function as ols5. here is what I get in terms of speed on a Mac Pro:
ols1 6.779 3.591 10.37 0 0
ols2 0.515 0.21 0.725 0 0
ols3 0.576 0.403 0.971 0 0
ols4 1.143 1.251 2.395 0 0
ols5 0.683 0.565 1.248 0 0
so the naive matrix operation
check the following options:
ols1 <- function (y, x) {
coef(lm(y ~ x - 1))
}
ols2 <- function (y, x) {
xy <- t(x)%*%y
xxi <- solve(t(x)%*%x)
b <- as.vector(xxi%*%xy)
b
}
ols3 <- function (y, x) {
XtX <- crossprod(x)
Xty <- crossprod(x, y)
solve(XtX, Xty)
}
ols4
Dear R experts:
I just tried some simple test that told me that hand computing the OLS
coefficients is about 3-10 times as fast as using the built-in lm()
function. (code included below.) Most of the time, I do not care,
because I like the convenience, and I presume some of the time goes
into s
12 matches
Mail list logo