correlation between latent variables in hybrid model
Posted: 29 Jun 2023, 09:39
Hi,
I am using Apollo to predict a hybrid model with two latent variables. However, the example in the manual only includes one latent variable, so I have a few questions. I made some adjustments to the code to accommodate two latent variables, assuming it considers a standard normal distribution for the error terms. I was wondering if this approach takes into account the correlation between the latent variables. If not, how can I incorporate a bivariate normal distribution for error terms to consider correlation between the latent variables?
Additionally, I would like to know if it's acceptable for some of the threshold variables to turn out insignificant. Furthermore, could you recommend a source or reference for writing the formulas in the methodology section for a hybrid choice model with more than one latent variable?
Thanks a lot for your assistance in advance.
code:
### Clear memory
rm(list = ls())
start_time <- Sys.time()
getwd()
#setwd('C:/Users/ehajhashemi/Desktop/EV public data')
### Load Apollo library
library(apollo)
##x = apollo_drugChoiceData
##Y = apollo_modeChoiceData
### Initialise code
apollo_initialise()
#predictions_base = apollo_prediction(model, apollo_probabilities, apollo_inputs, prediction_settings = list(runs=30))
### Set core controls
apollo_control = list(
modelName = "Hybrid",
modelDescr = "Hybrid choice model",
indivID = "ID",
mixing = TRUE,
nCores = 18,
outputDirectory = "output_solar_EV_new_data_test_17"
)
### Loading data from a file
database = read.csv("data_new.csv",header=TRUE)
# ################################################################# #
#### DEFINE MODEL PARAMETERS ####
# ################################################################# #
### Vector of parameters, including any that are kept fixed in estimation
apollo_beta = c(asc_solar = 0,
asc_EV = 0,
asc_PV_and_EV = 0,
b_gender_EV = 0,
b_gender_PV_and_EV = 0,
b_house_type_solar = 0,
b_house_type_PV_and_EV = 0,
b_home_status_solar = 0,
b_home_status_PV_and_EV = 0,
b_HH_size_solar = 0,
b_HH_size_PV_and_EV = 0,
b_empoyment_retired_solar = 0,
b_more_working_from_home_EV = 0,
b_smart_meter_PV_and_EV = 0,
b_energy_managemnet_solar = 0,
b_energy_managemnet_PV_and_EV = 0,
b_have_pool_solar = 0,
b_have_pool_PV_and_EV = 0,
b_have_freezers_solar = 0,
b_location_1_EV = 0,
lambda_env_EV = 0,
lambda_env_PV_and_EV = 0,
lambda_tech_solar = 0,
lambda_tech_EV = 0,
lambda_tech_PV_and_EV = 0,
gamma_age_1_env = 0,
gamma_age_2_env = 0,
gamma_age_3_env = 0,
gamma_age_1_tech = 0,
gamma_age_2_tech = 0,
gamma_income_3_env = 0,
gamma_income_1_tech = 0,
gamma_income_2_tech = 0,
gamma_income_3_tech = 0,
gamma_gender_env = 0,
gamma_gender_tech = 0,
gamma_HH_size_env = 0,
gamma_HH_size_tech = 0,
zeta_env_1 = 1,
zeta_env_2 = 1,
zeta_env_3 = 1,
zeta_env_4 = 1,
zeta_env_5 = 1,
zeta_tech_1 = 1,
zeta_tech_2 = 1,
zeta_tech_3 = 1,
tau_env_1_1 = -2,
tau_env_1_2 = -1,
tau_env_1_3 = 1,
tau_env_1_4 = 2,
tau_env_2_1 =-2,
tau_env_2_2 =-1,
tau_env_2_3 = 1,
tau_env_2_4 = 2,
tau_env_3_1 =-2,
tau_env_3_2 =-1,
tau_env_3_3 = 1,
tau_env_3_4 = 2,
tau_env_4_1 =-2,
tau_env_4_2 =-1,
tau_env_4_3 = 1,
tau_env_4_4 = 2,
tau_env_5_1 =-2,
tau_env_5_2 =-1,
tau_env_5_3 = 1,
tau_env_5_4 = 2,
tau_tech_1_1 =-2,
tau_tech_1_2 =-1,
tau_tech_1_3 = 1,
tau_tech_1_4 = 2,
tau_tech_2_1 =-2,
tau_tech_2_2 =-1,
tau_tech_2_3 = 1,
tau_tech_2_4 = 2,
tau_tech_3_1 =-2,
tau_tech_3_2 =-1,
tau_tech_3_3 = 1,
tau_tech_3_4 = 2)
### 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="halton",
interNDraws=100,
interUnifDraws=c(),
interNormDraws=c("eta_env","eta_tech"),
intraDrawsType="",
intraNDraws=0,
intraUnifDraws=c(),
intraNormDraws=c()
)
### Create random parameters
apollo_randCoeff=function(apollo_beta, apollo_inputs){
randcoeff = list()
randcoeff[['LV_env']] = (gamma_age_1_env * age_18_34_l + gamma_age_2_env * age_35_54_l + gamma_age_3_env * age_55_74_l +
gamma_income_3_env * X120.000.or.more_l +gamma_gender_env * gender_l +
gamma_HH_size_env * HH_size_continuous_l +
eta_env)
randcoeff[['LV_tech']] = ( gamma_age_1_tech * age_18_34_l_t + gamma_age_2_tech * age_35_54_l_t +
#gamma_age_3_tech * age_55_74 +
gamma_income_1_tech * income_40.001.to.under.80.000_l_t + gamma_income_2_tech * income_80.001.to.under.120.000_l_t +
gamma_income_3_tech * X120.000.or.more_l_t + gamma_gender_tech * gender_l_t +
gamma_HH_size_tech * HH_size_continuous_l_t + gamma_work_status_1_tech * full_time_l_t +
eta_tech)
return(randcoeff)
}
# ################################################################# #
#### 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))
### Create list of probabilities P
P = list()
## Likelihood of indicators
ol_settings1 = list(outcomeOrdered = env_1,
V = zeta_env_1*LV_env,
tau = list(tau_env_1_1, tau_env_1_2, tau_env_1_3, tau_env_1_4),
componentName = "indic_env_1")
ol_settings2 = list(outcomeOrdered = env_2,
V = zeta_env_2*LV_env,
tau = list(tau_env_2_1, tau_env_2_2, tau_env_2_3, tau_env_2_4),
componentName = "indic_env_2")
ol_settings3 = list(outcomeOrdered = env_3,
V = zeta_env_3*LV_env,
tau = list(tau_env_3_1, tau_env_3_2, tau_env_3_3, tau_env_3_4),
componentName = "indic_env_3")
ol_settings4 = list(outcomeOrdered = env_4,
V = zeta_env_4*LV_env,
tau = list(tau_env_4_1, tau_env_4_2, tau_env_4_3, tau_env_4_4),
componentName = "indic_env_4")
ol_settings5 = list(outcomeOrdered = env_5,
V = zeta_env_5*LV_env,
tau = list(tau_env_5_1, tau_env_5_2, tau_env_5_3, tau_env_5_4),
componentName = "indic_env_5")
ol_settings6 = list(outcomeOrdered = U12r1,
V = zeta_tech_1*LV_tech,
tau = list(tau_tech_1_1, tau_tech_1_2, tau_tech_1_3, tau_tech_1_4),
componentName = "indic_tech_1")
ol_settings7 = list(outcomeOrdered = U12r2,
V = zeta_tech_2*LV_tech,
tau = list(tau_tech_2_1, tau_tech_2_2, tau_tech_2_3, tau_tech_2_4),
componentName = "indic_tech_2")
ol_settings8 = list(outcomeOrdered = U12r3,
V = zeta_tech_3*LV_tech,
tau = list(tau_tech_3_1, tau_tech_3_2, tau_tech_3_3, tau_tech_3_4),
componentName = "indic_tech_3")
P[["indic_env_1"]] = apollo_ol(ol_settings1, functionality)
P[["indic_env_2"]] = apollo_ol(ol_settings2, functionality)
P[["indic_env_3"]] = apollo_ol(ol_settings3, functionality)
P[["indic_env_4"]] = apollo_ol(ol_settings4, functionality)
P[["indic_env_5"]] = apollo_ol(ol_settings5, functionality)
P[["indic_tech_1"]] = apollo_ol(ol_settings6, functionality)
P[["indic_tech_2"]] = apollo_ol(ol_settings7, functionality)
P[["indic_tech_3"]] = apollo_ol(ol_settings8, functionality)
### Likelihood of choices
### List of utilities: these must use the same names as in mnl_settings, order is irrelevant
V = list()
V[["adopting_none"]] = 0
V[["only_adopt_solar"]] = (asc_solar +
#b_age_solar_1 * age_18_34 + b_age_solar_2 * age_35_54 + b_age_solar_3 * age_55_74 +
b_house_type_solar * house_type + b_home_status_solar * home_status +
b_HH_size_solar * HH_size_continuous +
b_empoyment_retired_solar * Retired +
b_energy_managemnet_solar * energy_management_system +
b_have_pool_solar * swimming_pool +
b_have_freezers_solar * freezers +
#b_have_dishwasher_solar * Dishwasher +
lambda_tech_solar * LV_tech
)
V[["only_adopt_EV"]] = (asc_EV + b_gender_EV * gender
b_income_EV_3 * X120.000.or.more +
b_more_working_from_home_EV * more_working_home +
b_location_1_EV * Inner.Metro +
lambda_env_EV * LV_env +lambda_tech_EV * LV_tech
)
V[["adopt_PV_and_EV"]] = (asc_PV_and_EV + b_gender_PV_and_EV * gender +
b_house_type_PV_and_EV * house_type + b_home_status_PV_and_EV * home_status +
b_HH_size_PV_and_EV * HH_size_continuous +
b_smart_meter_PV_and_EV * smart_meter + b_energy_managemnet_PV_and_EV * energy_management_system +
b_have_pool_PV_and_EV * swimming_pool +
lambda_env_PV_and_EV * LV_env + lambda_tech_PV_and_EV * LV_tech
)
### Define settings for MNL model component
mnl_settings = list(
alternatives = c(adopting_none=1, only_adopt_solar=2, only_adopt_EV=3, adopt_PV_and_EV=4),
avail = list(adopting_none=1, only_adopt_solar=1, only_adopt_EV=1, adopt_PV_and_EV=1),
choiceVar = EV_solar_decision_coded_new,
utilities = V,
componentName = "choice"
)
### Compute probabilities for MNL model component
P[["choice"]] = apollo_mnl(mnl_settings, functionality)
### Likelihood of the whole model
P = apollo_combineModels(P, apollo_inputs, 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)
# ################################################################# #
##### POST-PROCESSING ####
# ################################################################# #
### Print outputs of additional diagnostics to new output file (remember to close file writing when complete)
apollo_sink()
# ----------------------------------------------------------------- #
#---- CONDITIONALS AND UNCONDITIONALS ----
# ----------------------------------------------------------------- #
#
# conditionals <- apollo_conditionals(model,apollo_probabilities,apollo_inputs)
#
# summary(conditionals)
#
# unconditionals <-
# apollo_unconditionals(model,apollo_probabilities,apollo_inputs)
#
# mean(unconditionals[[1]]) sd(unconditionals[[1]])
# ----------------------------------------------------------------- #
#---- switch off writing to file ----
# ----------------------------------------------------------------- #☻
apollo_sink()
end_time <- Sys.time()
end_time - start_time
apollo_modelOutput(model, modelOutput_settings=list(printPVal = 2))
I am using Apollo to predict a hybrid model with two latent variables. However, the example in the manual only includes one latent variable, so I have a few questions. I made some adjustments to the code to accommodate two latent variables, assuming it considers a standard normal distribution for the error terms. I was wondering if this approach takes into account the correlation between the latent variables. If not, how can I incorporate a bivariate normal distribution for error terms to consider correlation between the latent variables?
Additionally, I would like to know if it's acceptable for some of the threshold variables to turn out insignificant. Furthermore, could you recommend a source or reference for writing the formulas in the methodology section for a hybrid choice model with more than one latent variable?
Thanks a lot for your assistance in advance.
code:
### Clear memory
rm(list = ls())
start_time <- Sys.time()
getwd()
#setwd('C:/Users/ehajhashemi/Desktop/EV public data')
### Load Apollo library
library(apollo)
##x = apollo_drugChoiceData
##Y = apollo_modeChoiceData
### Initialise code
apollo_initialise()
#predictions_base = apollo_prediction(model, apollo_probabilities, apollo_inputs, prediction_settings = list(runs=30))
### Set core controls
apollo_control = list(
modelName = "Hybrid",
modelDescr = "Hybrid choice model",
indivID = "ID",
mixing = TRUE,
nCores = 18,
outputDirectory = "output_solar_EV_new_data_test_17"
)
### Loading data from a file
database = read.csv("data_new.csv",header=TRUE)
# ################################################################# #
#### DEFINE MODEL PARAMETERS ####
# ################################################################# #
### Vector of parameters, including any that are kept fixed in estimation
apollo_beta = c(asc_solar = 0,
asc_EV = 0,
asc_PV_and_EV = 0,
b_gender_EV = 0,
b_gender_PV_and_EV = 0,
b_house_type_solar = 0,
b_house_type_PV_and_EV = 0,
b_home_status_solar = 0,
b_home_status_PV_and_EV = 0,
b_HH_size_solar = 0,
b_HH_size_PV_and_EV = 0,
b_empoyment_retired_solar = 0,
b_more_working_from_home_EV = 0,
b_smart_meter_PV_and_EV = 0,
b_energy_managemnet_solar = 0,
b_energy_managemnet_PV_and_EV = 0,
b_have_pool_solar = 0,
b_have_pool_PV_and_EV = 0,
b_have_freezers_solar = 0,
b_location_1_EV = 0,
lambda_env_EV = 0,
lambda_env_PV_and_EV = 0,
lambda_tech_solar = 0,
lambda_tech_EV = 0,
lambda_tech_PV_and_EV = 0,
gamma_age_1_env = 0,
gamma_age_2_env = 0,
gamma_age_3_env = 0,
gamma_age_1_tech = 0,
gamma_age_2_tech = 0,
gamma_income_3_env = 0,
gamma_income_1_tech = 0,
gamma_income_2_tech = 0,
gamma_income_3_tech = 0,
gamma_gender_env = 0,
gamma_gender_tech = 0,
gamma_HH_size_env = 0,
gamma_HH_size_tech = 0,
zeta_env_1 = 1,
zeta_env_2 = 1,
zeta_env_3 = 1,
zeta_env_4 = 1,
zeta_env_5 = 1,
zeta_tech_1 = 1,
zeta_tech_2 = 1,
zeta_tech_3 = 1,
tau_env_1_1 = -2,
tau_env_1_2 = -1,
tau_env_1_3 = 1,
tau_env_1_4 = 2,
tau_env_2_1 =-2,
tau_env_2_2 =-1,
tau_env_2_3 = 1,
tau_env_2_4 = 2,
tau_env_3_1 =-2,
tau_env_3_2 =-1,
tau_env_3_3 = 1,
tau_env_3_4 = 2,
tau_env_4_1 =-2,
tau_env_4_2 =-1,
tau_env_4_3 = 1,
tau_env_4_4 = 2,
tau_env_5_1 =-2,
tau_env_5_2 =-1,
tau_env_5_3 = 1,
tau_env_5_4 = 2,
tau_tech_1_1 =-2,
tau_tech_1_2 =-1,
tau_tech_1_3 = 1,
tau_tech_1_4 = 2,
tau_tech_2_1 =-2,
tau_tech_2_2 =-1,
tau_tech_2_3 = 1,
tau_tech_2_4 = 2,
tau_tech_3_1 =-2,
tau_tech_3_2 =-1,
tau_tech_3_3 = 1,
tau_tech_3_4 = 2)
### 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="halton",
interNDraws=100,
interUnifDraws=c(),
interNormDraws=c("eta_env","eta_tech"),
intraDrawsType="",
intraNDraws=0,
intraUnifDraws=c(),
intraNormDraws=c()
)
### Create random parameters
apollo_randCoeff=function(apollo_beta, apollo_inputs){
randcoeff = list()
randcoeff[['LV_env']] = (gamma_age_1_env * age_18_34_l + gamma_age_2_env * age_35_54_l + gamma_age_3_env * age_55_74_l +
gamma_income_3_env * X120.000.or.more_l +gamma_gender_env * gender_l +
gamma_HH_size_env * HH_size_continuous_l +
eta_env)
randcoeff[['LV_tech']] = ( gamma_age_1_tech * age_18_34_l_t + gamma_age_2_tech * age_35_54_l_t +
#gamma_age_3_tech * age_55_74 +
gamma_income_1_tech * income_40.001.to.under.80.000_l_t + gamma_income_2_tech * income_80.001.to.under.120.000_l_t +
gamma_income_3_tech * X120.000.or.more_l_t + gamma_gender_tech * gender_l_t +
gamma_HH_size_tech * HH_size_continuous_l_t + gamma_work_status_1_tech * full_time_l_t +
eta_tech)
return(randcoeff)
}
# ################################################################# #
#### 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))
### Create list of probabilities P
P = list()
## Likelihood of indicators
ol_settings1 = list(outcomeOrdered = env_1,
V = zeta_env_1*LV_env,
tau = list(tau_env_1_1, tau_env_1_2, tau_env_1_3, tau_env_1_4),
componentName = "indic_env_1")
ol_settings2 = list(outcomeOrdered = env_2,
V = zeta_env_2*LV_env,
tau = list(tau_env_2_1, tau_env_2_2, tau_env_2_3, tau_env_2_4),
componentName = "indic_env_2")
ol_settings3 = list(outcomeOrdered = env_3,
V = zeta_env_3*LV_env,
tau = list(tau_env_3_1, tau_env_3_2, tau_env_3_3, tau_env_3_4),
componentName = "indic_env_3")
ol_settings4 = list(outcomeOrdered = env_4,
V = zeta_env_4*LV_env,
tau = list(tau_env_4_1, tau_env_4_2, tau_env_4_3, tau_env_4_4),
componentName = "indic_env_4")
ol_settings5 = list(outcomeOrdered = env_5,
V = zeta_env_5*LV_env,
tau = list(tau_env_5_1, tau_env_5_2, tau_env_5_3, tau_env_5_4),
componentName = "indic_env_5")
ol_settings6 = list(outcomeOrdered = U12r1,
V = zeta_tech_1*LV_tech,
tau = list(tau_tech_1_1, tau_tech_1_2, tau_tech_1_3, tau_tech_1_4),
componentName = "indic_tech_1")
ol_settings7 = list(outcomeOrdered = U12r2,
V = zeta_tech_2*LV_tech,
tau = list(tau_tech_2_1, tau_tech_2_2, tau_tech_2_3, tau_tech_2_4),
componentName = "indic_tech_2")
ol_settings8 = list(outcomeOrdered = U12r3,
V = zeta_tech_3*LV_tech,
tau = list(tau_tech_3_1, tau_tech_3_2, tau_tech_3_3, tau_tech_3_4),
componentName = "indic_tech_3")
P[["indic_env_1"]] = apollo_ol(ol_settings1, functionality)
P[["indic_env_2"]] = apollo_ol(ol_settings2, functionality)
P[["indic_env_3"]] = apollo_ol(ol_settings3, functionality)
P[["indic_env_4"]] = apollo_ol(ol_settings4, functionality)
P[["indic_env_5"]] = apollo_ol(ol_settings5, functionality)
P[["indic_tech_1"]] = apollo_ol(ol_settings6, functionality)
P[["indic_tech_2"]] = apollo_ol(ol_settings7, functionality)
P[["indic_tech_3"]] = apollo_ol(ol_settings8, functionality)
### Likelihood of choices
### List of utilities: these must use the same names as in mnl_settings, order is irrelevant
V = list()
V[["adopting_none"]] = 0
V[["only_adopt_solar"]] = (asc_solar +
#b_age_solar_1 * age_18_34 + b_age_solar_2 * age_35_54 + b_age_solar_3 * age_55_74 +
b_house_type_solar * house_type + b_home_status_solar * home_status +
b_HH_size_solar * HH_size_continuous +
b_empoyment_retired_solar * Retired +
b_energy_managemnet_solar * energy_management_system +
b_have_pool_solar * swimming_pool +
b_have_freezers_solar * freezers +
#b_have_dishwasher_solar * Dishwasher +
lambda_tech_solar * LV_tech
)
V[["only_adopt_EV"]] = (asc_EV + b_gender_EV * gender
b_income_EV_3 * X120.000.or.more +
b_more_working_from_home_EV * more_working_home +
b_location_1_EV * Inner.Metro +
lambda_env_EV * LV_env +lambda_tech_EV * LV_tech
)
V[["adopt_PV_and_EV"]] = (asc_PV_and_EV + b_gender_PV_and_EV * gender +
b_house_type_PV_and_EV * house_type + b_home_status_PV_and_EV * home_status +
b_HH_size_PV_and_EV * HH_size_continuous +
b_smart_meter_PV_and_EV * smart_meter + b_energy_managemnet_PV_and_EV * energy_management_system +
b_have_pool_PV_and_EV * swimming_pool +
lambda_env_PV_and_EV * LV_env + lambda_tech_PV_and_EV * LV_tech
)
### Define settings for MNL model component
mnl_settings = list(
alternatives = c(adopting_none=1, only_adopt_solar=2, only_adopt_EV=3, adopt_PV_and_EV=4),
avail = list(adopting_none=1, only_adopt_solar=1, only_adopt_EV=1, adopt_PV_and_EV=1),
choiceVar = EV_solar_decision_coded_new,
utilities = V,
componentName = "choice"
)
### Compute probabilities for MNL model component
P[["choice"]] = apollo_mnl(mnl_settings, functionality)
### Likelihood of the whole model
P = apollo_combineModels(P, apollo_inputs, 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)
# ################################################################# #
##### POST-PROCESSING ####
# ################################################################# #
### Print outputs of additional diagnostics to new output file (remember to close file writing when complete)
apollo_sink()
# ----------------------------------------------------------------- #
#---- CONDITIONALS AND UNCONDITIONALS ----
# ----------------------------------------------------------------- #
#
# conditionals <- apollo_conditionals(model,apollo_probabilities,apollo_inputs)
#
# summary(conditionals)
#
# unconditionals <-
# apollo_unconditionals(model,apollo_probabilities,apollo_inputs)
#
# mean(unconditionals[[1]]) sd(unconditionals[[1]])
# ----------------------------------------------------------------- #
#---- switch off writing to file ----
# ----------------------------------------------------------------- #☻
apollo_sink()
end_time <- Sys.time()
end_time - start_time
apollo_modelOutput(model, modelOutput_settings=list(printPVal = 2))