Page 1 of 1

Error when attempting to write F12 file

Posted: 06 Jul 2022, 08:58
by jmuller
Dear Stephane and David,

I've successfully estimated a simple MNL model in Apollo and I'd like to write the results to an Alogit F12 file. As per the manual, declaring `writeF12 = TRUE` in the `saveOutput_settings` argument should write an F12 file to the output folder. I've tried both

Code: Select all

apollo_saveOutput(model,
                  saveOutput_settings=list(saveEst = TRUE,
                                           saveCorr = TRUE,
                                           saveCov = TRUE,
                                           saveModelObject = FALSE,
                                           writeF12 = TRUE))
and

Code: Select all

apollo_saveOutput(model,
                  saveOutput_settings=list(writeF12 = TRUE))
yet the following error is displayed in the console:

Code: Select all

Error in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L,  : 
  invalid value 0 for 'digits' argument
I'm by no means an expert in the R programming language, so I might have gotten the syntax wrong in declaring the settings. However, a quick web search led me to the following discussion on Stack Overflow: https://stackoverflow.com/questions/676 ... -3l-invali. It seems that from R 4.1.* onwards the value 0 for `digits` in the prettyNum() function is no longer valid. Is it possible in Apollo to declare a different argument for `digits` or is it "baked in" to the Apollo function?

Details of of my current version of R and packages are provided below:

Code: Select all

R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8    LC_MONETARY=English_United Kingdom.utf8 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.utf8    

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

other attached packages:
[1] apollo_0.2.7

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8.3        compiler_4.2.1      RSGHB_1.2.2         pillar_1.7.0        miscTools_0.6-26    tools_4.2.1         digest_0.6.29       tibble_3.1.7       
 [9] lifecycle_1.0.1     lattice_0.20-45     pkgconfig_2.0.3     rlang_1.0.3         Matrix_1.4-1        cli_3.3.0           maxLik_1.5-2        parallel_4.2.1     
[17] mvtnorm_1.1-3       SparseM_1.81        coda_0.19-4         stringr_1.4.0       generics_0.1.2      vctrs_0.4.1         MatrixModels_0.5-0  grid_4.2.1         
[25] glue_1.6.2          randtoolbox_2.0.1   fansi_1.0.3         survival_3.3-1      magrittr_2.0.3      matrixStats_0.62.0  ellipsis_0.3.2      mcmc_0.9-7         
[33] MASS_7.3-57         splines_4.2.1       mnormt_2.1.0        Deriv_4.1.3         numDeriv_2016.8-1.1 quantreg_5.93       sandwich_3.0-2      utf8_1.2.2         
[41] stringi_1.7.6       MCMCpack_1.6-3      rngWELL_0.10-7      crayon_1.5.1        zoo_1.8-10 
Kind regards,
Jeroen

Re: Error when attempting to write F12 file

Posted: 07 Jul 2022, 16:30
by dpalma
Hi Jeroen,

I am not sure what is happening, as prettyNum is not used in Apollo. I recommend you update to Apollo v0.2.8 (soon to be released) and try again. I tested it with a simple MNL model and it worked fine. You can download it from one of the links below:

Windows
Mac
Linux

If updating doesn't solve the issue, please share your script and model file (.rds) so I can look at the issue in more detail.

Best wishes
David

Re: Error when attempting to write F12 file

Posted: 15 Jul 2022, 15:13
by jmuller
Hi David,

Took a little longer to get back to you on this issue, but luckily I have found the culprit. As I understand it, from R version 4.2.1 onwards, the use of `digits=0` in the `format()` function is no longer valid. Ran Apollo v0.2.7 and v0.2.8 and both gave me the same error as described above. Downgrading R to 4.1.3 resolves the issue and F12 files are written to the output folder.

More details of this change are found here https://cran.r-project.org/doc/manuals/ ... /NEWS.html. It's the first item under 'Bug fixes' for version 4.2.1.

Best wishes,
Jeroen

Re: Error when attempting to write F12 file

Posted: 09 Aug 2022, 16:34
by stephanehess
This should be fixed now in 0.2.8