msboxes_R: msboxes_R

View source: R/msboxes_R.R

msboxes_RR Documentation

msboxes_R

Description

msboxes_R will create a json file containing parameters that will help MSMplus to automatically create the multi-state graph of each specific setting. However, the user has the option to design and create the multistate graph within the app as well.

Usage

msboxes_R(
  data,
  id,
  yb,
  xb,
  boxwidth = 0.1,
  boxheight = 0.1,
  tstop,
  vartime = 1,
  tmatrix,
  scale = 1,
  msm = FALSE,
  jsonpath = NULL,
  name = "msboxes_R.json"
)

Arguments

data

Provide a dataset that is properly formatted for a multi-state analysis (eg. after msprep())

id

Provide an indentity variable

yb

Provide a vector of values for the y coordinates of the state boxes of the multi-state graph you want to create

xb

Provide a vector of values for the x coordinates of the state boxes of the multi-state graph you want to create

boxwidth

Provide the width of the state boxes of the multi-state graph you want to create (default 0.1)

boxheight

Provide the height of the state boxes of the multi-state graph you want to create (default 0.1)

tstop

Provide the Tstop variable of your dataset

vartime

A vector of time points at which the user wants to count the number of people in each state and the number of people that have made each transition

tmatrix

The transition matrix (e.g transMat(x = list(c(2, 3),c(3), c() )) ).

scale

rescale time value

msm

In case the msm package is used, the function uses statetable.msm to calculate the frequencies.Default: FALSE

jsonpath

specify the path of the folder that the json file should be saved, Default: "" saves the json file to the current working directory

name

Specify the name of the output json file, Default: 'msboxes_R.json'

Details

DETAILS

Value

Nstates, Ntransitions, xvalues, yvalues,boxwidth, boxheight, statenames, transnames, the start and end coordinates of the arrows that connect the state boxes, tmat, number of people in each state and the number of people that have made each transition

Examples

## Not run: 

 #EXAMPLE
 
 library("mstate")
 library("dplyr")
 library("RJSONIO")
head(ebmt)

tmat <- transMat(x = list(c(2, 3),c(3), c() ), names = c("Transplant", "Platelet Recovery", "Relapse/Death" ) )

ebmt$age2=  recode(ebmt$age, ">40" =0, "20-40"=1,"<=20" =0 )
ebmt$age3=  recode(ebmt$age, ">40" =1, "20-40"=0,"<=20" =0 )

msebmt <- msprep(data = ebmt, trans = tmat, time = c(NA, "prtime", "rfstime"), status = c(NA, "prstat", "rfsstat"), keep=c("age2","age3"))


results=MSMplus::msboxes_R(data=msebmt,id= msebmt$id, yb=c(0.3,0.5,0.75),
                              xb=c(0.5,0.2,0.7),boxwidth=0.1,boxheight=0.1,
                              tmatrix= tmat, tstop=msebmt$Tstop,vartime=c(seq(0,10,by=1)),scale=365.25,
                              jsonpath="", name="msboxes_EBMT_R.json" ) 

results
 

## End(Not run)

nskourlis/MSMplus documentation built on Dec. 7, 2023, 4:53 a.m.