Page 1 of 1

lastFuncParam == bVar

Posted: 05 Dec 2020, 03:07
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)
#

Re: lastFuncParam == bVar

Posted: 05 Dec 2020, 17:46
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