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

From   billy mairs <>
To   statalist <>
Subject   st: replacing values in panel data
Date   Wed, 27 Jul 2011 12:53:28 +0000

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:

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