Learn R Programming

MAPLES (version 1.0)

splitter: Creates a time-varying factor variables within a episode-data.

Description

Splits episode in sub-episodes according to the dates specified as input. The resulting dataframe contains a new time-varying factor variable with different user-defined values in each subinterval.

Usage

splitter(epdata, split, tvar.name = "Tvar", tvar.lev)

Arguments

epdata
a dataframe containing an episode-data file (obtained through the epdata command)
split
an array containing the date(s) at one (or more) specific event(s) that causes the change in the resulting time-varying variable. The original episode will be split at this date(s). If n vectors of dates have been spcified, the original episode
tvar.name
a string containing the name of the time-varying factor variable in the resulting dataframe.
tvar.lev
a vector of n+1 strings containing the level labels of the resulting time-varying variable (where n is the number of columns in the split argument).

Value

  • In the resulting dataframe each row is a subepisode obtained through the splitting procedure. The columns will be the same as the epdata argument plus one time-varying factor variable with levels specified through tvar.lev argument. In order to create several time-varying variables on the same dataframe, splitter procedure should be applied repeatedly for each new time-varying variable. At any step the input dataframe will be the resulting dataframe in the previous one.

Details

Split dates refer to event that can be experienced sequentially (first birth, second birth, third birth, ecc or first marriage, second marriage, third marriage, etc.). This implies that 1. Split dates must be strictly sequential: date1

References

Impicciatore R. and Billari F.C., (2010), MAPLES: a general method for the estimation of age profiles from standard demographic surveys (with an application to fertility), DEAS WP, http://ideas.repec.org/p/mil/wpdepa/2010-40.html

See Also

epdata, ageprofile, plotap

Examples

Run this code
# creates an episode-data structure relating to the transition 
# childless-->first child
ep1<-with(demogr,epdata(start=dbirth, event=dch1, rcensor=dint, 
          birth=dbirth,id=id,
          addvar=subset(demogr,select=c(-id,-dbirth)))) 

# creates a new episode-data structure with a time-varying factor 
# variable relating to the status "never married" (not_marr) or 
# "ever married" (marr)  
ep2<-splitter(ep1,split=ep1$d1marr,tvar.lev=c("not_marr","marr"),
              tvar.name="mar")

Run the code above in your browser using DataLab