Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

re: st: Processing speed for ttest


From   David Airey <[email protected]>
To   [email protected]
Subject   re: st: Processing speed for ttest
Date   Thu, 9 Oct 2003 00:22:02 -0500

John,

See the threads started by me on

Subject: st: give me some speed
Date: Thu, 4 Apr 2002 14:07:38 -0600

on analysis of Affy chip data by ttests and the many helpful responses. You have to use the Harvard archives to find this and related threads. There is a way to make the ttests very, very fast (2 seconds for 12K ttests), pointed out by Nick Winter, the winner of the speed contest. But your intuition to use an alternative form of the ttest (regress) will get you a quicker result too, as William Gould detailed.

clear
set more off
insheet using cxb.txt

/*
f1 f2 f3 f4 f5 f6 c1 c2 c3 c4 c5 c6 <--wide format, forebrain and cerebellum results for animals 1 to 6.
*/

display "$S_TIME"

forvalues j = 1/6 {
generate d`j' = f`j'-c`j'
}

egen dif_mean = rmean(d1-d6)
egen dif_sd = rsd(d1-d6)
egen dif_n = robs(d1-d6)
generate t = dif_mean/(dif_sd/sqrt(dif_n))
generate tp = tprob(dif_n-1,t)

display "$S_TIME"

save Winter, replace

smileplot, pvalue(tp) estimate(t) method(holland) nhcred(retain)
list t tp if retain == 0
set more on

*this takes 2 seconds for all 12422 ttests or 0.016 seconds per 100 ttests

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index