Last data update: 2014.03.03

R: Estimates cumulative transition rates
CumratesR Documentation

Estimates cumulative transition rates

Description

Estimates cumulative transition rates by origin, destination, and age. Two estimation methods are distinguished: the statistical method (Nelson-Aalen estimator) and the demographic method (occurrence-exposure rates).

Usage

Cumrates(irate, Bdata)

Arguments

irate

Indicator variable defining option to be used: 1 = Nelson-Aalen method; 2 = Occurrence-Exposure rate; 3 = Both

Bdata

Biograph object

Details

The Nelson- Aalen estimator is obtained using the mvna package. First the function Biograph.mvna is called to convert the Biograph object to a data frame of class mvna. Then the mvna and the predict functions of the mvna package are called. The predict function produces cumulative hazards (with confidence intervals) at each birthday.

For estimating the cumulative occurrence-exposure rates, the functions Occup, Trans and RateTable are called (among other functions). The object M is produced; it is a three-dimensional array containing the transition rates by age, origin and destination in a standard format used in multistate demographic analysis.

Value

D

The Biograph object Bdata with diagonal elements removed

irate

Option for estimation of rates: (1) Nelson-Aalen, (2) Occurrence-exposure rates, (3) both

NeAa

Nelson-Aalen estimator

predicted

Cumulative transition rates (Nelson-Aalen estimator) predicted at consecutive ages (using predict function of mvna package)

astr

Age-specific transition rate by age, derived from predicted cumulative transition rates

oeCum

Cumulative occurrence-exposure rates

oe

The M-matrix of age-specific transition (occurrence-exposure) rates by origin and destination

Note

The function takes time to execute. It calls Parameters, date_convert, Remove.intrastate, statesequence.ind, Occup, Trans, RateTable, Rates.ac, Biograph.mvna and the mvna and predict functions of the mvna package.

Author(s)

Frans Willekens

Examples

    data(GLHS)
    Bdata.a <- date_b (GLHS,format.out="age",covs=c("marriage","LMentry"))
    cumrates <- Cumrates (irate = 3,Bdata=Bdata.a)
  

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Biograph)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Biograph/Cumrates.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Cumrates
> ### Title: Estimates cumulative transition rates
> ### Aliases: Cumrates
> 
> ### ** Examples
> 
>     data(GLHS)
>     Bdata.a <- date_b (GLHS,format.out="age",covs=c("marriage","LMentry"))
cmc_as_age: negative ages are replaced by NA
>     cumrates <- Cumrates (irate = 3,Bdata=Bdata.a)
[1] ". . . . . .  Removing intrastate transitions . . . . . "
[1] . . . . . .   Removes intrastate transitions . . . .
[1] . . . . Intrastate transitions removed. Recalculating transitions . . . . 
[1] ". . . . Running function Parameters . . . . "
[1] "Exploring types of transitions"
[1] A new Biograph object without intrastate transitions is returned.
[1] ". . . . . . Estimating rates . . . . ."
[1] "  "
[1] "Cumrates: calls function Biograph.mvna  . . . "
  ID born start      end    sex edu marriage  LMentry  cohort path      Tr1
1  1  351     0 52.66667   Male  17 27.33333 17.00000 1929-31   NJ 17.00000
2  2  357     0 52.16667 Female  10 33.75000 19.66667 1929-31  NJN 19.66667
3  3  473     0 42.50000 Female  11 33.08333 17.91667 1939-41  NJN 17.91667
4  4  604     0 31.58333 Female  13 22.33333 22.33333 1949-51  NJN 22.33333
5  5  377     0 50.50000   Male  11 27.00000 17.16667 1929-31   NJ 17.16667
       Tr2 Tr3 Tr4 Tr5 Tr6 Tr7 Tr8 Tr9 Tr10 Tr11 Tr12
1       NA  NA  NA  NA  NA  NA  NA  NA   NA   NA   NA
2 44.66667  NA  NA  NA  NA  NA  NA  NA   NA   NA   NA
3 29.66667  NA  NA  NA  NA  NA  NA  NA   NA   NA   NA
4 26.91667  NA  NA  NA  NA  NA  NA  NA   NA   NA   NA
5       NA  NA  NA  NA  NA  NA  NA  NA   NA   NA   NA
[1] No intra-state transitions present in the data.
[1] "      Biograph.mvna: Calls function Biograph.long . . . "
[1] . . . . .  Creating long format  . . . . . .
[1] . . . . .  running reshape  . . . . . 
[1]  . . . . Sort data in long format  . . . . 
[1]  . . . . Adjust long format for survival package etc . . .  
[1]      Biograph.mvna completed: Object produced by Biograph.mvna: .$mvna 
[1] "Cumrates 88"
[1] ". . . . . . . . . . . . "
[1] ". . . . Running mvna . . . . . . "
[1] Computing occurrence-exposure rates
[1] Running Sequences.ind
[1] Running Occup
[1] The number of age groups is 54
[1] ". . . . Running function Parameters . . . . "
[1] "Exploring types of transitions"
[1] ". . . .  Running Occup . . . . "
[1] ". . . . Running function Parameters . . . . "
[1] "Exploring types of transitions"
[1] "state_time: compute state.n"
[1] Running Trans
[1] Running RateTable
[1] Running Rates
>   
> 
> 
> 
> 
> dev.off()
null device 
          1 
>