Page 1 of 1

Parameter does not influence the likelihood

Posted: 02 Feb 2021, 16:52
by anhntl
Hello Professors,
I am estimating MIXL model of pool sample for two types of respondents, with error component to account the difference of error variance between two respondents.
The model can be estimated with whole sample. Then I divide the sample based on the location of the respondents. (Whole sample is 3594 observations/ 599 individuals; each subsample is around 800-900 observations/130-150 individuals)

When I estimate for a subsample, some subsample can be estimated, while some got above error.

For this code, I got this error"mu.b.facT.v does not influence the likelihood"

I tried different suggestions in FAQ:
- check my code: it is ok because it can be estimated for another subsample
- change start value of parameters: taken from MNL or MIXL for the whole sample or mu from 1-3, sigma 0

But then I still got the error.

I would like to ask about your suggestion in my case. Below is my code:
Thank you very much.

apollo_initialise()
apollo_control = list(
modelName ="C_MIXL_Both",
modelDescr ="Pool Residents-Tourists",
indivID ="id",
mixing=TRUE,panelData=TRUE,
nCores=3
)
all<- read.csv("D:\\Research\\Theses\\Second Chapter\\Working\\Data\\Final\\apollo_pool1.csv", header=T)
database=all[which(all$ers_random_beach=="C"),]
### Vector of parameters, including any that are kept fixed in estimation
apollo_beta=c( mu.b.width=1, sigma.b.width=0.1,
sigma.hsk.v=0.1,
mu.b.asc.h = 1, mu.b.access.h=1,mu.b.tax.h=1,
mu.b.facR.h=1, mu.b.facRT.h=1, mu.b.facT.h=1,
mu.b.strucG.h=1, mu.b.strucSB.h=1, mu.b.strucRC.h=1, mu.b.strucRStairs.h=1,

mu.b.asc.v = 1, mu.b.access.v=1,mu.b.tax.v=1,
mu.b.facR.v=1, mu.b.facRT.v=1, mu.b.facT.v=1,
mu.b.strucG.v=1, mu.b.strucSB.v=1, mu.b.strucRC.v=1, mu.b.strucRStairs.v=1,

sigma.b.asc.h = 0.1, sigma.b.access.h=0.1,sigma.b.tax.h=0.1,
sigma.b.facR.h=0.1, sigma.b.facRT.h=0.1, sigma.b.facT.h=0.1,
sigma.b.strucG.h=0.1, sigma.b.strucSB.h=0.1, sigma.b.strucRC.h=0.1, sigma.b.strucRStairs.h=0.1,

sigma.b.asc.v = 0.1, sigma.b.access.v=0.1,sigma.b.tax.v=0.1,
sigma.b.facR.v=0.1, sigma.b.facRT.v=0.1, sigma.b.facT.v=0.1,
sigma.b.strucG.v=0.1, sigma.b.strucSB.v=0.1, sigma.b.strucRC.v=0.1, sigma.b.strucRStairs.v=0.1)

### 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()

### Read in starting values for at least some parameters from existing model output file
apollo_beta=apollo_readBeta(apollo_beta,apollo_fixed,"MNL_Both",overwriteFixed = FALSE)

### Set parameters for generating draws
apollo_draws = list(
interDrawsType = "mlhs",
interNDraws = 5,
interUnifDraws = c(),
interNormDraws = c("draws.asc.h","draws.width","draws.access.h","draws.facR.h",
"draws.facRT.h","draws.facT.h", "draws.strucSB.h","draws.strucG.h",
"draws.strucRC.h","draws.strucRStairs.h", "draws.tax.h",
"draws.asc.v","draws.access.v","draws.facR.v",
"draws.facRT.v","draws.facT.v", "draws.strucSB.v","draws.strucG.v",
"draws.strucRC.v","draws.strucRStairs.v","draws.tax.v", #"draws.hsk.h",
"draws.hsk.v1","draws.hsk.v2","draws.hsk.v3"),
intraDrawsType = "halton",
intraNDraws = 0,
intraUnifDraws = c(),
intraNormDraws = c()
)

