Hi there - sorry if this is a very silly question, but I was a little confused. Simplifed code and main output below.

Basically I am trying to figure out why the postestimation (pwcompare) results in the i.treatment##i.sex interaction model differ from the main model in (2), but are the same for the simpler model (1) - i.e. differences and p-values.

Which effects are best intepreted for the main effect of treatment1 (i.e. from the first main xtmixed model or the pwcompare effects), and does this differ when an interaction term (e.g. sex) is introduced?

Thanks!

Code:
// MODEL (1)
xtmixed glu_netauc_all_mmol glu_baseline_mmol_all treatment_order bmi age i.treatment1  ||  id: , mle var
testparm i.treatment1
margins i.treatment1
margins i.treatment1, atmeans pwcompare (effects)

// MODEL (2)
xtmixed glu_netauc_all_mmol glu_baseline_mmol_all treatment_order bmi age i.treatment1##i.sex ||  id: , mle
testparm i.treatment1##i.sex
margins i.treatment1##i.sex
margins i.treatment1##i.sex, atmeans pwcompare (effects)

RESULTS (1) - simple model with no sex interaction (e.g. 2 vs 1 and 3 vs 1 effects and p-values SAME for treatment1 effects in main model and pwcompare) Array
Array





RESULTS (2) - with sex*treatment interaction - (e.g. 2 vs 1 and 3 vs 1 effects and p-values DIFFERENT for treatment1 effects in main model and pwcompare) Array
Array
Array