Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in 'getParameterOrder' #791

Closed
jcpiquet opened this issue Mar 10, 2022 · 16 comments
Closed

Error in 'getParameterOrder' #791

jcpiquet opened this issue Mar 10, 2022 · 16 comments

Comments

@jcpiquet
Copy link

Hi everyone,
After downloading the latest version of TMB package, I tried to re-run a code on glmmTMB that was working just fine until this morning, and I got this error:
'Error in .Call("getParameterOrder", data, parameters, new.env(), NULL, :
Incorrect number of arguments (4), expecting 3 for 'getParameterOrder'
If I use the same code for lme4 it works perfectly fine. Any idea on what is happening and what can I do to fix this?
If needed, I would have no problem sharing the code or anything else.
Thanks!
Julien

@mebrooks
Copy link
Contributor

mebrooks commented Mar 10, 2022

Try re-installing glmmTMB (from source) after TMB. We're working on preventing this in the future.

@bbolker
Copy link
Contributor

bbolker commented Mar 10, 2022

I will point out that you should have gotten a warning about "Package version inconsistency detected" when you loaded glmmTMB. Did you?

@jcpiquet
Copy link
Author

Yes!! I saw the message right now. Thank you both for the rapid response. After re-installing glmmTMb from source it worked again.

@antigosa
Copy link

antigosa commented Jun 2, 2022

Hi all,

Sorry to open this again, but I have a related issue, I think. When I try to simply see what's inside a saved model that I have run using glmmTMB, I got this message:

Error in .Call("MakeDoubleFunObject", data, parameters, reportenv, PACKAGE = DLL) : 
Incorrect number of arguments (3), expecting 4 for 'MakeDoubleFunObject'

Try re-installing glmmTMB (from source) after TMB. We're working on preventing this in the future.

I tried this, but did not work unfortunately.

I will point out that you should have gotten a warning about "Package version inconsistency detected" when you loaded glmmTMB. Did you?

And I don't get this

Any idea? Do you need more info?

Thanks!
Raffa

@kaskr
Copy link
Contributor

kaskr commented Jun 2, 2022

@antigosa You might be able to run up2date(oldfit) on your old fit...

@antigosa
Copy link

antigosa commented Jun 2, 2022

@antigosa You might be able to run up2date(oldfit) on your old fit...

It works! Great, thanks @kaskr

@bbolker
Copy link
Contributor

bbolker commented Jun 2, 2022

We should make sure this is documented appropriately ...

@Thom-Teears
Copy link

Hello,
I get a similar error (shown below) as well when using the TMB package. I tried reinstalling TMB and glmmTMB from source and the error persists. I don't get any messages regarding package version inconsistency. Any help you can offer would be greatly appreciated.

Thanks,
Thom

Error in .Call("getParameterOrder", data, parameters, reportenv, control, :
Incorrect number of arguments (4), expecting 3 for 'getParameterOrder'

@bbolker
Copy link
Contributor

bbolker commented Oct 3, 2023

OK, the usual questions:

  • are you loading a stored fit from an older session (i.e., fitted with an older version of glmmTMB)? (In which case, run up2date() on your model.)
  • have you installed TMB and glmmTMB from source in that order?

I don't have many ideas beyond that, but it would be helpful if you can give the results of sessionInfo() from a clean R session (i.e., only TMB and glmmTMB loaded)

@bbolker bbolker reopened this Oct 3, 2023
@Thom-Teears
Copy link

Thank you so much for your response. I appreciate it.

I uninstalled R, RStudio, and Rtools and then reinstalled them as per the instructions at http://github.com/kaskr/adcomp/wiki/Download.

Then I installed TMB and glmmTMB from source in that order. The error still persists from a clean R session (i.e., only TMB and glmmTMB loaded). The results of sessionInfo() from a clean R session are below.

Thanks,
Thom

sessionInfo()
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.utf8 LC_CTYPE=English_Australia.utf8 LC_MONETARY=English_Australia.utf8
[4] LC_NUMERIC=C LC_TIME=English_Australia.utf8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] glmmTMB_1.1.7 TMB_1.9.6

