I am trying to bootstrap a gmm estimator with generated explanatory variables defined by the following mata function
mata:
mata set matastrict on
void gmmrsk(string scalar yname, string scalar hname, string scalar xname)
{
real colvector y, r, coeff, c1, c2, c
real matrix h, x, b11, b12, b21, b22, b
real scalar samvar, lambda
y = st_data(.,yname)
h = st_data(.,tokens(hname))
x = st_data(., tokens(xname))
r = h[.,1] \ h[.,2]
samvar = variance(r)
lambda = 0.526/samvar
// construct matrices for parameter estimation
// pieces are constructed and put together
// coefficient estimated
b11 = h'h
b12 = x'x
b21 = lambda*(x'h)
b22 = x'x
c1 = h'y
c2 = x'y
c = c1 \ c2
b = (b11 , b12) \ (b21, b22)
coeff = luinv(b)*c
// return coefficient to stata to bootstrap standard errors
st_numscalar("b1",coeff[1,1])
st_numscalar("b2",coeff[2,1])
st_numscalar("b3",coeff[3,1])
st_numscalar("b4",coeff[4,1])
}
end
When it runs I get the error gmmrsk() already exists r(3000).
With stata programs I know you avoid this with the capture program drop prefix.
Is there an analogous mata prefix or am I doing something else wrong?
Thanks.
Carl Nelson
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/