diff --git a/.Rbuildignore b/.Rbuildignore index 75d241a094abdeaa98d4b239ebaaf524d8997613..e728fde2056cef2fef88d42b16c6e5ad6cbb8eca 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -8,3 +8,5 @@ ^Examples .Rbuildignore$ +^revdep$ +^cran-comments\.md$ diff --git a/DESCRIPTION b/DESCRIPTION index 7a8e1487f0236bcc26557de4dabb756145e552e6..917d935be700798a6e7dd2e61d81736c8e948bf4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -6,14 +6,14 @@ Title: Framework for Traditional Life Insurance Contracts Description: R6 classes to model traditional life insurance contracts like annuities, whole life insurances or endowments. Such life insurance contracts provide a guaranteed interest and are not directly linked - to the performance of a particular investment vehicle. However, they typically + to the performance of a particular investment vehicle, but they typically provide (discretionary) profit participation. This package provides a framework to model such contracts in a very generic (cash-flow-based) way and includes modelling profit participation schemes, dynamic increases or more general contract layers, as well as contract changes (like sum increases or premium waivers). All relevant quantities like premium decomposition, reserves and benefits over the whole contract period are calculated and potentially - exported to excel. Mortality rates are given using the 'MortalityTables' package. + exported to 'Excel'. Mortality rates are given using the 'MortalityTables' package. Authors@R: c(person("Reinhold", "Kainhofer", role=c("aut", "cre"), email="reinhold@kainhofer.com")) Author: Reinhold Kainhofer [aut, cre] Maintainer: Reinhold Kainhofer <reinhold@kainhofer.com> diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000000000000000000000000000000000000..5645ebdfe9c2ccb75f3e6140440f3d612d1d667b --- /dev/null +++ b/NEWS.md @@ -0,0 +1,4 @@ + +# Version 1.0.0: October 27, 2023 + * Renamed package from LifeInsuranceContracts to LifeInsureR + diff --git a/R/HelperFunctions.R b/R/HelperFunctions.R index 9184fbaa187b13df519bebf371d47a3699ddc4f5..d955c81b3aaae1e18378c95dc726df4dc3e812d3 100644 --- a/R/HelperFunctions.R +++ b/R/HelperFunctions.R @@ -112,6 +112,7 @@ ProfitComponentsEnum = objectProperties::setMultipleEnum("ProfitComponents", #' #' @param params The parameters of the contract. #' @param values Unused by default (already calculated values of the contract) +#' @returns TRUE or FALSE, indicating a single-premium contract or not #' #' @export isSinglePremiumContract = function(params, values) { params$ContractData$premiumPeriod <= 1 } @@ -123,6 +124,7 @@ isSinglePremiumContract = function(params, values) { params$ContractData$premium #' #' @param params The parameters of the contract. #' @param values Unused by default (already calculated values of the contract) +#' @returns TRUE or FALSE, indicating a contract with regular premiums #' #' @export isRegularPremiumContract = function(params, values) { params$ContractData$premiumPeriod > 1 } @@ -141,6 +143,7 @@ isRegularPremiumContract = function(params, values) { params$ContractData$premiu #' @param params The full parameter set of the insurance contract (including #' all inherited values from the tariff and the profit participation) #' @param values The values calculated from the insurance contract so far +#' @returns vector of linearly decreasing benefits over the whole insurance coverage period #' #' @export deathBenefit.linearDecreasing = function(len, params, values) { @@ -158,6 +161,7 @@ deathBenefit.linearDecreasing = function(len, params, values) { #' @param params The full parameter set of the insurance contract (including #' all inherited values from the tariff and the profit participation) #' @param values The values calculated from the insurance contract so far +#' @returns The length of the premium refund period (deferral period for deferred contracts, contract period otherwise) #' #' @export premiumRefundPeriod.default = function(params, values) { @@ -187,6 +191,7 @@ premiumRefundPeriod.default = function(params, values) { #' #' #' @param interest The interest rate of the loan, which is underlying the insurance. +#' @returns vector of decreasing death benefits #' #' #' @export @@ -209,6 +214,7 @@ deathBenefit.annuityDecreasing = function(interest) { #' #' @param params The parameters of the contract. #' @param values Unused by default (already calculated values of the contract) +#' @returns the resulting age #' #' @export age.exactRounded = function(params, values) { @@ -222,6 +228,7 @@ age.exactRounded = function(params, values) { #' #' @param params The parameters of the contract. #' @param values Unused by default (already calculated values of the contract) +#' @returns the resulting age #' #' @export age.yearDifference = function(params, values) { @@ -255,6 +262,7 @@ age.yearDifference = function(params, values) { #' @param quarterly Surcharge for quarterly premium payments #' @param semiannually Surcharge for semi-annual premium payments #' @param yearly Surcharge for yearly premium payments (optiona, default is no surcharge) +#' @returns a named list of surcharges for names 1 (yearly), 2 (semiannually), 4 (quarterly) and 12 (monthly) payments #' #' @export freqCharge = function(monthly = 0, quarterly = 0, semiannually = 0, yearly = 0) { diff --git a/R/addDataTableWorksheet.R b/R/addDataTableWorksheet.R deleted file mode 100644 index a8b0f3ed4ba43dc575f978c150dfe66f2915fae0..0000000000000000000000000000000000000000 --- a/R/addDataTableWorksheet.R +++ /dev/null @@ -1,73 +0,0 @@ -#' Add a new worksheet to the excel workbook and export the given data table x to it nicely formatted. -# @export -# addDataTableWorksheet = function(wb, sheet, title = NULL, x = NULL, loopdim = 3, style = NULL, tableStyle = "TableStyleMedium17", comparisons = NULL, comparisonStyle = NULL, ...) { -# addWorksheet(wb, sheet); -# rw = 1; -# if (!missing(title)) { -# titleStyle = createStyle( -# fontSize = 26, -# fontColour = "#365F91", borderColour = "#4F81BD", -# borderStyle = "medium", border = "Bottom", textDecoration = "bold") -# writeData(wb, sheet, title, startCol = 1, startRow = rw) -# addStyle(wb, sheet, style = titleStyle, rows = rw, cols = 1); -# rw = rw + 2; -# } -# if (!missing(x)) { -# if (loopdim > length(dim(x))) -# loopdim = length(dim(x)); -# if (loopdim < 0) -# loopdim = 1; -# # str(dimnames(x)); -# rnames = dimnames(x)[[1]]; -# cnames = dimnames(x)[[2]]; -# # str("rnames, cnames: ");str(rnames);str(cnames); -# dmname = names(dimnames(x))[[loopdim]]; -# dmnameStyle = createStyle( -# fontSize = 20, -# fontColour = "#4F81BD", #borderColour = "#4F81BD", -# # borderStyle = "medium", border = "Bottom", -# textDecoration = "bold") -# headerStyle = createStyle(halign = "center", valign = "center"); -# lapply( -# seq_along(dimnames(x)[[loopdim]]), -# function(i) { -# dmheader = paste(dmname, dimnames(x)[[loopdim]][i], sep = " = ") -# writeData(wb, sheet, dmheader, startCol = 1, startRow = rw) -# addStyle(wb, sheet, style = dmnameStyle, rows = rw, cols = 1); -# rw <<- rw + 1; -# writeDataTable( -# wb, sheet, -# x = as.data.frame(x[,,i]), # TODO: Generalize this to use loopdim! -# colNames = TRUE, rowNames = TRUE, -# withFilter = FALSE, -# startCol = 1, startRow = rw, -# tableStyle = tableStyle, headerStyle = headerStyle); -# if (!is.null(style)) { -# addStyle(wb, sheet, style = style, rows = rw + seq_along(rnames), cols = 1 + seq_along(cnames), gridExpand = TRUE, stack = TRUE); -# } -# cl = 1 + length(cnames) + 2; -# -# lapply( -# seq_along(comparisons), -# function(j) { -# writeData(wb, sheet, names(comparisons)[j], startRow = rw - 1, startCol = cl) -# addStyle(wb, sheet, style = dmnameStyle, rows = rw - 1, cols = cl); -# -# writeDataTable( -# wb, sheet, -# x = as.data.frame(comparisons[[j]][,,i]), # TODO: Generalize this to use loopdim! -# colNames = TRUE, rowNames = TRUE, -# withFilter = FALSE, -# startCol = cl, startRow = rw, -# tableStyle = tableStyle, headerStyle = headerStyle); -# if (!is.null(comparisonStyle)) { -# addStyle(wb, sheet, style = comparisonStyle, rows = rw + seq_along(rnames), cols = cl + seq_along(cnames), gridExpand = TRUE, stack = TRUE); -# } -# cl <<- cl + 1 + length(cnames) + 1; -# } -# ) -# rw <<- rw + length(rnames) + 1 + 2; # TODO: Generalize this to use loopdim! -# } -# ); -# } -# } diff --git a/R/contractGrid.R b/R/contractGrid.R index fc74c8d6a6fbad1312be6b384eaf7d1df3f23f72..9b3f08fc98b9db786499ea17c729da468dcccb2e 100644 --- a/R/contractGrid.R +++ b/R/contractGrid.R @@ -48,6 +48,7 @@ #' type of premium given in the \code{premium} parameter. One can, #' however pass any other extractor function to access e.g. reserves, #' cash flows etc. at any desired time. +#' @returns multi-dimensional array of insurance contracts (dimensions defined by the axes argument) #' #' @rdname contractGrid #' @@ -100,6 +101,7 @@ makeContractGridDimname.default = function(value) { value } #' representation for the axes in the grid. #' #' @param value the value along the axis, for which a name should be generated +#' @returns The name of the entry in the dimnames of [makeContractGrid()] #' @describeIn makeContractGridDimname Create a short, human-readable dimensional name for an object (default S3 method) #' @examples #' library(MortalityTables) @@ -119,6 +121,7 @@ makeContractGridDimname = function(value) { UseMethod("makeContractGridDimname", #' dimnames for all entries of the axes of a [contractGrid()] by calling #' \code{makeContractGridDimname} on each of the axes' values #' @param axes the axes with all names, for which a name should be generated +#' @returns an array of dimnames derived from the axes definitions of [makeContractGrid()] #' @describeIn makeContractGridDimname Generate proper dimnames for all entries of the axes of a [contractGrid()] #' @export makeContractGridDimnames = function(axes) { @@ -148,6 +151,7 @@ makeContractGridDimnames = function(axes) { #' type of premium given in the \code{premium} parameter. One can, #' however pass any other extractor function to access e.g. reserves, #' cash flows etc. at any desired time. +#' @returns a array of premiums (or other contract-specific value) for the grid defined by the \code{axes} argument to \code{contractGrid} #' #' @rdname contractGrid #' @export diff --git a/R/exportInsuranceContractExample.R b/R/exportInsuranceContractExample.R index a9cc5ed8b1115c126f4f04bbf6daa58aee983a9f..f67f04f8823a282422ee5b221df82d2cf7b674a7 100644 --- a/R/exportInsuranceContractExample.R +++ b/R/exportInsuranceContractExample.R @@ -5,7 +5,7 @@ NULL #' Export the example calculations of an insurance contract #' -#' Export the given contract to excel (full history/timeseries of all cash +#' Export the given contract to 'Excel' (full history/timeseries of all cash #' flows, reserves, premiums, etc.) and to a text file (sample calculation #' required by the Austrian regulation). #' @@ -28,6 +28,7 @@ NULL #' @param extraname If basename is not given, this allows a suffix to distinguish #' multiple exports. #' @param ... Further parameters (passed on to \code{\link{showVmGlgExamples}}) +#' @returns None #' #' @examples #' library("MortalityTables") @@ -42,7 +43,7 @@ NULL #' sumInsured = 1000, #' contractClosing = as.Date("2016-10-01") #' ); -#' \dontrun{exportInsuranceContractExample(contract, prf = 10)} +#' \donttest{exportInsuranceContractExample(contract, prf = 10)} #' #' @export exportInsuranceContractExample = function(contract, prf = 10, outdir = ".", basename=NULL, extraname = NULL, ...) { diff --git a/R/exportInsuranceContract_xlsx.R b/R/exportInsuranceContract_xlsx.R index 19c49f2dc01191b3b91a921fc1456d3528a03d40..6c8ed15efc9f1fa93ceafa5ded298d38c095e2a6 100644 --- a/R/exportInsuranceContract_xlsx.R +++ b/R/exportInsuranceContract_xlsx.R @@ -846,10 +846,10 @@ exportCFTable = function(wb, sheet, contract, ccol = 1, crow = 1, styles = c(), # ############################################################################### # -#' Export an insurance act object tocontract (object of class [InsuranceContract]) to an Excel file +#' Export an insurance contract (object of class [InsuranceContract]) to an 'Excel' file #' #' @details The function \code{exportInsuranceContract.xlsx} exports an object -#' of class [InsuranceContract] to an Excel file. All basic data, as well as +#' of class [InsuranceContract] to an 'Excel' file. All basic data, as well as #' the time series of (absolute and unit) cash flows, reserves, premiums, premium #' composition and all profit participation scenarios are exported to the file #' in nicely looking tables. @@ -858,7 +858,8 @@ exportCFTable = function(wb, sheet, contract, ccol = 1, crow = 1, styles = c(), #' stored in \code{contract$Values}. #' #' @param contract The insurance contract to export -#' @param filename Target Excel filename for export +#' @param filename Target 'Excel' file name for export +#' @returns None #' #' @examples #' library("MortalityTables") @@ -873,7 +874,7 @@ exportCFTable = function(wb, sheet, contract, ccol = 1, crow = 1, styles = c(), #' sumInsured = 1000, #' contractClosing = as.Date("2016-10-01") #' ); -#' \dontrun{exportInsuranceContract.xlsx(contract, "Example_annuity_contract.xlsx")} +#' \donttest{exportInsuranceContract.xlsx(contract, "Example_annuity_contract.xlsx")} #' @export exportInsuranceContract.xlsx = function(contract, filename) { # TODO: argument checking for contract and filename diff --git a/R/showVmGlgExamples.R b/R/showVmGlgExamples.R index 3fff4d5134ac2177485e39167e25b4e9dcd125a1..bb10d579c30cb909a8fded476ab1c26bd0796110 100644 --- a/R/showVmGlgExamples.R +++ b/R/showVmGlgExamples.R @@ -82,6 +82,7 @@ calcVmGlgExample = function(contract, prf = 10, t = 10, t_prf = 12, ...) { #' @param t_prf Time for which to show all values after the premium waiver #' @param file If given, outputs all information to the file rather than the console #' @param ... Further parameters for generating the contract for a tariff object +#' @returns Name of the output file (invisible) or empty if printed to console #' #' @examples #' library(MortalityTables) @@ -99,8 +100,8 @@ calcVmGlgExample = function(contract, prf = 10, t = 10, t_prf = 12, ...) { #' showVmGlgExamples(contract) #' #' # Optionally output to a file rather than the console: -#' \dontrun{ -#' showVmGlgExamples(contract, file = "annuity-example.txt") +#' \donttest{ +#' showVmGlgExamples(contract, file = tempfile("annuity-example", fileext = ".txt")) #' } #' @export showVmGlgExamples = function(contract, prf = 10, t = 10, t_prf = 12, file = "", ...) { @@ -169,6 +170,7 @@ showVmGlgExamples = function(contract, prf = 10, t = 10, t_prf = 12, file = "", ); output.str = paste(output, collapse = '\r\n') cat(output.str, file = file) + invisible(file) } @@ -189,16 +191,19 @@ showVmGlgExamples = function(contract, prf = 10, t = 10, t_prf = 12, file = "", #' @param net,Zillmer,gross,written,savings,risk,ZillmerRes,ZillmerRes.prf,VwKostenRes,VwKostenRes.prf,Bilanzreserve,Praemienuebertrag,Rueckkaufsreserve,Rueckkaufswert,Abschlusskostenruecktrag,Rueckkaufswert.prf,VS.prf Values as printed out by showVmGlgExamples #' @param absTolerance If non-NULL, will ignore small floating point differences. It uses same algorithm as all.equal() #' @param ... Further parameters for generating the contract for a tariff object +#' @returns None #' #' @examples #' library(MortalityTables) +#' library(testthat) #' mortalityTables.load("Austria_Annuities_AVOe2005R") #' -#' \dontrun{ #' test_that("Testtarif", { #' # A trivial deferred annuity tariff with no costs: +#' library(MortalityTables) +#' mortalityTables.load("Austria_Annuities") #' tariff = InsuranceTarif$new(name="Test Annuity", type="annuity", -#' mortalityTable = AVOe2005R.unisex, i=0.01) +#' mortalityTable = AVOe2005R.unisex, i = 0.01) #' contract = InsuranceContract$new( #' tariff, #' age = 35, YOB = 1981, @@ -218,15 +223,14 @@ showVmGlgExamples = function(contract, prf = 10, t = 10, t_prf = 12, file = "", #' VwKostenRes = 0.00, #' VwKostenRes.prf = 0.00, #' Bilanzreserve = 9250.35, -#' Praemienuebertrag = 212.52, +#' Praemienuebertrag = 637.567, #' Rueckkaufsreserve = 9011.40, #' Rueckkaufswert = 9011.40, #' Abschlusskostenruecktrag = 0.00, #' Rueckkaufswert.prf = 9205.96, -#' VS.prf = 685.12 +#' VS.prf = 684.117 #' ) #' }) -#'} #' #' @export testVmGlgExample = function(contract, prf = 10, t = 10, t_prf = 12, net, Zillmer, gross, written, savings, risk, @@ -318,6 +322,7 @@ testVmGlgExample = function(contract, prf = 10, t = 10, t_prf = 12, net, Zillmer #' @param prf Time of premium waiver (premium-free) #' @param t_prf Time for which to calculated all values after the premium waiver #' @param ... Further parameters for generating the contract for a tariff object +#' @returns None (code is printed to the console, but no value returned) #' #' @examples #' library(MortalityTables) diff --git a/README.md b/README.md index dba4b1fd9b0fe5b93afe233610cb84ed20a134ac..fa7572bc34a869fd3b49e59059fd20dd595e8aac 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ R package implementing general life insurance contracts This package R6 classes to model traditional life insurance - contracts like annuities, whole life insurances or endowments. All relevant - quantities like premium decomposition, reserves and benefits over the whole - contract period are calculated and potentially exported to excel. Mortalities - are given using the MortalityTables package. +contracts like annuities, whole life insurances or endowments. All relevant +quantities like premium decomposition, reserves and benefits over the whole +contract period are calculated and potentially exported to 'Excel'. Mortalities +are given using the 'MortalityTables' package. diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000000000000000000000000000000000000..6fa8126f73b083670aa25cdd65e7d17b47fbe800 --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,14 @@ +## R CMD check results + +0 errors | 0 warnings | 1 note + +* Renamed the existing LifeInsuranceContracts package to LifeInsureR + So this is not a complately new package, just a new name! + +* Re-submission of the package taking into account the response of the CRAN team: + * Wrap Software and package names in quotes + * There are no external references describing the methods + * Removed Umlaute (UTF8 characters) to prevent unexecutable code on pure ANSI/ASCII machines + * replace \dontrun by \donttest wherever possible. + * Never change the options(..) + diff --git a/inst/Beispiele/Example_Endowment.R b/inst/Beispiele/Example_Endowment.R index f959d5fe14e8c98ae4fc6b31b82b61e7e373dab0..7d0a30ab98e05f5aeb2865ba49de2f17bbc615b5 100644 --- a/inst/Beispiele/Example_Endowment.R +++ b/inst/Beispiele/Example_Endowment.R @@ -78,10 +78,8 @@ contract.Bsp = InsuranceContract$ addDynamics(t = 5, NewSumInsured = 200000, id = "Dynamik 1", i = 0.05, age = 70)$ addDynamics(t = 10, NewSumInsured = 250000, id = "Dynamik 2", i = 0.01); -options('LIC.debug.premiumCalculation' = TRUE) contract.Bsp$premiumWaiver(t = 13) -options('LIC.debug.premiumCalculation' = FALSE) # exportInsuranceContractExample(contract.Bsp, t = 5); # showVmGlgExamples(contract.Bsp, t = 10) # diff --git a/man/age.exactRounded.Rd b/man/age.exactRounded.Rd index 71ae22f31416cc8ff7db132101bd9fc38b2f7524..cb32776eda81beec314dc8ab15612fb0cf84c399 100644 --- a/man/age.exactRounded.Rd +++ b/man/age.exactRounded.Rd @@ -12,6 +12,9 @@ age.exactRounded(params, values) \item{values}{Unused by default (already calculated values of the contract)} } +\value{ +the resulting age +} \description{ Calculate the age of the insured based on exact age at contract closing, rounded to the nearest birthday. diff --git a/man/age.yearDifference.Rd b/man/age.yearDifference.Rd index b972916c306f66b0347e650b19202110b394ee27..55876b1fe5fef7040f2d71a50589cd642143a152 100644 --- a/man/age.yearDifference.Rd +++ b/man/age.yearDifference.Rd @@ -12,6 +12,9 @@ age.yearDifference(params, values) \item{values}{Unused by default (already calculated values of the contract)} } +\value{ +the resulting age +} \description{ Calculate the age of the insured based on the difference of the bith year and contract closing year. diff --git a/man/contractGrid.Rd b/man/contractGrid.Rd index 64fb64afff5ac7e5971c7c41cf4fd458b82dc9c0..7a6aa062862c9e970f18e575e1820596f9062aef 100644 --- a/man/contractGrid.Rd +++ b/man/contractGrid.Rd @@ -42,6 +42,11 @@ type of premium given in the \code{premium} parameter. One can, however pass any other extractor function to access e.g. reserves, cash flows etc. at any desired time.} } +\value{ +multi-dimensional array of insurance contracts (dimensions defined by the axes argument) + +a array of premiums (or other contract-specific value) for the grid defined by the \code{axes} argument to \code{contractGrid} +} \description{ The function \code{contractGrid} creates a (two- or multi-dimensional) grid of InsuranceContract objects, where each axis represents one of the insurance diff --git a/man/deathBenefit.annuityDecreasing.Rd b/man/deathBenefit.annuityDecreasing.Rd index 8eb7ac1b9e66ba91107409c88380272118fd9ab2..76042c919293b4e3b3e73476b295e4b9c3968be6 100644 --- a/man/deathBenefit.annuityDecreasing.Rd +++ b/man/deathBenefit.annuityDecreasing.Rd @@ -9,6 +9,9 @@ deathBenefit.annuityDecreasing(interest) \arguments{ \item{interest}{The interest rate of the loan, which is underlying the insurance.} } +\value{ +vector of decreasing death benefits +} \description{ The death benefit will be the full sumInsured for the first year after the deferral period and then decrease like an annuity to 0 at the end of the policyPeriod. diff --git a/man/deathBenefit.linearDecreasing.Rd b/man/deathBenefit.linearDecreasing.Rd index b4f84ee64f35d21a2a9801f0b508a47a457036a2..7a889c5ee1023f5d3793c4872fb03232bcb2f356 100644 --- a/man/deathBenefit.linearDecreasing.Rd +++ b/man/deathBenefit.linearDecreasing.Rd @@ -16,6 +16,9 @@ all inherited values from the tariff and the profit participation)} \item{values}{The values calculated from the insurance contract so far} } +\value{ +vector of linearly decreasing benefits over the whole insurance coverage period +} \description{ The death benefit will be the full sumInsured for the first year after the deferral period and then decrease linearly to 0 at the end of the policyPeriod. diff --git a/man/exportInsuranceContract.xlsx.Rd b/man/exportInsuranceContract.xlsx.Rd index 7dad96fab80a227d308ca45719f8e08da566de23..bd442647cc3d3023225b9bcd8e1f0e71f6f2ecea 100644 --- a/man/exportInsuranceContract.xlsx.Rd +++ b/man/exportInsuranceContract.xlsx.Rd @@ -11,6 +11,9 @@ exportInsuranceContract.xlsx(contract, filename) \item{filename}{Target Excel filename for export} } +\value{ +None +} \description{ Export an insurance act object tocontract (object of class \link{InsuranceContract}) to an Excel file } @@ -37,5 +40,5 @@ contract = InsuranceContract$new( sumInsured = 1000, contractClosing = as.Date("2016-10-01") ); -\dontrun{exportInsuranceContract.xlsx(contract, "Example_annuity_contract.xlsx")} +\donttest{exportInsuranceContract.xlsx(contract, "Example_annuity_contract.xlsx")} } diff --git a/man/exportInsuranceContractExample.Rd b/man/exportInsuranceContractExample.Rd index fad74ad39918ffd9d95daf7acab5c148091cdd08..b434fc521473738441bc03e77a6e2d4e99ff9061 100644 --- a/man/exportInsuranceContractExample.Rd +++ b/man/exportInsuranceContractExample.Rd @@ -32,6 +32,9 @@ multiple exports.} \item{...}{Further parameters (passed on to \code{\link{showVmGlgExamples}})} } +\value{ +None +} \description{ Export the given contract to excel (full history/timeseries of all cash flows, reserves, premiums, etc.) and to a text file (sample calculation @@ -60,6 +63,6 @@ contract = InsuranceContract$new( sumInsured = 1000, contractClosing = as.Date("2016-10-01") ); -\dontrun{exportInsuranceContractExample(contract, prf = 10)} +\donttest{exportInsuranceContractExample(contract, prf = 10)} } diff --git a/man/freqCharge.Rd b/man/freqCharge.Rd index cdf33b55c4cd76dcaf9982b1aa27c950360c2194..3fd7bd426fe1af01bf710675d0956e34babbe8ad 100644 --- a/man/freqCharge.Rd +++ b/man/freqCharge.Rd @@ -15,6 +15,9 @@ freqCharge(monthly = 0, quarterly = 0, semiannually = 0, yearly = 0) \item{yearly}{Surcharge for yearly premium payments (optiona, default is no surcharge)} } +\value{ +a named list of surcharges for names 1 (yearly), 2 (semiannually), 4 (quarterly) and 12 (monthly) payments +} \description{ Tariffs are typically calculated with yearly premium installments. When premiums are paid more often then one a year (in advance), the insurance diff --git a/man/isRegularPremiumContract.Rd b/man/isRegularPremiumContract.Rd index f204dbae4e3ececbeed52762c336f7f5559f80e5..6288dab2e94097b5263bcb29ddc51e879289282b 100644 --- a/man/isRegularPremiumContract.Rd +++ b/man/isRegularPremiumContract.Rd @@ -11,6 +11,9 @@ isRegularPremiumContract(params, values) \item{values}{Unused by default (already calculated values of the contract)} } +\value{ +TRUE or FALSE, indicating a contract with regular premiums +} \description{ Regular premium contracts are identified by the parameter \code{premiumPeriod > 1}. } diff --git a/man/isSinglePremiumContract.Rd b/man/isSinglePremiumContract.Rd index b69cc80c59bb10a46f92e22dd9eb4160c051b5ee..d76f80bc36f3541135ee157cca6794fe18c2b1fa 100644 --- a/man/isSinglePremiumContract.Rd +++ b/man/isSinglePremiumContract.Rd @@ -11,6 +11,9 @@ isSinglePremiumContract(params, values) \item{values}{Unused by default (already calculated values of the contract)} } +\value{ +TRUE or FALSE, indicating a single-premium contract or not +} \description{ Single premium contracts are identified by the parameter \code{premiumPeriod = 1}. } diff --git a/man/makeContractGridDimname.Rd b/man/makeContractGridDimname.Rd index b09d322c857251bfdc07f3e8df0397778f38f059..25917b457f585fa1c48b19e0277fe0911d4179e4 100644 --- a/man/makeContractGridDimname.Rd +++ b/man/makeContractGridDimname.Rd @@ -14,6 +14,11 @@ makeContractGridDimnames(axes) \item{axes}{the axes with all names, for which a name should be generated} } +\value{ +The name of the entry in the dimnames of \code{\link[=makeContractGrid]{makeContractGrid()}} + +an array of dimnames derived from the axes definitions of \code{\link[=makeContractGrid]{makeContractGrid()}} +} \description{ The function \code{makeContractGridDimname} generates a short, human-readable dimension label for the entries along the axes of a \code{\link[=contractGrid]{contractGrid()}}. diff --git a/man/premiumRefundPeriod.default.Rd b/man/premiumRefundPeriod.default.Rd index 6b04c5241e7e56e60a6bb68624fde33207bb070f..65e2a19e2ba988f5e5793f5b3b5e5fe4d674b061 100644 --- a/man/premiumRefundPeriod.default.Rd +++ b/man/premiumRefundPeriod.default.Rd @@ -12,6 +12,9 @@ all inherited values from the tariff and the profit participation)} \item{values}{The values calculated from the insurance contract so far} } +\value{ +The length of the premium refund period (deferral period for deferred contracts, contract period otherwise) +} \description{ If a premium refund is set for the tariff, the default is the full contract period, except for deferred contracts (typically deferred life annuities), diff --git a/man/showVmGlgExamples.Rd b/man/showVmGlgExamples.Rd index 7ce4288f4f4694756a6f92ac53db61cc6d39a045..3000ccaf9838bd4a54911cd9ff68671d5b3c21e5 100644 --- a/man/showVmGlgExamples.Rd +++ b/man/showVmGlgExamples.Rd @@ -19,6 +19,9 @@ showVmGlgExamples(contract, prf = 10, t = 10, t_prf = 12, file = "", ...) \item{...}{Further parameters for generating the contract for a tariff object} } +\value{ +Name of the output file (invisible) or empty if printed to console +} \description{ Display the values of the example calculation of the given insurance contract as required by the Austrian regulation (LV-VMGLV, "LV @@ -40,7 +43,7 @@ contract = InsuranceContract$new( showVmGlgExamples(contract) # Optionally output to a file rather than the console: -\dontrun{ -showVmGlgExamples(contract, file = "annuity-example.txt") +\donttest{ +showVmGlgExamples(contract, file = tempfile("annuity-example", fileext = ".txt")) } } diff --git a/man/testVmGlgExample.Rd b/man/testVmGlgExample.Rd index 2e68a94f99aafbe3cdc4af88f1f1a2b82fc083f3..2f68cc8ef21fe27d3f0d8ccfb35cd2b989b1bfa6 100644 --- a/man/testVmGlgExample.Rd +++ b/man/testVmGlgExample.Rd @@ -45,6 +45,9 @@ testVmGlgExample( \item{...}{Further parameters for generating the contract for a tariff object} } +\value{ +None +} \description{ Check the values of the example calculation of the given insurance contract as required by the Austrian regulation (LV-VMGLV, "LV @@ -57,13 +60,15 @@ The easiest way to write unit-tests is using the function \code{vmGlgExample.gen } \examples{ library(MortalityTables) +library(testthat) mortalityTables.load("Austria_Annuities_AVOe2005R") -\dontrun{ test_that("Testtarif", { # A trivial deferred annuity tariff with no costs: + library(MortalityTables) + mortalityTables.load("Austria_Annuities") tariff = InsuranceTarif$new(name="Test Annuity", type="annuity", - mortalityTable = AVOe2005R.unisex, i=0.01) + mortalityTable = AVOe2005R.unisex, i = 0.01) contract = InsuranceContract$new( tariff, age = 35, YOB = 1981, @@ -83,14 +88,13 @@ test_that("Testtarif", { VwKostenRes = 0.00, VwKostenRes.prf = 0.00, Bilanzreserve = 9250.35, - Praemienuebertrag = 212.52, + Praemienuebertrag = 637.567, Rueckkaufsreserve = 9011.40, Rueckkaufswert = 9011.40, Abschlusskostenruecktrag = 0.00, Rueckkaufswert.prf = 9205.96, - VS.prf = 685.12 + VS.prf = 684.117 ) }) -} } diff --git a/man/vmGlgExample.generateTest.Rd b/man/vmGlgExample.generateTest.Rd index ab53b8e01478d7af5c4f1590bad224912dbea0de..447f5c5e991a511244a1b6f8cf4e6295404bb83c 100644 --- a/man/vmGlgExample.generateTest.Rd +++ b/man/vmGlgExample.generateTest.Rd @@ -19,6 +19,9 @@ values is generated.} \item{...}{Further parameters for generating the contract for a tariff object} } +\value{ +None (code is printed to the console, but no value returned) +} \description{ This function calculates the required reference values for the given insurance contract as required by the Austrian regulation (LV-VMGLV, "LV diff --git a/tests/testthat/test-extendContract.R b/tests/testthat/test-extendContract.R index e0a9f0f287e7c3dbdb37666ba541753e59d6a2e8..9def190ca0dd50216a241494fbf3eb89d70ddcc9 100644 --- a/tests/testthat/test-extendContract.R +++ b/tests/testthat/test-extendContract.R @@ -28,20 +28,20 @@ test_that("Extend contract by $addExtension", { # premium-free extension - ContractB = ContractA$clone()$addExtension(id = "Verlängerung1", contractPeriod = 5, premiumPeriod = 0) - expect_equal(ContractB$blocks$Verlängerung1$Parameters$ContractData$sumInsured, 15117.03896) + ContractB = ContractA$clone()$addExtension(id = "Verlaengerung1", contractPeriod = 5, premiumPeriod = 0) + expect_equal(ContractB$blocks$Verlaengerung1$Parameters$ContractData$sumInsured, 15117.03896) # extension with given sumInsured resulting in 0 premiums - ContractC = ContractA$clone()$addExtension(id = "Verlängerung1", contractPeriod = 5, sumInsured = 15117.03896) - expect_equal(ContractC$blocks$Verlängerung1$Values$premiums[["gross"]], 0, tolerance = 1e-06) + ContractC = ContractA$clone()$addExtension(id = "Verlaengerung1", contractPeriod = 5, sumInsured = 15117.03896) + expect_equal(ContractC$blocks$Verlaengerung1$Values$premiums[["gross"]], 0, tolerance = 1e-06) # extension with increased sumInsured: real premiums are charged, reserves start from the existing reserve: - ContractD = ContractA$clone()$addExtension(id = "Verlängerung1", contractPeriod = 5, sumInsured = 20000) - expect_equal(ContractD$blocks$Verlängerung1$Values$premiums[["written"]], 315.109) - expect_equal(ContractD$blocks$Verlängerung1$Values$reserves[["0", "contractual"]], 10000) + ContractD = ContractA$clone()$addExtension(id = "Verlaengerung1", contractPeriod = 5, sumInsured = 20000) + expect_equal(ContractD$blocks$Verlaengerung1$Values$premiums[["written"]], 315.109) + expect_equal(ContractD$blocks$Verlaengerung1$Values$reserves[["0", "contractual"]], 10000) # extension with increased sumInsured and different tariff: check whether interest rate has really changed - ContractE = ContractA$clone()$addExtension(id = "Verlängerung1", contractPeriod = 5, sumInsured = 20000, tarif = Tarif.EndowmentB) + ContractE = ContractA$clone()$addExtension(id = "Verlaengerung1", contractPeriod = 5, sumInsured = 20000, tarif = Tarif.EndowmentB) expect_equal(unname(ContractE$Values$basicData[c(1,20,30,40), "InterestRate"]), c(0.03, 0.03, 0.01, 0.01)) }) diff --git a/vignettes/creating-company-specific-implementations-as-package.Rmd b/vignettes/creating-company-specific-implementations-as-package.Rmd index e7af9919c3474f38c3151f74f4d0ee5958b3bc7c..739ff1744fd6c76566231484a18934db66e3e08d 100644 --- a/vignettes/creating-company-specific-implementations-as-package.Rmd +++ b/vignettes/creating-company-specific-implementations-as-package.Rmd @@ -29,7 +29,6 @@ library(LifeInsureR) library(dplyr) library(tibble) library(lubridate) -options(scipen=5) library(pander) ``` @@ -103,9 +102,8 @@ to validate the official numbers in the financial statements). ## Steps to implement batch-testing a whole (sub-)portfolio 1. Implement the corresponding products in the files in the `R/` - subdirectory. Use the LifeInsureR documentation for further details and guidance. - <!-- available at --> - <!-- <https://cran.r-project.org/package=LifeInsureR/vignettes/using-the-lifeinsurer-package.html> --> + subdirectory. Use the (LifeInsureR documentation)<using-the-lifeinsurer-package.html> + for further details and guidance. 2. Install the package (using the "Install" button in RStudio's "Build" pane) 3. Set up the mapping of the columns of the contract data source to the diff --git a/vignettes/using-the-lifeinsurer-package.Rmd b/vignettes/using-the-lifeinsurer-package.Rmd index c95b254b9370129f12167d27e9ccd0c9c527381a..a8a7ebf49c20b43f56053dc73fe8f3d2c7acd97b 100644 --- a/vignettes/using-the-lifeinsurer-package.Rmd +++ b/vignettes/using-the-lifeinsurer-package.Rmd @@ -28,7 +28,6 @@ library(LifeInsureR) library(dplyr) library(tibble) library(lubridate) -options(scipen=5) library(pander) @@ -1505,25 +1504,25 @@ ContractA = InsuranceContract$new( # premium-free extension ContractB = ContractA$clone()$ - addExtension(id = "Verlängerung1", contractPeriod = 5, premiumPeriod = 0) + addExtension(id = "Verlaengerung1", contractPeriod = 5, premiumPeriod = 0) # sumInsured calculated from existing reserve: -ContractB$blocks$Verlängerung1$Parameters$ContractData$sumInsured +ContractB$blocks$Verlaengerung1$Parameters$ContractData$sumInsured ContractB$Values$basicData # extension with given sumInsured resulting in 0 (gross) premiums ContractC = ContractA$clone()$ - addExtension(id = "Verlängerung1", contractPeriod = 5, sumInsured = 10723.07973354) -ContractC$blocks$Verlängerung1$Values$premiums[["gross"]] + addExtension(id = "Verlaengerung1", contractPeriod = 5, sumInsured = 10723.07973354) +ContractC$blocks$Verlaengerung1$Values$premiums[["gross"]] ContractC$Values$basicData # extension with increased sumInsured: real premiums are charged, reserves start from the existing reserve: ContractD = ContractA$clone()$ - addExtension(id = "Verlängerung1", contractPeriod = 5, sumInsured = 20000) + addExtension(id = "Verlaengerung1", contractPeriod = 5, sumInsured = 20000) ContractD$Values$basicData # extension with regular premiums, which are given: sumInsured is calculated from it, reserves start from the existing reserve: ContractD = ContractA$clone()$ - addExtension(id = "Verlängerung1", contractPeriod = 5, premium = 597.8771) + addExtension(id = "Verlaengerung1", contractPeriod = 5, premium = 597.8771) ContractD$Values$basicData ```