Good morning
I am trying to solve an issue with a big dataset (unbalanced panel with several missing data).
The task is quite easy, but the dimension of the panel require an automated routine.
Briefly speaking, I need to calculate a moving average of a variable including 3 lags and the current value.
I find that the command
tssmooth ma movaverage = targetvariable, window(3 1)
works fine, since it manages very well the missing values but it has a drawback; it provides values for each year, including the first three ones.
However, I expect (need) three missing values at the beginning of each time series, since only in year 4 the average can be properly calculated.
Some Statalist posts suggest to use the
(L3.var + L2.var + L1.var + var)/4
strategy, but I guess that missing data create several problems here.
Is there a better strategy to manage the issue?
Thanks again as usual for your insightful comments
Simone
Related Posts with Moving average for panel data with missing values
Age/sex/education match 3 groups (Apoe4 Homozygote, Apoe4 Heterozygote, non carriers)Hi there, I'd like to age/sex/education match 3 groups (genetic status: Apoe4 Homozygote, Apoe4 het…
Generating a date sheet/calendar in StataHi I have to generate a date sheet/calendar (week wise preferably) which looks at the application o…
Converting week to dateHi there, I'm currently working on a data that consist of 'date of birth' and 'gestational age' in …
-tabplot- (SSC) ignoring scheme-specific subtitle size?Dear Nick, I use -tabplot- from SSC in version 2.7.2 NJC 30 June 2017 and wonder why -tabplot- ignor…
Reshape : , not allowedHi everyone! I have results of interviews (one person interviewed in each household). There is info…
Subscribe to:
Post Comments (Atom)
0 Response to Moving average for panel data with missing values
Post a Comment