Page 2 of 2

Re: errors in Latent class model

Posted: 29 Aug 2023, 06:22
by georkapo
Hi again,

In addition, I have estimated the LC model with two classes and got the willingness to pay. However, since I kept some attribute levels as fixed, can I calculate the wtp for the fixed ones? Is it possible to get the wtp for all of the attributes?
Also, the wtp that I calculated is the relative wtp since it is always compared with the fixed attributes?

Sorry, if this is a silly question!

Thank you in advance.
Best regards,
Georgios

Re: errors in Latent class model

Posted: 29 Aug 2023, 15:02
by dpalma
Hi Georgios,

I'm not sure I fully understand all your questions, but will do my best to answer.

I understand you are modelling a health-related choice using latent classes, and you have data from different countries. So the country is not the dependent variable. I am not sure what you mean by the "posterior probability". Is it the posterior probability of the class allocation? And when you say "I can calculate the posterior probability for the aggregate data (all countries)", do you mean you can calculate the class allocation probability for each observation in your pooled data (the data including observations from all countries)?

If you want to calculate an average posterior class allocation probability for each country, I would simply take the average posterior for all individuals from each country. You can do that with the following code:

Code: Select all

# Calculate conditional (posterior) class allocation probabilities per indiv
conditionals <- apollo_conditionals(model,apollo_probabilities, apollo_inputs)
# Add country of origin to conditionals
tmp <- unique(database[,c("ID", "country")]) # create database with ID and country
conditionals <- merge(conditionals, tmp, by="ID") # merge the two databases
rm(tmp) # delete temporal database
# Get average conditionals by country
aggregate(conditionals[,c("X1","X2")], by=conditionals["country"], FUN=mean)
In the code, I am assuming you have variable in your database called "country" that indicates what country each observation is from. I also assume that there are only two classes, and that their posterior class allocation are called "X1" and "X2" when returned by apollo_conditionals.

You could also create a different model for each country, but I would not recommend it, as you would loose efficiency (each individual model would not as precise as your larger model).

I would recommend you include the country in the class allocation probability. But you should only keep it if it has a significant effect.

You can calculate the average posterior class allocation probability for other socio-demographics in the same way that you do for country of origin. So if you wanted to do it by income level (I am assuming you have a variable called "incomeLevel" in your database), you could use the following code:

Code: Select all

# Calculate conditional (posterior) class allocation probabilities per indiv
conditionals <- apollo_conditionals(model,apollo_probabilities, apollo_inputs)
# Add income level to conditionals
tmp <- unique(database[,c("ID", "incomeLevel")]) # create database with ID and country
conditionals <- merge(conditionals, tmp, by="ID") # merge the two databases
rm(tmp) # delete temporal database
# Get average conditionals by income level
aggregate(conditionals[,c("X1","X2")], by=conditionals["incomeLevel"], FUN=mean)
Finally, when you say "I kept some attribute levels as fixed", do you mean you fixed their corresponding parameters to zero, so you used them as base? If so, no, you cannot calculate the WTP for the base level, as all other WTP are with respect to that level. For example, if you have a categorical variable that can take three levels: red, green, and blue. And you fix the coefficient of b_red=0, but estimate b_green and b_blue. Then b_green/b_cost (where b_cost is the non-random coefficient of price) is the WTP for a green alternative with respect to a red one. The only thing you can say about the WTP for a red alternative is that it is b_green/b_cost lower than the WTP for a green alternative, a statement that doesn't really add any new information.

Best wishes
David

Re: errors in Latent class model

Posted: 17 Sep 2023, 16:11
by georkapo
Dear David,

Thank you very much. I really appreciate your help.

Indeed, I want to calculate the average posterior class allocation probability for each country and for some other sociodemographic variables. What you recommended works fine.

Another question I have is about the heterogeneity. In the model I calculated, I found some deterministic heterogeneity and then also random heterogeneity (in the class allocation). However, I am not sure if I need to use the determinist heterogeneity in my final model. Should I keep the variables with deterministic heterogeneity (e.g. female, elderly), or should I just keep the random heterogeneity? Does it make any sense to keep both (deterministic and random)?

Best regards,
Georgios

Re: errors in Latent class model

Posted: 18 Sep 2023, 09:30
by stephanehess
Georgios

it's always best to have deterministic heterogeneity too. That means you're actually explaining things

Stephane