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. In addition, help files are available for all functions, using e.g. ?apollo_mnl
  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.

Export model summary from Apollo objects to LaTeX

Ask questions about post-estimation functions (e.g. prediction, conditionals, etc) or other processing of results.
Post Reply
alvarogutyerrez
Posts: 12
Joined: 19 Jan 2021, 07:53
Contact:

Export model summary from Apollo objects to LaTeX

Post by alvarogutyerrez »

Dear Stephane and David,

[Disclaimer: this is not particularly a feature request because it is related to the Apollo objects' post-processing, but I couldn't find a better topic to post this question.]

First of all, thank you for this fantastic software. I have been using it a lot lately, and it's awesome. However, a significant drawback compared to other ''standard'' R canned packages is that it's rather tedious to export results to LaTeX or word. In particular, for complex models like a Latent Class with a large allocation model.

I am very much used to use `modelsummary` to create my tables on my documents easily from my R-script, but given that the object created by apollo is a MaxLik, it required a lot of work to generate a well-formatted table.

Do you generate your tables ''manually'' on your documents, or is there a feature that I am missing here to export results? So far, I am aware of the `apollo_modelOutput(model)` function, which works great for simpler models, but in complex specifications, gets a little bit messy.

Thank you for your time!
Best wishes,
Last edited by alvarogutyerrez on 21 Jan 2021, 14:51, edited 2 times in total.
Álvaro A. Gutiérrez-Vargas
https://alvarogutyerrez.github.io/
dpalma
Posts: 190
Joined: 24 Apr 2020, 17:54

Re: Export model summary from Apollo objects

Post by dpalma »

Hi Alvaro,

We are aware that exporting to latex is a useful feature currently missing in Apollo, and we are looking into adding it in the medium term. Thank you for pointing us towards “modelsummary”, it might come in handy in the future.

In the meantime, I would recommend you using the apollo_combineResults function. It can generate a single table (in csv format) presenting results from multiple models. Then, you can format the table in excel, and export it to latex using excel2latex (an excel extension). Or if you use LibreOffice, you can install the calc2latex extension.

Best wishes
David
alvarogutyerrez
Posts: 12
Joined: 19 Jan 2021, 07:53
Contact:

Re: Export model summary from Apollo objects

Post by alvarogutyerrez »

Hi David, thanks for your answer!

I actually decided to create a workaround for this problem. I have created a minimalist example of how to work with `modelsummary` on `Apollo` objects on my GitHub. I think people that work with LaTeX could benefit from it.

Feel free to use it and modified further. I will probably add more examples on my way because I am quite tired of changing the library each time I fit a different model, so I will probably stick to Apollo from now on :D .

Here is the link: https://github.com/alvarogutyerrez/expo ... delsummary

Best regards!
Álvaro A. Gutiérrez-Vargas
https://alvarogutyerrez.github.io/
dpalma
Posts: 190
Joined: 24 Apr 2020, 17:54

Re: Export model summary from Apollo objects

Post by dpalma »

Thank you for your work, Alvaro! This looks very useful!
gregorymacfarlane
Posts: 11
Joined: 29 Oct 2020, 23:11
Contact:

Re: Export model summary from Apollo objects to LaTeX

Post by gregorymacfarlane »

Yes, I agree this looks very good! Getting tidy, glance, and augment methods written for apollo objects will help users access tools like modelsummary (which is amazing, and should be the model summary package to end all model summary packages), coefplot, and lots of other great pieces of the R ecosystem.

I started working on the same thing this afternoon before I saw this post; I've got a fork of the broom repository with tidy and glance methods written already. I haven't confirmed if they work on the latent class object that you posted. The code is at https://github.com/gregmacfarlane/broom ... -tidiers.R.

Here's what I get when I run the methods I wrote on the example MNL data.

Code: Select all

