Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: Re: st: sample splitting problem


From   dist@interfree.it
To   statalist@hsphsun2.harvard.edu
Subject   Re: Re: st: sample splitting problem
Date   21 Nov 2007 07:14:24 -0000

Thank you for you reply but it is not clear to me if your suggested procedure is a solution. The restore command gives me back an "error" (nothing to restore r(622);).  Besides, after posting my request I have also searched for a code. Do you (or someone else) think the following one is a way to solve my problem? 

> gen ratio = x/y
> egen m1=mean(ratio), by(id)
> egen medm1=median(m1)
> gen hi1=m1<medm1 if !mi(m1, medm1)

( uncertain if it should be: by(id) or by (firm) )

Please, help! Thank you in advance. 


-----------------------------------------------------------------------------
------------------------------------------------------------------------

>Probably the simplest thing is to collapse the dataset and then
>obtaining the median. Something like this (change the varnames where
>appropiate):
>
>preserve
>gen ratio = x/y
>collapse ratio, by(firm)
>su ratio, detail
>local threshold = r(p50)
>restore
>
>gen more_x = (x/y > `threshold')
>
>In the end, we restore the data and create a dummy variable that indicates 
>whether each firm has more of x or not (not having more of x
>is the same as having more of y).
>
>HTH,
>Sergio
>
>PS: I'm assuming your panel is in -long- format. If not, set it as long.
>
>On 21 Nov 2007 06:00:21 -0000,  <dist@interfree.it> wrote: > Dear all, here I'm 
>again for a new request of help. I would like to replicate a sample splitting 
>into my research. > Given an unbalanced panel (ts-cs data) and two variables, x 
>and y, the sample splitting criterion is the following: > a firm is identified 
>as having more "x" (high_x) if "x/y" is larger than the median accross firms of 
>the firms' time averages. Conversely, a firm is identified as having less "x" 
>(low_x) if "x/y" is less than (or equal to) the median accross firms of these 
>time averages. I would be grateful if someone can help me with the commands 
>(just an example to use for my dataset). >
>> Thank you very much.
>>
>>


----------------------------------------------------------------------------
DEXGATEMICRO il centralino VoIP multifunzione per l'azienda.
Prova gratuita per 4 utenti!


Scopri tutte le funzionalita' sul sito Dexgate.com
----------------------------------------------------------------------------

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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