Hello all,
I am using Stata 13.1 on Windows. This is my first time posting to Statalist, so please correct any foibles so that I can learn.
I am attempting to perform a random effects regression on time series data. My question is: the periodicity of my predictor is daily; whereas the periodicity of my outcome variable is weekly (and in some cases, monthly; for now we can set aside that complication). I know how to merge the two datasets together, but this will create an unbalanced panel, since I will only have data for my outcome variable once a week (or month). Therefore, I am concerned that xtreg will only consider the values of my predictor variables for the end-of-week (or month) day on which I happen to have outcome data, which is not appropriate. How can I fit a model which incorporates the information from my daily predictor to predict my weekly outcome?
I have a dataset with my predictor variable, which is an index score estimating the intensity of policymaking activity for each day of the COVID pandemic, by each national government, as follows:
So for this dataset, I would
However, my outcome variable is excess mortality p-scores, which has a weekly periodicity for most countries (monthly for others, but we can set aside that complication for now; if I need to, I will analyze weekly vs monthly groups of countries separately). It looks like this:
For this dataset alone, I would
Unfortunately, I did not create the daily indices I am using as a predictor, so I cannot remodel them as a weekly index to match my outcome variable. They are from Kubinec R, Barcel J, Goldszmidt R, et al. Statistically Validated Indices for COVID-19 Public Health Policies. SocArXiv. 2021;1–29.
I would appreciate any ideas. Perhaps I am misunderstanding how xtreg works, as I am new to panel data analysis.
Many thanks,
Sarah
I am using Stata 13.1 on Windows. This is my first time posting to Statalist, so please correct any foibles so that I can learn.
I am attempting to perform a random effects regression on time series data. My question is: the periodicity of my predictor is daily; whereas the periodicity of my outcome variable is weekly (and in some cases, monthly; for now we can set aside that complication). I know how to merge the two datasets together, but this will create an unbalanced panel, since I will only have data for my outcome variable once a week (or month). Therefore, I am concerned that xtreg will only consider the values of my predictor variables for the end-of-week (or month) day on which I happen to have outcome data, which is not appropriate. How can I fit a model which incorporates the information from my daily predictor to predict my weekly outcome?
I have a dataset with my predictor variable, which is an index score estimating the intensity of policymaking activity for each day of the COVID pandemic, by each national government, as follows:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str32 countrystr str21 modtype str10 date_policy double(med_est high_est low_est sd_est) float(date country iso3numeric) byte MARKER str3 iso3c float iso "Afghanistan" "Health Resources" "2020-01-01" 25.9722126250969 32.219066858511304 20.560525573413777 3.6037616464112268 21915 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-02" 25.9722126250969 32.219066858511304 20.560525573413777 3.6037616464112268 21916 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-03" 25.9722126250969 32.219066858511304 20.560525573413777 3.6037616464112268 21917 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-04" 25.9722126250969 32.219066858511304 20.560525573413777 3.6037616464112268 21918 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-05" 25.9722126250969 32.219066858511304 20.560525573413777 3.6037616464112268 21919 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-06" 26.144121945825823 31.377526554406607 21.348419229991727 3.173195354369845 21920 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-07" 26.144121945825823 31.377526554406607 21.348419229991727 3.173195354369845 21921 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-08" 25.921784478312304 31.188290700980847 21.581555803792725 2.8679207884199136 21922 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-09" 25.921784478312304 31.188290700980847 21.581555803792725 2.8679207884199136 21923 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-10" 25.921784478312304 31.188290700980847 21.581555803792725 2.8679207884199136 21924 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-11" 25.921784478312304 31.188290700980847 21.581555803792725 2.8679207884199136 21925 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-12" 25.921784478312304 31.188290700980847 21.581555803792725 2.8679207884199136 21926 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-13" 25.921784478312304 31.188290700980847 21.581555803792725 2.8679207884199136 21927 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-14" 25.921784478312304 31.188290700980847 21.581555803792725 2.8679207884199136 21928 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-15" 25.921784478312304 31.188290700980847 21.581555803792725 2.8679207884199136 21929 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-16" 25.918555992625684 30.90023253851845 21.76324567450482 2.809923064610894 21930 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-17" 25.930770616910387 30.644527200029547 21.708434657350082 2.7606465152938195 21931 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-18" 25.930770616910387 30.644527200029547 21.708434657350082 2.7606465152938195 21932 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-19" 25.930770616910387 30.644527200029547 21.708434657350082 2.7606465152938195 21933 1 4 1 "AFG" 1 "Afghanistan" "Health Resources" "2020-01-20" 25.895474535667418 30.630445381222174 21.60560935367298 2.7430899735147274 21934 1 4 1 "AFG" 1 end format %td date label values country country label def country 1 "Afghanistan", modify label values iso iso label def iso 1 "AFG", modify
Code:
xtset country date
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(p_scores_all_ages enddate month week timeunit country) str3 iso3c .47 21919 . 3120 2 6 "AUS" 1.33 21926 . 3121 2 6 "AUS" 2.05 21933 . 3122 2 6 "AUS" 7.06 21940 . 3123 2 6 "AUS" 2.91 21947 . 3124 2 6 "AUS" 3.71 21954 . 3125 2 6 "AUS" 6.68 21961 . 3126 2 6 "AUS" 5.7 21968 . 3127 2 6 "AUS" 8.37 21975 . 3128 2 6 "AUS" 3.54 21982 . 3129 2 6 "AUS" 4.89 21989 . 3130 2 6 "AUS" 7.64 21996 . 3131 2 6 "AUS" 10.62 22003 . 3132 2 6 "AUS" 13.51 22010 . 3133 2 6 "AUS" 8.79 22017 . 3134 2 6 "AUS" 4.02 22024 . 3135 2 6 "AUS" 5.84 22031 . 3136 2 6 "AUS" 2.3 22038 . 3137 2 6 "AUS" 3.51 22045 . 3138 2 6 "AUS" -.88 22052 . 3139 2 6 "AUS" end format %td enddate format %tm month format %tw week label values timeunit timeunit label def timeunit 2 "weekly", modify label values country country label def country 6 "Australia", modify
Code:
xtset country enddate, delta (7 days)
I would appreciate any ideas. Perhaps I am misunderstanding how xtreg works, as I am new to panel data analysis.
Many thanks,
Sarah
Comment