@@ -34,7 +34,10 @@ singlearmOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
3434 ci95 = FALSE ,
3535 risktable = FALSE ,
3636 censored = FALSE ,
37- medianline = " none" , ... ) {
37+ medianline = " none" ,
38+ person_time = FALSE ,
39+ time_intervals = " 12, 36, 60" ,
40+ rate_multiplier = 100 , ... ) {
3841
3942 super $ initialize(
4043 package = " jsurvival" ,
@@ -195,6 +198,18 @@ singlearmOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
195198 " v" ,
196199 " hv" ),
197200 default = " none" )
201+ private $ ..person_time <- jmvcore :: OptionBool $ new(
202+ " person_time" ,
203+ person_time ,
204+ default = FALSE )
205+ private $ ..time_intervals <- jmvcore :: OptionString $ new(
206+ " time_intervals" ,
207+ time_intervals ,
208+ default = " 12, 36, 60" )
209+ private $ ..rate_multiplier <- jmvcore :: OptionInteger $ new(
210+ " rate_multiplier" ,
211+ rate_multiplier ,
212+ default = 100 )
198213
199214 self $ .addOption(private $ ..elapsedtime )
200215 self $ .addOption(private $ ..tint )
@@ -227,6 +242,9 @@ singlearmOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
227242 self $ .addOption(private $ ..risktable )
228243 self $ .addOption(private $ ..censored )
229244 self $ .addOption(private $ ..medianline )
245+ self $ .addOption(private $ ..person_time )
246+ self $ .addOption(private $ ..time_intervals )
247+ self $ .addOption(private $ ..rate_multiplier )
230248 }),
231249 active = list (
232250 elapsedtime = function () private $ ..elapsedtime $ value ,
@@ -259,7 +277,10 @@ singlearmOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
259277 ci95 = function () private $ ..ci95 $ value ,
260278 risktable = function () private $ ..risktable $ value ,
261279 censored = function () private $ ..censored $ value ,
262- medianline = function () private $ ..medianline $ value ),
280+ medianline = function () private $ ..medianline $ value ,
281+ person_time = function () private $ ..person_time $ value ,
282+ time_intervals = function () private $ ..time_intervals $ value ,
283+ rate_multiplier = function () private $ ..rate_multiplier $ value ),
263284 private = list (
264285 ..elapsedtime = NA ,
265286 ..tint = NA ,
@@ -291,7 +312,10 @@ singlearmOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
291312 ..ci95 = NA ,
292313 ..risktable = NA ,
293314 ..censored = NA ,
294- ..medianline = NA )
315+ ..medianline = NA ,
316+ ..person_time = NA ,
317+ ..time_intervals = NA ,
318+ ..rate_multiplier = NA )
295319)
296320
297321singlearmResults <- if (requireNamespace(" jmvcore" , quietly = TRUE )) R6 :: R6Class(
@@ -303,6 +327,8 @@ singlearmResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
303327 medianTable = function () private $ .items [[" medianTable" ]],
304328 survTableSummary = function () private $ .items [[" survTableSummary" ]],
305329 survTable = function () private $ .items [[" survTable" ]],
330+ personTimeTable = function () private $ .items [[" personTimeTable" ]],
331+ personTimeSummary = function () private $ .items [[" personTimeSummary" ]],
306332 plot = function () private $ .items [[" plot" ]],
307333 plot2 = function () private $ .items [[" plot2" ]],
308334 plot3 = function () private $ .items [[" plot3" ]],
@@ -446,6 +472,76 @@ singlearmResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
446472 " dxdate" ,
447473 " tint" ,
448474 " multievent" )))
475+ self $ add(jmvcore :: Table $ new(
476+ options = options ,
477+ name = " personTimeTable" ,
478+ title = " Person-Time Analysis" ,
479+ visible = " (person_time)" ,
480+ rows = 0 ,
481+ columns = list (
482+ list (
483+ `name` = " interval" ,
484+ `title` = " Time Interval" ,
485+ `type` = " text" ),
486+ list (
487+ `name` = " events" ,
488+ `title` = " Events" ,
489+ `type` = " integer" ),
490+ list (
491+ `name` = " person_time" ,
492+ `title` = " Person-Time" ,
493+ `type` = " number" ,
494+ `format` = " zto" ),
495+ list (
496+ `name` = " rate" ,
497+ `title` = " Incidence Rate" ,
498+ `type` = " number" ,
499+ `format` = " zto" ),
500+ list (
501+ `name` = " rate_ci_lower" ,
502+ `title` = " Lower" ,
503+ `superTitle` = " 95% CI" ,
504+ `type` = " number" ,
505+ `format` = " zto" ),
506+ list (
507+ `name` = " rate_ci_upper" ,
508+ `title` = " Upper" ,
509+ `superTitle` = " 95% CI" ,
510+ `type` = " number" ,
511+ `format` = " zto" )),
512+ clearWith = list (
513+ " outcome" ,
514+ " outcomeLevel" ,
515+ " elapsedtime" ,
516+ " rate_multiplier" ,
517+ " time_intervals" ,
518+ " person_time" ,
519+ " outcome" ,
520+ " outcomeLevel" ,
521+ " overalltime" ,
522+ " fudate" ,
523+ " dxdate" ,
524+ " tint" ,
525+ " multievent" )))
526+ self $ add(jmvcore :: Html $ new(
527+ options = options ,
528+ name = " personTimeSummary" ,
529+ title = " Person-Time Summary" ,
530+ visible = " (person_time)" ,
531+ clearWith = list (
532+ " outcome" ,
533+ " outcomeLevel" ,
534+ " elapsedtime" ,
535+ " rate_multiplier" ,
536+ " time_intervals" ,
537+ " person_time" ,
538+ " outcome" ,
539+ " outcomeLevel" ,
540+ " overalltime" ,
541+ " fudate" ,
542+ " dxdate" ,
543+ " tint" ,
544+ " multievent" )))
449545 self $ add(jmvcore :: Image $ new(
450546 options = options ,
451547 name = " plot" ,
@@ -572,7 +668,7 @@ singlearmBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
572668 super $ initialize(
573669 package = " jsurvival" ,
574670 name = " singlearm" ,
575- version = c(1 , 0 ,0 ),
671+ version = c(0 ,0 , 3 ),
576672 options = options ,
577673 results = singlearmResults $ new(options = options ),
578674 data = data ,
@@ -701,13 +797,24 @@ singlearmBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
701797# ' ticks on the survival curves.
702798# ' @param medianline If true, displays a line indicating the median survival
703799# ' time on the survival plot.
800+ # ' @param person_time Enable this option to calculate and display person-time
801+ # ' metrics, including total follow-up time and incidence rates. These metrics
802+ # ' help quantify the rate of events per unit of time in your study population.
803+ # ' @param time_intervals Specify time intervals for stratified person-time
804+ # ' analysis. Enter a comma-separated list of time points to create intervals.
805+ # ' For example, "12, 36, 60" will create intervals 0-12, 12-36, 36-60, and
806+ # ' 60+.
807+ # ' @param rate_multiplier Specify the multiplier for incidence rates (e.g.,
808+ # ' 100 for rates per 100 person-years, 1000 for rates per 1000 person-years).
704809# ' @return A results object containing:
705810# ' \tabular{llllll}{
706811# ' \code{results$todo} \tab \tab \tab \tab \tab a html \cr
707812# ' \code{results$medianSummary} \tab \tab \tab \tab \tab a preformatted \cr
708813# ' \code{results$medianTable} \tab \tab \tab \tab \tab a table \cr
709814# ' \code{results$survTableSummary} \tab \tab \tab \tab \tab a preformatted \cr
710815# ' \code{results$survTable} \tab \tab \tab \tab \tab a table \cr
816+ # ' \code{results$personTimeTable} \tab \tab \tab \tab \tab a table \cr
817+ # ' \code{results$personTimeSummary} \tab \tab \tab \tab \tab a html \cr
711818# ' \code{results$plot} \tab \tab \tab \tab \tab an image \cr
712819# ' \code{results$plot2} \tab \tab \tab \tab \tab an image \cr
713820# ' \code{results$plot3} \tab \tab \tab \tab \tab an image \cr
@@ -753,7 +860,10 @@ singlearm <- function(
753860 ci95 = FALSE ,
754861 risktable = FALSE ,
755862 censored = FALSE ,
756- medianline = " none" ) {
863+ medianline = " none" ,
864+ person_time = FALSE ,
865+ time_intervals = " 12, 36, 60" ,
866+ rate_multiplier = 100 ) {
757867
758868 if ( ! requireNamespace(" jmvcore" , quietly = TRUE ))
759869 stop(" singlearm requires jmvcore to be installed (restart may be required)" )
@@ -800,7 +910,10 @@ singlearm <- function(
800910 ci95 = ci95 ,
801911 risktable = risktable ,
802912 censored = censored ,
803- medianline = medianline )
913+ medianline = medianline ,
914+ person_time = person_time ,
915+ time_intervals = time_intervals ,
916+ rate_multiplier = rate_multiplier )
804917
805918 analysis <- singlearmClass $ new(
806919 options = options ,
0 commit comments