knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Recently, the FDA has recommended ICC(A,1). Refer to this article: https://link.springer.com/article/10.1007/s11136-018-2076-0
COA34::compute_iccA1
is just a wrapper for the icc
function in the irr
R package. This R function just makes it easier to compute the values and output the tables. The underlying code is available here: https://github.com/cran/irr/blob/master/R/icc.R
Figure out what the generating value is - is it the residual correlation? Sim study needed!
Explore further how MAR/MNAR drop-out severely attenuates the ICC(A,1) value
print.dir = "C:/Users/ciaconangelo/OneDrive - OPEN Health/Documents/misc_R_table_output"
library(COA34) # In addition, you'll need the following library(ggplot2) library(grid) library(gridExtra)
set.seed(12162021) sim.out <- COA34::sim_pro_dat_v2(N=1000, number.timepoints = 3, Beta.PRO = NULL, number.of.anchor.groups = 5, polychor.value = 0.7, corr = 'ar1', cor.value = 0.8, #var.values = c(7.136)) var.values = c(2)) dat <- sim.out$dat
dat <- COA34::dropout(dat = dat, type_dropout = c('mcar', 'mar', 'mnar'), prop.miss = 0.5, stochastic.component = 0.2)
# Simulate IRT items # use the scores generated as the theta in the IRT model sim.out2 <- COA34::sim_irt_item(dat = dat, J = 5, K = 4, latent.variable = 'Y_comp') str(sim.out2) dat <- sim.out2$dat # Score the PRO - just take a simple sum score here: dat$PRO.score <- apply(dat[, grep('Item', colnames(dat))], 1, sum) # Create the same PRO score, but with MAR drop-out: dat$PRO.score_mar <- dat$PRO.score dat$PRO.score_mar[is.na(dat$Y_mar)] <- NA # Note that you've just set the PRO score to missing wherever the Y_mar variable is missing # Now for the other missing types: dat$PRO.score_mcar <- dat$PRO.score_mnar <- dat$PRO.score dat$PRO.score_mcar[is.na(dat$Y_mcar)] <- NA dat$PRO.score_mnar[is.na(dat$Y_mnar)] <- NA aggregate(cbind(PRO.score, PRO.score_mcar, PRO.score_mar, PRO.score_mnar) ~ Time, function(x) mean(x, na.rm = T), data = dat, na.action = na.pass)
# You already have the PGIS_bl and PGIS_delta in the generated data, # you wouldn't have that in a real dataset, so drop that first dat <- dat[, !(colnames(dat) %in% c('PGIS_bl', 'PGIS_delta'))] # This makes this more realistic # use the function below: dat <- COA34::compute_anchor_delta(dat = dat, subject.id = 'USUBJID', time.var = 'Time', anchor = 'PGIS')
dat <- COA34::compute_change_score(dat = dat, subject.id = 'USUBJID', time.var = 'Time', score = c('PRO.score', 'PRO.score_mcar', 'PRO.score_mar', 'PRO.score_mnar')) # The function creates variables with the same name plus "_delta": str(dat)
Compute the ICC(A,1) values and output them to a table:
icc <- COA34::compute_iccA1(dat = dat, PRO.score = c('PRO.score', 'PRO.score_mcar', 'PRO.score_mar', 'PRO.score_mnar'), time.var = 'Time', subject.id = 'USUBJID', anchor = 'PGIS_delta', stable.score = 0, first.timepoint = 'Time_1', second.timepoint = 'Time_2')
Print the table out:
library(R2Word) R2Word::dump_df_mat_to_file(out = icc$icc.A1, decimals = c(2, 0, 0), table.title = 'ICC(A,1) - Vignette Illustration', table.footnote = '**All data simulated', file.name = 'trtr_vig_iccA1', print.dir = print.dir)
If you're putting together shell tables, use the function shell_table
, specifying that you want columns 2 and 3 to be converted to x instead of the numeric values.
st <- R2Word::shell_table(out = icc$icc.A1, decimals = c(2, 0), cols = c(2, 3)) R2Word::dump_df_mat_to_file(out = st, decimals = 0, table.title = 'ICC(A,1) - Vignette Illustration', table.footnote = '**All data simulated', file.name = 'trtr_vig_iccA1_shell_tables', print.dir = print.dir)
Is it the correlation between the two timepoints? That is equal to 0.80.
sim.out$cor.mat
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.