### Create random parameters
apollo_randCoeff = function(apollo_beta, apollo_inputs){
randcoeff = list()
randcoeff[["b.width"]] = mu.b.width + sigma.b.width * draws.width
randcoeff[["b.asc.h"]] = mu.b.asc.h + sigma.b.asc.h * draws.asc.h
randcoeff[["b.access.h"]] = mu.b.access.h + sigma.b.access.h * draws.access.h
randcoeff[["b.tax.h"]] = mu.b.tax.h + sigma.b.tax.h * draws.tax.h
randcoeff[["b.facR.h"]] = mu.b.facR.h + sigma.b.facR.h * draws.facR.h
randcoeff[["b.facRT.h"]] = mu.b.facRT.h + sigma.b.facRT.h * draws.facRT.h
randcoeff[["b.facT.h"]] = mu.b.facT.h + sigma.b.facT.h * draws.facT.h
randcoeff[["b.strucSB.h"]] = mu.b.strucSB.h + sigma.b.strucSB.h * draws.strucSB.h
randcoeff[["b.strucRC.h"]] = mu.b.strucRC.h + sigma.b.strucRC.h * draws.strucRC.h
randcoeff[["b.strucG.h"]] = mu.b.strucG.h + sigma.b.strucG.h * draws.strucG.h
randcoeff[["b.strucRStairs.h"]] = mu.b.strucRStairs.h + sigma.b.strucRStairs.h * draws.strucRStairs.h
randcoeff[["ec.v1"]] = sigma.hsk.v * draws.hsk.v1
randcoeff[["ec.v2"]] = sigma.hsk.v * draws.hsk.v2
randcoeff[["ec.v3"]] = sigma.hsk.v * draws.hsk.v3

randcoeff[["b.asc.v"]] = mu.b.asc.v + sigma.b.asc.v * draws.asc.v
randcoeff[["b.access.v"]] = mu.b.access.v + sigma.b.access.v * draws.access.v
randcoeff[["b.tax.v"]] = mu.b.tax.v + sigma.b.tax.v * draws.tax.v
randcoeff[["b.facR.v"]] = mu.b.facR.v + sigma.b.facR.v * draws.facR.v
randcoeff[["b.facRT.v"]] = mu.b.facRT.v + sigma.b.facRT.v * draws.facRT.v
randcoeff[["b.facT.v"]] = mu.b.facT.v + sigma.b.facT.v * draws.facT.v
randcoeff[["b.strucSB.v"]] = mu.b.strucSB.v + sigma.b.strucSB.v * draws.strucSB.v
randcoeff[["b.strucRC.v"]] = mu.b.strucRC.v + sigma.b.strucRC.v * draws.strucRC.v
randcoeff[["b.strucG.v"]] = mu.b.strucG.v + sigma.b.strucG.v * draws.strucG.v
randcoeff[["b.strucRStairs.v"]] = mu.b.strucRStairs.v + sigma.b.strucRStairs.v * draws.strucRStairs.v

return(randcoeff)
}

apollo_inputs = apollo_validateInputs()

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[['alt.1']] = b.asc.h*hh+ b.asc.v*vit+
b.access.h* hh*access.1+b.width*width.1+b.facR.h* hh* facR.1+
b.facRT.h*hh*facRT.1+b.facT.h* hh* facT.1+b.strucG.h* hh*strucG.1+b.strucRC.h* hh*strucRC.1+
b.strucRStairs.h* hh*strucRStairs.1+b.strucSB.h* hh*strucSB.1+b.tax.h* hh*otax.1+
b.access.v* vit*access.1+b.facR.v* vit* facR.1+
b.facRT.v* vit*facRT.1+b.facT.v* vit* facT.1+b.strucG.v* vit*strucG.1+b.strucRC.v* vit*strucRC.1+
b.strucRStairs.v* vit*strucRStairs.1+b.strucSB.v* vit*strucSB.1+b.tax.v* vit*otax.1+#ec.h*hh+
ec.v1*hh

