Jack Needleman <[email protected]> :
Try replacing the mata function in -overid- with the version below
(and replace the top program name with overid2 then save as
overid2.ado), which avoids making any 2Nx2N matrices. [The authors of
-overid- may want to test my code against theirs to confirm it does
the same thing.]
mata:
void overidreg3(string scalar epss, ///
string scalar exog, ///
real scalar nbeta, ///
string scalar touse)
{
epssv = tokens(epss)
vepss = epssv[|1,.|]
evec = vec( st_data(., vepss, touse) )
exogv = tokens(exog)
vexog = exogv[|1,.|]
st_view(wmat,.,vexog,touse)
meat=invsym(quadcross(wmat,wmat))
zz=rank(meat)
sigma = st_matrix("__sigma")
isigma=invsym(sigma)
crit=0
for (i=1; i<=cols(vepss); i++) {
v1=vepss[i]
st_view(vv1,.,v1,touse)
for (j=1; j<=cols(vepss); j++) {
v2=vepss[j]
st_view(vv2,.,v2, touse)
crit=crit+isigma[i,j]*quadcross(vv1,wmat)*meat*quadcross(wmat,vv2)
}
}
nconstr = nbeta - rank(st_matrix("__V"))
df = rows(sigma) * zz - ( nbeta - nconstr)
chi2 = chi2tail(df, crit)
st_numscalar("crit",crit)
st_numscalar("df",df)
st_numscalar("chi2",chi2)
st_numscalar("nexog",zz)
st_numscalar("nconstr",nconstr)
}
end
On Thu, May 21, 2009 at 1:28 PM, Jack Needleman <[email protected]> wrote:
> Thanks to both Martin and Austin.
>
> To clarify, stata is up to date, so mata should be up to date
> overid is up to date.
> Austin suggests it is a memory problem because of the number of
> observations.
>
> I've set up a 400m space for Stata, and the data set has 7880 observations,
> and takes up about 600kb.
> It does look like overid wants to set up a matrix of 15760*15760, or two
> times^2 the number of observations.
>
> I agree that if I were running a two two equation recursive model like that
> I outlined, I should use ivreg2, but this was a test and my goal was to run
> a four equation model. Looks like I'll need to develop an alternative
> strategy to testing overidentification if the size of the matrix used by
> overid is (obs*number of equations)^2
>
> jack
>
> Austin Nichols wrote:
>>
>> Jack Needleman <[email protected]> :
>> It looks like -overid- wants to make a big matrix (15760x15760) that
>> your current memory settings preclude (help memory). You should
>> probably use -ivreg2- for this model, though, with appropriate SE
>> adjustments depending on your data structure.
>>
>> ssc inst ivreg2
>> ssc inst ranktest
>> ivreg2 mcs female age bach black hs (alcohol = liquornear bluelaw),
>> first robust
>>
>> More useful advice probably depends on more info on the research
>> question and data...
>>
>> On Thu, May 21, 2009 at 12:44 PM, Jack Needleman <[email protected]>
>> wrote:
>>
>>>
>>> I have downloaded the most recent version of overid from ssc, and am
>>> attempting to use it after reg3. A preliminary test using a two equation
>>> system results in the following message:
>>>
>>>
>>> . overid
>>> #: 3900 unable to allocate real <tmp>[15760,15760]
>>> overidreg3(): - function returned error
>>> <istmt>: - function returned error
>>>
>>> The reg3 command and output is:
>>>
>>> . reg3 (mcs alcohol female age bach black ) (alcohol female age bach
>>> black
>>> liquornear bluelaw hs)
>>>
>>> Three-stage least-squares regression
>>> ----------------------------------------------------------------------
>>> Equation Obs Parms RMSE "R-sq" chi2 P
>>> ----------------------------------------------------------------------
>>> mcs 7880 5 8.750366 0.3323 802.29 0.0000
>>> alcohol 7880 7 23.6458 0.0219 188.43 0.0000
>>> ----------------------------------------------------------------------
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> | Coef. Std. Err. z P>|z| [95% Conf.
>>> Interval]
>>>
>>> -------------+----------------------------------------------------------------
>>> mcs |
>>> alcohol | -.2995934 .0277023 -10.81 0.000 -.3538889
>>> -.2452979
>>> female | -3.301902 .1981787 -16.66 0.000 -3.690325
>>> -2.913479
>>> age | -.0266717 .0123345 -2.16 0.031 -.050847
>>> -.0024965
>>> bach | 4.190949 .2342934 17.89 0.000 3.731743
>>> 4.650156
>>> black | -2.273621 .2765272 -8.22 0.000 -2.815605
>>> -1.731638
>>> _cons | 63.05408 1.575275 40.03 0.000 59.9666
>>> 66.14156
>>>
>>> -------------+----------------------------------------------------------------
>>> alcohol |
>>> female | -.1236572 .5351798 -0.23 0.817 -1.17259
>>> .925276
>>> age | .0565479 .0330303 1.71 0.087 -.0081904
>>> .1212861
>>> bach | -1.090354 .6567427 -1.66 0.097 -2.377546
>>> .1968384
>>> black | -.017214 .746943 -0.02 0.982 -1.481195
>>> 1.446768
>>> liquornear | 6.901345 .5325147 12.96 0.000 5.857635
>>> 7.945054
>>> bluelaw | -.6087095 .5259382 -1.16 0.247 -1.639529
>>> .4221104
>>> hs | -2.713659 .6842939 -3.97 0.000 -4.05485
>>> -1.372468
>>> _cons | 50.64838 1.58318 31.99 0.000 47.5454
>>> 53.75136
>>>
>>> ------------------------------------------------------------------------------
>>> Endogenous variables: mcs alcohol
>>> Exogenous variables: female age bach black liquornear bluelaw hs
>>> -
>>>
>>> The intent is to instrument alcohol with liquornear and bluelaw.
>>>
>>> Any help would be appreciated.
>>>
>>> Jack Needleman
*
* 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/