What is the proper syntax to fit a random intercept model using NLMER?
10:57 26 Feb 2026

I am using NLMER and a custom logistic formula to try and fit a random intercept model. When I try to fit a random intercept model as all the documentation I have seen using ~ 1 | ID I get an error that "1 is not meaningful in a nonlinear model formula."

Unfortunately I cannot share my actual dataset to maintain privacy of the participants so here is the logistic model with a sample data set that is throwing the error.

set.seed(123)

# Logistic function and model

logistic.fcn <- function (x, y0, y100B, dy100.F, a, x0B, dx0.F, isF_num) {
  y0 + ((y100B + isF_num*dy100.F) - y0) /
    (1 + exp(-a * (x - (x0B + isF_num*dx0.F))))
}

logistic.model <- deriv(
  ~ y0 + ((y100B + isF_num*dy100.F) - y0) /
    (1 + exp(-a * (x - (x0B + isF_num*dx0.F)))),
  namevec = c("y0","y100B","dy100.F","a","x0B","dx0.F"),
  function.arg = c("x","y0","y100B","dy100.F","a","x0B","dx0.F","isF_num")
)

# Sample data

n_id  <- 20
n_obs <- 20

ID <- factor(rep(1:n_id, each = n_obs))
visibility <- rep(seq(0, 1, length.out = n_obs), times = n_id)

isF_num <- unlist(lapply(1:n_id, function(i) {
  rbinom(n_obs, 1, 0.5)
}))

pars <- list(
  y0 = -2,
  y100B = 2,
  dy100.F = 0.5,
  a = 10,
  x0B = 0.5,
  dx0.F = 0.1
)

ptlt_logit <- logistic.fcn(
  visibility,
  pars$y0, pars$y100B, pars$dy100.F,
  pars$a, pars$x0B, pars$dx0.F,
  isF_num
) + rnorm(length(visibility), 0, 0.2)

looking_times <- data.frame(
  ptlt_logit,
  visibility,
  isF_num,
  ID
)

start <- list(
  nlpars = c(
    y0 = -1.5,
    y100B = 1.5,
    dy100.F = 0.3,
    a = 8,
    x0B = 0.5,
    dx0.F = 0.05
  )
)


fit <- nlmer(
  ptlt_logit ~ logistic.model(
    visibility, y0, y100B, dy100.F,
    a, x0B, dx0.F, isF_num
  ) ~ 1 | ID,
  data = looking_times,
  start = start,
  control = nlmerControl(tolPwrss = 1e-6)
)

I am getting the following error:

Error in chck1(meform <- form[[3L]]) : 
  1 is not meaningful in a nonlinear model formula

I do not get an error when fitting to a random slope model such as

 ~ y100B|ID 

So I know it is a problem with the syntax of

~ 1|ID
r mixed-models nlme random-effects