2012-02-27 62 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