#contents *survival analysis (11 April 2004)[#h9e1c007] ショウジョウバエの配偶行動を見るときに、観察時間内に交尾しないものがある。そこで、交尾したものを「dead」、交尾しなかったものを「survive」とみなしてsurvival analysisを行う。 Kaplan-Meier estimatorを計算 > library(survival) > mydata <- read.table("data.txt", header=TRUE) > mydata > sink("out.txt") > myfit <- survfit( Surv(Time, Copl)~Age, data=mydata) > myfit > summary(myfit) プロット > plot(myfit) Log Rank test > survdiff( Surv(Time, Copl)~Age, data=mydata) データの形式~ Copl=1は交尾。Copl=0は交尾せず(ここでは観察時間が120)。 Age Time Copl 2 41 1 . . . 2 120 0 . . . - ''Tomaru, M.'', Oguma, Y. & Watada, M. 2005. Courtship in '''Drosophila quadrilineata''' with a unique male behavioral element, abdomen bending. Journal of Ethology. published online 12 October 2005.[[doi: 10.1007/s10164-005-0172-4:http://dx.doi.org/10.1007/s10164-005-0172-4]] *Contingency Table [#t9c03134] **Fisher test (03 Oct 2005) [#te11009a] > mydata <- matrix(c(4,6,3,4), nr=2) > fisher.test(mydata) *ノンパラメトリック検定 [#t1badf9b] **Kruskal-Wallis test (09 May 2004) [#a267b855] 3つ以上の$Ageの$Durationについて検定。Kruskal-Wallis検定の後に、ペアワイズでWilcoxon Rank Sum Test(=U検定)をする。おまけで最後に分散分析。 > sink("out.txt") > mydata2 <- read.table("data2.txt", header=TRUE) > mydata2 > summary(mydata2) > kruskal.test(mydata2$Duration, mydata2$Age) > pairwise.wilcox.test(mydata2$Duration~mydata2$Age) > summary(aov(mydata2$Duration~mydata2$Age)) データの形式 Age Duration Age2 6 . . . - ''Tomaru, M.'', Oguma, Y. & Watada, M. 2005. Courtship in '''Drosophila quadrilineata''' with a unique male behavioral element, abdomen bending. Journal of Ethology. published online 12 October 2005.[[doi: 10.1007/s10164-005-0172-4:http://dx.doi.org/10.1007/s10164-005-0172-4]] *パラメトリック検定 [#ta052279] *データのまとめ (09 May 2004) [#xaf6ba55] 各$Ageの$Durationについて、 データのまとめ、平均、標準偏差の出力。~ > sink("out.txt") > mydata <- read.table("data.txt", header=TRUE, fill=TRUE) > mydata > summary(mydata) > mean(mydata, na.rm=TRUE) > sd(mydata, na.rm=TRUE) データの形式 Age2 Age4 Age6 Age8 Age10 9 6 7 4 8 . . . - ''Tomaru, M.'', Oguma, Y. & Watada, M. 2005. Courtship in '''Drosophila quadrilineata''' with a unique male behavioral element, abdomen bending. Journal of Ethology. published online 12 October 2005.[[doi: 10.1007/s10164-005-0172-4:http://dx.doi.org/10.1007/s10164-005-0172-4]] *ESS [#s80ba893] ** 03 Oct 2005 [#q15bf9ff] iESS起動 M-x R コマンド入力後 C-c C-j C-m (改行) で、1行ずつコマンドを実行する。 *コマンドメモ (30 March 2004) [#ve4bd0d4] > q() ← quit > source("commands.R") ← コマンドを書き込んだソースを読み実行 > sink("out.txt") ← ファイルに出力 > sink() ← 出力をコンソールに戻す > objects() ← 現在あるオブジェクトを表示 > mydata <- read.table("data.txt", header=TRUE) ← ファイルからデータを読み込む > library(ctest) ← ライブラリを使う > t.test(A, B) ← t検定(unpaired)。※ A、Bにはデータを入れておく > var.test(A, B) ← F検定 > t.test(A, B, var.equal=TRUE) ← t検定、等分散 > wilcox.test(A, B) ← U検定(=Wilcoxon test) > ks.test(A, B) ← Kolmogorov-Smirnov test > getwd() ← working directoryの表示 > setwd("c:/cygwin/home/tomaru/stats") ← working directoryの変更 *Rのリンク [#fd0daed0] - [[RjpWiki>http://www.okada.jp.org/RWiki/]] |Today:&counter(today); |Yesterday:&counter(yesterday); |Total:&counter(); since 04 April 2006|