Hello Statalist,
I am using a user-written program and estimating it with bayesmh evaluators in Stata 14. I am having the following issue. The program works fine up to 3 dependent variables in the regression; when I add a fourth variable, the program stops working and gives me the following error:
invalid bayesmh specification
Equation is misspecified:
variable rho not found
{p_end}
-- above applies to equation (rho)
The error seems odd given that I have added the new variable in exactly the same way as previous ones (tried and retired from scratch). The maximum likelihood estimator works fine when I run it outside the Bayesian setup. Here is the code I am using and that is troubling me (dropping the rho from everywhere in the code, it works just fine):
And here is an extract from the data I use:
Any help would be much appreciated!
Ferdinand
I am using a user-written program and estimating it with bayesmh evaluators in Stata 14. I am having the following issue. The program works fine up to 3 dependent variables in the regression; when I add a fourth variable, the program stops working and gives me the following error:
invalid bayesmh specification
Equation is misspecified:
variable rho not found
{p_end}
-- above applies to equation (rho)
The error seems odd given that I have added the new variable in exactly the same way as previous ones (tried and retired from scratch). The maximum likelihood estimator works fine when I run it outside the Bayesian setup. Here is the code I am using and that is troubling me (dropping the rho from everywhere in the code, it works just fine):
Code:
program pt_b args lnf rho alpha beta noise tempvar probhigh high_amount low_amount upper lower equivalent weighting_gains utility_high utility_low utility_prospect ce_calc diff_high diff_low lnfj quietly { generate double `probhigh' = probability generate double `high_amount' = high generate double `low_amount' = low generate double `upper' = max generate double `lower' = min generate double `utility_high' = (`high_amount')^`rho' generate double `utility_low' = (`low_amount')^`rho' generate double `weighting_gains' = exp(-`beta'*(-ln(`probhigh'))^`alpha') generate double `utility_prospect' = (`weighting_gains'*`utility_high') + ((1-`weighting_gains')*`utility_low') generate double `ce_calc' = `utility_prospect'^(1/`rho') generate double `diff_high' = (`upper' - `ce_calc')/(`noise'*(`high_amount' - `low_amount')) generate double `diff_low' = (`lower' - `ce_calc')/(`noise'*(`high_amount' - `low_amount')) generate double `lnfj' = ln(normal(`diff_high') - normal(`diff_low')) sum `lnfj', meanonly if r(N)< $MH_n{ scalar `lnf' = . exit } scalar `lnf' = r(sum) } end bayesmh (rho alpha beta noise = , llevaluator(pt_b)), prior({rho:}, flat) prior({alpha:}, igamma(2,1)) prior({beta:}, igamma(1,0.5)) prior({noise:}, beta(2,5))
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(probability high low max min) .5 5 0 2 1.5 .5 10 0 2 1.5 .5 20 0 2.5 2 .5 30 0 5.5 5 .5 30 10 10.5 10 .5 30 20 20.5 20 .125 20 0 2 1.5 .125 20 5 5.5 5 .25 20 0 2 1.5 .375 20 0 2 1.5 .625 20 0 2 1.5 .75 20 0 2.5 2 .875 20 0 3 2.5 .875 20 5 5.5 5 .5 5 0 2.5 2 .5 10 0 4 3.5 .5 20 0 7 6.5 .5 30 0 7.5 7 .5 30 10 14.5 14 .5 30 20 24.5 24 .125 20 0 2 1.5 .125 20 5 8 7.5 .25 20 0 3.5 3 .375 20 0 4.5 4 .625 20 0 6.5 6 .75 20 0 8.5 8 .875 20 0 14 13.5 .875 20 5 15 14.5 .5 5 0 3 2.5 .5 10 0 4.5 4 .5 20 0 7 6.5 .5 30 0 10.5 10 .5 30 10 10.5 10 .5 30 20 20.5 20 .125 20 0 4 3.5 .125 20 5 5.5 5 .25 20 0 4 3.5 .375 20 0 4 3.5 .625 20 0 5.5 5 .75 20 0 6.5 6 .875 20 0 7 6.5 .875 20 5 9 8.5 .5 5 0 1.5 1 .5 10 0 3 2.5 .5 20 0 5 4.5 .5 30 0 6 5.5 .5 30 10 17 16.5 .5 30 20 26 25.5 .125 20 0 1 .5 .125 20 5 7 6.5 .25 20 0 1 .5 .375 20 0 1 .5 .625 20 0 3 2.5 .75 20 0 6 5.5 .875 20 0 8.5 8 .875 20 5 15 14.5 .5 5 0 5 4.5 .5 10 0 10 9.5 .5 20 0 20 19.5 .5 30 0 23 22.5 .5 30 10 23 22.5 .5 30 20 30 29.5 .125 20 0 5.5 5 .125 20 5 11.5 11 .25 20 0 10 9.5 .375 20 0 10 9.5 .625 20 0 14.5 14 .75 20 0 20 19.5 .875 20 0 20 19.5 .875 20 5 20 19.5 .5 5 0 3 2.5 .5 10 0 7 6.5 .5 20 0 11 10.5 .5 30 0 15 14.5 .5 30 10 20 19.5 .5 30 20 25 24.5 .125 20 0 3 2.5 .125 20 5 7.5 7 .25 20 0 3 2.5 .375 20 0 5 4.5 .625 20 0 15 14.5 .75 20 0 17.5 17 .875 20 0 18 17.5 .875 20 5 20 19.5 .5 5 0 3.5 3 .5 10 0 5.5 5 .5 20 0 8.5 8 .5 30 0 10.5 10 .5 30 10 17.5 17 .5 30 20 24.5 24 .125 20 0 4.5 4 .125 20 5 7.5 7 .25 20 0 5.5 5 .375 20 0 5.5 5 .625 20 0 8 7.5 .75 20 0 8 7.5 .875 20 0 9.5 9 .875 20 5 11 10.5 .5 5 0 2 1.5 .5 10 0 3 2.5 end
Any help would be much appreciated!
Ferdinand