2012-02-27 65 views
2

如果我從一組風向標獲得風向讀數,是否有類似t.test(或其他重要性測試),我可以在循環數據上執行?我假設一個正態分佈(下面的數據來自)。我發現了CircStats包,但我想我會在這裏查看一些額外的指導。圓形重要性測試

一些樣本數據:

df1 <- data.frame(unit=letters, wind.direction=c(99,88,93,99,86,90,101,109,109,91,86,94,106,92,99,103,110,98,107,109,93,102,92,99,109,85)) 

這一個只使用一個標準的t.test工作得很好,因爲它不環繞爲零。但是,

df2 <- data.frame(unit=letters, wind.direction=c(1,350,355,1,348,352,3,11,11,353,348,356,8,3,1,5,12,0,9,11,355,4,354,1,11,347)) 

不會因爲它的圓形均值爲〜0,但線性平均值爲〜139 ...

+0

將這工作許多觀察這會工作apply(as.matrix(df2 [,2]),1,function(x)ifelse(x> 180,360-x,x))'; '平均(df2 $ wd.scaled' = 6.69。 – 2012-02-27 22:57:53

+0

@ baha-kev一些風向標已經過校準,我想標記這些風向標,因此往往可能會有一個完全朝錯誤的方向讀取, (我的意思是〜90,有一個風向標讀數爲〜270) – Justin 2012-02-27 23:03:06

回答

1

您可以使用aov.circular,在circular包。

# Sample data (with two groups, to compare the means) 
library(circular) 
x <- as.circular( 
    c(1,350,355,1,348,352,3,11,11,353,348,356, 
    8,3,1,5,12,0,9,11,355,4,354,1,11,347), 
    unit="degrees" 
) 
g <- sample(LETTERS[1:2], 26, replace=TRUE) 
# Test 
aov.circular(x, g) 
+0

完美!「CircStats」似乎有點複雜,我需要。 – Justin 2012-02-27 23:31:15

+0

快速跟進:我可以從mle .vonmises.bootstrap.ci(aov.circular(x,g)$ mu,mu = aov.circular(x,g)$ mu.all)'correct? – Justin 2012-02-28 00:05:33

0

這就是我的意思是說:`$ DF2 = wd.scaled:

> df2$wd.scaled = apply(as.matrix(df2[,2]),1,function(x) ifelse(x>180,x-360,x)) 
> df2 
    unit wind.direction wd2 wd.scaled 
1  a    1 1   1 
2  b   350 -10  -10 
3  c   355 -5  -5 
4  d    1 1   1 
5  e   348 -12  -12 
6  f   352 -8  -8 

> mean(df2$wd.scaled) 
[1] 0.3846154 

,如果你不具備近180