Hi,

Here is the data set I am analyzing. It is in a long format: 3-time points (time=1, 2, and 3 ) and 3 groups (group=A, B, and C). The outcome variable ("outcome") is a continuous variable.

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input int id byte(group time) int outcome
 7 3 1  16
 7 3 2   8
 7 3 3  16
20 3 1  50
20 3 2   .
20 3 3   .
21 3 1  65
21 3 2  47
21 3 3  61
25 2 1  74
25 2 2   .
25 2 3   .
28 1 1  76
28 1 2   .
28 1 3   .
29 1 1  71
29 1 2   8
29 1 3   4
31 3 1  70
31 3 2  48
31 3 3  31
33 2 1  26
33 2 2  33
33 2 3  34
36 2 1  53
36 2 2  30
36 2 3   4
37 1 1  58
37 1 2  20
37 1 3   .
40 3 1  66
40 3 2  20
40 3 3  17
45 3 1  75
45 3 2  46
45 3 3  68
49 3 1  93
49 3 2  98
49 3 3 102
50 3 1  88
50 3 2   .
50 3 3   .
52 3 1  96
52 3 2  61
52 3 3  97
62 1 1  44
62 1 2  57
62 1 3  64
66 1 1  32
66 1 2  52
66 1 3  31
67 2 1  42
67 2 2  79
67 2 3  38
71 2 1  69
71 2 2  21
71 2 3  36
72 2 1  37
72 2 2  28
72 2 3  41
end
label values group group_l
label def group_l 1 "group A", modify
label def group_l 2 "group B", modify
label def group_l 3 "group C", modify

I used tabstat command to get the means and sds of the outcome.
Code:
by time, sort: tabstat outcome, by(group) statistics(n mean sd min max)
To analyze the data set, I first ran a mixed model without any covariates. Then I used margins to get the estimated values for each group at each time point.
Code:
mixed outcome i.time##i.group ||id:, cov(ind) var
margins, over(group time)
Here is the issue.
At time 1, all three values for three groups are identical between estimated (margins) and observed (tabstat).
At time 2 and 3, however, numbers are slightly different between estimated (margins) and observed (tabstat).

I cannot figure out why. I have the same issue with another analysis, so it would be really helpful if anyone can help me understand why and guide me towards the solution!
Looking forward to discussing it with you all.