# How to set up a non-linear mixed effects model with random effects in R using nlme?

I have some data with predictor variables, A and B and response variable C. I have a grouping factor SITE.

df <- data.frame(A = c(0.4, 0.4, 0.2, 0.2, 0.2, 0.2, 0.2), B = c(0.3, 0.3, 0.1, 0.1, 0.1, 0.1, 0.1),
C = c(4.4, 4.3, 5.6, 4.7, 5.1, 4.5, 4.9), SITE = c("south","south","east","east", "east", "north", "north"))


The relationships between C and predictor variables are non-linear.

I have not shown all the dataframe.

I would like to fit a non-linear mixed effects model with random effects in R.

I can use nlme() to fit this model. However, I am struggling to find any 'accessible' (I don't have a strong statistics background) documentation that goes through how I can set up the model.

Could someone please assist me in sitting up my model?

My 'attempt' to set up the model is:

m1 <- nlme(C ~ A + B, data = df, random = ~1 | SITE)


However, when I run the above, I get an error: argument "start" is missing, with no default.

-
Is it nonlinear in the parameters? If it is nonlinear in the predictors only a linear mixed model may be appropriate. –  Michael Chernick Sep 1 '12 at 11:41
Hi Michael. Thanks for your response. The relationship between the response variable C and predictor variables A and B are highly non-linear... –  mjburns Sep 1 '12 at 13:41
@mjburns the model you have specified in the question is linear in the parameters. You need to chose a functional form for the non-linearity, see e.g. ?selfStart for a description and list of the available functional forms built in to R. –  atiretoo Sep 1 '12 at 13:53
Yrs if it is linear in the parameters you can use a linear model and just specfy the form of the transformed variable (polynomial, exponential, log, Box-Cox power transformation etc. –  Michael Chernick Sep 1 '12 at 14:12
Thanks all. I am still a little confused. So, it is plausible to have a linear model: C = A+B, but where the model parameters are transformed - i.e. C = sqrt(A) + B? Is what I've described then a linear model? So in defining a non-linear model, would I be right in saying that: C = "some non-linear relationships" between A and B? Thanks. –  mjburns Sep 2 '12 at 8:16