Description Usage Arguments Value Examples

View source: R/transition_probabilities.R

Estimates transition probabilities of an individual's passage through a multi-state model by discrete event simulation.

1 2 3 4 | ```
predict_transitions(models, newdata, trans_mat, times, start_times = 0,
tcovs = NULL, N = 1e+05, M = 1000, ci = FALSE,
ci_margin = 0.95, agelimit = FALSE, agecol = "age",
agescale = 365.25)
``` |

`models` |
List of |

`newdata` |
Data frame with covariates of individual to simulate times for. Must contain all fields required by models. |

`trans_mat` |
Transition matrix, such as that used in |

`times` |
Times at which to estimate transition probabilities. |

`start_times` |
Conditional time for transition probability. |

`tcovs` |
As in |

`N` |
Number of times to repeat the individual |

`M` |
Number of times to run the simulations in order to obtain confidence interval estimates. |

`ci` |
Whether to calculate confidence intervals. See |

`ci_margin` |
Confidence interval range to use if |

`agelimit` |
Whether to automatically assign people to an 'early death' state.
This is useful as otherwise individuals can be assigned unrealistic time-to-events due to the
nature of sampling times from a random number distribution.
If this value is |

`agecol` |
The name of the column in |

`agescale` |
Any multiplication to be applied to the age covariate to put it onto the same time-scale as the simulation. This is often useful as time-to-event may be measured on a day-based time-scale while age is typically measured in years. |

A data frame with estimates of transition probabilities.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ```
library(multistateutils)
library(mstate)
library(flexsurv)
# Convert data to long
data(ebmt3)
tmat <- trans.illdeath()
long <- msprep(time=c(NA, 'prtime', 'rfstime'),
status=c(NA, 'prstat', 'rfsstat'),
data=ebmt3,
trans=tmat,
keep=c('age', 'dissub'))
# Fit parametric models
models <- lapply(1:3, function(i) {
flexsurvreg(Surv(time, status) ~ age + dissub, data=long, dist='weibull')
})
# New individual to estimate transition probabilities for
newdata <- data.frame(age="20-40", dissub="AML")
# Estimate transition probabilties at 1 year
predict_transitions(models, newdata, tmat, times=365)
# Estimate transition probabilties at 1 year given we know they're alive after 6 months
predict_transitions(models, newdata, tmat, times=365, start_times = 365/2)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.