_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › 覿磯

Contents

1
2 覓伎 企慨蠍
3 殊 覿磯
4 覦覲旧 れ 覿 覿
5 覦覲旧 れ 覿磯
6 觜覈 覦覯
7 襴譴..


1 #

  • 蠏 谿 蟆
  • 譟郁唄
    • 襴曙: 螳 讌 襦 襴曙伎伎 .
    • 蠏: 螳 讌 蠏覿襯 企伎 .
    • 覿ク: 螳 讌覲 覿一 螳 觜訣伎 .
  • 襴暑(or 語 or factor) 譬覲 蟯螻襯 覿 蠍磯. 襯 れ, 覓伎, 一, 觜れ 蠍 谿企ゼ 覿 蟆曙 覓伎, 一, 觜れ 襴暑()願, 蠍 譬覲. 蠏碁Μ螻 覓伎, 一, 觜れ 語譴(factor levle)企手 .
  • 殊 覿磯(one-way ANOVA): 語襯 覿 朱 蟆曙
  • 伎 覿磯(two-way ANOVA): 螳 語襯 覿 朱 蟆曙
  • れ 覿磯(multi-way ANOVA): 螳 伎 語襯 覿 朱 蟆曙
  • 誤螻 = 譯狩螻 + 蟲語
  • 螻燕蠏(=覿ク覿) = ク谿螻煙 /

2 覓伎 企慨蠍 #

use tempdb;

--drop table 煙
create table 煙
(
	糾 int
,	蟆一 int
,	 int
);

insert 煙 values (85, 3, 65);
insert 煙 values (74, 7, 50);
insert 煙 values (76, 5, 55);
insert 煙 values (90, 1, 65);
insert 煙 values (85, 3, 55);
insert 煙 values (87, 3, 70);
insert 煙 values (94, 1, 65);
insert 煙 values (98, 2, 70);
insert 煙 values (81, 4, 55);
insert 煙 values (91, 2, 70);
insert 煙 values (76, 3, 50);
insert 煙 values (74, 4, 55);

> library("RODBC")
> conn <- odbcConnect("26")
> data <- sqlQuery(conn, "SELECT 糾, , 蟆一 FROM tempdb.dbo.煙")
> a <- aov(糾 ~  + 蟆一, data)
> a
Call:
   aov(formula = 糾 ~  + 蟆一, data = data)

Terms:
                         蟆一 Residuals
Sum of Squares  541.6927  61.9657  124.5916
Deg. of Freedom        1        1         9

Residual standard error: 3.720687 
Estimated effects may be unbalanced
> summary(a)
            Df Sum Sq Mean Sq F value    Pr(>F)    
         1 541.69  541.69 39.1297 0.0001487 ***
蟆一         1  61.97   61.97  4.4762 0.0634803 .  
Residuals    9 124.59   13.84                      
---
Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1   1 
> 

蟆郁骸伎

    • 蠏覓願: 碁 谿願 .
    • 襴所: 碁 谿願 .
  • p-value = 0.0001487襦 譴 0.05覲企 朱襦 襴所れ 觧 伎襯 谿場 覈詩. 蠏碁覩襦 糾 谿願 .
  • 蟆一 p-value = 0.0634803襦 譴 0.05覲企 覩襦 襴所れ 觧 伎襯 谿場. 蠏碁覩襦 蠏覓願れ 讌讌. 蠏碁覩襦 糾 蟆一 磯殊 譬讌一 り .



3 殊 覿磯 #

c1 <- c(3.6, 4.1, 4.0)
c2 <- c(3.1, 3.2, 3.9)
c3 <- c(3.2, 3.5, 3.5)
c4 <- c(3.5, 3.8, 3.9)
data <- data.frame(c1,c2,c3,c4)

#一危磯ゼ 襷れ伎 . stack()
data <- stack(data)
summary(aov(values ~ ind, data))

蟆郁骸 れ螻 螳.
            Df  Sum Sq Mean Sq F value Pr(>F)
ind          3 0.56250 0.18750    2.25 0.1598
Residuals    8 0.66667 0.08333          
aov_rs1.jpg

蟆郁骸 伎

    • 蠏覓願: 谿願 .
    • 襴所: 谿願 .
  • p-value = 0.1598 朱 襴所れ 觧 1譬 る 襯 0.05覲企 . 蠏碁覩襦 蠏覓願れ 讌讌.
  • 讀, 3螳 蠏碁9 蠏 谿企 .

