However, I get the following error: no matches for normal(real, real). Function normal not found. So I must be miscasting the variables? I have also tried the line below instead, but from what I can tell from this group and the documentation, the ~ increments the log posterior, and does not mean "drawn from." This throws an error that the dimension of the right side of the statement is 0.
perceived_rprob[trial_i] ~ normal(rightprob[trial_i], rightprob[trial_i]*prob_m+prob_offset);
I am using rstan; my code is below. I apologize if I am doing something super dumb, any help is very much appreciated. Thank you so much!!!
model_code <- "data {
int nTrials;
int choices[nTrials]; //values of 1 (chose left) or 2 (chose right)
real<lower=0, upper=1> leftprob[nTrials];
real<lower=0, upper=1> leftvol[nTrials]; //rewards are normalized by max reward
real<lower=0, upper=1> rightprob[nTrials];
real<lower=0, upper=1> rightvol[nTrials]; //rewards are normalized by max reward
}
transformed data {
// this executes once vs on each sample in the model block, so better to transform here and pay for the conditional once
int<lower=0,upper=1> choices_01[nTrials];
for (i in 1:nTrials){
choices_01[i] <- (choices[i]==2);
}
}
parameters {
real rho; //exponential of utility function
real alpha; //parameter for probability weighting function
real<lower=0> lambda; //softmax parameter
real<lower=0> prob_m; //slope of scalar variability relationship
real<lower=0> prob_offset; //offset of scalar variability relationship
real<lower=0> vol_m;
real<lower=0> vol_offset;
}
model {
real Rval[nTrials];
real Lval[nTrials];
real perceived_rprob[nTrials];
real perceived_lprob[nTrials];
real perceived_rvol[nTrials];
real perceived_lvol[nTrials];
rho ~ cauchy(0, 2.5);
for (trial_i in 1:nTrials) {
perceived_rprob[trial_i] <- normal(rightprob[trial_i], rightprob[trial_i]*prob_m+prob_offset);
perceived_lprob[trial_i] <- normal(leftprob[trial_i], leftprob[trial_i]*prob_m+prob_offset);
perceived_rvol[trial_i] <- normal(rightvol[trial_i], rightvol[trial_i]*vol_m+vol_offset);
perceived_lvol[trial_i] <- normal(leftvol[trial_i], leftvol[trial_i]*vol_m+vol_offset);
Rval <- exp(-(-log(perceived_rprob[trial_i]))^alpha)*(perceived_rvol[trial_i]^rho);
Lval <- exp(-(-log(perceived_lprob[trial_i]))^alpha)*(perceived_lvol[trial_i]^rho);
choices_01[trial_i] ~ bernoulli_logit(lambda*(Rval-Lval));
}
}"
--
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thank you Ben and Michael. I apologize for the confusion, I have not done a good job of describing the model.
According to some economic theories, humans choose between two prospects, or gambles, based on the relative value of those prospects (in my case, Rval and Lval), where the value is the product of a nonlinear subjective function relating true probability and perceived probability (in my case, exp(-(-log(p))^alpha)), and a nonlinear function relating true reward amount and perceived reward amount (in my case, vol^rho). My primary interest is in inferring the parameters alpha and rho from many thousands of choices between different gambles.However, in my experiment, I am using certain sensory cues to convey reward probability and reward amount to the subject (e.g., # light flashes conveys the true probability). It is known that subjects' estimates of such stimuli can be noisy. Specifically, the standard deviation in the subjects' estimate of # flashes grows linearly with the # flashes presented.My concern is that if I don't account for this sensory noise, it could mess up my estimates of alpha and rho. So I was hoping to compare the alpha and rho parameters before accounting for noise (that model already works in stan) and afterwards, to see if it is something I should worry about.Does that make sense? Please let me know if I should clarify anything, and thanks so much for your feedback!
model_code <- "data {
int nTrials;
int choices[nTrials]; //values of 1 (chose left) or 2 (chose right)
real<lower=0, upper=1> leftprob[nTrials];
real<lower=0, upper=1> leftvol[nTrials]; //rewards are normalized by max reward
real<lower=0, upper=1> rightprob[nTrials];
real<lower=0, upper=1> rightvol[nTrials]; //rewards are normalized by max reward
}
transformed data {
// this executes once vs on each sample in the model block, so better to transform here and pay for the conditional once
int<lower=0,upper=1> choices_01[nTrials];
for (i in 1:nTrials){
choices_01[i] <- (choices[i]==2);
}
}
parameters {
real rho; //exponential of utility function
real alpha; //parameter for probability weighting function
real<lower=0> lambda; //softmax parameter
real<lower=0> prob_m; //slope of scalar variability relationship
real<lower=0> prob_offset; //offset of scalar variability relationship
real<lower=0> vol_m;
real<lower=0> vol_offset;
}
model {
real Rval[nTrials];
real Lval[nTrials];
real rflashes[nTrials]; //sensory cues conveying probability
real lflashes[nTrials];
real rclicks[nTrials]; //sensory cues conveying reward amount
real lclicks[nTrials];
int latent_rprob[nTrials]; //latent estimate of probability
int latent_lprob[nTrials];
int latent_rvol[nTrials]; //latent estimate of reward amount
int latent_lvol[nTrials];
rho ~ cauchy(0, 2.5);
for (trial_i in 1:nTrials) {
rflashes[trial_i] ~ normal(rightprob[trial_i], rightprob[trial_i]*prob_m + prob_offset); //latent variable: number of flashes are estimated with gaussian noise
lflashes[trial_i] ~ normal(leftprob[trial_i], leftprob[trial_i]*prob_m + prob_offset);
latent_rprob[trial_i] ~ binomial(nTrials, tanh(rflashes[trial_i])); //noisy estimate of flashes maps onto latent estimate of probability
latent_lprob[trial_i] ~ binomial(nTrials, tanh(lflashes[trial_i]));
lclicks[trial_i] ~ normal(leftvol[trial_i], leftvol[trial_i]*vol_m + vol_offset);
rclicks[trial_i] ~ normal(rightvol[trial_i], rightvol[trial_i]*vol_m + vol_offset);
latent_rvol[trial_i] ~ binomial(nTrials, tanh(rclicks[trial_i]));
latent_lvol[trial_i] ~ binomial(nTrials, tanh(lclicks[trial_i]));
Rval[trial_i] <- exp(-(-log(latent_rprob[trial_i]))^alpha)*(latent_rvol[trial_i]^rho);
Lval[trial_i] <- exp(-(-log(latent_lprob[trial_i]))^alpha)*(latent_lvol[trial_i]^rho);
choices_01[trial_i] ~ bernoulli_logit(lambda*(Rval[trial_i]-Lval[trial_i]));
}
}"
Hope that helps,
Jonah
I am attempting to build a model describing economic choices. I would like to model noise in subjects' estimates of probability and value. It is known that people exhibit scalar variability, i.e. the standard deviation in their estimate of magnitude grows linearly with the magnitude. So, I would like to model the subjects' perception of reward amount/probability, accounting for the linear noise scaling. Something like this:perceived_rprob[trial_i] <- normal(rightprob[trial_i], rightprob[trial_i]*prob_m+prob_offset);
However, I get the following error: no matches for normal(real, real). Function normal not found. So I must be miscasting the variables? I have also tried the line below instead, but from what I can tell from this group and the documentation, the ~ increments the log posterior, and does not mean "drawn from." This throws an error that the dimension of the right side of the statement is 0.
perceived_rprob[trial_i] ~ normal(rightprob[trial_i], rightprob[trial_i]*prob_m+prob_offset);
I am using rstan; my code is below. I apologize if I am doing something super dumb, any help is very much appreciated. Thank you so much!!!
model_code <- "data {
int nTrials;
int choices[nTrials]; //values of 1 (chose left) or 2 (chose right)
real<lower=0, upper=1> leftprob[nTrials];
real<lower=0, upper=1> leftvol[nTrials]; //rewards are normalized by max reward
real<lower=0, upper=1> rightprob[nTrials];
real<lower=0, upper=1> rightvol[nTrials]; //rewards are normalized by max reward
}
transformed data {
// this executes once vs on each sample in the model block, so better to transform here and pay for the conditional once
int<lower=0,upper=1> choices_01[nTrials];
for (i in 1:nTrials){
choices_01[i] <- (choices[i]==2);
}
}
parameters {
real rho; //exponential of utility function
real alpha; //parameter for probability weighting function
real<lower=0> lambda; //softmax parameter
real<lower=0> prob_m; //slope of scalar variability relationship
real<lower=0> prob_offset; //offset of scalar variability relationship
real<lower=0> vol_m;
real<lower=0> vol_offset;
}
model {
real Rval[nTrials];
real Lval[nTrials];
real perceived_rprob[nTrials];
real perceived_lprob[nTrials];
real perceived_rvol[nTrials];
real perceived_lvol[nTrials];
rho ~ cauchy(0, 2.5);
for (trial_i in 1:nTrials) {
perceived_rprob[trial_i] <- normal(rightprob[trial_i], rightprob[trial_i]*prob_m+prob_offset);
perceived_lprob[trial_i] <- normal(leftprob[trial_i], leftprob[trial_i]*prob_m+prob_offset);
perceived_rvol[trial_i] <- normal(rightvol[trial_i], rightvol[trial_i]*vol_m+vol_offset);
perceived_lvol[trial_i] <- normal(leftvol[trial_i], leftvol[trial_i]*vol_m+vol_offset);
Rval <- exp(-(-log(perceived_rprob[trial_i]))^alpha)*(perceived_rvol[trial_i]^rho);
Lval <- exp(-(-log(perceived_lprob[trial_i]))^alpha)*(perceived_lvol[trial_i]^rho);
choices_01[trial_i] ~ bernoulli_logit(lambda*(Rval-Lval));
}
}"
I am attempting to build a model describing economic choices. I would like to model noise in subjects' estimates of probability and value. It is known that people exhibit scalar variability, i.e. the standard deviation in their estimate of magnitude grows linearly with the magnitude. So, I would like to model the subjects' perception of reward amount/probability, accounting for the linear noise scaling. Something like this:
perceived_rprob[trial_i] <- normal(rightprob[trial_i], rightprob[trial_i]*prob_m+prob_offset);
perceived_rprob[trial_i] <- normal(rightprob[trial_i], rightprob[trial_i]*prob_m+prob_offset);
perceived_lprob[trial_i] <- normal(leftprob[trial_i], leftprob[trial_i]*prob_m+prob_offset);
Are you suggesting that the perceived left/right probabilities (and volumes) on each trial should be model parameters? That would mean I would have to have 4x as many model parameters as I have data: for each trial, there would be 4 model parameters (left/right probabilities/volumes). Is that what you are suggesting? That seems insane to me. I don't grok it.
I know you said that the perception variances are supposed to vary in this way and I am in no way claiming that I am experienced in your field, but these kinds of conceptual conflicts are _huge_ red flags that almost always indicate that there’s tension between claims and the underlying statistics.Just to clarify, perception variances have been reported to vary in this way for potentially unbounded stimuli (e.g., estimation of stimulus intensity, time, magnitudes, etc.) These variances are not thought to apply to perception of probability. What is unique to my experiment is that I am using stimuli that cause this particular perception variance to convey probability to the subject. Anyway, not sure if that is helpful/useful at all, but it's a weird artifact of my experiment (I have my reasons, but we'll leave it there).
I think the first thing I will try is to unconstrain everything, as you suggest. On trials where p=1, I suppose I can set it to p=.999?
I think the first thing I will try is to unconstrain everything, as you suggest. On trials where p=1, I suppose I can set it to p=.999?This is the open question to which I do not have a great answer. Settingthose extremes to 0.999 might work okay but I couldn’t guarantee it. Youmight have to resort to a probabilistic model, for example with beta distributions.Anyone else have any ideas?