>   apollo_mnl
Maximum Likelihood estimation
BFGS maximization, 78 iterations
Return code 0: successful convergence 
Log-Likelihood: -1025.756 (9 free parameter(s))
Estimate(s): 0 0.4746553 1.629093 0.9445357 -0.003646093 -0.008846134 -0.02068522 -0.01123936 -0.0114658 -0.03394737 
>   tidy.apollo(apollo_mnl) 
# A tibble: 9 x 5
  term      estimate std.error statistic    p.val
  <chr>        <dbl>     <dbl>     <dbl>    <dbl>
1 asc_bus    0.475     1.02        0.466 1.36e+ 0
2 asc_air    1.63      0.827       1.97  1.95e+ 0
3 asc_rail   0.945     0.804       1.18  1.76e+ 0
4 b_tt_car  -0.00365   0.00155    -2.35  1.90e- 2
5 b_tt_bus  -0.00885   0.00262    -3.37  7.49e- 4
6 b_tt_air  -0.0207    0.00660    -3.13  1.72e- 3
7 b_tt_rail -0.0112    0.00439    -2.56  1.04e- 2
8 b_access  -0.0115    0.00643    -1.78  7.46e- 2
9 b_cost    -0.0339    0.00329   -10.3   6.79e-25
>   tidy.apollo(apollo_mnl, se.type = "robust") 
# A tibble: 9 x 5
  term      estimate std.error statistic    p.val
  <chr>        <dbl>     <dbl>     <dbl>    <dbl>
1 asc_bus    0.475     0.991       0.479 1.37e+ 0
2 asc_air    1.63      0.818       1.99  1.95e+ 0
3 asc_rail   0.945     0.795       1.19  1.77e+ 0
4 b_tt_car  -0.00365   0.00157    -2.33  2.01e- 2
5 b_tt_bus  -0.00885   0.00262    -3.38  7.21e- 4
6 b_tt_air  -0.0207    0.00642    -3.22  1.28e- 3
7 b_tt_rail -0.0112    0.00447    -2.52  1.19e- 2
8 b_access  -0.0115    0.00630    -1.82  6.86e- 2
9 b_cost    -0.0339    0.00318   -10.7   1.32e-26
>   tidy.apollo(apollo_mnl, conf.int = TRUE) 
# A tibble: 9 x 7
  term      estimate std.error statistic    p.val conf.low conf.high
  <chr>        <dbl>     <dbl>     <dbl>    <dbl>    <dbl>     <dbl>
1 asc_bus    0.475     1.02        0.466 1.36e+ 0 -0.493     1.44   
2 asc_air    1.63      0.827       1.97  1.95e+ 0  0.843     2.42   
3 asc_rail   0.945     0.804       1.18  1.76e+ 0  0.181     1.71   
4 b_tt_car  -0.00365   0.00155    -2.35  1.90e- 2 -0.00512  -0.00217
5 b_tt_bus  -0.00885   0.00262    -3.37  7.49e- 4 -0.0113   -0.00635
6 b_tt_air  -0.0207    0.00660    -3.13  1.72e- 3 -0.0270   -0.0144 
7 b_tt_rail -0.0112    0.00439    -2.56  1.04e- 2 -0.0154   -0.00707
8 b_access  -0.0115    0.00643    -1.78  7.46e- 2 -0.0176   -0.00536
9 b_cost    -0.0339    0.00329   -10.3   6.79e-25 -0.0371   -0.0308 
> 
>   glance.apollo(apollo_mnl)
# A tibble: 1 x 4
  logLik rho20   AIC  nobs
   <dbl> <dbl> <dbl> <int>
1 -1026. 0.124 2070.  1000
I would add that a lot of this would be a bit easier to write and more robust if there was an apollo class and a summary method in the apollo package.
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: Export model summary from Apollo objects to LaTeX

Post by stephanehess »

Hi

we will consider an apollo class in future, but it's somewhat down our list of priorities at the moment as there are many other pressing developments

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Post Reply