after having observed some unexpected results from permutation tests using stata command "permute" I tried to run the following code:
------------------------------------------------------------------------------------------------------------------------
clear
set obs 200
gen x = uniform()
gen treat = (x>.5)
capture:program drop sum2
program define sum2, rclass
quietly{
tempname mean1
summarize x if treat==1
scalar `mean1'=r(mean)
return scalar sum2mean = `mean1'
}
end
set more off
permute treat mean=r(sum2mean) , ///
seed(123456) reps(10000) : sum2
set more off
permute treat mean=r(mean) , ///
seed(123456) reps(10000): summarize x if treat==1
------------------------------------------------------------------------------------------------------------------------
From my understanding of the command the two instances of it in the code above should be equivalent, nevertheless they give me two opposite results: the first one reports a p-value of zero (which makes sense) while the second one reports a p-value of one (which makes no sense at all to me).
I experience this problem with the following versions of the command: *! version 2.6.1 05feb2014
*! version 2.5.1 09jun2011
Am I using the command incorrectly?
Thanks for any answer,
Tommaso
------------------------------------------------------------------------------------------------------------------------
clear
set obs 200
gen x = uniform()
gen treat = (x>.5)
capture:program drop sum2
program define sum2, rclass
quietly{
tempname mean1
summarize x if treat==1
scalar `mean1'=r(mean)
return scalar sum2mean = `mean1'
}
end
set more off
permute treat mean=r(sum2mean) , ///
seed(123456) reps(10000) : sum2
set more off
permute treat mean=r(mean) , ///
seed(123456) reps(10000): summarize x if treat==1
------------------------------------------------------------------------------------------------------------------------
From my understanding of the command the two instances of it in the code above should be equivalent, nevertheless they give me two opposite results: the first one reports a p-value of zero (which makes sense) while the second one reports a p-value of one (which makes no sense at all to me).
I experience this problem with the following versions of the command: *! version 2.6.1 05feb2014
*! version 2.5.1 09jun2011
Am I using the command incorrectly?
Thanks for any answer,
Tommaso

Comment