4 覦覲旧 れ 覿 覿 #



ろ <- c(rep("1",4), rep("2",4), rep("3",4))
 <- c(rep(c("A","B","C","D"),3))
蟯豸′ <- c(3.6,3.1,3.2,3.5,4.1,3.2,3.5,3.8,4.0,3.9,3.5,3.8)
data <- data.frame(蟯豸′, ろ, )
data
summary(aov(蟯豸′ ~  + ろ), data)

蟆郁骸 れ螻 螳.
> data
   蟯豸′ ろ 
1     3.6      1    A
2     3.1      1    B
3     3.2      1    C
4     3.5      1    D
5     4.1      2    A
6     3.2      2    B
7     3.5      2    C
8     3.8      2    D
9     4.0      3    A
10    3.9      3    B
11    3.5      3    C
12    3.8      3    D
> summary(aov(蟯豸′ ~  + ろ), data)
            Df  Sum Sq Mean Sq   F value    Pr(>F)    
(Intercept)  1 155.520 155.520 4241.4545 8.813e-10 ***
         3   0.540   0.180    4.9091   0.04692 *  
ろ       2   0.420   0.210    5.7273   0.04062 *  
Residuals    6   0.220   0.037                        
---
Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1   1 
Warning messages:
1: In model.matrix.default(mt, mf, contrasts) :
  variable '' converted to a factor
2: In model.matrix.default(mt, mf, contrasts) :
  variable 'ろ' converted to a factor
3: In Ops.factor(left) : ! 語 伎 覓伎覩誤
4: In Ops.factor(left) : ! 語 伎 覓伎覩誤
> 


蟆郁骸 伎

    • 蠏覓願: 碁 谿願 .
    • 襴所: 碁 谿願 .
  • p-value = 0.04692企襦 0.05覲企 . 讀, 襴所れ 觧 蟇企讌襯 谿場 覈詩. 蠏覓願 蠍郁. 蠏碁覩襦 覲襦 蟯豸♀ 蠏 谿願 .
  • ろれ p-value= 0.04062企襦 0.05覲企 . 讀, 襴所れ 觧 蟇企讌襯 谿場 覈詩. 蠏覓願 蠍郁. 蠏碁覩襦 ろる襦 蟯豸♀ 蠏 谿願 .

5 覦覲旧 れ 覿磯 #

"覦覲旧 "企 詞 れ螻 螳 詞企. 讀, 譴覲給 一危郁 詩. ("select distinct 蠍, 讌"螻 "select 蠍, 讌" るゴ.)

aov_rs2.jpg

讌 <-c(rep("",4), rep("譴覿",4), rep("覿",4))
蠍 <- rep(c("","","",""), 3)
蟯豸′ <- c(74,78,70,74,78,74,68,72,68,72,60,64)
data <- data.frame(蟯豸′, 讌, 蠍)

> data
   蟯豸′ 讌 蠍
1      74        
2      78        
3      70        
4      74        
5      78 譴覿       
6      74 譴覿       
7      68 譴覿       
8      72 譴覿       
9      68 覿       
10     72 覿       
11     60 覿       
12     64 覿       


覦覲旧 れ 覿磯 れ 蟆曙, 螳 襾殊 蟲語 讌 危エ覲伎 . 蟲語 蟲語(interaction plot) 伎覃 . R 蟆曙 れ螻 螳 覃 .
par(mfrow=c(1,2))
interaction.plot(讌,蠍,蟯豸′)
interaction.plot(蠍,讌,蟯豸′)

蟆郁骸 れ螻 螳. 襷 蟲語 覦る 蠏碁螳 蟲谿 覿覿 蠍企.
aov_rs3.jpg

蟲語 蟆 讌襷 蠏碁 覯 蟲語 讌 危エ覲企襦 .
summary(aov(蟯豸′ ~ 蠍 + 讌 + 蠍:讌, data))

蟆郁骸 螳.

              Df Sum Sq Mean Sq F value    Pr(>F)    
(Intercept)    1  60492   60492  7561.5 1.558e-10 ***
蠍       1    108     108    13.5   0.01040 *  
讌           2    152      76     9.5   0.01382 *  
蠍:讌  2      8       4     0.5   0.62974    
Residuals      6     48       8                      
---
Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1   1 
Warning messages:
1: In model.matrix.default(mt, mf, contrasts) :
  variable '蠍' converted to a factor
