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
530fda99
Commit
530fda99
authored
8 years ago
by
Reinhold Kainhofer
Browse files
Options
Downloads
Patches
Plain Diff
Add contractGrid and contractGridPremium functions to compare tariffs
parent
1514470d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
DESCRIPTION
+1
-0
1 addition, 0 deletions
DESCRIPTION
NAMESPACE
+2
-0
2 additions, 0 deletions
NAMESPACE
R/contractGrid.R
+43
-0
43 additions, 0 deletions
R/contractGrid.R
with
46 additions
and
0 deletions
DESCRIPTION
+
1
−
0
View file @
530fda99
...
...
@@ -23,6 +23,7 @@ Collate:
'ProfitParticipation.R'
'InsuranceTarif.R'
'InsuranceContract.R'
'contractGrid.R'
'exportInsuranceContract_xlsx.R'
'showVmGlgExamples.R'
'exportInsuranceContractExample.R'
...
...
This diff is collapsed.
Click to expand it.
NAMESPACE
+
2
−
0
View file @
530fda99
...
...
@@ -8,6 +8,8 @@ export(InsuranceContract.ParametersFill)
export(InsuranceContract.Values)
export(InsuranceTarif)
export(ProfitParticipation)
export(contractGrid)
export(contractGridPremium)
export(deathBenefit.annuityDecreasing)
export(deathBenefit.linearDecreasing)
export(exportInsuranceContract.xlsx)
...
...
This diff is collapsed.
Click to expand it.
R/contractGrid.R
0 → 100644
+
43
−
0
View file @
530fda99
#' @export
contractGrid
=
function
(
axes
=
list
(
ages
=
seq
(
20
,
60
,
10
),
policyPeriod
=
seq
(
5
,
35
,
5
)),
...
)
{
# Create all combinations of the variables given for the axes:
gridByRow
=
expand.grid
(
axes
);
# Apply InsuranceContract$new to each combination (and add the additional arguments)
vals
=
apply
(
gridByRow
,
1
,
function
(
axisVals
)
{
do.call
(
InsuranceContract
$
new
,
c
(
as.list
(
axisVals
),
...
))
})
dimnames
=
makeContractGridDimnames
(
axes
)
matrix
(
vals
,
nrow
=
length
(
axes
[[
1
]]),
ncol
=
length
(
axes
[[
2
]]),
byrow
=
FALSE
,
dimnames
=
dimnames
)
}
makeContractGridDimname
=
function
(
value
)
{
UseMethod
(
"makeContractGridDimname"
,
value
)
}
makeContractGridDimname.InsuranceTarif
=
function
(
tarif
)
{
tarif
$
name
}
makeContractGridDimname.mortalityTable
=
function
(
table
)
{
table
@
name
}
makeContractGridDimname.default
=
function
(
value
)
{
value
}
makeContractGridDimnames
=
function
(
axes
)
{
lapply
(
axes
,
function
(
axis
)
{
lapply
(
axis
,
makeContractGridDimname
);
}
)
}
#' @export
contractGridPremium
=
function
(
contractGrid
=
NULL
,
premium
=
"written"
,
...
)
{
if
(
missing
(
contractGrid
)
||
is.null
(
contractGrid
))
{
contractGrid
=
contractGrid
(
...
)
}
apply
(
contractGrid
,
1
:
2
,
function
(
c
)
{
c
[[
1
]]
$
Values
$
premiums
[[
premium
]]
})
}
if
(
FALSE
)
{
gg
=
contractGrid
(
tarif
=
Generali.U188
,
axes
=
list
(
age
=
seq
(
20
,
60
,
10
),
policyPeriod
=
seq
(
5
,
35
,
5
)),
sumInsured
=
100000
)
contractGridPremium
(
gg
)
apply
(
gg
,
1
:
2
,
function
(
c
)
{
c
[[
1
]]
$
Parameters
$
ContractData
$
sumInsured
})
contractGridPremium
(
tarif
=
Generali.U188
,
axes
=
list
(
age
=
seq
(
20
,
60
,
10
),
policyPeriod
=
seq
(
5
,
35
,
5
)),
sumInsured
=
100000
)
contractGridPremium
(
age
=
30
,
axes
=
list
(
tarif
=
c
(
Generali.U188
,
Generali.U180
,
Generali.U3.1_2015
),
policyPeriod
=
seq
(
5
,
35
,
5
)),
sumInsured
=
100000
)
}
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