Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Testing for autocorrelation: dataset with two time variables ?

    Greetings,

    I'm running Stata 14 with Time Series data from the American National Election Studies 2016 survey. I'd like to test an OLS regression model for autocorrelation. What confuses me is that there are two time variables which store the respondent interview dates--one for the first wave of the survey (Sept-Nov 2016) and one for the second (Nov 2016-January 2017). I know that I have to use xtset to define the data as a time series, but the syntax I've seen here specifies the use of a single time variable. Do I need to combine the two time variables into one? Or how should I approach this?

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str8 V164002 str31 V165002
    "20161011" "20161208"                      
    "20161024" "20161128"                      
    "20161023" "20161112"                      
    "20161022" "20161116"                      
    "20160928" "20161130"                      
    "20160920" "20161212"                      
    "20161031" "20161204"                      
    "20161024" "20161123"                      
    "20161101" "20161117"                      
    "20160927" "20161206"                      
    "20161015" "-6. No post-election interview"
    "20161016" "-6. No post-election interview"
    "20160913" "20161115"                      
    "20160909" "20161115"                      
    "20160909" "20161112"                      
    "20160923" "20161130"                      
    "20160923" "20161209"                      
    "20161026" "20161116"                      
    "20161103" "20161128"                      
    "20160908" "20161115"                      
    "20161029" "20161209"                      
    "20160915" "20170108"                      
    "20161003" "20161129"                      
    "20160912" "20161207"                      
    "20161016" "20161119"                      
    "20161009" "20161211"                      
    "20161101" "20161217"                      
    "20160910" "20161119"                      
    "20160917" "20161115"                      
    "20161030" "20161118"                      
    "20161022" "20161123"                      
    "20160916" "-6. No post-election interview"
    "20160909" "20161118"                      
    "20160912" "20161122"                      
    "20160908" "20161116"                      
    "20161023" "20161119"                      
    "20161004" "-6. No post-election interview"
    "20160922" "20161218"                      
    "20160923" "20161118"                      
    "20160927" "20161207"                      
    "20161104" "20161122"                      
    "20161014" "20161121"                      
    "20161008" "20161217"                      
    "20161025" "20161122"                      
    "20160923" "20161115"                      
    "20160915" "20161122"                      
    "20161006" "20161205"                      
    "20161106" "20161116"                      
    "20160910" "20161214"                      
    "20161105" "-6. No post-election interview"
    "20160914" "-6. No post-election interview"
    "20161018" "20161121"                      
    "20161026" "-6. No post-election interview"
    "20160912" "20161227"                      
    "20160921" "20161120"                      
    "20161104" "20161230"                      
    "20160914" "20161213"                      
    "20160912" "20161122"                      
    "20161023" "20161126"                      
    "20160914" "20161212"                      
    "20161010" "20161230"                      
    "20160909" "20161111"                      
    "20160924" "20161117"                      
    "20160908" "20161130"                      
    "20161004" "-6. No post-election interview"
    "20161010" "-6. No post-election interview"
    "20161106" "20161121"                      
    "20161023" "20161205"                      
    "20161021" "20161110"                      
    "20160917" "20161119"                      
    "20160912" "20161116"                      
    "20160913" "20161128"                      
    "20161025" "20161121"                      
    "20161022" "20161117"                      
    "20161019" "20161116"                      
    "20160916" "20161118"                      
    "20160917" "20161126"                      
    "20161015" "20161205"                      
    "20160909" "20161114"                      
    "20161021" "20161229"                      
    "20160912" "-6. No post-election interview"
    "20160914" "20161115"                      
    "20160920" "20161219"                      
    "20160926" "20161123"                      
    "20161024" "20161121"                      
    "20160909" "20161206"                      
    "20160927" "20161202"                      
    "20160924" "20161112"                      
    "20161030" "20161121"                      
    "20160922" "-6. No post-election interview"
    "20160911" "-6. No post-election interview"
    "20161103" "20161119"                      
    "20161018" "-6. No post-election interview"
    "20160926" "20161121"                      
    "20161002" "20161210"                      
    "20161016" "20161129"                      
    "20161107" "-6. No post-election interview"
    "20161010" "-6. No post-election interview"
    "20161005" "20161207"                      
    "20161102" "20161207"                      
    end

    Thanks!

  • #2
    You are right that Stata only takes one variable to define the time, so yes, you will need to change the structure of the data to accommodate that, probably through the use of -reshape-.

    Comment

    Working...
    X