[R] stats lm() function

Ravi Varadhan rvaradhan at jhmi.edu
Thu Mar 12 20:34:46 CET 2009


Look at:

?update

For example:

lm.obj <- lm (y ~ x1 + ... + x300)

lm.obj1 <- update(lm.obj, . ~ .  - x1)

lm.obj2 <- update(lm.obj1, . ~ .  - x2)


Ravi.

____________________________________________________________________

Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvaradhan at jhmi.edu


----- Original Message -----
From: ph84 <masterodspam at gmx.de>
Date: Thursday, March 12, 2009 3:28 pm
Subject: [R]  stats lm() function
To: r-help at r-project.org


>  Hi,
>  
>  Im using the lm() function where the formula is quite big (300 arguments)
>  and the data is a frame of 3000 values.
>  
>  This is running in a loop where in each step the formula is reduced 
> by one
>  argument, and the lm command is called again (to check which 
> arguments are
>  useful) .
>  
>  This takes 1-2 minutes.
>  Is there a way to speed this up?
>  i checked the code of the lm function and its seems that its 
> preparing the
>  data and then calls lm.Fit(). i thought about just doing this praparing
>  stuff first and only call lm.fit() 300 times.
>  
>  
>  -- 
>  View this message in context: 
>  Sent from the R help mailing list archive at Nabble.com.
>  
>  ______________________________________________
>  R-help at r-project.org mailing list
>  
>  PLEASE do read the posting guide 
>  and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list