Error in "gamm" ("unused argument = offset ...")

Hi, everyone!

First-time poster, here, so please be forbearing if I've violated some of the conventions for asking questions (like, for example, providing a replicable example).

I'm trying to estimate a Generalized Additive Mixed Model using the "gamm" function with this code:

fit1.1 = gamm(opioidNonFatalOD ~ s(mandatoryReg.l2, k = 3, fx = TRUE, 
                                         bs = "cr") +
                  s(coalitionActive.l2, k = 3, fx = TRUE, bs = "cr") +
                  monthsSinceJan2011 +
                  everFunded +
                  ICD10 +
                  spoke5 +
                  hub +
                  s(monthly2, bs = "cc", fx = FALSE, k = 4) +
                  s(county2, bs = "re"),
                  #+ offset(log(population / 100000)),
           correlation = corAR1(form = ~ monthsSinceJan2011 | county2),
           data = tsData,
           family = quasipoisson, offset = log(population / 100000),
           niterPQL = 20,
           verbosePQL = TRUE)type or paste code here

For some reason, it looks like the "offset" argument isn't getting passed to gammPQL. I get this error:

iteration 1
Quitting from lines 201-220 (pfs_model_experiments_041520.Rmd) 
Error in lme(fixed = fixed, random = random, data = data, correlation = correlation,  : 
  unused argument (offset = log(population/1e+05))
Calls: <Anonymous> ... withVisible -> eval -> eval -> gamm -> eval -> eval -> gammPQL
Execution halted

Here're the traceback messages:

Error in lme(fixed = fixed, random = random, data = data, correlation = correlation, : unused argument (offset = log(population/1e+05))
4.
gammPQL(y ~ X - 1, random = rand, data = strip.offset(mf), family = family, correlation = correlation, control = control, weights = weights, niter = niterPQL, verbose = verbosePQL, mustart = mustart, etastart = etastart, ...) at <text>#1
3.
eval(parse(text = paste("ret$lme<-gammPQL(", deparse(fixed.formula), ",random=rand,data=strip.offset(mf),family=family,", "correlation=correlation,control=control,", "weights=weights,niter=niterPQL,verbose=verbosePQL,mustart=mustart,etastart=etastart,...)", sep = "")))
2.
eval(parse(text = paste("ret$lme<-gammPQL(", deparse(fixed.formula), ",random=rand,data=strip.offset(mf),family=family,", "correlation=correlation,control=control,", "weights=weights,niter=niterPQL,verbose=verbosePQL,mustart=mustart,etastart=etastart,...)", sep = "")))
1.
gamm(opioidNonFatalOD ~ s(mandatoryReg.l2, k = 3, fx = TRUE, bs = "cr") + s(coalitionActive.l2, k = 3, fx = TRUE, bs = "cr") + monthsSinceJan2011 + everFunded + ICD10 + spoke5 + hub + s(monthly2, bs = "cc", fx = FALSE, k = 4) + s(county2, bs = "re"), ...

I've tried using the offset as a term in the model (see commented-out code), but get a similar error.

Just from inspecting the code, does anyone have an idea of what I'm doing wrong?

Thanks, David

I don't see any offset argument in ?mgcv::gamm()

not in ?lme

Your offset argument you are passing in the function (offset = ...) is not understand.

This explains the error.

This is another question on how to pass offset to your model.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.