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.

How to install older Apollo version? R automatically updated v0.3.3 (underdevelopment)

Ask questions about installing Apollo, running it inside a shell, and updating to new versions. Please make sure you provide information about which version of Apollo and R you are using.
Post Reply
saumitra
Posts: 2
Joined: 24 Jul 2024, 21:30

How to install older Apollo version? R automatically updated v0.3.3 (underdevelopment)

Post by saumitra »

Hello,

My R studio updated the Apollo version to v0.3.3 which is currently underdevelopment and unreleased. I ran some models that worked fine previously, but are now either giving strange results or are showing errors that weren't there previously. I was confused at first, but I opened the files from a recent backup, which had the model results saved. It seems that the new version that has been automatically installed is giving problems.

I tried to install the older version after downloading it to my laptop. It did not work, I also tried to use the URL directly, and that also did not work. It would be helpful if someone could provide a solution to this.

Thank you

Saumitra

Code: Select all

> library(remotes)
> install_url("http://apollochoicemodelling.com/files/versions/apollo_0.3.2.tar.gz")
Downloading package from url: http://apollochoicemodelling.com/files/versions/apollo_0.3.2.tar.gz
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?

1: All                              
2: CRAN packages only               
3: None                             
4: SparseM (1.84   -> 1.84-2) [CRAN]
5: Rcpp    (1.0.12 -> 1.0.13) [CRAN]

