Page 1 of 1

MMNL model with panel data

Posted: 10 Jan 2023, 12:17
by sethyash52
Why I am getting mean and standard deviation of some parameters as statistically insignificant? I have included code and results below please take a look on it. I am working on panel data where there are 4 observations per individual.

******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************

# ################################################################# #
#### LOAD LIBRARY AND DEFINE CORE SETTINGS ####
# ################################################################# #

### Clear memory
rm(list = ls())

### Load Apollo library
library(apollo)

### Initialise code
apollo_initialise()

### Set core controls
apollo_control = list(
modelName = "ECL_preference_space_panel_effect",
modelDescr = "Error components logit model on Swiss route choice data, uncorrelated Lognormals in preference space, with panel effect term",
indivID = "Person_ID",
mixing = TRUE,
nCores = 4,
outputDirectory = "output"
)

# ################################################################# #
#### LOAD DATA AND APPLY ANY TRANSFORMATIONS ####
# ################################################################# #

setwd("")

getwd()

# ################################################################# #
#### LOAD DATA AND APPLY ANY TRANSFORMATIONS ####
# ################################################################# #

database = read.csv("",header=TRUE)
# ################################################################# #
#### DEFINE MODEL PARAMETERS ####
# ################################################################# #

### Vector of parameters, including any that are kept fixed in estimation
apollo_beta = c(mu_log_b_pp = -3,
sigma_log_b_pp = -0.01,
mu_log_b_oc = -3,
sigma_log_b_oc = -0.01,
mu_log_b_ct = -3,
sigma_log_b_ct = -0.01,
mu_log_b_r = -3,
sigma_log_b_r = -0.01,
b_e = 0,
sigma_panel = 0)

### Vector with names (in quotes) of parameters to be kept fixed at their starting value in apollo_beta, use apollo_beta_fixed = c() if none
apollo_fixed = c()

# ################################################################# #
#### DEFINE RANDOM COMPONENTS ####
# ################################################################# #

### Set parameters for generating draws
apollo_draws = list(
interDrawsType = "mlhs",
interNDraws = 500,
interUnifDraws = c(),
interNormDraws = c("draws_pp","draws_oc","draws_ct","draws_r","draws_alt1","draws_alt2"),
intraDrawsType = "halton",
intraNDraws = 0,
intraUnifDraws = c(),
intraNormDraws = c()
)

### Create random parameters
apollo_randCoeff = function(apollo_beta, apollo_inputs){
randcoeff = list()

randcoeff[["b_pp"]] = -exp( mu_log_b_pp + sigma_log_b_pp * draws_pp )
randcoeff[["b_oc"]] = -exp( mu_log_b_oc + sigma_log_b_oc * draws_oc )
randcoeff[["b_ct"]] = -exp( mu_log_b_ct + sigma_log_b_ct * draws_ct )
randcoeff[["b_r"]] = -exp( mu_log_b_r + sigma_log_b_r * draws_r )
randcoeff[["ec_alt1"]] = sigma_panel * draws_alt1
randcoeff[["ec_alt2"]] = sigma_panel * draws_alt2

return(randcoeff)
}

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

apollo_inputs = apollo_validateInputs()

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

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

### Function initialisation: do not change the following three commands
### Attach inputs and detach after function exit
apollo_attach(apollo_beta, apollo_inputs)
on.exit(apollo_detach(apollo_beta, apollo_inputs))

### Create list of probabilities P
P = list()

### List of utilities: these must use the same names as in mnl_settings, order is irrelevant
V = list()
V[["alt1"]] = b_pp*ppEV + b_oc*ocEV + b_ct*ctEV + b_r*rEV + b_e*eEV + ec_alt1
V[["alt2"]] = b_pp*ppCV + b_oc*ocCV + b_ct*ctCV + b_r*rCV + b_e*eCV + ec_alt2

### Define settings for MNL model component
mnl_settings = list(
alternatives = c(alt1=1, alt2=2),
avail = list(alt1=1, alt2=1),
choiceVar = CHALT,
utilities = V
)

### Compute probabilities using MNL model
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)
}

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

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

# ################################################################# #
#### MODEL OUTPUTS ####
# ################################################################# #

# ----------------------------------------------------------------- #
#---- FORMATTED OUTPUT (TO SCREEN) ----
# ----------------------------------------------------------------- #

apollo_modelOutput(model)

# ----------------------------------------------------------------- #
#---- FORMATTED OUTPUT (TO FILE, using model name) ----
# ----------------------------------------------------------------- #

apollo_saveOutput(model)

******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************

Estimates:
Estimate s.e. t.rat.(0) Rob.s.e. Rob.t.rat.(0)
mu_log_b_pp -1.50557 1.07720 -1.397669 0.85757 -1.75563
sigma_log_b_pp -1.01690 1.02521 -0.991900 0.73934 -1.37543
mu_log_b_oc -5.89415 0.63766 -9.243339 0.40335 -14.61288
sigma_log_b_oc -3.80494 0.44928 -8.468923 0.22814 -16.67813
mu_log_b_ct -8.32174 0.82787 -10.052048 0.31731 -26.22584
sigma_log_b_ct -13.15450 1.00469 -13.093100 0.32429 -40.56397
mu_log_b_r -28.62923 6.181e+05 -4.632e-05 0.66774 -42.87467
sigma_log_b_r -0.66243 6.128e+05 -1.081e-06 0.86745 -0.76365
b_e -0.04314 0.07606 -0.567181 0.07485 -0.57634
sigma_panel 9.1747e-04 0.14410 0.006367 0.02576 0.03562

Re: MMNL model with panel data

Posted: 18 Jan 2023, 18:57
by stephanehess
This is an empirical finding telling you that these parameters are not different from zero with your data