Re: [R] linear regression in a ragged array

From: Greg Snow <Greg.Snow_at_imail.org>
Date: Tue, 22 Mar 2011 13:17:40 -0600

In general when you want to split up your data and do the same thing on each piece then combine the results back together it is good to look at the plyr package. But for this specific case you should look at the lmList function in the nlme package which may do exactly what you want with the least effort.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow_at_imail.org
801.408.8111



> -----Original Message-----
> From: r-help-bounces@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Marcel Curlin
> Sent: Monday, March 21, 2011 3:26 AM
> To: r-help_at_r-project.org
> Subject: [R] linear regression in a ragged array
>
> Hello,
> I have a large dataset of the form
>
> subj var1 var2
> 001 100 200
> 001 120 226
> 001 130 238
> 001 140 245
> 001 150 300
> 002 110 205
> 002 125 209
> 003 101 233
> 003 115 254
>
> I would like to perform linear regression of var2 on var1 for each
> subject
> separately. It seems like I should be able to use the tapply function
> as you
> do for simple operations (like finding a mean of var1 for each
> subject), but
> I am not sure of the correct syntax for this. Is there a way to do
> this?
>
> Many thanks, Marcel
>
> --
> View this message in context: http://r.789695.n4.nabble.com/linear-
> regression-in-a-ragged-array-tp3393033p3393033.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
______________________________________________ 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.
Received on Tue 22 Mar 2011 - 19:23:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 22 Mar 2011 - 20:00:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive