[R] help with a regression

arun smartpink111 at yahoo.com
Wed Aug 1 01:32:28 CEST 2012



HI,

Not sure how your dataset looks like.

Is it something like this?

dat1<-data.frame(ID=rep(1:2,each=5),X1=rnorm(10,10),X2=rnorm(10,3),X3=runif(10,0.4),X4=runif(10,0.8),X5=c(10,7,8,10,15,9,6,5,4,2), Y1=rnorm(10,25),Y2=rnorm(10,18),Y3=rnorm(10,35),
Y4=rnorm(10,45),Y5=rnorm(10,46))
I assume the IDs are subjects.  Then, for each subject, you want to calculate lm(Y(i)~X1+X2+X3+X4+X5), where i= 1 to 5.

Anyway, it would be better to post 10-15 lines of your dataset using dput.  Please post the output of : dput(head(data, 15)).

A.K.




----- Original Message -----
From: "R Heberto Ghezzo, Dr" <heberto.ghezzo at mcgill.ca>
To: "r-help at r-project.org" <r-help at r-project.org>
Cc: 
Sent: Tuesday, July 31, 2012 4:33 PM
Subject: [R] 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
______________________________________________
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.




More information about the R-help mailing list