library(nlme)
Loblolly$age2 <- as.factor(ifelse(Loblolly$age < 12.5, 0, 1))
Here I define a binary covariate that I'm interested in.
model <- nlme(height ~ (R0) + 1,
data = Loblolly,
fixed = list(R0 ~ 1 + (age2)),
random = list(Seed = pdDiag(list(R0 ~ 1))),
start = list(fixed = c(R0 = -8.5, age2 = 1)))
Running this gives me the error,
Error in nlme.formula(height ~ (R0) + 1, data = Loblolly, fixed = list(R0 ~ :
step halving factor reduced below minimum in PNLS step
After changing the starting values, it works fine.
model2 <- nlme(height ~ (R0) + 1,
data = Loblolly,
fixed = list(R0 ~ 1 + (age2)),
random = list(Seed = pdDiag(list(R0 ~ 1))),
start = list(fixed = c(R0 = 0, age2 = 30)), verbose=TRUE)
What are some ways of selecting starting values for age2
? I thought about fitting a nonlinear least squares model using nls2
but that requires specifying a set of starting values as well.
I was thinking maybe I could plot the data, height ~ age2
, but since age2
is binary...I'm not sure how to go about it.