V[['alt.2']] = b.access.h* hh*access.2+b.width*width.2+b.facR.h* hh* facR.2+
b.facRT.h*hh*facRT.2+b.facT.h* hh* facT.2+b.strucG.h* hh*strucG.2+b.strucRC.h* hh*strucRC.2+
b.strucRStairs.h* hh*strucRStairs.2+b.strucSB.h* hh*strucSB.2+b.tax.h* hh*otax.2+
b.access.v* vit*access.2+b.facR.v* vit* facR.2+
b.facRT.v* vit*facRT.2+b.facT.v* vit* facT.2+b.strucG.v* vit*strucG.2+b.strucRC.v* vit*strucRC.2+
b.strucRStairs.v* vit*strucRStairs.2+b.strucSB.v* vit*strucSB.2+b.tax.v* vit*otax.2+ec.v2*hh
V[['alt.3']] = b.access.h* hh*access.3+b.width*width.3+b.facR.h* hh* facR.3+
b.facRT.h* hh*facRT.3+b.facT.h* hh* facT.3+b.strucG.h* hh*strucG.3+b.strucRC.h* hh*strucRC.3+
b.strucRStairs.h* hh*strucRStairs.3+b.strucSB.h* hh*strucSB.3+b.tax.h* hh*otax.3+
b.access.v* vit*access.3+b.facR.v* vit* facR.3+
b.facRT.v* vit*facRT.3+b.facT.v* vit* facT.3+b.strucG.v* vit*strucG.3+b.strucRC.v* vit*strucRC.3+
b.strucRStairs.v* vit*strucRStairs.3+b.strucSB.v* vit*strucSB.3+b.tax.v* vit*otax.3+ec.v3*hh

### Define settings for MNL model component
mnl_settings = list(
alternatives = c(alt.1=1, alt.2=2,alt.2=3),
avail = list(alt.1=1, alt.2=1,alt.2=1),
choiceVar = choice,
V = 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 = apollo_estimate(apollo_beta, apollo_fixed,
apollo_probabilities, apollo_inputs)#, estimate_settings=list(hessianRoutine="maxLik"))

apollo_modelOutput(model)
apollo_saveOutput(model)

Re: Parameter does not influence the likelihood

Posted: 03 Feb 2021, 17:36
by stephanehess
Hi

so the model works for the code you show below, correct? Can you also reproduce the code for which it doesn't work?

Thanks

Stephane

Re: Parameter does not influence the likelihood

Posted: 04 Feb 2021, 02:21
by anhntl
Hello Professor Stephane,
This above code works. But when I change to another subsample, for example: database=all[which(all$ers_random_beach=="A"),] (instead of database=all[which(all$ers_random_beach=="C"),]), I got the error "mu.b.facT.v does not influence the likelihood".
Thank you.

Re: Parameter does not influence the likelihood

Posted: 04 Feb 2021, 02:22
by anhntl
Hello Professor Stephane,
This above code works. But when I change to another subsample, for example: database=all[which(all$ers_random_beach=="A"),] (instead of database=all[which(all$ers_random_beach=="C"),]), I got the error "mu.b.facT.v does not influence the likelihood".
Thank you.

Re: Parameter does not influence the likelihood

Posted: 04 Feb 2021, 10:06
by stephanehess
As I don't know your data, it is impossible to understand immediately why this is happening. But there are two key possibilities:

the associated parameter is used to create b.facT.v

In the utilities, this is used in

b.facT.v* vit* facT.1
b.facT.v* vit* facT.2
b.facT.v* vit* facT.3

1. In the subsample, is vit maybe always 0? If so, you obviously can't estimate that parameter as it won't be used
2. Or is facT.1=facT.2=facT.3? Again, you can't use it then as it won't influence differences in the utilities

Re: Parameter does not influence the likelihood

Posted: 05 Feb 2021, 08:44
by anhntl
Dear Professor Stephane,
I have checked both and they are not the case:

1. 30% subsample has vit=1,
2. facT.1=0 while facT.2 and facT.3 is different. They are dummy variables.

vit*facT.1, vit*facT.2 and vit*facT.3 are also different.

Re: Parameter does not influence the likelihood

Posted: 05 Feb 2021, 15:15
by stephanehess
Hi

you had:

alternatives = c(alt.1=1, alt.2=2,alt.2=3)

instead of

alternatives = c(alt.1=1, alt.2=2,alt.3=3)

Re: Parameter does not influence the likelihood

Posted: 05 Feb 2021, 15:31
by anhntl
Thank you very much Professor Stephane for pointing out this silly mistake of me. It took me weeks to try to understand why I always didnt get normal results in various estimations. Now I know. Thank you.