Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LifeInsureR package for R
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
R
LifeInsureR package for R
Commits
f06a2e16
Commit
f06a2e16
authored
1 year ago
by
Reinhold Kainhofer
Browse files
Options
Downloads
Patches
Plain Diff
CRAN_V1.0.0: Add examples, fix more warnings
parent
0e666084
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
R/contractGrid.R
+43
-4
43 additions, 4 deletions
R/contractGrid.R
cran-comments.md
+7
-1
7 additions, 1 deletion
cran-comments.md
man/contractGrid.Rd
+18
-1
18 additions, 1 deletion
man/contractGrid.Rd
man/makeContractGridDimname.Rd
+2
-2
2 additions, 2 deletions
man/makeContractGridDimname.Rd
with
70 additions
and
8 deletions
R/contractGrid.R
+
43
−
4
View file @
f06a2e16
...
...
@@ -40,7 +40,7 @@
#
# Params of the contractGridPreimium function:
#' @param contractGrid (optional) existing contract grid from which to derive
#' premiums. If not given, [contractGrid] is called with all parameters, so
#' premiums. If not given, [contractGrid
()
] is called with all parameters, so
#' \code{...} should contain an \code{axes} argument in that case.
#' @param premium The type of premium to derive (key of the \code{contract$Values$premiums} list.
#' @param .fun The function to extract the desired premium from a contract
...
...
@@ -53,7 +53,24 @@
#' @rdname contractGrid
#'
#' @examples
#' # TODO
#' library("MortalityTables")
#' mortalityTables.load("Austria_Annuities_AVOe2005R")
#' # A trivial deferred annuity tariff with no costs, premiums during whole
#' # deferral period, 30 years annuity payments:
#' tariff = InsuranceTarif$new(name="Test Annuity", type="annuity", tarif = "Annuity 1A",
#' mortalityTable = AVOe2005R.unisex, i=0.01,
#' deferralPeriod = function(params, ...) { params$ContractData$premiumPeriod },
#' policyPeriod = function(params, ...) { params$ContractData$premiumPeriod + 30 }
#' )
#' contractGrid(
#' axes = list(
#' age = seq(20, 60, 10),
#' premiumPeriod = seq(5,30, 5)
#' ),
#' tarif = tariff,
#' sumInsured = 1000,
#' contractClosing = as.Date("2023-11-01")
#' )
#'
#' @export
contractGrid
=
function
(
axes
=
list
(
age
=
seq
(
20
,
60
,
10
),
policyPeriod
=
seq
(
5
,
35
,
5
)),
YOB
=
NULL
,
observationYear
=
NULL
,
...
)
{
...
...
@@ -101,7 +118,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 [
makeC
ontractGrid()]
#' @returns The name of the entry in the dimnames of [
c
ontractGrid()]
#' @describeIn makeContractGridDimname Create a short, human-readable dimensional name for an object (default S3 method)
#' @examples
#' library(MortalityTables)
...
...
@@ -121,7 +138,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 [
makeC
ontractGrid()]
#' @returns an array of dimnames derived from the axes definitions of [
c
ontractGrid()]
#' @describeIn makeContractGridDimname Generate proper dimnames for all entries of the axes of a [contractGrid()]
#' @export
makeContractGridDimnames
=
function
(
axes
)
{
...
...
@@ -154,6 +171,28 @@ makeContractGridDimnames = function(axes) {
#' @returns a array of premiums (or other contract-specific value) for the grid defined by the \code{axes} argument to \code{contractGrid}
#'
#' @rdname contractGrid
#'
#' @example
#' library("MortalityTables")
#' mortalityTables.load("Austria_Annuities_AVOe2005R")
#' # A trivial deferred annuity tariff with no costs, premiums during whole
#' # deferral period, 30 years annuity payments:
#' tariff = InsuranceTarif$new(name="Test Annuity", type="annuity", tarif = "Annuity 1A",
#' mortalityTable = AVOe2005R.unisex, i=0.01,
#' deferralPeriod = function(params, ...) { params$ContractData$premiumPeriod },
#' policyPeriod = function(params, ...) { params$ContractData$premiumPeriod + 30 }
#' )
#' contractGridPremium(
#' axes = list(
#' age = seq(20, 60, 10),
#' premiumPeriod = seq(5,30, 5)
#' ),
#' tarif = tariff,
#' sumInsured = 1000,
#' contractClosing = as.Date("2023-11-01")
#' )
#'
#'
#' @export
contractGridPremium
=
function
(
contractGrid
=
NULL
,
premium
=
"written"
,
.fun
=
function
(
cntr
)
{
cntr
$
Values
$
premiums
[[
premium
]]
},
...
)
{
if
(
missing
(
contractGrid
)
||
is.null
(
contractGrid
))
{
...
...
This diff is collapsed.
Click to expand it.
cran-comments.md
+
7
−
1
View file @
f06a2e16
## R CMD check results
0 errors | 0 warnings | 1 note
❯ checking CRAN incoming feasibility ... NOTE
Maintainer: 'Reinhold Kainhofer
<reinhold@kainhofer.com>
'
New submission
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!
...
...
This diff is collapsed.
Click to expand it.
man/contractGrid.Rd
+
18
−
1
View file @
f06a2e16
...
...
@@ -80,6 +80,23 @@ human-readable representations e.g. of a tariff or a mortality table as
the dimension label.
}
\examples{
# TODO
library("MortalityTables")
mortalityTables.load("Austria_Annuities_AVOe2005R")
# A trivial deferred annuity tariff with no costs, premiums during whole
# deferral period, 30 years annuity payments:
tariff = InsuranceTarif$new(name="Test Annuity", type="annuity", tarif = "Annuity 1A",
mortalityTable = AVOe2005R.unisex, i=0.01,
deferralPeriod = function(params, ...) { params$ContractData$premiumPeriod },
policyPeriod = function(params, ...) { params$ContractData$premiumPeriod + 30 }
)
contractGrid(
axes = list(
age = seq(20, 60, 10),
premiumPeriod = seq(5,30, 5)
),
tarif = tariff,
sumInsured = 1000,
contractClosing = as.Date("2023-11-01")
)
}
This diff is collapsed.
Click to expand it.
man/makeContractGridDimname.Rd
+
2
−
2
View file @
f06a2e16
...
...
@@ -15,9 +15,9 @@ 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[=
makeC
ontractGrid]{
makeC
ontractGrid()}}
The name of the entry in the dimnames of \code{\link[=
c
ontractGrid]{
c
ontractGrid()}}
an array of dimnames derived from the axes definitions of \code{\link[=
makeC
ontractGrid]{
makeC
ontractGrid()}}
an array of dimnames derived from the axes definitions of \code{\link[=
c
ontractGrid]{
c
ontractGrid()}}
}
\description{
The function \code{makeContractGridDimname} generates a short, human-readable
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment