deltavar()始终返回0

时间:2017-08-31 19:03:53

标签: r variance

我正在使用emdbook中的deltavar()函数来承载鲸鱼潜水时间,水面时间以及表面上的鲸鱼在平面视野中通过下面的可用性等式得出的时间差。

z_jan <- 533.27531  47.87911  52.62564 #vector of means for January.  The first number is the mean dive time, followed by the mean surface time, and the mean field of view.  
sigma_jan <- 690226.840   7550.909   2677.737 #vector of variances for January.  The first number is the variance of the dive times, followed by the variance of surface times, and variance of field of view.

fun <- (s/(s+d)) + (d*(1 - 2.71828^(t(-1)/d))/(s+d)) ## availability equation I need to carry the variance through
fun<- as.character(fun)
vars <- c("d", "s", "t") ## variables in the function (d = dive times, s = surface times, t = field of view time)

delta_jan <- deltavar(fun = fun, meanval=z_jan,vars = vars,Sigma = sigma_jan)

代码运行,看起来一切都应该有效,但我尝试的每个月的数据都会返回0.有什么想法吗?

1 个答案:

答案 0 :(得分:0)

尝试以下操作:

delta_jan <- deltavar(fun = s/(s+d)) + (d*(1 - 2.71828^(t(-1)/d))/(s+d),
                      meanval=z_jan,
                      vars = vars,
                      Sigma = sigma_jan)

我认为“乐趣”不能是字符,只能是函数。