[R] nlme help please

Bill Simpson wsi at gcal.ac.uk
Thu May 24 11:05:28 CEST 2001


I am trying to learn how to use nlme by working on a simple example. I
attach the data from a toy example I made up which is similar to my real
problem. (My grasp of fixed/random effects is still a bit tenuous)

It is a longitudinal study of the effect of two treatments: A and B. The
data were created by:
A: y<-12/(1+exp((2-time)/.5)),y<-8/(1+exp((2-time)/.5))
B: y<-22/(1+exp((2-time)/.5)), y<-18/(1+exp((2-time)/.5))
fixed effect for param a = 10,10, 20,20, random effects= +2, -2, +2, -2
fixed effect for param b=2, fixed effect for c = .5
normal noise with sd=1 was added to all y values.

I do:
df<-read.table(file="papers/alex/junk.dat",header=TRUE)
attach(df)

fullfit<-nlsList(y~SSlogis(Time,Asym,xmid,scal)|Subject,data=df)
and get the separate fits of the logistic to each subject's data. 4 curves
and 4 sets of param values (12 params total for the model).

How do I get the fit of the model which is the true one as stated above:
Asym for group A (fixed effect)
Asym for group B  (fixed effect)
Asym diff from group A mean for subject 1 (random effect)
Asym diff from group A mean for subject 2 (random effect)
Asym diff from group B mean for subject 3 (random effect)
Asym diff from group B mean for subject 4 (random effect)

xmid (fixed effect)
scal (fixed effect)
= 8 params total
I would like 95% CIs for params and in particular a CI for the diff in
Asym for groups A and B (or a hypo test).

If I had an additional grouping factor (e.g. Sex), how would I do it? (I
would have enough subjects to make it worthwhile--I actually have 53).

Thanks very much for any help.

BTW I have not tried to use groupedData object because I think that's
mainly useful for the fancy trellis graphics, which we don't have in R. I
know there was a recent announcement about lattice, but I'm not at all
sure that would work with nlme at this point...

Bill Simpson
-------------- next part --------------
"Subject"	"Group"	"Time"	"y"
1	a	1	1.803407
1	a	2	3.790964
1	a	3	6.885437
1	a	4	6.304922
1	a	5	6.423945
2	a	1	1.685487
2	a	2	4.775235
2	a	3	12.058397
2	a	4	12.500626
2	a	5	12.602189
3	b	1	1.532756
3	b	2	9.866473
3	b	3	16.928385
3	b	4	17.762473
3	b	5	18.493848
4	b	1	2.975398
4	b	2	13.158969
4	b	3	19.589508
4	b	4	22.389456
4	b	5	21.381210


More information about the R-help mailing list