2: In model.matrix.default(mt, mf, contrasts) :
  variable '讌' converted to a factor
3: In Ops.factor(left) : ! 語 伎 覓伎覩誤
4: In Ops.factor(left) : ! 語 伎 覓伎覩誤

蟆郁骸伎

    • 蠏覓願: 碁 谿願 .
    • 襴所: 碁 谿願 .
  • 蠍 p-value = 0.01040 襦 譴 0.05覲企 朱襦 襴所れ 觧 伎襯 谿場 覈詩. 襴所れ 讌讌螻, 蠏覓願れ 蠍郁. 讀, 蠍一 磯殊 蟯豸′(螳蟆) 谿願 .
  • 讌 p-value = 0.01382 襦 譴 0.05覲企 朱襦 襴所れ 觧 伎襯 谿場 覈詩. 襴所れ 讌讌螻, 蠏覓願れ 蠍郁. 讀, 讌 磯殊 蟯豸′(螳蟆) 谿願 .
  • 蠍:讌 p-value = 0.629742 襦 譴 0.05覲企 覩襦 襴所れ 觧 伎襯 谿場. 蠏覓願れ 讌讌. 讀, 蠍一 讌 覲牛螻殊 蟯豸′(螳蟆) 谿企 . (蟲語 )

6 觜覈 覦覯 #

  • 襭れ梗-襴 蟆讀(kruskcal-wallis rank sum test)
  • 觜覈: 覲, 蠏 螳 蠍 企れ 蟆曙
  • kruskcal.test() 伎

> # 蠏碁9 蠍郁讌 襷覈 煙 豸′ 蟆郁骸
> x <- c(2.9, 3.0, 2.5, 2.6, 3.2) #
> y <- c(3.8, 2.7, 4.0, 2.4)      # 蠍磯讌
> z <- c(2.8, 3.4, 3.7, 2.2, 2.0) #覃危讀 
> data <- data.frame(x,y,z)
危 data.frame(x, y, z) : 語 るジ 伎襯 覩誤 5, 4
> kruskal.test(data)

        Kruskal-Wallis rank sum test

data:  data 
Kruskal-Wallis chi-squared = 0.7714, df = 2, p-value = 0.68

>  

蟆郁骸伎

    • 蠏覓願: 谿願 .
    • 襴所: 谿願 .
  • p-value = 0.68企襦 譴 0.05 襴所れ 觧. 蠏碁覩襦 蠏覓願 讌讌
  • 讀, 3蠏碁9 覿讌蟇一 襷覈 煙 谿願 .

れ螻 螳 蠏碁9 襷れ伎 . (g螳 蠏碁9企)
s <- c(x,y,z)
g <- rep(1:3, c(length(x),length(y),length(z)))
data <- data.frame(s,g)
kruskal.test(s,g)

> s <- c(x,y,z)
> g <- rep(1:3, c(length(x),length(y),length(z)))
> data <- data.frame(s,g)
> kruskal.test(s,g)

        Kruskal-Wallis rank sum test

data:  s and g 
Kruskal-Wallis chi-squared = 0.7714, df = 2, p-value = 0.68

> 

7 襴譴.. #

{ろ螻覯, 覦燕, 覩殊} 3.1
#3-1
x <- read.table(header=T, text="
factorLevel  characteristicValue
A1	8.44
A1	8.36
A1	8.28
A2	8.59
A2	8.91
A2	8.6
A3	9.34
A3	9.41
A3	9.69
A4	8.92
A4	8.92
A4	8.74") 
head(x)

aov.out <- aov(characteristicValue~factorLevel, data=x)
summary(aov.out)
drop1(aov.out,~.,test="F")

model.tables(aov.out, type="means", se=T)
model.tables(aov.out, type="effects", se=T)

TukeyHSD(aov.out)
plot(TukeyHSD(aov.out))


library(gplots)
plotmeans(characteristicValue~factorLevel, data=x)


lm.out <- lm(characteristicValue~factorLevel, data=x)
summary(lm.out)
summary.aov(lm.out)


#焔 蟆
bartlett.test(characteristicValue~factorLevel, data=x)
fligner.test(characteristicValue~factorLevel, data=x)
#library(HH)
#hov(characteristicValue~factorLevel, data=x)
#library(lawstat)
#levene.test(characteristicValue~factorLevel, data=x)
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:53Anonymous