Re: [R] lme model specification
If you are now presenting subjects with pairs, have you considered multidimensional scaling and possibly "Bradley-Terry" models & extensions? RSiteSearch("multidimensional scaling") and RSiteSearch("Bradley-Terry") both seemed to contain potentially useful information. best wishes, spencer graves # Bill Simpson wrote: > Thanks very much Spencer for your helpful reply. > > On Fri, 2006-01-20 at 07:38 -0800, Spencer Graves wrote: > >> Does each subject get only one LED per session or all 4 LEDs? > > I simplified a bit. Each subject gets pairs of LEDs and needs to > estimate the distance between them. LED1 can be Red or Blue, and LED2 > can be R or B -- so there are 4 combos. These are presented in random > order. So in one session yes each subject sees all combos of LEDs. > > >> This >>should be important regarding which models are estimaable. In either >>case, might the following help you? >> >>nSubj <- 8 >>nSess <- 4 >>nObsPerSess <- 3 >> >>library(nlme) >>library(e1071) >>P4 <- permutations(4) >> >>LED <- letters[t(P4[permSubj,])] >> >>set.seed(1) >>permSubj <- sample(24, nSubj) >>N <- nSubj*nSess*nObsPerSess >>DF <- data.frame( >> Subject=rep(1:nSubj, each=nSess*nObsPerSess), >> illum=rep(c("star", "moon"), each=N/2), >> feedback=rep(c("yes", "no"), each=N/4, length=N), >> session=rep(1:nSess, each=nObsPerSess, nSubj), >> LED=rep(LED, each=nObsPerSess), >> Rep=rep(1:nObsPerSess, nSess*nSubj), >> logdistance=rep(1:nObsPerSess, nSess*nSubj), >> logestimate=rnorm(nSubj*nSess*nObsPerSess) ) >> >>fit <- lme(logestimate~logdistance*illum*feedback+LED, >> random=~1|Subject, >> correlation=corAR1(form=~Rep|Subject/session), >> data=DF) > > Thanks very much, I didn't know about the corAR1 statement. > > Best wishes > Bill __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lme model specification
Does each subject get only one LED per session or all 4 LEDs? This should be important regarding which models are estimaable. In either case, might the following help you? nSubj <- 8 nSess <- 4 nObsPerSess <- 3 library(nlme) library(e1071) P4 <- permutations(4) LED <- letters[t(P4[permSubj,])] set.seed(1) permSubj <- sample(24, nSubj) N <- nSubj*nSess*nObsPerSess DF <- data.frame( Subject=rep(1:nSubj, each=nSess*nObsPerSess), illum=rep(c("star", "moon"), each=N/2), feedback=rep(c("yes", "no"), each=N/4, length=N), session=rep(1:nSess, each=nObsPerSess, nSubj), LED=rep(LED, each=nObsPerSess), Rep=rep(1:nObsPerSess, nSess*nSubj), logdistance=rep(1:nObsPerSess, nSess*nSubj), logestimate=rnorm(nSubj*nSess*nObsPerSess) ) fit <- lme(logestimate~logdistance*illum*feedback+LED, random=~1|Subject, correlation=corAR1(form=~Rep|Subject/session), data=DF) spencer graves Bill Simpson wrote: > I have been asked to analyse the results of (what is to me) a very > complicated experiment. > > The dependent measure is the estimated distance, which is measured as a > function of the actual distance. There are also several other IVs. > > The plot of log estimated distance as a function of log distance is > linear. So in the rest of the analysis I will use logestimate and > logdistance. > > My plan is to see how the other IVs affect the slope and intercept of > this linear relationship between logestimate and log distance. > > What complicates everything is that each datum point is not independent. > Rather, many data points come from each subject. > > So: > * Each subject gets many objects at many distances which he has to > estimate. > * Each subject repeats this experiment using 4 colours of LEDs. > * Each subject repeats this experiment on 4 different sessions. > * Half the subjects do this under starlight, half under moonlight. > * Half the subjects do it with feedback and half without. > > So some of these variables are within subjects and some between. I think > lme is a good way to proceed. But I am hung up on how to specify the > model > > fit<-lme(fixed=logestimate~logdistance*session*illum*feedback, > random=???|subject???, data=df1) > > I am familiar with the steps of model building using lm(), exploring > different models etc, so I think I will be OK once I get the idea of > specifying the basic lme model. > > I have Pinheiro and Bates (2000) here. > > Thanks very much for any help > > Bill Simpson > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] lme model specification
Thanks for the response. It is actually a repeated measures study, I just mention the fixed effects specification because I think I know the random effect specification, i.e.: Random = ~ 1|subject And thanks for the tip about the nonlinear model and the S-plus list. I will check out nlme and the other list. Eric On 6/9/05, Eric Hack <[EMAIL PROTECTED]> wrote: > Dear All, > > > > I am trying to specify the following fixed effects model for lme: If you have a linear fixed-effects model you should use lm, not lme. > > y ~ constant1 - beta1*(x - beta2) > > where y is the response, x is the independent variable, and the > operators above are real arithmetic operations of addition, subtraction, > and multiplication. I realize that this model is just a > reparameterization of y=beta0+beta1*x, but I am using this > parameterization because I am specifically interested in confidence > bounds for beta2. You would need to fit that as a nonlinear model. In reference to such models "linear" means "linear in the parameters" and that model isn't. > I have looked at the help, but the closest hint I find is the I() > function, and that does not seem to work this way. > > > > I confess that I am actually using S-plus, but there does not seem to be > a resource like this list for S-plus. Look for the S-news email list (http://www.biostat.wustl.edu/s-news/) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lme model specification
On 6/9/05, Eric Hack <[EMAIL PROTECTED]> wrote: > Dear All, > > > > I am trying to specify the following fixed effects model for lme: If you have a linear fixed-effects model you should use lm, not lme. > > y ~ constant1 - beta1*(x - beta2) > > where y is the response, x is the independent variable, and the > operators above are real arithmetic operations of addition, subtraction, > and multiplication. I realize that this model is just a > reparameterization of y=beta0+beta1*x, but I am using this > parameterization because I am specifically interested in confidence > bounds for beta2. You would need to fit that as a nonlinear model. In reference to such models "linear" means "linear in the parameters" and that model isn't. > I have looked at the help, but the closest hint I find is the I() > function, and that does not seem to work this way. > > > > I confess that I am actually using S-plus, but there does not seem to be > a resource like this list for S-plus. Look for the S-news email list (http://www.biostat.wustl.edu/s-news/) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html