Hi,
I have 2 data sets that I have merged. The linked data is yearly data, starting 1996 and the survey dataset is every 3- 4 years starting 1996 then 2000, 2003 ,2006 and so on. The merged data undoubtely has a lot of missing values due to the discrepency in the years the data is collected for and since it is an unbalanced panel. id is individual ID and t is time. I was adviced to use Moving averages (MA) to try and fill the missing values. I need some help here.
FIrst, I am not sure how many lags and leads to use. I am currently using 2 leads but no lags.
Second, how does one take MA for catergorical and binary variables?
I have tired to used ipolate for variables such as age and looked into mipolate as well , any methods recommendation would be appreciated.
Please see the example, of the data below. Thanks in advance.
clear
input double id float t byte c float(age phi_bin gh mh smokingstat)
700001 1996 0 20 0 62 92 1
700001 1997 0 . . . . .
700001 1998 0 . . . . .
700001 1999 0 . . . . .
700001 2000 0 . . . . .
700001 2001 0 . . . . .
700001 2002 0 . . . . .
700001 2003 0 . . . . .
700001 2004 0 . . . . .
700001 2005 0 . . . . .
700001 2006 0 . . . . .
700001 2007 0 . . . . .
700001 2008 0 . . . . .
700001 2009 0 . . . . .
700001 2010 0 . . . . .
700001 2011 0 . . . . .
700001 2012 0 . . . . .
700001 2013 0 . . . . .
700001 2014 0 . . . . .
700001 2015 0 . . . . .
700001 2016 0 . . . . .
700001 2017 0 . . . . .
700001 2018 0 . . . . .
700001 2019 0 . . . . .
700002 1997 0 . . . . .
700002 1998 0 . . . . .
700002 1999 0 . . . . .
700002 2001 0 . . . . .
700002 2002 0 . . . . .
700002 2003 0 29 1 82 88 2
700002 2004 0 . . . . .
700002 2005 0 . . . . .
700002 2006 0 33 1 77 88 1
700002 2007 0 . . . . .
700002 2008 0 . . . . .
700002 2009 0 36 1 90 84 1
700002 2010 0 . . . . .
700002 2011 0 . . . . .
700002 2012 0 . . . . .
700002 2013 0 . . . . .
700002 2014 0 . . . . .
700002 2015 0 42 1 100 92 1
700002 2016 0 . . . . .
700002 2017 0 . . . . .
700002 2018 0 46 1 97 100 1
700002 2019 0 . . . . .
700003 1996 0 21 0 82 80 1
700003 1997 0 . . . . .
700003 1998 0 . . . . .
700003 1999 0 . . . . .
700003 2000 0 25 0 77 84 2
700003 2001 0 . . . . .
700003 2002 0 . . . . .
700003 2003 0 28 0 82 68 1
700003 2004 0 . . . . .
700003 2005 0 . . . . .
700003 2011 0 . . . . .
700003 2012 0 . . . . .
700003 2013 0 . . . . .
700003 2014 0 . . . . .
700003 2015 0 . . . . .
700003 2016 0 . . . . .
700003 2017 0 . . . . .
700003 2018 0 . . . . .
700003 2019 0 . . . . .
700004 1996 0 21 0 82 84 1
700004 1997 0 . . . . .
700004 1998 0 . . . . .
700004 1999 0 . . . . .
700004 2000 0 25 0 82 72 1
700004 2001 0 . . . . .
700004 2002 0 . . . . .
700004 2003 0 . . . . .
700004 2004 0 . . . . .
700004 2005 0 . . . . .
700004 2006 0 31 0 62 64 1
700004 2007 0 . . . . .
700004 2008 0 . . . . .
700004 2009 0 . . . . .
700004 2010 0 . . . . .
700004 2011 0 . . . . .
700004 2012 0 . . . . .
700004 2013 0 . . . . .
700004 2014 0 . . . . .
700004 2015 0 40 1 42 56 1
700004 2017 0 . . . . .
700004 2018 0 . . . . .
700004 2019 0 . . . . .
700005 1996 0 21 0 52 92 5
700005 1997 0 . . . . .
700005 1998 0 . . . . .
700005 1999 0 . . . . .
700005 2000 0 25 0 50 92 4
700005 2001 0 . . . . .
700005 2002 0 . . . . .
700005 2003 0 . . . . .
700005 2004 0 . . . . .
700005 2005 0 . . . . .
700005 2006 0 . . . . .
700005 2007 0 . . . . .
end
label values smokingstat smoke1
label def smoke1 1 "Never smoked", modify
label def smoke1 2 "Ex-smoker", modify
label def smoke1 4 "Smoke 10-19 day", modify
label def smoke1 5 "Smoke >=20 day", modify
[/CODE]
Related Posts with Moving Averages Unbalanced Panel data
weird characters of ChineseI have used the following codes to translate the Chiense characters in my dataset (attached). But it…
Pre and post policy countHI, So I have panel data for 5 years (4,5,6,7,8) and I am evaluating a policy change that happened …
create a table with mean sd and t-test ==0I would like to create a table with the variables as columns and the mean, the standard deviation an…
How do I graph a parameter t distributionDear Statalisters, I have a regression coefficient x2=.2227885 with a SE=.056563 and a 95% Conf. In…
one year entry for each variableDear all, I'm having a problem with the shape of my data. It is formatted as follows: YEAR id1 i…
Subscribe to:
Post Comments (Atom)
0 Response to Moving Averages Unbalanced Panel data
Post a Comment