wbMarkov: Markov test function

Description Usage Arguments Examples

View source: R/wbMarkov.R

Description

Produces the grid and the point test of the Markov assumption.

Usage

1
wbMarkov(time_grid, data, grp1, grp2, trans, n_boot, ...)

Arguments

time_grid

landmark time grid.

data

multi state date to be tested.

grp1

landmark group 1.

grp2

landmark group 2.

trans

transitions to be tested.

n_boot

number of bootsrap samples of test statistics under the null hypothesis of being Markov.

Examples

 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
################ Example 1: Dynamic intensity update
## Matrix of determaning interarrval distribution for each transition
jump_types <- matrix(
  c(NA,"exp", "exp",
    "exp", NA, "exp",
    NA, NA, NA), 3, 3, byrow = T)
tmat <- tmat_function(jump_types)

## Form parameter list acording to tmat numbers
lambda <- matrix(c(NA, 0.12, 0.03,
                   0.15, NA, 0.1,
                   NA, NA, NA), 3, 3, byrow = T)

## list of parameters
par_list2 <- list(lambda = lambda)



## update function to dynamicly update interarrival distributions
lambda_update <- function(lambda, vsts, state, jump_time, i, id){

  # individual frailty at transition 4
  if(state[i] == 2){
    lambda[2,1] <-  0.15 * frail[id]
  }

  lambda
}


frail <- rep_rgamma(n = 1000, var = 0.4)
data_sim <- sim_fun(init_probs = c(1,0,0), jump_types, pars = par_list2,
                    cens_time = 1000, nbr = 1000, hist_dep = T)


wb <- wbMarkov(time_grid = s_grid, data = df1$long_data, grp1 = 1,
               grp2 = 2, trans = c(1,2,3,4), n_boot = 100)


wb_frames <- frames_wbMarkov(wb)

## plot of bootsraded distriubtions (global then local)
plot_wbMarkov(wb)
plot_wbMarkov(wb, type = "point", time_pt = 6)

niklasmaltzahn/multistate documentation built on Nov. 4, 2019, 10:06 p.m.