Hello,
I'm having trouble correctly specifying the random effects for a nlme
model. The general summary of what I'm trying to do is that I've got a
data set that has multiple individuals and multiple machines that took
measurements from those individuals. At least one of the machines has
drift during the day causing a visually linear decrease in the readout
during the day, so I have labeled that machine as broken in the data
frame.
Assuming that my data frame has the following:
> names(data)
[1] "AN" "period" "day"
[4] "time" "machine"
"readout"
[7] "gender" "age"
"weight"
[10] "height" "time.hr"
Where AN is the subject identifier, machine is the machine identifier,
(gender, age, weight, and height) are the demographic data, and time.hr
is the time since the machine was turned on that day.
I have two functions defined that take define the machine effect and the
demographic effects (with appropriate return values):
e.demog <- function(e0, age, weight, height, gender,
m.age, m.weight, m.height, m.gender)
e.broken.machine <- function(e0.machine, slope.machine, time, day,
machine)
Now, I want e0.machine to be the calibration value of any machine and
slope.machine to be the slope over time of the broken machine, and
random effects should be defined by machine. I also want to have a
random effect on the m.age and e0 to be defined by individual (AN). As
I understand the nlme documentation, I should write something like
mod <- nlme(readout~e.demog(e0, age, weight, height, gender,
m.age, m.weight, m.height, m.gender) +
e.machine(e0.machine, slope.machine, time.hr, day,
machine),
fixed=e0+m.age+m.weight+m.height+m.gender+slope.machine~1,
random=list(e0.machine~1|factor(machine),
e0+m.age~1|factor(AN)),
start=c(1, 1, 1, 1, 1, 1))
(FYI, this was typed into here, so there may be a typo, but the main
part is to look at the random= part of the call to nlme.)
This gives me an error of
Error in parse(text = paste("~", paste(nVal, collapse =
"/"))) :
unexpected end of input in "~ "
Can you give a suggestion of how to include the random effects correctly
so that e0.machine is given its random effect based on machine and e0
and m.age are given random effects based on AN?
Thanks,
Bill Denney
Drug Metabolism and Pharmacokinetics
Merck & Co, Inc.
Notice: This e-mail message, together with any attachme...{{dropped:12}}