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: RE: replacing values in panel data


From   Mauro Mastrogiacomo <M.Mastrogiacomo@cpb.nl>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: replacing values in panel data
Date   Wed, 27 Jul 2011 15:17:30 +0200

If I understand you correctly you want the first u of i=1 to be also the first u of all other i's.
If this is correct then type
bys i: gen position = _n
egen uu=max(u), by(position)
drop u position
rename uu u

ciao
mauro

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of billy mairs
Sent: woensdag 27 juli 2011 14:53
To: statalist
Subject: st: replacing values in panel data


Dear reader, 

I have a panel data set and wish to replace multiple values over the different cross sections.
 
Say the panel data is N=20 and T=5. I have 5 values for a standard normal error term 'u' (for every t) for my first panel, say i = 1. I want to copy these 5 values into the other cross section units, so that u is the same in the other 19 panels as it is in my first panel. Here is what I have come up with so far
 
clear all
set obs 20
gen i = _n
expand 5
sort i
by i: gen t=_n
tsset i t
gen x = rnormal()
gen u = rnormal() in 1/5
br
 
How would I then copy the values for u into the missing values so that at each t, u is the same across the panels?
I hope to then use the command
 
replace u = (0.5)*u + ((1-0.25)^0.5)*rnormal() if i>1
 
in order to create dependence in error terms across the panels. Thanks for your time 		 	   		  
*
*   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/

--
================================================================================
Dit bericht kan informatie bevatten die niet voor u is bestemd. Indien u niet
de geadresseerde bent of dit bericht abusievelijk aan u is toegezonden, wordt
u verzocht dat aan de afzender te melden en het bericht te verwijderen.
De Staat aanvaardt geen aansprakelijkheid voor schade, van welke aard ook, die
verband houdt met risico's verbonden aan het elektronisch verzenden van
berichten.

This message may contain information that is not intended for you. If you are
not the addressee or if this message was sent to you by mistake, you are
requested to inform the sender and delete the message. The State accepts no
liability for damage of any kind resulting from the risks inherent in the
electronic transmission of messages.
================================================================================

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index