在 R 中绘制废墟
我正在尝试使用 R 重新创建类似于现代精算风险理论中的图像的内容: https://www .academia.edu/37238799/Modern_Actuarial_Risk_Theory(第89页)
在我的例子中,水滴的大小基于参数为 1/ 的指数分布2000 并且它们以泊松到达时间间隔开,这意味着它们以 0.25 的速率参数呈指数分布(在我的模型中)
U 的值由初始盈余加上每单位时间的保费收入 (c) 给出(对于一个由到达间隔分布确定的时间量)减去索赔金额,索赔金额是从上述指数分布中随机产生的。
我有一种感觉需要使用一个循环,这就是我到目前为止所拥有的:
lambda <- 0.25
EX <- 2000
theta <- 0.5
c <- lambda*EX*(1+theta)
x <- rexp(1, 1/2000)
s <- function(t1){for(t1 in 1:10){v <- c(rep(rexp(t1,1/2000)))
print(sum(v))}}
u <- function(t){10000+c*t}
plot(u, xlab = "t", xlim = c(-1,10), ylim = c(0,20000))
abline(v=0)
for(t1 in 1:10){v <- c(rep(rexp(t1,1/2000)))
print(sum(v))}
最终目标是在 10 年的时间内运行此模拟 10,000 次,并将其用作可视化表示,作为一个项目的破产率。保险公司。
任何帮助表示赞赏。
I'm trying to recreate something similar to an image in modern actuarial risk theory using R: https://www.academia.edu/37238799/Modern_Actuarial_Risk_Theory (page 89)
In my case, the drops are of size based on an exponential distribution with parameter 1/2000 and they are spaced apart with Poisson inter arrival times which means they are distributed exponentially with a rate parameter of 0.25 (in my model)
The value of U is given by an initial surplus plus a premium income (c) per unit time (for an amount of time determined by the inter arrival distribution) minus a claim amount which would be random from the exponential distribution mentioned above.
I have a feeling a loop will need to be used and this is what I have so far:
lambda <- 0.25
EX <- 2000
theta <- 0.5
c <- lambda*EX*(1+theta)
x <- rexp(1, 1/2000)
s <- function(t1){for(t1 in 1:10){v <- c(rep(rexp(t1,1/2000)))
print(sum(v))}}
u <- function(t){10000+c*t}
plot(u, xlab = "t", xlim = c(-1,10), ylim = c(0,20000))
abline(v=0)
for(t1 in 1:10){v <- c(rep(rexp(t1,1/2000)))
print(sum(v))}
The end goal is to run this simulation say 10,000 times over a 10 year span and use it as a visible representation as the rate of ruin for an insurance company.
Any help appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您正在寻找这样的东西,所有这些都包裹在整洁的功能中,默认情况下绘制了剧情,但是如果想要的话,请简单地返回“ ruin”或“安全”,以便您可以在模拟中运行它:
因此我们可以称呼它一次进行模拟:
,并且再次进行其他模拟
和表10,000个模拟的结果以找到毁灭的速率,事实证明约为3%
< sup>由
I think you're looking for something like this, all wrapped up in a neat function which by default draws the plot, but if wanted simply returns "ruin" or "safe" so you can run it in simulation:
So we can call it once for a simulation:
And again for a different simulation
And table the results of 10,000 simulations to find the rate of ruin, which turns out to be around 3%
Created on 2022-04-06 by the reprex package (v2.0.1)