Important: Read this before posting to this forum

  1. This forum is for questions related to the use of Apollo. We will answer some general choice modelling questions too, where appropriate, and time permitting. We cannot answer questions about how to estimate choice models with other software packages.
  2. There is a very detailed manual for Apollo available at http://www.ApolloChoiceModelling.com/manual.html. This contains detailed descriptions of the various Apollo functions, and numerous examples are available at http://www.ApolloChoiceModelling.com/examples.html.
  3. Before asking a question on the forum, users are kindly requested to follow these steps:
    1. Check that the same issue has not already been addressed in the forum - there is a search tool.
    2. Ensure that the correct syntax has been used. For any function, detailed instructions are available directly in Apollo, e.g. by using ?apollo_mnl for apollo_mnl
    3. Check the frequently asked questions section on the Apollo website, which discusses some common issues/failures. Please see http://www.apollochoicemodelling.com/faq.html
    4. Make sure that R is using the latest official release of Apollo.
  4. If the above steps do not resolve the issue, then users should follow these steps when posting a question:
    1. provide full details on the issue, including the entire code and output, including any error messages
    2. posts will not immediately appear on the forum, but will be checked by a moderator first. This may take a day or two at busy times. There is no need to submit the post multiple times.

Error when attempting to write F12 file

Report bugs or highlight issues with Apollo functions. At a minimum, please include the part of the output where you believe the bug is manifested. Ideally, please share your model file.
Post Reply
jmuller
Posts: 2
Joined: 06 Jul 2022, 08:37

Error when attempting to write F12 file

Post by jmuller » 06 Jul 2022, 08:58

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

dpalma
Posts: 136
Joined: 24 Apr 2020, 17:54

Re: Error when attempting to write F12 file

Post by dpalma » 07 Jul 2022, 16:30

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

jmuller
Posts: 2
Joined: 06 Jul 2022, 08:37

Re: Error when attempting to write F12 file

Post by jmuller » 15 Jul 2022, 15:13

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

stephanehess
Site Admin
Posts: 632
Joined: 24 Apr 2020, 16:29

Re: Error when attempting to write F12 file

Post by stephanehess » 09 Aug 2022, 16:34

This should be fixed now in 0.2.8
--------------------------------
Stephane Hess
www.stephanehess.me.uk

Post Reply