CreateTrans {bayesmlogit} | R Documentation |
Create Transition Vector
Description
A function used to create transition vectors with data in long format, which requires the dplyr
package.
Usage
CreateTrans(ID, Age, State, Death, states)
Arguments
ID |
A vector that specifies the ID for each subject. |
Age |
A vector that indicates each subject's age at this visit. |
State |
A vector or a factor that indicates the state for each subject at this visit. |
Death |
A vector that indicates whether the subject died or not at this visit. |
states |
The total number of states in our data. |
Details
The rules for creating transitions can be found with ?lifedata
. In essence, arrange the data in long format, including details about the present state at time t. This procedure will assist in generating a dataset in long format that captures transitions by utilizing states from both time t-1 and t.
Value
A vector that contains all transitions.
See Also
Examples
ID <- rep(1:50, each = 5)
Age <- rep(31:35, times = 50)
State <- sample(1:5,size=250,replace=TRUE)
Death <- rep(c(0,0,0,0,1),times=50)
Example <- data.frame(ID,Age,State,Death)
Example$trans <- CreateTrans(Example$ID,Example$Age, Example$State,Example$Death,states=6)
[Package bayesmlogit version 1.0.1 Index]