# help with a regression

3 messages
Open this post in threaded view
|
Report Content as Inappropriate

## help with a regression

 Hello, I have a data frame with the following variables:  ID, X1,X2,X3,X4,X5,Y1,Y2,Y3,Y4,Y5 and some other that do not matter, some of the X and Y can be missing (NA). I want to compute the slope of the linear regression Y ~ X for each subject, so using  apply(DF,1,FUN,ra.rm=TRUE) now How do I define FUN? The X are different for each subject. Thanks for any help R.Heberto Ghezzo Ph.D. Montreal - Canada ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: help with a regression

 Can you provide a small example data set? Does the number after the X and Y indicate the subject? Are you trying to come up with a single line of code to do this ... ?      lm(Y1 ~ X1, data=DF)      lm(Y2 ~ X2, data=DF)      ...      lm(Y5 ~ X5, data=DF) Jean "R Heberto Ghezzo, Dr" <[hidden email]> wrote on 07/31/2012 03:33:40 PM: > > Hello, I have a data frame with the following variables: >  ID, X1,X2,X3,X4,X5,Y1,Y2,Y3,Y4,Y5 and some other that do not > matter, some of the X and Y can be missing (NA). I want to compute > the slope of the linear regression Y ~ X for each subject, so using >  apply(DF,1,FUN,ra.rm=TRUE) now How do I define FUN? The X are > different for each subject. > Thanks for any help > > R.Heberto Ghezzo Ph.D. > Montreal - Canada         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.