smpl 1990 1998 scalar n = 9 scalar prior_odds = 1 ' Assign the prior odds in favour of Model 1 over Model 2 scalar w1 = 2.001 'In this, & the next 7, lines we provide the parameters for the prior scalar w2 = 2.001 ' w1 and w2 must exceed 2.0 to ensure the existence of the 2nd moment scalar c1 = 0.0122 scalar c2 = 0.0122 scalar a1 = 0.053 scalar a2 = 0.053 scalar bbar1 = -1 ' The mean of our prior for each price elasticity is -1 scalar bbar2 = -1 series y=log(qb) series x1=log(pb / ps) 'Here we have just 2 models one with X=spirits & one with X=marijuana series x2=log(pb / pm) 'Change "pm" to "pw" to get the BPO when X=spirits and X=wine series y=y-@mean(y) 'Take deviations about the sample mean to eliminate the intercept for !i=1 to 2 series x!i=x!i-@mean(x!i) 'Take deviations about the sample means for the X data equation eq!i.ls y x!i scalar bols!i=c(1) 'Compute the OLS (ML) estimators series resid2!i=(y-c(1)*x!i)^2 scalar ssq!i=@sum(resid2!i) / (n-1) series xsq!i=x!i*x!i scalar xx!i=@sum(xsq!i) series xy!i=x!i*y scalar x!iy=@sum(xy!i) series ysq=y*y scalar yy=@sum(ysq) scalar bayes!i=(a!i*bbar!i+x!iy) / (a!i+xx!i) 'Compute the natural conjugate Bayes estimators scalar npcsq!i=w!i*c!i^2+yy+(bbar!i^2*a!i)-bayes!i^2*(a!i+xx!i) scalar postvar!i=((npcsq!i^2)/(n+w!i-2))/(a!i+xx!i) scalar qa!i=a!i*(bbar!i-bayes!i)^2 scalar qb!i=xx!i*(bols!i-bayes!i)^2 scalar delta!i=((n-1)*ssq!i+qa!i+qb!i) / n scalar cdel!i=(c!i^2/delta!i) next scalar term1=@sqrt((a1/a2)*((a2+xx2) / (a1+xx1))) scalar term2=(delta1/delta2)^(-n/2) scalar term3= (cdel1/cdel2) scalar term4=@dfdist(cdel1,w1,n) / @dfdist(cdel2,w2,n) scalar bayesfactor=TERM1*TERM2*TERM3*TERM4 scalar bpo=prior_odds*bayesfactor ' BPO in favour of 1st model over 2nd model