Hi Listers,
I need to calculate the sample size for a 2x2 crossover study, where the order of treatment received is randomised (1:1 allocation) so that half of the participants receive treatment A then B while the other half receive treatment B then A.
We are comparing 2 different diets and are expecting under diet#1 participants will put on 2kg (compared to baseline) while they will lose 2kg under diet#2 (there will be a washout period when we expect them to return to their initial weight). We assume that the standard deviation difference is 3.
I have used the -power pairedmeans- command and this suggests that 9 participants are needed to achieve >90% power with alpha =0.05 (2-tailed):
power pairedmeans -2 2, sddiff(3) power(.9)
I get similar results using -xsampsi-
xsampsi, alpha(0.05) beta(0.1) n(6(1)12) delta(4) stddev(3)
However, based on an earlier posts on the forum which suggests analyses for this type of study should not rely on paired t-test but mixed models, I decided to run some simulations to estimate the needed sample so to reflect the planned analysis.
I am new to this so I was hoping to get some input on whether this is the correct approach- would compare weight at the end of each experimental period while adjusting for baseline scores be a more appropriate approach than using change from baseline at the end of each experimental period?
I need to calculate the sample size for a 2x2 crossover study, where the order of treatment received is randomised (1:1 allocation) so that half of the participants receive treatment A then B while the other half receive treatment B then A.
We are comparing 2 different diets and are expecting under diet#1 participants will put on 2kg (compared to baseline) while they will lose 2kg under diet#2 (there will be a washout period when we expect them to return to their initial weight). We assume that the standard deviation difference is 3.
I have used the -power pairedmeans- command and this suggests that 9 participants are needed to achieve >90% power with alpha =0.05 (2-tailed):
power pairedmeans -2 2, sddiff(3) power(.9)
I get similar results using -xsampsi-
xsampsi, alpha(0.05) beta(0.1) n(6(1)12) delta(4) stddev(3)
However, based on an earlier posts on the forum which suggests analyses for this type of study should not rely on paired t-test but mixed models, I decided to run some simulations to estimate the needed sample so to reflect the planned analysis.
I am new to this so I was hoping to get some input on whether this is the correct approach- would compare weight at the end of each experimental period while adjusting for baseline scores be a more appropriate approach than using change from baseline at the end of each experimental period?
Code:
program letsample, rclass
version 16.0
syntax, n(integer) ///
[ alpha(real 0.05) ///
m1(real 1) ///
m2(real 1) ///
sd1(real 1) ///
sd2(real 1) ///
]
clear
set obs 1
expand `n'
* Create sequence variable: 0 for treatment A first vs. 1 for treatment B
local mid = round(`n'/2,1)
local mid2 = `mid'+1
di `mid'
di `mid2'
g seq= 0 in 1/`mid'
replace seq= 1 in `mid2'/`n'
g nid=_n
* Create difference scores
g scores1 = rnormal(`m1', `sd1')
g scores2 = rnormal(`m2', `sd2')
reshape long scores , i(n) j(treat)
mixed scores i.seq##i.treat || nid:
return scalar pos = r(table)["pvalue", "scores:2.treat"] < `alpha'
end
simulate reject = r(pos), reps(1000) seed(73450): ///
letsample, n(12) m1(-2) m2(2) sd1(2.3) sd2(2.3)
tab reject

Comment