Page 1 of 1

object '"validate"' not found error in MNL_SP

Posted: 15 Jun 2023, 23:59
by manes
Hi,
I'm new to this forum. I just quit Stata after the recent (and excellent) advanced CMC course in Leeds.
I have followed all three steps prior to posting this Q.
I'm running a very basic MNL model (I have not included any covariates other than the atts of the alts.)
I can't figure out why I keep receiving the following error message:
Error in apollo_probabilities(apollo_beta, apollo_inputs, functionality = "validate") :
object '"validate"' not found
despite the fact that after running the

Code: Select all

apollo_inputs = apollo_validateInputs()
I receive the following:
Several observations per individual detected
based on the value of ID. Setting panelData in apollo_control set to TRUE.
All checks on apollo_control completed.
All checks on database completed.
.
This is the data: https://www.dropbox.com/s/p5mdvvdeec2w9 ... 1.csv?dl=0
It includes 2404 observations of 601 respondents making 4 SP choice tasks, each choice task is between ICE and Hybrid vehicle.

This is the code:

Code: Select all

setwd("C:/Users/Anat/Dropbox/Rfiles/radiation")
rm(list = ls())
library ("apollo")
apollo_initialise()
apollo_control = list(
modelName       = "MNL_A",
 indivID         = "ID",
  outputDirectory = "output"
)

database=read.csv("data_wide_mnl1.csv",header=TRUE)
apollo_beta=  c(asc_ice     =0, 
                    asc_hybrid   = 0,
                    b_cost       = 0,
                    b_radiation  = 0,
                    b_safety     = 0,
                    b_hp         = 0,
                    b_trunk       =0,
                    b_emission    =0)

apollo_fixed = c("asc_ice")
apollo_inputs = apollo_validateInputs()

apollo_probabilities=function(apollo_beta, apollo_inputs, functionality="estimate"){
  
apollo_attach(apollo_beta, apollo_inputs)
on.exit(apollo_detach(apollo_beta, apollo_inputs))
  
P = list()  
V=list()
V[["ice"]]  =    asc_ice  +  b_cost* ice_cost +   b_radiation * ice_radiation  + b_safety*ice_safety +    beta_hp*ice_hp +      
                      b_trunk*ice_trunk+  b_emission*ice_emission 
V[["hybrid"]] = asc_hybrid  + b_cost*hybrid_cost + b_radiation*hybrid_radiation + b_safety*hybrid_safety + beta_hp*hybrid_hp + 
                      b_trunk*hybrid_trunk+ b_emission*hybrid_emission 
  
 mnl_settings = list(
 alternatives  = c(hybrid=1, ice=2),
 choiceVar     = choice,
utilities     = V
  )
 
P[["model"]] = apollo_mnl(mnl_settings, functionality)
  
P = apollo_panelProd(P, apollo_inputs, functionality)
  
P = apollo_prepareProb(P, apollo_inputs, functionality)
  return(P)
}
model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)
I might have an issue with scaling the data (I have 000' vars and 1-10 vars) but I don't think that this is the problem..
All example codes are running on my very new laptop..
Any help will be appreciated!
Anat

Re: object '"validate"' not found error in MNL_SP

Posted: 17 Jun 2023, 08:54
by stephanehess
Hi Anat

are you by any chance running R4.3.0 or another very recent version. The R team made a change that led to this rather unhelpful error message. If you upgrade to R4.3.1, you will get the right messages

Stephane

Re: object '"validate"' not found error in MNL_SP

Posted: 17 Jun 2023, 13:54
by manes
Thank you Stephane,
It seems that I have a problem.
I uninstall both R and R studio and then re-install R 4.3.1 and R studio.
I then run

Code: Select all

 install.packages("apollo")
and receive:
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/Anat/AppData/Local/R/win-library/4.3’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/co ... _0.2.9.zip'
Content type 'application/zip' length 2174096 bytes (2.1 MB)
downloaded 2.1 MB
I'm not sure how to go from here, will try to sort it out.
Anat

Re: object '"validate"' not found error in MNL_SP

Posted: 18 Jun 2023, 10:15
by stephanehess
Hi Anat

if you reinstalled RStudio, then you may need to reinstall Rtools too as it says. Did you try that?

Stephane

Re: object '"validate"' not found error in MNL_SP

Posted: 19 Jun 2023, 10:54
by manes
yes, I have R4.3.1, Rtools43, and RStudio 0.2.9 all installed (by this order)
After validate returns:
All checks on apollo_control completed. All checks on database completed
The error is:
Testing likelihood function...
Error in apollo_probabilities(apollo_beta, apollo_inputs, functionality = "validate") :
object 'hybrid_radiation' not found
It's weird since hybrid_radiation does exist in the database, I didn't touch anything.
this is my V specification:

Code: Select all

V=list()
V[["hybrid"]] = asc_hybrid  + b_cost*hybrid_cost + b_radiation* hybrid_radiation + b_safety*hybrid_safety + beta_hp*hybrid_hp + 
                      b_trunk*hybrid_trunk+ b_emission*hybrid_emission 
V[["ice"]]  = asc_ice  +          b_cost* ice_cost +   b_radiation * ice_radiation +        b_safety*ice_safety +    beta_hp*ice_hp +      
                    b_trunk*ice_trunk+  b_emission*ice_emission 
and that's a screenshots of the database:
Image

Re: object '"validate"' not found error in MNL_SP

Posted: 19 Jun 2023, 15:07
by manes
I found the mistake! just a simple syntax... thank you, Stephan, I was that close to give up (:

Re: object '"validate"' not found error in MNL_SP

Posted: 10 Jul 2023, 07:35
by Sanesk
Hi, I found the same question that "validate"' not found. How did you solve it?

Re: object '"validate"' not found error in MNL_SP

Posted: 10 Jul 2023, 08:39
by stephanehess
Hi

did you update to the new version of R?

Stephane

Re: object '"validate"' not found error in MNL_SP

Posted: 10 Jul 2023, 09:26
by Sanesk
Yes. I have R4.3.1

Re: object '"validate"' not found error in MNL_SP

Posted: 10 Jul 2023, 09:42
by Sanesk
Oh I see, I launched the wrong version. Thank you!