R/RcppExports.R

Defines functions gillespie

Documented in gillespie

# This file was generated by Rcpp::compileAttributes
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' The Gillespie algorithm for simulating continuous time Markov chains.
#'
#' This function is called by \code{\link{Simulate.EventSim}} 
#'
#' @param start_states an integer vector giving the start states for each patient
#' @param start_times a numeric vector containing the calendar time at which each patient is recruited 
#' @param n_state an integer, the number of states on the underlying DAG 
#' @param rates A list of \code{n_state * n_state * length(patientEndTime)} transition rates
#' @param patientEndTimes The ith \code{n_state*n_state} block of rates represents the transition
#' rate matrix until patient time patientEndTimes[i]
#' @param calendarEndTimes The ith \code{n_state*n_state} block of rates represents the transition
#' rate matrix until calendar time calendarEndTimes[i]
#' @param shape The shape parameter for the edges in the DAG. A matrix where shape[i,j] is the Weibull
#' shape parameter for the edge from node i to node j. If there is no edge between i and j
#' then shape[i,j] = 0.
#' @param resetEdges A vector (from1,to1,from2,to2,...) of edges for which if a subject traverses 
#' one of these edges then patient time switches are reset. See \code{SetIsResetEdge.ProgressionGraph} for further 
#' details
#' @param duration The total (patient) time each subject is to be simulated 
#' @return A data frame with columns "id", "state" and "patient_transition_time" listing the (patient) time at
#' which patients transition into new states. For example
#' 
#' id state patient_transition_time
#' 1   1      0.0
#' 1   2      1.4
#' 
#' patient 1 transitions to state 1 at time 0 (w.r.t. patient time) and then at time 1.4 transitions
#' to state 2
gillespie <- function(start_states, start_times, n_state, rates, patientEndTimes, calendarEndTimes, shape, resetEdges, duration) {
    .Call('badminton_gillespie', PACKAGE = 'badminton', start_states, start_times, n_state, rates, patientEndTimes, calendarEndTimes, shape, resetEdges, duration)
}
scientific-computing-solutions/badminton documentation built on May 29, 2019, 3:43 p.m.