0% found this document useful (0 votes)
27 views2 pages

Freq Sev Model

The document outlines a simulation study using R to analyze frequency and severity of risks, employing Poisson and gamma distributions. It includes calculations for quantiles, means, and standard deviations across multiple simulations. The results are visualized through histograms and statistical measures such as Coefficient of Variation for both mean and quantile estimates.

Uploaded by

DunsScoto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Freq Sev Model

The document outlines a simulation study using R to analyze frequency and severity of risks, employing Poisson and gamma distributions. It includes calculations for quantiles, means, and standard deviations across multiple simulations. The results are visualized through histograms and statistical measures such as Coefficient of Variation for both mean and quantile estimates.

Uploaded by

DunsScoto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

#frequency-severity

#parametri

library(VGAM)
nRischi = 10000
nSimulazioni = 50
lambda = 100
alfa = 0.7
beta = 1000
xm = 1000
theta = 1
p = 0.6

#punto (a)

set.seed(1)

t0 = Sys.time()

fn=array(0,nSimulazioni)
X=array(0,nSimulazioni)

for (i in 1:nSimulazioni){
if(i%%5==0) print(i)

fn[i] = sum(rpois(nRischi,lambda))
X[i] = sum(p*rgamma(fn[i],shape = alfa,scale = beta)+(1-p)*rparetoII(fn[i],xm,theta))

print(t1-t0)

hist(X)

#punto (b)
q=quantile(S,probs = 0.995,type=5)

#punto (c)
Ncopie=100
q.ar=array(NA,Ncopie)
for(ncop in 1:Ncopie){
S=array(NA,nSimulazioni)
for (i in 1:nSimulazioni){
fn = rpois(nRischi,lambda)
X = p*rgamma(nRischi,shape = alfa,scale = beta)+(1-p)*rparetoII(nRischi,2,2)
S[i] = fn %*% X
}
q.ar[ncop]=quantile(S,probs = 0.995,type=5)
}

std.q.ar=sd(q.ar)

#punto (d)
m.S=mean(S)
m.S

Ncopie=500
m.S.ar=array(NA,Ncopie)
for(ncop in 1:Ncopie){
S=array(NA,nSimulazioni)
for (i in 1:nSimulazioni){
fn = rpois(nRischi,lambda)
X = p*rgamma(nRischi,shape = alfa,scale = beta)+(1-p)*rparetoII(nRischi,2,2)
S[i] = fn %*% X
}
m.S.ar[ncop]=quantile(S,probs = 0.995,type=5)
}

std.m.S.ar=sd(m.S.ar)

#punto e

CoVAm=sdt.m.S.ar/mean(m.S.ar)
CoVAq=std.q.ar/mean(q.ar)

You might also like