Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: RE: replacing values in panel data

From   Mauro Mastrogiacomo <>
To   "''" <>
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


-----Original Message-----
From: [] 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
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:

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

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:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index