issues running a GAM model in a different machine

Dear all,

I apologies in advance if this is not the correct forum for this question. I'm happy to remove it if it is the case.

I fitted a GAM model in my university computer and saved it. Then, when I loaded it to my personal laptop, and ran gam.check(model), I keep getting this error:

Error in 1:dk$nr[i] : NA/NaN argument
In addition: Warning message:
prediction from discrete bam models prior to 1.8-32 is deprecated, please refit 

summary(model) works fine, no issue. Running other functions from different packages such as draw(model) from gratia version 0.7.2 works fine as well.

Here is the model structure, just in case it matters:

beep(t_var_ini__aa_m2 <- system.time(var_ini__aa_m2 <- bam(val ~ x1x2 +
                                                         s(percent, bs= "cr", k=10) +
                                                         s(percent, bs= "cr", k=10, by=x1x2) +
                                                         s(percent, stim, bs="fs", m=1, k=10, by=x1x2)+
                                                         s(percent, stim, bs="fs", m=1, k=10)+
                                                         s(percent, word, bs="fs", m=1, k=10),   
                                                         data = var_gam_aa_ini,
                                                         method = "fREML",
                                                         family = "scat",
                                                         rho = var_ini__aa_m1_roh)))

save(var_ini__aa_m2, file = "var_ini__aa_m2.RData")

I using mgcv version 1.8-39 in my personal machine, but not sure about the mgcv version in my university machine. I'll check it out tomorrow, if relevant. Could anybody please advise on what is going on and how to get the output of gam.check()?
Note that gam.check(model) works fine in my university machine.

Thank you in advance,

I feel you are being hit by reproducibility issues. There is two ways out IMHO

  1. Get the output of sessionInfo() from both your university and personal machine and compare the package versions. Modify the package versions on your local machine until they match up, especially with mgcv.
  2. Get started with using renv for general reproducibility. If you adopted renv into your general code development workflow, renv will keep track of the package versions used on your university machine (in a file called renv.lock). The reproducible code would then consist of your R code + renv.lock. If you then ship this to your personal machine, a simple renv::restore() would replicate exactly the same package versions.

I am fully aware that adopting renv poses an initial overhead but I am convinced it will pay out big time in the long run.

1 Like

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.