Announcement

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

  • Time interval

    hello,

    I am working with a panel data in which a year is divided to 13 of four-weekly periods, can you tell me how should i define my date variable in order to be understood this four-weekly periods by stata?

    Thanks

  • #2
    There is no single answer to this question. It depends on how you plan to analyze the data, and interpret your analyses after that. Among the possibilities:

    1. Create two variables, one identifying the start date, and the other the end date of the four week period.
    2. Just use the start date, or just use the end date.
    3. Use the mid-point of the four week interval.

    If you are asking about Stata code to implement one of these suggestions, that, too, has many possible answers. This time, it depends on what the date information you already have looks like. So to get an answer to this one, you need to post an example of your data. Please install (-ssc install dataex-) the -dataex- command if you have not already done so, and use it (-help dataex- for instructions) to create a code block on this forum that enables those who would help you to easily and faithfully replicate your situation.

    Comment


    • #3
      Thanks, I installed it. my data is like below. just before that two more questions:

      1) for the second and third choice, does stata recognize it as a four-week period or just one day to next one day?

      2) for the first choice, then for analyzing and setting the panel data i should use both start and end date for xtset?



      my data is like below

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input int id str19 date float weekly str30 MARQUE double Adsawareness
       55 "May 21, 2007"       17307 "ARVIE"           2.41
       55 "June 18, 2007"      17335 "ARVIE"           4.23
       55 "July 16, 2007"      17363 "ARVIE"           3.41
       55 "August 13, 2007"    17391 "ARVIE"           5.04
       55 "September 10, 2007" 17419 "ARVIE"           5.06
       55 "October 8, 2007"    17447 "ARVIE"           4.92
       55 "November 5, 2007"   17475 "ARVIE"           5.18
       55 "December 3, 2007"   17503 "ARVIE"           3.28
       55 "December 31, 2007"  17531 "ARVIE"           4.22
       55 "January 28, 2008"   17559 "ARVIE"           4.75
       55 "February 25, 2008"  17587 "ARVIE"           3.92
       55 "March 24, 2008"     17615 "ARVIE"           3.53
       55 "April 21, 2008"     17643 "ARVIE"           2.84
       55 "May 19, 2008"       17671 "ARVIE"           2.83
       55 "June 16, 2008"      17699 "ARVIE"           5.53
       55 "July 14, 2008"      17727 "ARVIE"           4.86
       55 "August 11, 2008"    17755 "ARVIE"           3.71
       55 "September 8, 2008"  17783 "ARVIE"              4
       55 "October 6, 2008"    17811 "ARVIE"           4.64
       55 "November 3, 2008"   17839 "ARVIE"           3.65
       55 "December 1, 2008"   17867 "ARVIE"           5.45
       55 "December 29, 2008"  17895 "ARVIE"           2.89
       55 "January 26, 2009"   17923 "ARVIE"           4.99
       55 "February 23, 2009"  17951 "ARVIE"            3.9
       55 "March 23, 2009"     17979 "ARVIE"           2.83
       55 "April 20, 2009"     18007 "ARVIE"           1.93
       55 "May 18, 2009"       18035 "ARVIE"           3.77
       55 "June 15, 2009"      18063 "ARVIE"           1.72
       55 "July 13, 2009"      18091 "ARVIE"           5.53
       55 "August 10, 2009"    18119 "ARVIE"           2.15
       55 "September 7, 2009"  18147 "ARVIE"           3.03
       55 "October 5, 2009"    18175 "ARVIE"           2.49
       55 "November 2, 2009"   18203 "ARVIE"            5.2
       55 "November 30, 2009"  18231 "ARVIE"             .4
       55 "January 4, 2010"    18266 "ARVIE"           3.04
       55 "February 1, 2010"   18294 "ARVIE"           4.34
       55 "March 1, 2010"      18322 "ARVIE"           2.59
       55 "March 29, 2010"     18350 "ARVIE"           3.73
       55 "April 26, 2010"     18378 "ARVIE"           3.73
       55 "May 24, 2010"       18406 "ARVIE"           3.73
       55 "June 21, 2010"      18434 "ARVIE"           3.73
      114 "May 21, 2007"       17307 "Autres Marques"   .97
      114 "June 18, 2007"      17335 "Autres Marques"  2.46
      114 "July 16, 2007"      17363 "Autres Marques"  2.15
      114 "August 13, 2007"    17391 "Autres Marques"  1.41
      114 "September 10, 2007" 17419 "Autres Marques"  1.79
      114 "October 8, 2007"    17447 "Autres Marques"  2.22
      114 "November 5, 2007"   17475 "Autres Marques"  3.12
      114 "December 3, 2007"   17503 "Autres Marques"  2.19
      114 "December 31, 2007"  17531 "Autres Marques"  5.54
      114 "January 28, 2008"   17559 "Autres Marques"  4.37
      114 "February 25, 2008"  17587 "Autres Marques"  2.58
      114 "March 24, 2008"     17615 "Autres Marques"  4.59
      114 "April 21, 2008"     17643 "Autres Marques"  3.29
      114 "May 19, 2008"       17671 "Autres Marques"  2.18
      114 "June 16, 2008"      17699 "Autres Marques"  5.66
      114 "July 14, 2008"      17727 "Autres Marques"  2.24
      114 "August 11, 2008"    17755 "Autres Marques"  4.61
      114 "September 8, 2008"  17783 "Autres Marques"  2.75
      114 "October 6, 2008"    17811 "Autres Marques"  2.93
      114 "November 3, 2008"   17839 "Autres Marques"  3.65
      114 "December 1, 2008"   17867 "Autres Marques"  4.28
      114 "December 29, 2008"  17895 "Autres Marques"  5.64
      114 "January 26, 2009"   17923 "Autres Marques"  4.64
      114 "February 23, 2009"  17951 "Autres Marques"  3.76
      114 "March 23, 2009"     17979 "Autres Marques"  5.25
      114 "April 20, 2009"     18007 "Autres Marques"  5.57
      114 "May 18, 2009"       18035 "Autres Marques"  4.19
      114 "June 15, 2009"      18063 "Autres Marques"  3.39
      114 "July 13, 2009"      18091 "Autres Marques"  4.54
      114 "August 10, 2009"    18119 "Autres Marques"  4.65
      114 "September 7, 2009"  18147 "Autres Marques"  3.05
      114 "October 5, 2009"    18175 "Autres Marques"  6.76
      114 "November 2, 2009"   18203 "Autres Marques"  3.47
      114 "November 30, 2009"  18231 "Autres Marques"  6.17
      114 "January 4, 2010"    18266 "Autres Marques"  4.77
      114 "February 1, 2010"   18294 "Autres Marques"   4.8
      114 "March 1, 2010"      18322 "Autres Marques"  2.82
      114 "March 29, 2010"     18350 "Autres Marques"   5.1
      114 "April 26, 2010"     18378 "Autres Marques"   3.4
      114 "May 24, 2010"       18406 "Autres Marques"  3.37
      114 "June 21, 2010"      18434 "Autres Marques"  3.89
      173 "May 21, 2007"       17307 "BADOIT ROUGE"   15.75
      173 "June 18, 2007"      17335 "BADOIT ROUGE"   26.07
      173 "July 16, 2007"      17363 "BADOIT ROUGE"   18.92
      173 "August 13, 2007"    17391 "BADOIT ROUGE"   21.02
      173 "September 10, 2007" 17419 "BADOIT ROUGE"   16.51
      173 "October 8, 2007"    17447 "BADOIT ROUGE"    18.8
      173 "November 5, 2007"   17475 "BADOIT ROUGE"   14.34
      173 "December 3, 2007"   17503 "BADOIT ROUGE"   11.39
      173 "December 31, 2007"  17531 "BADOIT ROUGE"   17.33
      173 "January 28, 2008"   17559 "BADOIT ROUGE"   10.68
      173 "February 25, 2008"  17587 "BADOIT ROUGE"   16.88
      173 "March 24, 2008"     17615 "BADOIT ROUGE"   19.92
      173 "April 21, 2008"     17643 "BADOIT ROUGE"   14.56
      173 "May 19, 2008"       17671 "BADOIT ROUGE"   13.76
      173 "June 16, 2008"      17699 "BADOIT ROUGE"   17.47
      173 "July 14, 2008"      17727 "BADOIT ROUGE"   20.28
      173 "August 11, 2008"    17755 "BADOIT ROUGE"   17.78
      173 "September 8, 2008"  17783 "BADOIT ROUGE"   16.74
      end
      format %td weekly

      Comment


      • #4
        Well, this is a bit complicated because your data are not as regular as you describe. My first instinct was to suggest -xtset id weekly, delta(28 days)-. But not all of your intervals are exactly 28 days. Evidently for both id 55 and id 114, we have November 30, 2009 followed by January 4, 2010, which is a 35 day (5 week) gap.

        What you need to do at this point really depends in detail on what your analytic plans for this data are. If you do not plan on analyses that rely on the lag and lead or difference operators, and won't be using models with auto-regressive structure, then you can just -xtset id- and be done with it. But if you need to avail yourself of lag and lead operators, or auto-regressive modeling, then you have to decide whether you can live with the fact that some of these intervals are not actually the same as the rest. If you can live with that, that is, if you are content to say that 30Nov2009 to 4Jan2010 can be treated in all my analyses just if it really were a 4 week interval, then I would handle this by assigning sequence numbers:

        Code:
        by id (weekly): gen int seq = _n
        xtset id seq
        In this approach, all the intervals are treated equally for analysis purposes, even though on the calendar they are not all exactly equal. In this approach Stata neither knows nor cares that the usual interval is 28 days. And this approach can be characterized as flexible (or, you could also characterize it as dangerous) because it accommodates both 4 and 5 week intervals (but would also accept a 1 day interval or a 5 year interval).


        If you can't live with that, then you may have to exclude those irregular intervals from your analyses. You can go ahead and -xtset id weekly, delta(28 days)-, but then these anomalous 35 day intervals will turn up missing values whenever you use the lag or lead operators. The advantage of this approach is that Stata will actually recognize these as four week intervals, at the cost of excluding the ones that aren't literally that.

        Those are your options as I see them. Ultimately this is a choice you must make based on your understanding of how the exact timing plays into your research questions and your approach to answering them. As I know nothing of your context and goals, I can't advise. But this appears to be some kind of marketing study, which is way out of my area of expertise (epidemiology), so even if I knew them, my advice might not be worth much.

        Comment


        • #5
          Thanks a lot Clyde, i really appreciate your very helpful answer. You are right i am in marketing and I think i can go ahead with delta(28 days). thanks again

          Comment

          Working...
          X