0

I would like to fit a nonlinear model just with the fixed structure specification using nlme R package.

model <- nlme(y ~ Asym/(1+exp((xmid-x)/scal)),
                      data = data,
                      fixed = list(Asym + xmid + scal ~ treatment))
                      #random =  Asym ~ 1|subject)

However I am getting the following error:

Error in parse(text = paste("~", paste(nVal, collapse = "/"))) : 
  <text>:2:0: unexpected end of input
1: ~ 
   ^

Is there a way to circunvent this issue? Any advice is more than welcome.

1 Answers1

0

I believe you want the gnls() function (also from the nlme package) with the params= argument rather than fixed=. Try this:

model <- gnls(y ~ Asym/(1+exp((xmid-x)/scal)),
                  data = data,
                  params = list(Asym + xmid + scal ~ treatment),
                  start= ...)

FWIW, if you're really fitting a logistic (and this isn't just a simplified example of what you want to do), fitting might be faster/more robust with the SSlogis() self-starting function in place of your explicit formula ...

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453