Announcement

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

  • xtset with time variable and categorical variable

    Hi,
    Im trying to set up a long format data structure to use xtgee models. For each time variable (week) there are three tilt levels. The other variables eg sbp are measured at each tilt level for each assessment week.
    When I try to xtset with id week this is not allowed because of repeat weeks (one for each tilt level). I wish to assess time trends in measurements within id across weeks and assess changes within individuals based upon tilt.
    Clearly I have set up an incorrect structure for xtset or this is not possible?
    Here is an excerpt of the data structure

    id week tilt sbp
    1 20 10 119
    1 20 15 114
    1 20 0 117
    1 30 15 .
    1 30 0 121
    1 30 10 113
    2 20 0 .
    2 20 15 93
    2 20 10 106
    2 30 15 123
    2 30 0 123


    any advice would be greatly appreciated
    yours
    Richard Hiscock

  • #2
    It depends on what analyses you want to do. If you want to use time-series operators like lags and leads, or if you want to model autoregressive correlation structure, then you must have a panel variable that occurs in only one observation in any time period. Without that constraint, it isn't even possible to define things like lag and lead or autoregressive correlation. In your situation you could handle this with:
    Code:
    egen panel = group(id tilt)
    xtset panel week
    However, if you don't need to use time-series operators or autoregressive structure, then you don't have to specify a time variable in your -xtset- command anyway. You can just -xtset id- and proceed. -xtgee- will not care that no time variable has been specified.

    Comment


    • #3
      Clyde
      many thanks for the advice
      Richard

      Comment

      Working...
      X