【发布时间】:2019-05-23 18:58:30
【问题描述】:
我一直在研究一个大型财务模型,并试图对数据中的不确定性进行建模。为此,我一直将变量建模为正态分布(我知道,我可能应该使用 Weibull 或其他什么,但鉴于我的时间限制,目前这只是最简单的。
我找到了distr 包,它是统计对象数学的绝妙实现,但我不知道如何让乘法起作用,因为我正在处理数百万美元。我认为我重载了包中的一些函数,因为它们旨在处理 X ~ [0,1] 而不是 X_mean = 70000, X_sd = 250 之类的数据,这些数据代表财务不确定性。
代码如下:
```{r one more thing}
library(distr)
library(tidyverse)
distroptions("DefaultNrFFTGridPointsExponent" = 50)
distroptions("DefaultNrGridPoints" = 2^50)
Containers <- Norm(mean=71000, sd=250)
# Containers is how many containers we own in the wild
Container_Unit_Cap_Cost <- Norm(mean=85,sd=2)
# Container_Unit_Cap_Cost is the unit cost to acquire new containers
Container_Total_Cap_Cost <- Containers * Container_Unit_Cap_Cost
# Container_Total_Cap_Cost is product distribution of the two previous uncertain variables
xlim_min <- Container_Total_Cap_Cost@gaps[1,2]
xlim_max <- Container_Total_Cap_Cost@gaps[2,2]
ggplot(tibble(x = c(xlim_min, xlim_max)), aes(x)) +
stat_function(fun = conv@d, n = 101) +
scale_y_continuous() +
theme_dark()
```
这导致了错误
Grid for approxfun too wide, increase DefaultNrFFTGridPointsExponentError in seq.default(from = lower, to = upper, by = h) : 'by' argument is much too small
来自 RStudio 的以下回溯
14. stop("'by' argument is much too small")
13. seq.default(from = lower, to = upper, by = h)
12. seq(from = lower, to = upper, by = h)
11. .discretizeP(e1, lower, upper, h)
10. e10 + e20
9. e10 + e20
8. .class1(object)
7. as(e10 + e20, "UnivarLebDecDistribution")
6. log(e1DC$pos$D) + log(e2DC$pos$D)
5. log(e1DC$pos$D) + log(e2DC$pos$D)
4. .class1(object)
3. as(exp(log(e1DC$pos$D) + log(e2DC$pos$D)), "UnivarLebDecDistribution")
2. Containers * Container_Unit_Cap_Cost
1. Containers * Container_Unit_Cap_Cost
我在distr 的选项中搞砸了,但似乎无法找到一种方法让它以更大的时间间隔进行迭代。我增加了DefaultNrFFTGridPointsExponentError
有人有什么想法吗?
【问题讨论】:
标签: r statistics distribution