Skip to content

Commit

Permalink
Set seed for IBNR triangles and test for it
Browse files Browse the repository at this point in the history
  • Loading branch information
mages committed Jan 9, 2023
1 parent 3cd018f commit 5cd0dd4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions R/BootstrapReserve.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ BootChainLadder <- function(Triangle, R = 999,
simExp <- getIncremental(getExpected(simUlts, 1/simUltDFs))
simExp[!is.na(simClaims)] <- NA
processTriangle <-array(NA,c(n,n,R))

if(!is.null(seed)){
set.seed(seed)
}
if(process.distr=="gamma")
processTriangle[!is.na(simExp)] <- sign(simExp[!is.na(simExp)])*rgamma(length(simExp[!is.na(simExp)]), shape=abs(simExp[!is.na(simExp)]/scale.phi), scale=scale.phi)

if(!is.null(seed)){
set.seed(seed)
}
if(process.distr=="od.pois")
processTriangle <- apply(simExp,c(1,2,3), function(x)
ifelse(is.na(x), NA, sign(x)*rpois.od(1, abs(x), scale.phi)))
Expand Down
3 changes: 2 additions & 1 deletion inst/unitTests/runit.BootChainLadder.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ test.seed.BootChainLadder <- function() {
# Test that print(x) returns x; see ?print
B1 <- BootChainLadder(RAA, R = 10, seed = 123)
B2 <- BootChainLadder(RAA, R = 100, seed = 123)
checkEquals(B1$simClaims[,,1], B2$simClaims[,,1])
checkEquals(B1$IBNR.Triangles[,,1], B2$IBNR.Triangles[,,1])
checkEquals(B1$IBNR.Triangles[,,1], B2$IBNR.Triangles[,,1])
}

0 comments on commit 5cd0dd4

Please sign in to comment.