Statalist


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

RE: st: re: What to do about multiple observations for one individual in one same period in a panel


From   kokootchke <[email protected]>
To   statalist <[email protected]>
Subject   RE: st: re: What to do about multiple observations for one individual in one same period in a panel
Date   Sun, 19 Jul 2009 15:27:01 -0400

Nick, Kit, Martin... thanks a lot for your suggestions. The only one that had occurred to me was the one that averages spreads (yes, Kit, I have yield spreads, not prices) and other variables by country whenever there are multiple bonds issued in a given time period... I was not a fan of this approach because I would "lose" observations... but then again, I don't know exactly how much I'm actually losing, if all my macro variables for each of those "repeated" observations in one same time period have the same value (different spread for each bond... but same GDP growth, debt/GDP, inflation, etc.).

Anyway, let me try these suggestions. Thanks a lot!

Adrian


----------------------------------------
> From: [email protected]
> To: [email protected]
> Subject: st: re: What to do about multiple observations for one individual in one same period in a panel
> Date: Sun, 19 Jul 2009 15:02:33 -0400
>
> <>
> Martin (yes, I doublechecked, this was Martin!) suggested
>
> Aggregate the two levels via -egen, group()-:
>
> I applaud Martin's efforts in answering questions, but a couple of
> issues with this one:
> (1) example code would be more useful if it runs when pasted in the do-
> file editor, which this does not
> (2) this solution does not really address the question, as it does not
> answer how the questioner can end up with panel data.
> This code modifies Martin's suggestions to implement my earlier
> suggestions:
> -----------------------
> clear*
> input country:mylabel /*
> */ str10 date, auto
> Argentina "1990:1"
> Argentina "1990:1"
> Argentina "1990:1"
> Argentina "1990:2"
> Argentina "1990:3"
> Argentina "1990:4"
> Argentina "1990:4"
> Argentina "1990:4"
> Argentina "1990:4"
> Argentina "1991:1"
> Argentina "1991:1"
> Argentina "2008:3"
> Argentina "2008:4"
> Argentina "2008:4"
> Brazil "1990:1"
> Brazil "1990:2"
> Brazil "1990:2"
> Brazil "1990:3"
> Brazil "1990:3"
> Brazil "1990:3"
> Brazil "1990:3"
> end
>
> gen date2 = quarterly(date, "YQ")
> format date2 %tq
> drop date
>
> // some fake data on amounts, yields, tenors
> gen amount = runiform()*1000 + 100
> gen yield = runiform()*5 + 4
> gen tenor = runiform()*2 + 8
> l, sepby(country date2)
>
> // get total issued by country-year
> bys country date2: gen tot = sum(amount)
> // get weights for each issue within country-year
> bys country date2: g weight = amount / tot[_N]
> // calc weighted average yield and tenor
> bys country date2: g wtyield = weight * yield
> bys country date2: g wttenor = weight * tenor
> collapse (count) nissue=amount (sum) amount ///
> wtyield wttenor, by(country date2)
> tsset country date2
> l, sepby(country)
> ------------------------------------------
> Kit
> Kit Baum | Boston College Economics & DIW Berlin | http://ideas.repec.org/e/pba1.html
> An Introduction to Stata Programming
> | http://www.stata-press.com/books/isp.html
> An Introduction to Modern Econometrics Using Stata | http://www.stata-press.com/books/imeus.html
>
>
>
> *
> * 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/

_________________________________________________________________
Windows Live™ Hotmail®: Celebrate the moment with your favorite sports pics. Check it out.
http://www.windowslive.com/Online/Hotmail/Campaign/QuickAdd?ocid=TXT_TAGLM_WL_QA_HM_sports_photos_072009&cat=sports
*
*   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/



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