Originally posted by John Mullahy
View Post
Code:
. mata
------------------------------------------------- mata (type end to exit) ------------------------------------------------
: xn="x1 x2 x3 x4"
: yn="y1 y2 y3 y4"
: ic="if _n<=10000"
: bv=bvpmvp(yn,xn,ic,1,.0001,1)
equation athrho not found
stata(): 3598 Stata returned error
bvpmvp(): - function returned error
<istmt>: - function returned error
r(3598);
: end
The data generate code is as followings (also from John Mullahy (2016)):
Code:
set obs 100000
gen u=invnorm(uniform())
forvalues i=1(1)8 {
gen u`i'=invnorm(uniform())
gen x`i'=uniform()
}
gen y1s=.5+.5*x1-.5*x2+.5*x3-.5*x4+u+u1
gen y2s=-.5-.5*x1+.5*x2-.5*x3+.5*x4+.5*u+u2
gen y3s=.5+.5*x1+.5*x2-.5*x3-.5*x4+u+u3
gen y4s=-.5+.5*x1-.5*x2-.5*x3+.5*x4+.5*u+u4
gen y5s=.5+.5*x1-.5*x2+.5*x3-.5*x4+u+u5
gen y6s=-.5-.5*x1+.5*x2-.5*x3+.5*x4+.5*u+u6
gen y7s=.5+.5*x1+.5*x2-.5*x3-.5*x4+u+u7
gen y8s=-.5+.5*x1-.5*x2-.5*x3+.5*x4+.5*u+u8
forvalues i=1(1)8 {
gen y`i'=y`i's>0
}
gen y1o=y1
replace y1o=2 if (y1s>=1 & y1s<=2)
replace y1o=3 if (y1s>2)
gen y2o=y2
replace y2o=2 if (y2s>=1)
gen y3o=y3
gen y4o=y4
replace y4o=2 if (y4s>=1 & y4s<=2)
replace y4o=3 if (y4s>2)
gen tmpxb=.25*x5-.25*x6+.25*x7-.25*x8
gen y1as=.5+.5*x1-.5*x2+.5*x3-.5*x4+tmpxb+u+u1
gen y2as=-.5-.5*x1+.5*x2-.5*x3+.5*x4-tmpxb+.5*u+u2
gen y3as=.5+.5*x1+.5*x2-.5*x3-.5*x4+tmpxb+u+u3
gen y4as=-.5+.5*x1-.5*x2-.5*x3+.5*x4-tmpxb+.5*u+u4
gen y5as=.5+.5*x1-.5*x2+.5*x3-.5*x4+tmpxb+u+u5
gen y6as=-.5-.5*x1+.5*x2-.5*x3+.5*x4-tmpxb+.5*u+u6
gen y7as=.5+.5*x1+.5*x2-.5*x3-.5*x4+tmpxb+u+u7
gen y8as=-.5+.5*x1-.5*x2-.5*x3+.5*x4-tmpxb+.5*u+u8
forvalues i=1(1)8 {
gen y`i'a=y`i'as>0
}

Comment