loaded via a namespace (and not attached):
[1] minqa_1.2.6 MASS_7.3-56 compiler_4.2.0 Matrix_1.4-1 tools_4.2.0
[6] rstudioapi_0.15.0 Rcpp_1.0.11 splines_4.2.0 nlme_3.1-157 grid_4.2.0
[11] nloptr_2.0.3 boot_1.3-28 numDeriv_2016.8-1.1 lme4_1.1-34 lattice_0.20-45

@Thom-Teears
Copy link

I should also mention that I am not trying to load a stored fit from an older session.

Thanks,
Thom

@bbolker
Copy link
Contributor

bbolker commented Oct 10, 2023

So far I haven't been able to reproduce this. Do you get this with any glmmTMB fit (e.g.

library(glmmTMB)
data("sleepstudy", package = "lme4")
glmmTMB(Reaction ~ Days + (Days|Subject), sleepstudy)

) or is it only with a specific model? (Note that you might as well update now to glmmTMB 1.1.8, which just went up on CRAN, although I doubt it will make a difference ...)

If it's with a specific model, can you create a reproducible example for us?

@Thom-Teears
Copy link

Thom-Teears commented Oct 10, 2023

Running the code you provided above worked without any problems. The issue I was having was related to the specific model demo that I was trying to run. I was able to get the model demo to run without any errors by replacing the .cpp file with another that was correctly specified. Thanks again for your assistance.

@bbolker
Copy link
Contributor

bbolker commented Oct 11, 2023

OK, closing this, but if you can provide us a reproducible example that's causing a problem we can try to help diagnose (or, send it to r-sig-mixed-models@r-project.org)

@bbolker bbolker closed this as completed Oct 11, 2023
@Thom-Teears
Copy link

I was able to correct the error by replacing the .cpp file and the model ran without error so there is no longer a need for diagnosis. It seems that maybe the .cpp file I was using had an error. Thanks again for your assistance. I appreciate it.

@amynang
Copy link

amynang commented Jun 19, 2024

Sorry to resurrect this issue but I have similar problems after updating to R 4.4.1.
I have installed Rtools44.
I have reinstalled the Matrix package and then installed TMB and glmmTMB from source as suggested here.
This made the "Package version inconsistency" warning go away but what has not changed is the following behavior:

library(glmmTMB)
set.seed(42)
d = data.frame(s = c(rep(letters, times = sample(5:50, 26, replace = T))),
               x = NA,
               y = NA)
d$x = runif(nrow(d), -5,5)
for (i in letters) {
 d$y[d$s == i] = runif(1, 8,12) + (runif(1, -2,4) + rnorm(nrow(d[d$s == i,]), 0, 5))*d$x[d$s == i]
}
mcp = glmmTMB(y ~ x, data = d) # no problems
summary(mcp)
mnp = glmmTMB(y ~ 0 + s + x:s, data = d) # throws error:

Error in getParameterOrder(data, parameters, new.env(), DLL = DLL) :
Error when reading the variable: 'Z'. Please check data and parameters.
In addition: Warning message:
In getParameterOrder(data, parameters, new.env(), DLL = DLL) :
Expected sparse matrix of class 'dgTMatrix'.

mpp = glmmTMB(y ~ x + (x|s), data = d) # throws warning:

Warning message:
In augReTrms$theta[barpos] <- reTrms$theta :
number of items to replace is not a multiple of replacement length

ranef(mpp) # error

Error in if (ub2 == length(levs[[i]])) levs[[i]] else seq(ub2) :
argument is of length zero

This example is pre-existing code that was running without issues.
I there anything else I can try?

(perhaps irrelevant: I also had to troubleshoot to make brms, cmdstanr and cmdstan to work together. In that case it was a matter of getting the cmdstan toolchain to use rtools44 instead of rtools42)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants