Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
R - Mortality Tables
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
R - Mortality Tables
Commits
d67a3d53
Commit
d67a3d53
authored
7 years ago
by
Reinhold Kainhofer
Browse files
Options
Downloads
Patches
Plain Diff
Switch mT.fitExtrapolationLaw to use the qx rather than the Dx and Ex to fit
parent
beeaa415
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/utilityFunctions.R
+11
-9
11 additions, 9 deletions
R/utilityFunctions.R
with
11 additions
and
9 deletions
R/utilityFunctions.R
+
11
−
9
View file @
d67a3d53
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
NULL
NULL
fitExtrapolationLaw
=
function
(
data
,
ages
,
data.ages
=
ages
,
Dx
=
data
*
Ex
,
Ex
,
method
=
"LF2"
,
law
=
"HP"
,
fit
=
75
:
99
,
extrapolate
=
80
:
120
,
fadeIn
=
80
:
90
,
fadeOut
=
NULL
,
verbose
=
FALSE
)
{
fitExtrapolationLaw
=
function
(
data
,
ages
,
data.ages
=
ages
,
Dx
=
NULL
,
Ex
=
NULL
,
qx
=
NULL
,
method
=
"LF2"
,
law
=
"HP"
,
fit
=
75
:
99
,
extrapolate
=
80
:
120
,
fadeIn
=
80
:
90
,
fadeOut
=
NULL
,
verbose
=
FALSE
)
{
# Add the extrapolate ages to the needed ages
# Add the extrapolate ages to the needed ages
neededAges
=
union
(
ages
,
extrapolate
)
neededAges
=
union
(
ages
,
extrapolate
)
# constrain the fit and fade-in range to given ages
# constrain the fit and fade-in range to given ages
...
@@ -14,7 +14,7 @@ fitExtrapolationLaw = function(data, ages, data.ages = ages, Dx = data * Ex, Ex,
...
@@ -14,7 +14,7 @@ fitExtrapolationLaw = function(data, ages, data.ages = ages, Dx = data * Ex, Ex,
# Hohe Alter: Fitte Heligman-Pollard im Bereich 75-99
# Hohe Alter: Fitte Heligman-Pollard im Bereich 75-99
fitLaw
=
MortalityLaw
(
fitLaw
=
MortalityLaw
(
x
=
data.ages
,
Dx
=
Dx
,
Ex
=
Ex
,
x
=
data.ages
,
Dx
=
Dx
,
Ex
=
Ex
,
qx
=
qx
,
law
=
law
,
opt.method
=
method
,
law
=
law
,
opt.method
=
method
,
fit.this.x
=
fit
)
fit.this.x
=
fit
)
# summary(fitAP.m.75.99)
# summary(fitAP.m.75.99)
...
@@ -188,19 +188,21 @@ mT.fitExtrapolationLaw = function(table, method = "LF2", law = "HP",
...
@@ -188,19 +188,21 @@ mT.fitExtrapolationLaw = function(table, method = "LF2", law = "HP",
ages
=
ages
(
table
)
ages
=
ages
(
table
)
if
(
!
is.null
(
table
@
exposures
)
&&
!
is.na
(
table
@
exposures
))
{
if
(
!
is.null
(
table
@
exposures
)
&&
!
is.na
(
table
@
exposures
))
{
Ex
=
table
@
exposures
Ex
=
table
@
exposures
if
(
!
is.null
(
table
@
data
$
deaths
))
{
qx
=
table
@
deathProbs
Dx
=
table
@
data
$
deaths
# if (!is.null(table@data$deaths)) {
}
else
{
# Dx = table@data$deaths
Dx
=
table
@
deathProbs
*
Ex
# } else {
}
# Dx = table@deathProbs * Ex
# }
}
else
{
}
else
{
Ex
=
rep
(
1
,
length
(
ages
))
Ex
=
rep
(
1
,
length
(
ages
))
Dx
=
table
@
deathProbs
# Dx = table@deathProbs
qx
=
table
@
deathProbs
}
}
table
=
mT.fillAges
(
table
,
neededAges
=
union
(
ages
,
extrapolate
),
fill
=
0
)
table
=
mT.fillAges
(
table
,
neededAges
=
union
(
ages
,
extrapolate
),
fill
=
0
)
fitted
=
fitExtrapolationLaw
(
fitted
=
fitExtrapolationLaw
(
data
=
table
@
deathProbs
,
ages
=
ages
(
table
),
data
=
table
@
deathProbs
,
ages
=
ages
(
table
),
D
x
=
D
x
,
Ex
=
Ex
,
data.ages
=
ages
,
q
x
=
q
x
,
Ex
=
Ex
,
data.ages
=
ages
,
method
=
method
,
law
=
law
,
method
=
method
,
law
=
law
,
fit
=
fit
,
extrapolate
=
extrapolate
,
fit
=
fit
,
extrapolate
=
extrapolate
,
fadeIn
=
fadeIn
,
fadeOut
=
fadeOut
,
fadeIn
=
fadeIn
,
fadeOut
=
fadeOut
,
...
...
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