ch12.6.do open
file:script:do
| # | content |
|---|---|
| 1 [+] | * ITSP 12.6 - |
| 3 [+] | type meanvar.ado |
| 5 [+] | /* capture program drop meanvar program meanvar version 10.1 args lnf mu1 mu2 sigma1 sigma2 qui replace `lnf' = ln(normalden($ML_y1, `mu1', `sigma1')) /// if $disease == 0 qui replace `lnf' = ln(normalden($ML_y1, `mu2', `sigma2')) /// if $disease == 1 end */ |
| 17 [+] | sysuse auto , |
| 18 [+] | global subsample foreign |
| 19 [+] | ml model lf meanvar (mu1: price = ) (mu2: price = ) /sigma1 /sigma2 |
| 20 [+] | ml maximize , |
| 21 [+] | estimates store unconstr |
| 24 [+] | nlcom ([sigma1]_b[_cons] - [sigma2]_b[_cons]) / /// ([sigma1]_b[_cons] + [sigma2]_b[_cons]) |
| 26 [+] | nlcom 2*_pi*sqrt(3) * (([mu1]_b[_cons] - [mu2]_b[_cons]) / /// ([sigma1]_b[_cons] + [sigma2]_b[_cons])) |
| 29 [+] | constraint 1 [sigma1]_cons = [sigma2]_cons |
| 30 [+] | ml model lf meanvar (mu1: price = ) (mu2: price = ) /sigma1 /sigma2 , /// constraints(1) |
| 32 [+] | ml maximize , |
| 33 [+] | estimates store constr |
| 34 [+] | nlcom 2*_pi*sqrt(3) * (([mu1]_b[_cons] - [mu2]_b[_cons]) / /// ([sigma1]_b[_cons] + [sigma2]_b[_cons])) |
| 37 [+] | lrtest unconstr constr |
| 39 [+] | type onespell_part1.txt |
| 41 [+] | type onespell_part2.txt |
* ITSP 12.6 -
type meanvar.ado
/*
capture program drop meanvar
program meanvar
version 10.1
args lnf mu1 mu2 sigma1 sigma2
qui replace `lnf' = ln(normalden($ML_y1, `mu1', `sigma1')) ///
if $disease == 0
qui replace `lnf' = ln(normalden($ML_y1, `mu2', `sigma2')) ///
if $disease == 1
end
*/
sysuse auto, clear
global subsample foreign
ml model lf meanvar (mu1: price = ) (mu2: price = ) /sigma1 /sigma2
ml maximize, nolog
estimates store unconstr
nlcom ([sigma1]_b[_cons] - [sigma2]_b[_cons]) / ///
([sigma1]_b[_cons] + [sigma2]_b[_cons])
nlcom 2*_pi*sqrt(3) * (([mu1]_b[_cons] - [mu2]_b[_cons]) / ///
([sigma1]_b[_cons] + [sigma2]_b[_cons]))
constraint 1 [sigma1]_cons = [sigma2]_cons
ml model lf meanvar (mu1: price = ) (mu2: price = ) /sigma1 /sigma2, ///
constraints(1)
ml maximize, nolog
estimates store constr
nlcom 2*_pi*sqrt(3) * (([mu1]_b[_cons] - [mu2]_b[_cons]) / ///
([sigma1]_b[_cons] + [sigma2]_b[_cons]))
lrtest unconstr constr
type onespell_part1.txt
type onespell_part2.txt