Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Mata: Calculating conditional expectation


From   Ivan Png <iplpng@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Mata: Calculating conditional expectation
Date   Tue, 23 Apr 2013 11:45:51 +0800

Many thanks to Statalist members for their previous help on
constructing the matrix.

To recall, my dependent variable is categorical: Mobility = 1 if
inventor changed employer, else = 0.  I'm investigating the effect of
classification error.  Obviously, this cannot be classical.  Let Y =
true mobility and Z = recorded mobility. If Y = 0 and Z = 1, then
error = -1, while if Y = 1 and Z = 0, error = +1.

Meyer and Mittag, U of Chicago (2012) characterize the bias as
N(X'X)^{-1} [ Pr( Y = 0 & Z = 1) E(X :  Y = 0 & Z = 1) - Pr(Y = 1 & Z
= 0) E(X :  Y = 1 & Z = 0) ].  I have a benchmark data set with both
the true and inaccurate mobility data, and would like to compute the
bias.

So, I need to compute the conditional expectations, E(X :  Y = 0 & Z =
1) and E(X :  Y = 1 & Z = 0), and then weight by the probabilities,
take the difference, and pre-multiply by N(X'X)^{-1}.  My idea:

. keep if Y = 0 & Z = 1
. mata : F = mean(X)
. mata : mata matsave filename

and repeat for Y = 1 & Z = 0.

But, sadly, I don't how to proceed.  How to combine the original data
with the two new files containing the conditional expectations, and
then going back to MATA to calculate the bias.  Grateful to
Statalisters for help.

-- 
Best wishes
Ivan Png
Skype: ipng00
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index