@@ -147,8 +147,14 @@ CoxRun <- function(model, df, a_n = list(c(0)), keep_constant = c(0), control =
147147model_control [[" gmix_theta" ]]<- coxmodel $ gmix_theta
148148 }
149149 }
150- if (coxmodel $ strata != " NONE" ) {
150+ if (all( coxmodel $ strata != " NONE" ) ) {
151151model_control [[" strata" ]]<- TRUE
152+ #
153+ df $ " _strata_col" <- format(df [,strat_col [1 ],with = FALSE ])# defining a strata column
154+ for (i in seq_len(length(strat_col )- 1 )) {
155+ df $ " _strata_col" <- paste(df $ " _strata_col" , format(df [,strat_col [i + 1 ],with = FALSE ]),sep = " _" )# interacting with any other strata columns
156+ }
157+ df $ " _strata_col" <- factor (df $ " _strata_col" )# converting to a factor
152158 }
153159if (coxmodel $ weight != " NONE" ) {
154160model_control [[" cr" ]]<- TRUE
@@ -198,7 +204,7 @@ CoxRun <- function(model, df, a_n = list(c(0)), keep_constant = c(0), control =
198204 }
199205 }
200206# ------------------------------------------------------------------------------ #
201- res <- RunCoxRegression_Omnibus(df ,time1 ,time2 ,event0 ,names ,term_n ,tform ,keep_constant ,a_n ,modelform ,control ,strat_col ,cens_weight ,model_control ,cons_mat ,cons_vec )
207+ res <- RunCoxRegression_Omnibus(df ,time1 ,time2 ,event0 ,names ,term_n ,tform ,keep_constant ,a_n ,modelform ,control ," _strata_col " ,cens_weight ,model_control ,cons_mat ,cons_vec )
202208if (int_count > 0 ) {
203209control $ thres_step_max <- control $ thres_step_max * (int_avg_weight / int_count )
204210 }
@@ -734,8 +740,14 @@ CaseControlRun <- function(model, df, a_n = list(c(0)), keep_constant = c(0), co
734740model_control [[" gmix_theta" ]]<- caseconmodel $ gmix_theta
735741 }
736742 }
737- if (caseconmodel $ strata != " NONE" ) {
743+ if (all( caseconmodel $ strata != " NONE" ) ) {
738744model_control [[" strata" ]]<- TRUE
745+ #
746+ df $ " _strata_col" <- format(df [,strat_col [1 ],with = FALSE ])# defining a strata column
747+ for (i in seq_len(length(strat_col )- 1 )) {
748+ df $ " _strata_col" <- paste(df $ " _strata_col" , format(df [,strat_col [i + 1 ],with = FALSE ]),sep = " _" )# interacting with any other strata columns
749+ }
750+ df $ " _strata_col" <- factor (df $ " _strata_col" )# converting to a factor
739751 }
740752if (time1 != time2 ) {
741753model_control [[" time_risk" ]]<- TRUE
@@ -786,7 +798,7 @@ CaseControlRun <- function(model, df, a_n = list(c(0)), keep_constant = c(0), co
786798 }
787799 }
788800# ------------------------------------------------------------------------------ #
789- res <- RunCaseControlRegression_Omnibus(df ,time1 ,time2 ,event0 ,names ,term_n ,tform ,keep_constant ,a_n ,modelform ,control ,strat_col ,cens_weight ,model_control ,cons_mat ,cons_vec )
801+ res <- RunCaseControlRegression_Omnibus(df ,time1 ,time2 ,event0 ,names ,term_n ,tform ,keep_constant ,a_n ,modelform ,control ," _strata_col " ,cens_weight ,model_control ,cons_mat ,cons_vec )
790802if (int_count > 0 ) {
791803control $ thres_step_max <- control $ thres_step_max * (int_avg_weight / int_count )
792804 }
@@ -1207,9 +1219,15 @@ plot.coxres <- function(x, df, plot_options, a_n = c(), ...) {
12071219 }else {
12081220 stop(" Error: control argument must be a list" )
12091221 }
1210- if (coxmodel $ strata != " NONE" ) {
1222+ if (all( coxmodel $ strata != " NONE" ) ) {
12111223plot_options [[" strat_haz" ]]<- TRUE
1212- plot_options $ strat_col <- strat_col
1224+ plot_options $ strat_col <- " _strata_col"
1225+ #
1226+ df $ " _strata_col" <- format(df [,strat_col [1 ],with = FALSE ])# defining a strata column
1227+ for (i in seq_len(length(strat_col )- 1 )) {
1228+ df $ " _strata_col" <- paste(df $ " _strata_col" , format(df [,strat_col [i + 1 ],with = FALSE ]),sep = " _" )# interacting with any other strata columns
1229+ }
1230+ df $ " _strata_col" <- factor (df $ " _strata_col" )# converting to a factor
12131231 }
12141232 RunCoxPlots(df ,time1 = time1 ,time2 = time2 ,event0 = event0 ,names = names ,term_n = term_n ,tform = tform ,keep_constant = keep_constant ,a_n = a_n ,modelform = modelform ,control = control ,plot_options = plot_options ,model_control = model_control )
12151233}
@@ -1352,8 +1370,14 @@ CoxRunMulti <- function(model, df, a_n = list(c(0)), keep_constant = c(0), reali
13521370model_control [[" gmix_theta" ]]<- coxmodel $ gmix_theta
13531371 }
13541372 }
1355- if (coxmodel $ strata != " NONE" ) {
1373+ if (all( coxmodel $ strata != " NONE" ) ) {
13561374model_control [[" strata" ]]<- TRUE
1375+ #
1376+ df $ " _strata_col" <- format(df [,strat_col [1 ],with = FALSE ])# defining a strata column
1377+ for (i in seq_len(length(strat_col )- 1 )) {
1378+ df $ " _strata_col" <- paste(df $ " _strata_col" , format(df [,strat_col [i + 1 ],with = FALSE ]),sep = " _" )# interacting with any other strata columns
1379+ }
1380+ df $ " _strata_col" <- factor (df $ " _strata_col" )# converting to a factor
13571381 }
13581382if (coxmodel $ weight != " NONE" ) {
13591383model_control [[" cr" ]]<- TRUE
@@ -1389,7 +1413,7 @@ CoxRunMulti <- function(model, df, a_n = list(c(0)), keep_constant = c(0), reali
13891413 }
13901414 }
13911415# ------------------------------------------------------------------------------ #
1392- res <- RunCoxRegression_Omnibus_Multidose(df ,time1 = time1 ,time2 = time2 ,event0 = event0 ,names = names ,term_n = term_n ,tform = tform ,keep_constant = keep_constant ,a_n = a_n ,modelform = modelform ,realization_columns = realization_columns ,realization_index = realization_index ,control = control ,strat_col = strat_col ,cens_weight = cens_weight ,model_control = model_control ,cons_mat = cons_mat ,cons_vec = cons_vec )
1416+ res <- RunCoxRegression_Omnibus_Multidose(df ,time1 = time1 ,time2 = time2 ,event0 = event0 ,names = names ,term_n = term_n ,tform = tform ,keep_constant = keep_constant ,a_n = a_n ,modelform = modelform ,realization_columns = realization_columns ,realization_index = realization_index ,control = control ,strat_col = " _strata_col " ,cens_weight = cens_weight ,model_control = model_control ,cons_mat = cons_mat ,cons_vec = cons_vec )
13931417res $ model <- coxmodel
13941418res $ modelcontrol <- model_control
13951419res $ control <- control
@@ -1696,6 +1720,15 @@ LikelihoodBound.coxres <- function(x, df, curve_control = list(), control = list
16961720 }
16971721 }
16981722#
1723+ if (all(strat_col != " NONE" )) {
1724+ #
1725+ df $ " _strata_col" <- format(df [,strat_col [1 ],with = FALSE ])# defining a strata column
1726+ for (i in seq_len(length(strat_col )- 1 )) {
1727+ df $ " _strata_col" <- paste(df $ " _strata_col" , format(df [,strat_col [i + 1 ],with = FALSE ]),sep = " _" )# interacting with any other strata columns
1728+ }
1729+ df $ " _strata_col" <- factor (df $ " _strata_col" )# converting to a factor
1730+ }
1731+ #
16991732norm_res <- apply_norm(df ,norm ,names ,TRUE ,list (" a_n" = a_n ," cons_mat" = cons_mat ," tform" = tform ),model_control )
17001733a_n <- norm_res $ a_n
17011734cons_mat <- norm_res $ cons_mat
@@ -1719,10 +1752,10 @@ LikelihoodBound.coxres <- function(x, df, curve_control = list(), control = list
17191752 }
17201753#
17211754if (" bisect" %in% names(model_control )) {
1722- res <- CoxCurveSolver(df ,time1 = time1 ,time2 = time2 ,event0 = event0 ,names = names ,term_n = term_n ,tform = tform ,keep_constant = keep_constant ,a_n = a_n ,modelform = modelform ,control = control ,strat_col = strat_col ,cens_weight = cens_weight ,model_control = model_control ,cons_mat = cons_mat ,cons_vec = cons_vec )
1755+ res <- CoxCurveSolver(df ,time1 = time1 ,time2 = time2 ,event0 = event0 ,names = names ,term_n = term_n ,tform = tform ,keep_constant = keep_constant ,a_n = a_n ,modelform = modelform ,control = control ,strat_col = " _strata_col " ,cens_weight = cens_weight ,model_control = model_control ,cons_mat = cons_mat ,cons_vec = cons_vec )
17231756res $ method <- " bisection"
17241757 }else {
1725- res <- RunCoxRegression_Omnibus(df ,time1 = time1 ,time2 = time2 ,event0 = event0 ,names = names ,term_n = term_n ,tform = tform ,keep_constant = keep_constant ,a_n = a_n ,modelform = modelform ,control = control ,strat_col = strat_col ,cens_weight = cens_weight ,model_control = model_control ,cons_mat = cons_mat ,cons_vec = cons_vec )
1758+ res <- RunCoxRegression_Omnibus(df ,time1 = time1 ,time2 = time2 ,event0 = event0 ,names = names ,term_n = term_n ,tform = tform ,keep_constant = keep_constant ,a_n = a_n ,modelform = modelform ,control = control ,strat_col = " _strata_col " ,cens_weight = cens_weight ,model_control = model_control ,cons_mat = cons_mat ,cons_vec = cons_vec )
17261759res $ method <- " Venzon-Moolgavkar"
17271760 }
17281761res $ model <- coxmodel
@@ -1735,6 +1768,15 @@ LikelihoodBound.coxres <- function(x, df, curve_control = list(), control = list
17351768 }else if (tolower(norm )%in% c(" max" ," mean" )) {
17361769# weight by the maximum value
17371770res $ Parameter_Limits <- res $ Parameter_Limits / norm_weight [model_control $ para_number ]
1771+ for (i in seq_along(names )) {
1772+ if (grepl(" _int" ,tform [i ])) {
1773+ res $ Lower_Values [i ]<- res $ Lower_Values [i ]* norm_weight [i ]
1774+ res $ Upper_Values [i ]<- res $ Upper_Values [i ]* norm_weight [i ]
1775+ }else {
1776+ res $ Lower_Values [i ]<- res $ Lower_Values [i ]/ norm_weight [i ]
1777+ res $ Upper_Values [i ]<- res $ Upper_Values [i ]/ norm_weight [i ]
1778+ }
1779+ }
17381780 }else {
17391781 stop(gettextf(
17401782" Error: Normalization arguement '%s' not valid." ,
@@ -1876,6 +1918,15 @@ LikelihoodBound.poisres <- function(x, df, curve_control = list(), control = lis
18761918 }else if (tolower(norm )%in% c(" max" ," mean" )) {
18771919# weight by the maximum value
18781920res $ Parameter_Limits <- res $ Parameter_Limits / norm_weight [model_control $ para_number ]
1921+ for (i in seq_along(names )) {
1922+ if (grepl(" _int" ,tform [i ])) {
1923+ res $ Lower_Values [i ]<- res $ Lower_Values [i ]* norm_weight [i ]
1924+ res $ Upper_Values [i ]<- res $ Upper_Values [i ]* norm_weight [i ]
1925+ }else {
1926+ res $ Lower_Values [i ]<- res $ Lower_Values [i ]/ norm_weight [i ]
1927+ res $ Upper_Values [i ]<- res $ Upper_Values [i ]/ norm_weight [i ]
1928+ }
1929+ }
18791930 }else {
18801931 stop(gettextf(
18811932" Error: Normalization arguement '%s' not valid." ,
@@ -2207,8 +2258,9 @@ EventAssignment.poisresbound <- function(x, df, assign_control = list(), control
22072258 }
22082259 }
22092260# Start with low
2210- a_n <- object $ beta_0
2211- a_n [check_num ]<- Parameter_Limits [1 ]
2261+ a_n <- x $ Lower_Values
2262+ # a_n <- object$beta_0
2263+ # a_n[check_num] <- Parameter_Limits[1]
22122264# Get the new optimum values
22132265if (model_control [[" constraint" ]]) {
22142266low_res <- PoisRun(object ,df ,control = control ,norm = norm ,cons_mat = cons_mat ,cons_vec = cons_vec ,keep_constant = keep_constant ,a_n = a_n )
@@ -2223,8 +2275,9 @@ EventAssignment.poisresbound <- function(x, df, assign_control = list(), control
22232275model_control
22242276 )
22252277# Now the high
2226- a_n <- object $ beta_0
2227- a_n [check_num ]<- Parameter_Limits [2 ]
2278+ a_n <- x $ Upper_Values
2279+ # a_n <- object$beta_0
2280+ # a_n[check_num] <- Parameter_Limits[2]
22282281# Get the new optimum values
22292282if (model_control [[" constraint" ]]) {
22302283high_res <- PoisRun(object ,df ,control = control ,norm = norm ,cons_mat = cons_mat ,cons_vec = cons_vec ,keep_constant = keep_constant ,a_n = a_n )