# Re: st:how to match created matrix to the original data set

 From Tirthankar Chakravarty To statalist@hsphsun2.harvard.edu Subject Re: st:how to match created matrix to the original data set Date Tue, 18 Aug 2009 19:47:21 +0100

```<>

The last part can be done this way:
********************************
mat define A=(2,2,2,2,2,2,2,2,2 \/*
*/2,2,2,2,2,2,2,2,2 \/*
*/2,2,2,2,2,2,2,2,2)
mat list A
mat A = (A, J(rowsof(A), 1, 1))
mat list A
********************************

T
On Tue, Aug 18, 2009 at 7:39 PM, Mandy fu<mandy.fu1@gmail.com> wrote:
> Hi all,
>
> It would be great if you could give me some suggestion on the
> following question about matrix operation for a survey data set. It is
> like, based on  a data set, I create matrix. Then I  convert the
> matrix into variables and want to add the new  variables into the
> original data set. The problem is that I am not sure how to make sure
> the ID number matches during the last step.
>
> The data set includes respondents of  male (2517 obs)and female(2480
> obs).First I run  earnings function for male and female separately.
> Then I want to do a t test for comparing the group mean of (sum of
> Xfemale*B'male ) and (sum of X'female *B'female). The former means the
> earnings of a female when she is treated the same as a male with
> identical endowment in labor market. The  latter means the predicted
> value of how much a female earns.,
>
> where Bmale:   the coefficients get for a regression for each male
>          Bfemale: the coefficients get for a regression for each female
>          Xmale:    the original values of independent variables for each male
>          Xfemale: the original values of independent variables for each female
>
> From matrix calculation, I have get two matrices( each has 2480 rows
> and 1 column ) that each row presents each female in the data set. But
> in order to do the t-test , I need to take the probability weight into
> consideration.
>
> I am thinking maybe I could use one of the following way  to do this:
> (1) During matrix calculation, I include the probability weight as an
> additional column. So, I can do the t-test without coming back to the
> original data set.
> (2)After matrix calculation, I convert the results into variables for
> each female and add the new variables to the original data set. Then
> do the t test in the original data set.
>
> As to (2),  I am not sure using --svmat--how to make sure the new
> variables converted from matrices match to the ID numbers in the original
> data set(each matrix is only for female, but the data set includes
> male and female). I am not sure how to match them.
> --------------------
> By the way, I was wondering if anyone could help me with a quick
> question: how to add a column which contains constant number 1 to an
> existent matrix? Let's say. matrix B is [m,n]. I was wondering how to
> create a new matrix or replace B with a matrix [m,n+1], with the last
> column is constant 1.
>
> If there is anything I need to clarify, please let me know. Thanks for
>
>
> Mandy
> *
> *   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/
>

--
To every ω-consistent recursive class κ of formulae there correspond
recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
belongs to Flg(κ) (where v is the free variable of r).

*
*   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/
```