Hello,

I have a panel data (N=820, obervations=8,395) of a dynamic population i.e. there is no fixed start/ end date for patients to enroll in an intervention. In addition, the number of follow-ups per patient is not the same and the repeated measures per patient (and within patients) recorded are unequally spaced. For example:
  • Patient A enrolled in an intervention on Jan 1, 2015 and dropped April 1, 2016, had 10 follow-up visits by the doctor and the average number of days between two visits in 28days.
  • Patient B also enrolled in an intervention on Jan 1, 2015 and dropped April 1, 2016, had 15 follow-up visits and the average number of days between two visits in 21days.
  • Patient C enrolled in an intervention on Sept 1, 2015 and dropped March 1, 2016, had 6 follow-up visits and the average number of days between two visits in 35days.
During each follow-up visit, patient's blood glucose was measured. Below is the sample data. Here variables patientid and id correspond to unique patient; visit is number of follow-up visits a patient had; dov is date of each visit which is %td formatted.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str22 patientid float(id visit endfbs dov)
"10-986"  1 1   . 20280
"10-986"  1 2   .     .
"10-986"  1 3 132     .
"10-986"  1 4 179     .
"10-986"  1 5 137     .
"10-986"  1 6 132     .
"10-986"  1 7 126     .
"11-1050" 2 1   . 20314
"11-1050" 2 2   .     .
"11-1050" 2 3 105     .
"11-1050" 2 4 110     .
"2-128"   3 1   . 20164
"2-128"   3 2 120     .
"2-128"   3 3 130     .
"2-128"   3 4 110     .
"2-128"   3 5 110     .
"2-128"   3 6 118     .
"2-128"   3 7 118     .
"2-128"   3 8 145     .
"2-138"   4 1   . 20166
end
format %td dov
Main Question: I want to run a linear mixed model to measure the mean change in blood glucose over time for all patients enrolled in the intervention. On using xtset, STATA shows that I have an unbalanced panel. How should I proceed with my analysis?

Code:
xtset id dov, daily
       panel variable:  id (unbalanced)
        time variable:  dov, 17mar2015 to 15mar2017
                delta:  1 day

. 
end of do-file

. xtdescribe

      id:  1, 2, ..., 820                                    n =        820
     dov:  17mar2015, 19mar2015, ..., 15mar2017              T =        399
           Delta(dov) = 1 day
           Span(dov)  = 730 periods
           (id*dov does not uniquely identify observations)

Distribution of T_i:   min      5%     25%       50%       75%     95%     max
                         3       3       4         7        13      29      41

     Freq.  Percent    Cum. |  Pattern*
 ---------------------------+------------------------------------------------------------------------------------
> -----------------------
       35      4.27    4.27 |  ......................................1...........................................
> .......................
       28      3.41    7.68 |  ....................................1.............................................
> .......................
       23      2.80   10.49 |  .....................................1............................................
> .......................
       23      2.80   13.29 |  ...................................1..............................................
> .......................
       23      2.80   16.10 |  ......................1...........................................................
> .......................
       19      2.32   18.41 |  ............................1.....................................................
> .......................
       18      2.20   20.61 |  .............................1....................................................
> .......................
       16      1.95   22.56 |  ...............................................................................1..
> .......................
       16      1.95   24.51 |  .................................1................................................
> .......................
      619     75.49  100.00 | (other patterns)
 ---------------------------+------------------------------------------------------------------------------------
> -----------------------
      820    100.00         |  XXXXXXX......X.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
> XXXXXXXXXXXXXXXXXXXXXXX
 ----------------------------------------------------------------------------------------------------------------
> -----------------------
 *Each column represents 7 periods.
Thanks,
Preeti