I have a simple MLE estimation in Stata 14, which I want to move towards a Bayesian estimation using `bayesmh`.
MLE is quite easy then:
Now I want to move towards simple Bayesian analysis. For starters I wanted to try out the simplest possible version with flat priors:
By attempt so far:
Which gives me the error:
I suspect I need to specify the parameters passed on the mylikelihod somehow, but I'm not sure how.
Code:
program define mylikelihood args lnf Xb1 Xb2 qui replace `lnf' = ln(1-normal(`Xb1'))+ln(1-normal(`Xb2')) if $ML_y1==0 qui replace `lnf' = ln(normal(`Xb1'))+ln(1-normal(`Xb1'))+ln(1-normal(`Xb2')) if $ML_y1==1 & $ML_y2==0 qui replace `lnf' = ln(1-(1-normal(`Xb1')*normal(`Xb1'))*(1-normal(`Xb2'))) if $ML_y1==1 & $ML_y2==1 end
Code:
ml model lf mylikelihood (link=treatment x1 x2 x3 x4 x5) (bilink=treatment x5 x6 x7), /// vce(cluster clustvar)
By attempt so far:
Code:
bayesmh (link=treatment x1 x2 x3 x4 x5) (bilink=treatment x5 x6 x7) ,/// llevaluator(mylikelihood) /// prior({eco_link: treatment x1 x2 x3 x4 x5} {bilink: treatment x5 x6 x7},flat)
Code:
==0 invalid name mylikelihood could not be evaluated
Comment