Coding interaction effects in RPL model
Posted: 17 Oct 2020, 16:35
I'm trying to specify an RPL model with interaction effects between variables. I'm having some issues understanding the syntax of how this is done in Apollo.
Suppose I have two attributes and two alternatives, and I want to estimate the mean and standard deviation of the two attributes and the interaction between them. I.e., I want to estimate mu of b1, mu of b2, and mu of b1*b2, along with the inter-subject SD of each. Would someone be willing to point out how to do this?
Here's a mock-up of the code I have:
apollo_beta=c(
mu_b1 = 0
mu_b2 = 0
mu_b1_b2 = 0 ## This is the key variable I want to estimate (b1*b2)
sigma_b1 = 0
sigma_b2 = 0
sigma_b1_b2 = 0
)
apollo_draws = list(
interDrawsType = "mlhs",
interNDraws = 100,
interUnifDraws = c(),
interNormDraws = c(
"inter_draws_b1",
"inter_draws_b2",
"inter_draws_b1_b2
)
)
apollo_randCoeff = function(apollo_beta, apollo_inputs){
randcoeff = list()
randcoeff[["b_X1"]] = mu_b1 + sigma_b1 * inter_draws_b1
randcoeff[["b_X2"]] = mu_b2 + sigma_b2 * inter_draws_b2
randcoeff[["b_X1_X2"]] = mu_b1_b2 + sigma_b1_b2 * inter_draws_b1_b2 ## I'm unsure about how to specify the coefficient
return(randcoeff)
}
apollo_probabilities=function(apollo_beta, apollo_inputs, functionality="estimate"){
## skipping some code
P = list()
V = list()
V[['Alt1']] = b_X1 * Alt1_X1 +
b_X2 * Alt1_X2 +
b_X1_X2 ## I'm unsure about how to specify the utility function for alternative 1
V[['Alt2']] = b_X1 * Alt2_X1 +
b_X2 * Alt2_X2 +
b_X1_X2 ## I'm unsure about how to specify the utility function for alternative 1
## skipping some code
}
Thanks!
Suppose I have two attributes and two alternatives, and I want to estimate the mean and standard deviation of the two attributes and the interaction between them. I.e., I want to estimate mu of b1, mu of b2, and mu of b1*b2, along with the inter-subject SD of each. Would someone be willing to point out how to do this?
Here's a mock-up of the code I have:
apollo_beta=c(
mu_b1 = 0
mu_b2 = 0
mu_b1_b2 = 0 ## This is the key variable I want to estimate (b1*b2)
sigma_b1 = 0
sigma_b2 = 0
sigma_b1_b2 = 0
)
apollo_draws = list(
interDrawsType = "mlhs",
interNDraws = 100,
interUnifDraws = c(),
interNormDraws = c(
"inter_draws_b1",
"inter_draws_b2",
"inter_draws_b1_b2
)
)
apollo_randCoeff = function(apollo_beta, apollo_inputs){
randcoeff = list()
randcoeff[["b_X1"]] = mu_b1 + sigma_b1 * inter_draws_b1
randcoeff[["b_X2"]] = mu_b2 + sigma_b2 * inter_draws_b2
randcoeff[["b_X1_X2"]] = mu_b1_b2 + sigma_b1_b2 * inter_draws_b1_b2 ## I'm unsure about how to specify the coefficient
return(randcoeff)
}
apollo_probabilities=function(apollo_beta, apollo_inputs, functionality="estimate"){
## skipping some code
P = list()
V = list()
V[['Alt1']] = b_X1 * Alt1_X1 +
b_X2 * Alt1_X2 +
b_X1_X2 ## I'm unsure about how to specify the utility function for alternative 1
V[['Alt2']] = b_X1 * Alt2_X1 +
b_X2 * Alt2_X2 +
b_X1_X2 ## I'm unsure about how to specify the utility function for alternative 1
## skipping some code
}
Thanks!