Enter one or more numbers, or an empty line to skip updates: 
Running `R CMD build`...
* checking for file 'C:\Users\saumi\AppData\Local\Temp\Rtmpw5vttn\remotes3570535f622\apollo/DESCRIPTION' ... OK
* preparing 'apollo':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking vignette meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building 'apollo_0.3.2.tar.gz'
Installing package into ‘C:/Users/saumi/AppData/Local/R/win-library/4.4’
(as ‘lib’ is unspecified)
* installing *source* package 'apollo' ...
** using staged installation
** libs
Error in system(paste(MAKE, p1(paste("-f", shQuote(makefiles))), "compilers"),  : 
  'make' not found
* removing 'C:/Users/saumi/AppData/Local/R/win-library/4.4/apollo'
Warning messages:
1: In missing_devel_warning(pkgdir) :
  Package apollo has compiled code, but no suitable compiler(s) were found. Installation will likely fail.
  Install Rtools (https://cran.r-project.org/bin/windows/Rtools/).Then use the pkgbuild package, or make sure that Rtools in the PATH.
2: In i.p(...) :
  installation of package ‘C:/Users/saumi/AppData/Local/Temp/Rtmpw5vttn/file35703b435a6b/apollo_0.3.2.tar.gz’ had non-zero exit status
stephanehess
Site Admin
Posts: 1210
Joined: 24 Apr 2020, 16:29

Re: How to install older Apollo version? R automatically updated v0.3.3 (underdevelopment)

Post by stephanehess »

Hi

0.3.3 is not a development version (this was a typo on the website) but the official current release on CRAN. You should use that one.

What problems are you having?

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
saumitra
Posts: 2
Joined: 24 Jul 2024, 21:30

Re: How to install older Apollo version? R automatically updated v0.3.3 (underdevelopment)

Post by saumitra »

Dear Stephane,

Thank you. I am using a repeated BWS case 1 (no levels) to evaluate preferences for alternative policies. So it is Best-Worst-Best (Second)-Worst (Second). There are 6 alternatives (objectives) and a status quo (SQ) option for a policy. As per the experimental design, there are 15 blocks, 4 out of the 6 alternatives are shown per block and the SQ is always available. So there are a total of 5 options shown for each block. An individual is only shown 1 block. I have added conditions in the "avail" to indicate if the alternative is available in the block or not.

I used a series of multinomial logit models and used the combine command. I get results in the v 3.2, but when I try to run the model in 3.3, I get this error.
Testing influence of parametersError in nRows(P$like) :
INTERNAL ISSUE - An element of P did not have as many rows as observations or individuals, so it was not weighted.
One of the options (shown by "Caste_based" option in the code) is never chosen as the best, and it is chosen as the worst or second worst the most number of times. Which was expected. But that could be an issue. I have shared the full code if that helps.

Just to add, it runs when I remove the weights. But I get a log likelihood of -3000. In the previous version, when the models were running the log likelihood was around the range of -104

Please also note that I have another BWS, a Case 2, from the same survey. It uses the same weights. In that case all the alternatives are always available. That runs fine on v 3.3 and the results are the same as that from when I ran the model in v.3.2

Code: Select all

### Vector of parameters
apollo_beta = c(b_Income              = 0, 
                b_HH_Member           = 0, 
                b_Caste               = 0, 
                b_Elderly_DiffAble    = 0, 
                b_NotPlanned          = 0,
                b_10k_All             = 0,
                b_CurrentPolicy       = 0, 
                mu_worst              = 1)


apollo_fixed = c("b_CurrentPolicy")

# ################################################################# #
#### GROUP AND VALIDATE INPUTS                                   ####
# ################################################################# #

apollo_inputs = apollo_validateInputs()

# ################################################################# #
#### DEFINE MODEL AND LIKELIHOOD FUNCTION                        ####
# ################################################################# #

apollo_probabilities=function(apollo_beta, apollo_inputs, functionality="estimate"){

  ### Attach inputs and detach after function exit
  apollo_attach(apollo_beta, apollo_inputs)
  on.exit(apollo_detach(apollo_beta, apollo_inputs))

  ### list of probabilities P
  P = list()
  
  ### List of utilities:
  V = list()
  V[["Income"]]           = b_Income
  
  V[["HH_Members"]]       = b_HH_Member
  
  V[["Caste_Based"]]      = b_Caste
  
  V[["Elderly_DiffAble"]] = b_Elderly_DiffAble
  
  V[["Not_in_Planned"]]   = b_NotPlanned
  
  V[["Universal"]]        = b_10k_All
  
  V[["Keep_Current"]]     = b_CurrentPolicy  

  ### FIRST BEST: Compute probabilities for "best" choice using MNL model
  mnl_settings_best = list(
    alternatives  = c(Income           =1, 
                      HH_Members       =2, 
                      Caste_Based      =3, 
                      Elderly_DiffAble =4, 
                      Not_in_Planned   =5,
                      Universal        =6, 
                      Keep_Current     =7),
    
    avail         = list(Income             =(Inc==1), 
                         HH_Members         =(HH==1), 
                         Caste_Based        =(Caste==1), 
                         Elderly_DiffAble   =(ElderDiffAble==1), 
                         Not_in_Planned     =(NotPlanned==1),
                         Universal          =(First10k==1), 
                         Keep_Current       =(CurrentPolicy==1) ),
    
    choiceVar     = BWS_1_F_Most,
    utilities     = V,
    componentName = "best"
  )
  P[["choice_best"]] = apollo_mnl(mnl_settings_best, functionality)
  
  
  
  ### FIRST WORST: Compute probabilities for "worst" choice using MNL model
  mnl_settings_worst = list(
    alternatives  = c(Income           =1, 
                      HH_Members       =2, 
                      Caste_Based      =3, 
                      Elderly_DiffAble =4, 
                      Not_in_Planned   =5,
                      Universal        =6, 
                      Keep_Current     =7),
    
    avail         = list(Income            =(Inc==1 &
                                               BWS_1_F_Most!=1), 
                         
                         HH_Members        =(HH==1 & 
                                               BWS_1_F_Most!=2),
                         
                         Caste_Based       =(Caste==1 & 
                                               BWS_1_F_Most!=3),
                         
                         Elderly_DiffAble  =(ElderDiffAble==1 & 
                                               BWS_1_F_Most!=4),
                         
                         Not_in_Planned    =(NotPlanned==1 & 
                                               BWS_1_F_Most!=5),
                         
                         Universal         =(First10k==1 & 
                                               BWS_1_F_Most!=6),
                         
                         Keep_Current      =(CurrentPolicy==1 & 
                                               BWS_1_F_Most!=7)),
    
    choiceVar     = BWS_1_F_Least, 
    utilities     = list(Income            = -mu_worst*V[["Income"]],
                         HH_Members        = -mu_worst*V[["HH_Members"]],
                         Caste_Based       = -mu_worst*V[["Caste_Based"]],
                         Elderly_DiffAble  = -mu_worst*V[["Elderly_DiffAble"]],
                         Not_in_Planned    = -mu_worst*V[["Not_in_Planned"]],
                         Universal         = -mu_worst*V[["Universal"]],
                         Keep_Current      = -mu_worst*V[["Keep_Current"]]),
    componentName = "worst" 
  )
  
  P[["choice_worst"]] = apollo_mnl(mnl_settings_worst, functionality)
  
  ### Compute probabilities for "Second Best" choice using MNL model
  mnl_settings_best_2 = list(
    alternatives  = c(Income           =1, 
                      HH_Members       =2, 
                      Caste_Based      =3, 
                      Elderly_DiffAble =4, 
                      Not_in_Planned   =5,
                      Universal        =6, 
                      Keep_Current     =7),
    
    avail         = list(Income            =(Inc==1 & 
                                               BWS_1_F_Most!=1 & 
                                               BWS_1_F_Least!=1) ,
                         
                         HH_Members        =(HH==1 & 
                                               BWS_1_F_Most!=2 &
                                               BWS_1_F_Least!=2),
                         
                         Caste_Based       =(Caste==1 & 
                                               BWS_1_F_Most!=3 &
                                               BWS_1_F_Least!=3),
                         
                         Elderly_DiffAble  =(ElderDiffAble==1 & 
                                               BWS_1_F_Most!=4 &
                                               BWS_1_F_Least!=4),
                         
                         Not_in_Planned    =(NotPlanned==1 & 
                                               BWS_1_F_Most!=5 &
                                               BWS_1_F_Least!=5),
                         
                         Universal         =(First10k==1 & 
                                               BWS_1_F_Most!=6 &
                                               BWS_1_F_Least!=6),
                         
                         Keep_Current      =(CurrentPolicy==1 & 
                                               BWS_1_F_Most!=7 &
                                               BWS_1_F_Least!=7)),
    
    choiceVar     = BWS_1_S_Most, 
    utilities     = V,
    componentName = "second_best"
  )
  
  P[["choice_best_2"]] = apollo_mnl(mnl_settings_best_2, functionality)
  
  
  ### Compute probabilities for "Second Worst" choice using MNL model
  mnl_settings_worst_2 = list(
    alternatives  = c(Income           =1, 
                      HH_Members       =2, 
                      Caste_Based      =3, 
                      Elderly_DiffAble =4, 
                      Not_in_Planned   =5,
                      Universal        =6, 
                      Keep_Current     =7),
    
    avail         = list(Income            =(Inc==1 & 
                                               BWS_1_F_Most!=1 & 
                                               BWS_1_F_Least!=1 &
                                               BWS_1_S_Most!=1) ,
                         
                         HH_Members        =(HH==1 & 
                                               BWS_1_F_Most!=2 &
                                               BWS_1_F_Least!=2 &
                                               BWS_1_S_Most!=2),
                         
                         Caste_Based       =(Caste==1 & 
                                               BWS_1_F_Most!=3 &
                                               BWS_1_F_Least!=3 &
                                               BWS_1_S_Most!=3),
                         
                         Elderly_DiffAble  =(ElderDiffAble==1 & 
                                               BWS_1_F_Most!=4 &
                                               BWS_1_F_Least!=4 &
                                               BWS_1_S_Most!=4),
                         
                         Not_in_Planned    =(NotPlanned==1 & 
                                               BWS_1_F_Most!=5 &
                                               BWS_1_F_Least!=5 &
                                               BWS_1_S_Most!=5),
                         
                         Universal         =(First10k==1 & 
                                               BWS_1_F_Most!=6 &
                                               BWS_1_F_Least!=6 &
                                               BWS_1_S_Most!=6),
                         
                         Keep_Current      =(CurrentPolicy==1 & 
                                               BWS_1_F_Most!=7 &
                                               BWS_1_F_Least!=7 &
                                               BWS_1_S_Most!=7)),
    
    choiceVar     = BWS_1_S_Least, 
    utilities     = list(Income            = -mu_worst*V[["Income"]],
                         HH_Members        = -mu_worst*V[["HH_Members"]],
                         Caste_Based       = -mu_worst*V[["Caste_Based"]],
                         Elderly_DiffAble  = -mu_worst*V[["Elderly_DiffAble"]],
                         Not_in_Planned    = -mu_worst*V[["Not_in_Planned"]],
                         Universal         = -mu_worst*V[["Universal"]],
                         Keep_Current      = -mu_worst*V[["Keep_Current"]]),
    componentName = "second worst"
  )
  
  P[["choice_worst_2"]] = apollo_mnl(mnl_settings_worst_2, functionality)
  
  
  ### Combined model
  P = apollo_combineModels(P, apollo_inputs, functionality)
  
  # ### Including individual weights
  P = apollo_weighting(P, apollo_inputs, functionality)

  ### Prepare and return outputs of function
  P = apollo_prepareProb(P, apollo_inputs, functionality)
  return(P)
}

# ################################################################# #
#### MODEL ESTIMATION                                            ####
# ################################################################# #

model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)
Thank you

Best,
Saumitra
Last edited by saumitra on 08 Aug 2024, 03:00, edited 6 times in total.
stephanehess
Site Admin
Posts: 1210
Joined: 24 Apr 2020, 16:29

Re: How to install older Apollo version? R automatically updated v0.3.3 (underdevelopment)

Post by stephanehess »

Hi

can you explain why you are using weighting?

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
saumitra
Posts: 2
Joined: 24 Jul 2024, 21:30

Re: How to install older Apollo version? R automatically updated v0.3.3 (underdevelopment)

Post by saumitra »

Hi,

I am using weights because of my stratified random sampling strategy. The data was collected through a face-to-face survey. Because of unavailability of up to date government/census datasets to identify a sampling frame easily, and requirements to do a sub-group analysis, I had unequal probabilities of selection. Individuals from a cluster had the same probability of being selected, but probability of selection varied across clusters.

To share some more information:

For the BWS Case 1 (in which all the utility functions/alternatives are not always available), using the latest version 3.3, an for an MNL model I am getting the error with weights. When I use without weights it works. I also created a new column with all values equal to 1 and then used those as weights, I got the same error.

I also have a BWS Case 2 from the same survey that uses the same weights. In this case, all the utility functions are always available. The MNL model runs with and without weights in the latest version 3.3. The results are the same as when I used 3.2. However, when I try to run a latent class, I get the same error in 3.3 although it works in 3.2

Thank you

Best,
Saumitra
Last edited by saumitra on 17 Aug 2024, 04:36, edited 3 times in total.
stephanehess
Site Admin
Posts: 1210
Joined: 24 Apr 2020, 16:29

Re: How to install older Apollo version? R automatically updated v0.3.3 (underdevelopment)

Post by stephanehess »

Hi

if you are able to share your code and data with me outside the forum, I can try to make this work for you

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