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. We check the forum at least twice a week. It may thus take a couple of days for your post to appear and before we reply. There is no need to submit the post multiple times.

lastFuncParam == bVar

Ask questions about errors you encouunter. Please make sure to include full details about your model specifications, and ideally your model file.
Post Reply
jjanmaat
Posts: 14
Joined: 01 Dec 2020, 20:01

lastFuncParam == bVar

Post by jjanmaat »

I have been running a variety of mixed models and the estimation has produced warnings:

In lastFuncParam == bVar :
longer object length is not a multiple of shorter object length

This doesn't seem to cause any problems with the program finding a solution. However, the warning leaves me a bit unsure about trusting the results.

Comments?

Thanks.

John.

CODE:

#
#####-------------------------------------------------------------#####
##### MNL model including scale parameter as test for endogeneity and
##### estimated in WTP space, with triangular distribution on levy.
#####-------------------------------------------------------------#####
#
apollo_control <- list(
modelName="LCF_MML2",
modelDescr=paste("Multinomial logit with scale in WTP space,",
"levy and attribute wtp random"),
indivID="id",
mixing=T,
nCores=4
)
#
# Set up starting values for parameters to estimate
apollo_beta <- c(asc = 0,
# b_Wea = 0,
mu_Wea = 0,
sigma_Wea = 1,
# b_Spe = 0,
mu_Spe = 0,
sigma_Spe = 1,
# b_Nat = 0,
mu_Nat = 0,
sigma_Nat = 1,
# b_Levy = 0,
scl_Levy = 1,
b_IncMid = 0,
b_IncHigh = 0,
scl = 1)
#
# Don't have any fixed parameters, so this list empty.
apollo_fixed <- c()
#
# Set up the form of the maximum simulated likelihood
apollo_draws <- list(
interDrawsType = "halton",
interNDraws = 500,
interNormDraws = c("draws_wea_inter","draws_spe_inter",
"draws_nat_inter"),
# interUnifDraws = c("draws_sclSQ_inter")
interUnifDraws = c("draws_sclSQ_inter",
"draws_sclLevy_inter1", "draws_sclLevy_inter2")
# interUnifDraws = c("draws_sclSQ_inter","draws_sclAlt_inter")
)
#
# Set up random coefficients definitions
apollo_randCoeff <- function(apollo_beta, apollo_inputs) {
randcoef <- list()
randcoef[['err_SQ']] <- log(-log(draws_sclSQ_inter))
# randcoef[['err_Alt']] <- log(-log(draws_sclAlt_inter))
randcoef[['b_Levy']] <- scl_Levy * (
draws_sclLevy_inter1 + draws_sclLevy_inter2)
randcoef[['b_Wea']] <- -exp(mu_Wea + sigma_Wea * draws_wea_inter)
randcoef[['b_Spe']] <- -exp(mu_Spe + sigma_Spe * draws_spe_inter)
randcoef[['b_Nat']] <- -exp(mu_Nat + sigma_Nat * draws_nat_inter)
return(randcoef)
}
#
# Validate the inputs, and get a list of information needed by
# later routines.
apollo_inputs <- apollo_validateInputs()
#
# Set up the probabilities for the choices.
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))
### Create list for probabilities
P <- list()
### Create alternative specific constants
asc_SQ_value = err_SQ
asc_Alt_value = asc + b_IncMid * (IncCat=='Mid') +
b_IncHigh * (IncCat=='High')
### List of utilities
V <- list()
V[['SQ']] <- asc_SQ_value + b_Levy * (b_Wea * WeaAbsLin_S + b_Spe * SpeAbsLin_S + b_Nat * NatAbsLin_S +
Lev_S)
V[['Alt']] <- asc_Alt_value + b_Levy * (b_Wea * WeaAbsLin_A + b_Spe * SpeAbsLin_A + b_Nat * NatAbsLin_A +
Lev_A)
### MNL settings. Define choices, choice variable, utilities, availability of cases
mnl_settings <- list(
alternatives = c(SQ="S",Alt="A"),
avail = 1,
choiceVar = Choice,
V = lapply(V, "*", scl)
)
### Compute probabilities
P[['model']] <- apollo_mnl(mnl_settings, functionality)
### Take product across observation for same individual
P <- apollo_panelProd(P, apollo_inputs, functionality)
### Average across inter-individual draws
P <- apollo_avgInterDraws(P, apollo_inputs, functionality)
### Prepare and return outputs of function
P <- apollo_prepareProb(P, apollo_inputs, functionality)
return(P)
}
#
# Estimate the model
modelMML2 <- apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities,
apollo_inputs)
#
dpalma
Posts: 227
Joined: 24 Apr 2020, 17:54

Re: lastFuncParam == bVar

Post by dpalma »

Hi John,

This problem should be gone in the new version of Apollo (v0.2.2), which will be available through CRAN very soon. I'd recommend you update Apollo next week using the command

Code: Select all

install.packages("apollo")
These warnings were due to a bug when writing iterations to disk (the file modelName_iterations.csv). The issue did not influence estimation in any way, so all results are safe to use.

Best
David
Post Reply