I'm studying bootstrap for microarray analysis. I found this code from http://www.compgen.org/tools/microarrays
Code:
program define ttestboot, rclass
version 10.1
syntax , x(varlist numeric max=1) type(varlist numeric max=1) [ reps(real 100) var(string ) ]
set more off
di in ye "______________________________________________________________________________"
di in ye " Calculation of Achieved Significance Level (ASL) using the bootstrap"
di in ye " The idea is to recenter the two samples to the combined sample mean"
di in ye " so that the data now conform to the null hypothesis but that the"
di in ye " variances within the samples remain unchanged"
di in ye "______________________________________________________________________________"
preserve
ttest `x',by(`type') uneq
tempname tobs omean
scalar `tobs' = r(t)
qui summarize `x', meanonly
scalar `omean' = r(mean)
qui summarize `x' if `type'==0, meanonly
qui replace `x' = `x' - r(mean) + scalar(`omean') if `type'==0
qui summarize `x' if `type'==1, meanonly
qui replace `x' = `x' - r(mean) + scalar(`omean') if `type'==1
tempfile boot
bootstrap t=r(t),nolegend nowarn notable reps(`reps') strata(`type') saving(`boot'): ttest `x',by(`type') `var'
use `boot',clear
qui generate indicator = abs(t)>=abs(scalar(`tobs'))
qui summarize indicator, meanonly
display in ye "ASLboot = " r(mean)
restore
return scalar p=r(mean)
end| Gene | Exp | Type |
| Gene1 | 1.602014 | 1=treat |
| Gene1 | 1.497501 | 0=control |
| Gene2 | 1.675608 | 1 |
| Gene2 | 3.727904 | 0 |
Code:
ttestboot Expr Type [reps(100) Gene] #varlist not allowed
Code:
list Expr Type Gene
0 Response to Bootstrap as manual
Post a Comment