Adrian
Adrian

Reputation: 9793

How to select starting value for covariates in NLME

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.

Upvotes: 4

Views: 1706

Answers (1)

G. Grothendieck
G. Grothendieck

Reputation: 269664

Try lm like this:

fm.lm <- lm(height ~ age2, Loblollly) # modified Loblolly as per question
st <- coef(fm.lm)
names(st)[1] <- "R0"
nlme(height ~ (R0) + 1, data = Loblolly,
               fixed = list(R0 ~ 1 + (age2)),
               random = list(Seed = pdDiag(list(R0 ~ 1))),
               start = list(fixed = st))

giving:

Nonlinear mixed-effects model fit by maximum likelihood
  Model: height ~ (R0) + 1 
  Data: Loblolly 
  Log-likelihood: -305.1093
  Fixed: list(R0 ~ 1 + (age2)) 
R0.(Intercept)       R0.age21 
      12.96167       36.80548 

Random effects:
 Formula: R0 ~ 1 | Seed
        R0.(Intercept) Residual
StdDev:   0.0002791602 9.145988

Number of Observations: 84
Number of Groups: 14 

Upvotes: 2

Related Questions