Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Re: st: robust estimation SUREG,
From
Jorge Eduardo Pérez Pérez <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: Re: st: robust estimation SUREG,
Date
Sun, 29 May 2011 18:41:18 -0400
Very clever solution. It is not clear for me how to adjust the
standard errors in the final step though. Maybe someone else in the
list has ideas.
_______________________
Jorge Eduardo Pérez Pérez
On Sun, May 29, 2011 at 2:14 PM, [email protected]
<[email protected]> wrote:
> Dear M. Pérez,
>
> Thanks a lot for your prompt reply and your very helpful suggestions and the corresponding stata code!
> As you mentioned the rreg does not have any "hascons" option, which is critical as the constant
> of the first model is dropped (due to perfect multicollinearity). To circumvent this problem, I first of all
> performed a robust regression for each equation taken independently.
> Then I generated the weights in a matrix and used these weights in the final step.
> The adapted program is shown below (the parts I added are marked with an @ at the end).
>
> Regards,
>
> Pierrick Jan
>
> - -- Begin code ----
>
> sysuse auto, clear
> * Robust regression and weights generation @
> rreg price weight trunk, genwt (w1) @
> rreg length trunk, genwt (w2) @
> * Benchmark
> sureg (price weight trunk) (length trunk)
> est store sur
> * Obtain errors
> reg price weight trunk
> predict e1, resid
> reg length trunk
> predict e2, resid
> * Obtain covariance
> cor e1 e2, cov
> mat s = r(C)
> mat i = I(_N)
> mat v = s#i
> * Generating a weights vector*@
> mkmat w1, matrix (W1) @
> mkmat w2, matrix (W2) @
> matrix W = W1\W2 @
> * Stack dependent
> gen zero=0
> stack price weight trunk zero length zero zero trunk, into(y weight
> trunk trunk2) clear
> gen cons1 =(_stack==1)
> gen cons2 =(_stack==2)
> * Transform variables
> mkmat weight trunk cons1 trunk2 cons2, matrix(X)
> drop weight trunk cons1 trunk2 cons2
> matrix Xa=(cholesky(inv(v))'*X)
> svmat Xa, names(col)
> mkmat y
> drop y
> matrix ya=(cholesky(inv(v))'*y)
> svmat ya, names(col)
> * Introducing the weights of the robust regressions in the dataset @
> svmat W, names(wrreg) @
> reg y weight trunk cons1 trunk2 cons2, hascons
> * Which is same as SUR, se needs adjustment
> est replay sur
> * Now run robust instead, does not have nocons option. Would have to
> modify the call to -reg- in rreg.ado
> rreg y weight trunk cons1 trunk2 cons2
> * Alternative: perform a regression using the reg command and introduce the weights of the initial robust regressions @
> reg y weight trunk cons1 trunk2 cons2 [aweight = wrreg], hascons @
>
> - -- End code ----
> _______________________
>
> -----------------------------
>
> Date: Sat, 28 May 2011 14:19:49 -0400
> From: =?ISO-8859-1?Q?Jorge_Eduardo_P=E9rez_P=E9rez?= <[email protected]>
> Subject: Re: st: robust estimation SUREG
>
> A geometric mean might be more appropiate, so the final weight is zero
> if any of them is zero.
>
> An alternative is to run the SUR manually, stacking the variables,
> correcting for the error covariance and estimating with -reg- at the
> end. In this case, you could do the last step with -rreg- instead of
> - -reg-. -rreg- does not allow a -nocons- option, so you would have to
> modify its call to -reg-. See the code below.
>
> - -- Begin code ----
>
> sysuse auto, clear
> * Benchmark
> sureg (price weight trunk) (length trunk)
> est store sur
> * Obtain errors
> reg price weight trunk
> predict e1, resid
> reg length trunk
> predict e2, resid
> * Obtain covariance
> cor e1 e2, cov
> mat s = r(C)
> mat i = I(_N)
> mat v = s#i
> * Stack dependent
> gen zero=0
> stack price weight trunk zero length zero zero trunk, into(y weight
> trunk trunk2) clear
> gen cons1 =(_stack==1)
> gen cons2 =(_stack==2)
> * Transform variables
> mkmat weight trunk cons1 trunk2 cons2, matrix(X)
> drop weight trunk cons1 trunk2 cons2
> matrix Xa=(cholesky(inv(v))'*X)
> svmat Xa, names(col)
> mkmat y
> drop y
> matrix ya=(cholesky(inv(v))'*y)
> svmat ya, names(col)
> reg y weight trunk cons1 trunk2 cons2, hascons
> * Which is same as SUR, se needs adjustment
> est replay sur
> * Now run robust instead, does not have nocons option. Would have to
> modify the call to -reg- in rreg.ado
> rreg y weight trunk cons1 trunk2 cons2
>
> - -- End code ----
> _______________________
> Jorge Eduardo Pérez Pérez
>
>
>
>
> On Sat, May 28, 2011 at 9:27 AM, [email protected]
> <[email protected]> wrote:
>> Thanks a lot for your answer!! I have also tried to perform a SUREG by introducing
>> the three sets of weights generated by the rreg command but I realized that it was not
>> possible. As you mention I would have to combine them somehow. However it is for me
>> not clear how to combine them. An arithmetic average is definitely not appropriate. I was
>> wondering if it would not be more appropriate to proceed as described hereafter. In a first step,
>> on the basis of each robust regression performed, I determine outliers (i.e. observations under a
>> certain threshold in terms of weight height). In a second step I exclude these outliers from the data set
>> and then perform the SUR regression. I am however not really satisfied with this solution.
>>
>> Pierrick Jan
>> __________________________________________________________________________
>>
>> Date: Fri, 27 May 2011 12:47:38 -0400
>> From: =?ISO-8859-1?Q?Jorge_Eduardo_P=E9rez_P=E9rez?= <[email protected]>
>> Subject: Re: st: robust estimation SUREG
>>
>> You could use the -genwt- option in -rreg- to generate the weights
>> used in the robust regression, then use those weights in -sureg-. You
>> will have three sets of weights from your first three regressions, and
>> - -sureg- will only allow a set of weights, so you would have to combine
>> them somehow.
>> _______________________
>> Jorge Eduardo Pérez Pérez
>
> *
> * 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/
>
*
* 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/