1

I am trying to run the following model:

mod1<- phylo_glmmTMB(response ~ sv1 + # sampling variables
sv2 + sv3 + sv4 + sv5 + 
sv6 + sv7 +  
(1|phylo) + (1|reference_id), #random effects
ziformula = ~ 0,
#ar1(pos + 0| group) # spatial autocorrelation structure; group is a dummy variable
phyloZ = supertreenew,
phylonm = "phylo",
family = "binomial",
data = data)
              

But I keep getting the error:

Error in Matrix::rankMatrix(TMBStruc$data.tmb[[whichX]]) : 
length(d <- dim(x)) == 2 is not TRUE

This error is also occurring with other reproducible example (data) that I found.

Before I run the model, I just loaded my data (data and supertree) and computed a Z matrix from supertree:

#Compute Z matrix
#supertreenew <- vcv.phylo(supertreenew) 
#or
supertreenew <- phylo.to.Z(supertreenew)
#enforced match between
supertreenew <- supertreenew[levels(factor(data$phylo)), ]

I have installed the development version via:

remotes::install_github("wzmli/phyloglmm/pkg") 

But no success.

The dimension of my supertree are:

[[1]] ... [351]
[[2]] ... [645]

Any guess?

My session info:

R version 4.2.2 (2022-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22621) Matrix products: default attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] phyloglmm_0.1.0.9001 brms_2.18.0 cpp_1.0.9 performance_0.10. DHARMa_0.4.6
[6] phytools_1.2-0 maps_3.4.0 ape_5.6-2 lme4_1.1-31 Matrix_1.5-1
[11] TMB_1.9.1 glmmTMB_1.1.5.9000 remotes_2.4.2

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
  • There's probably a typo in your variable name: `referecen_id` - maybe that's all there is to the error. – I_O Dec 30 '22 at 17:01

1 Answers1

3
  • (First error, "Error in Matrix::rankMatrix") This is a consequence of the addition of a check of the rank of the fixed-effects matrix in recent versions of glmmTMB. For now, adding
control = glmmTMB::glmmTMBControl(rank_check = "skip")

to your phylo_glmmTMB call should work around the problem.

  • (Second error, "Error in getParameterOrder(data, parameters, new.env(), DLL = DLL) ...") I just updated the refactor branch to handle this problem [caused by internal changes in glmmTMB]. Use remotes::install_github("wzmli/phyloglmm/pkg@refactor") to install this version, then try your example again.
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • It worked, thanks @benbolker. But now I am getting another set of errors: Error in getParameterOrder(data, parameters, new.env(), DLL = DLL) : Error when reading the variable: 'psi'. Please check data and parameters. In addition: Warning message: In getParameterOrder(data, parameters, new.env(), DLL = DLL) : Expected object. Got NULL. Any advice? Thanks – Non_Praying_Mantis Dec 30 '22 at 22:12
  • @Non_Praying_Mantis did you manage to get around it? I am having the same issue. – Rheum_Glutinosa Aug 06 '23 at 08:14
  • @Rheum_Glutinosa: are you reading in a model fitted with an older version of glmmTMB? If so, try running the `up2date()` function on your object. If not, or if that doesn't work, please post a new question. (You could also post this on the glmmTMB issues list if you prefer.) – Ben Bolker Aug 06 '23 at 14:02
  • @BenBolker no, I need to fit a new model. Can this be because I am using CRAN version of glmmTMB? Because I am not able to install the github version for some reason. – Rheum_Glutinosa Aug 07 '23 at 09:33
  • Please post a new question with all of the required info (versions of TMB and glmmTMB, whether you got any other warning messages, why you had difficulty installing the development version [i.e. what errors/symptoms], etc.) – Ben Bolker Aug 07 '23 at 14:00
  • 1
    well, this is a bit stupid but rebooting the laptop did the trick... With the "control = glmmTMB::glmmTMBControl(rank_check = "skip")" within phylo_glmmTMB I can build new models now – Rheum_Glutinosa Aug 08 '23 at 07:38