@@ -58,7 +58,13 @@ h_coef_table <- function(object) {
5858 colnames(coef_table ),
5959 identical.to = c(" est" , " se" , " df" , " t_stat" , " p_val" )
6060 )
61- colnames(coef_table ) <- c(" Estimate" , " Std. Error" , " df" , " t value" , " Pr(>|t|)" )
61+ colnames(coef_table ) <- c(
62+ " Estimate" ,
63+ " Std. Error" ,
64+ " df" ,
65+ " t value" ,
66+ " Pr(>|t|)"
67+ )
6268
6369 coef_aliased <- component(object , " beta_aliased" )
6470 if (any(coef_aliased )) {
@@ -89,11 +95,20 @@ summary.mmrm <- function(object, ...) {
8995 )
9096 coefficients <- h_coef_table(object )
9197 call <- stats :: getCall(object )
92- components <- component(object , c(
93- " cov_type" , " reml" , " n_groups" , " n_theta" ,
94- " n_subjects" , " n_timepoints" , " n_obs" ,
95- " beta_vcov" , " varcor"
96- ))
98+ components <- component(
99+ object ,
100+ c(
101+ " cov_type" ,
102+ " reml" ,
103+ " n_groups" ,
104+ " n_theta" ,
105+ " n_subjects" ,
106+ " n_timepoints" ,
107+ " n_obs" ,
108+ " beta_vcov" ,
109+ " varcor"
110+ )
111+ )
97112 components $ method <- object $ method
98113 components $ vcov <- object $ vcov
99114 structure(
@@ -129,8 +144,15 @@ h_print_call <- function(call, n_obs, n_subjects, n_timepoints) {
129144 }
130145 if (! is.null(call $ data )) {
131146 cat(
132- " Data: " , deparse(call $ data ), " (used" , n_obs , " observations from" ,
133- n_subjects , " subjects with maximum" , n_timepoints , " timepoints)" ,
147+ " Data: " ,
148+ deparse(call $ data ),
149+ " (used" ,
150+ n_obs ,
151+ " observations from" ,
152+ n_subjects ,
153+ " subjects with maximum" ,
154+ n_timepoints ,
155+ " timepoints)" ,
134156 fill = TRUE
135157 )
136158 }
@@ -152,7 +174,8 @@ h_print_cov <- function(cov_type, n_theta, n_groups) {
152174 assert_string(cov_type )
153175 assert_count(n_theta , positive = TRUE )
154176 assert_count(n_groups , positive = TRUE )
155- cov_definition <- switch (cov_type ,
177+ cov_definition <- switch (
178+ cov_type ,
156179 us = " unstructured" ,
157180 toep = " Toeplitz" ,
158181 toeph = " heterogeneous Toeplitz" ,
@@ -182,8 +205,7 @@ h_print_cov <- function(cov_type, n_theta, n_groups) {
182205# ' @param digits (`number`)\cr number of decimal places used with [round()].
183206# '
184207# ' @keywords internal
185- h_print_aic_list <- function (aic_list ,
186- digits = 1 ) {
208+ h_print_aic_list <- function (aic_list , digits = 1 ) {
187209 diag_vals <- round(unlist(aic_list ), digits )
188210 diag_vals <- format(diag_vals )
189211 print(diag_vals , quote = FALSE )
@@ -192,10 +214,12 @@ h_print_aic_list <- function(aic_list,
192214# ' @describeIn mmrm_methods prints the MMRM fit summary.
193215# ' @exportS3Method
194216# ' @keywords internal
195- print.summary.mmrm <- function (x ,
196- digits = max(3 , getOption(" digits" ) - 3 ),
197- signif.stars = getOption(" show.signif.stars" ), # nolint
198- ... ) {
217+ print.summary.mmrm <- function (
218+ x ,
219+ digits = max(3 , getOption(" digits" ) - 3 ),
220+ signif.stars = getOption(" show.signif.stars" ), # nolint
221+ ...
222+ ) {
199223 cat(" mmrm fit\n\n " )
200224 h_print_call(x $ call , x $ n_obs , x $ n_subjects , x $ n_timepoints )
201225 h_print_cov(x $ cov_type , x $ n_theta , x $ n_groups )
@@ -209,7 +233,12 @@ print.summary.mmrm <- function(x,
209233 cat(" \n " )
210234 cat(" Coefficients: " )
211235 if (x $ n_singular_coefs > 0 ) {
212- cat(" (" , x $ n_singular_coefs , " not defined because of singularities)" , sep = " " )
236+ cat(
237+ " (" ,
238+ x $ n_singular_coefs ,
239+ " not defined because of singularities)" ,
240+ sep = " "
241+ )
213242 }
214243 cat(" \n " )
215244 stats :: printCoefmat(
@@ -248,10 +277,15 @@ confint.mmrm <- function(object, parm, level = 0.95, ...) {
248277 check_subset(parm , pnames ),
249278 check_integerish(parm , lower = 1L , upper = length(cf ))
250279 )
251- if (is.numeric(parm )) parm <- pnames [parm ]
280+ if (is.numeric(parm )) {
281+ parm <- pnames [parm ]
282+ }
252283 assert_number(level , lower = 0 , upper = 1 )
253284 a <- (1 - level ) / 2
254- pct <- paste(format(100 * c(a , 1 - a ), trim = TRUE , scientific = FALSE , digits = 3 ), " %" )
285+ pct <- paste(
286+ format(100 * c(a , 1 - a ), trim = TRUE , scientific = FALSE , digits = 3 ),
287+ " %"
288+ )
255289 coef_table <- h_coef_table(object )
256290 df <- coef_table [parm , " df" ]
257291 ses <- coef_table [parm , " Std. Error" ]
@@ -263,7 +297,6 @@ confint.mmrm <- function(object, parm, level = 0.95, ...) {
263297}
264298
265299
266-
267300# ' Analysis of Variance for `mmrm` Fits
268301# '
269302# ' If supplied only one model fit, the function will calculate and return the
@@ -443,16 +476,13 @@ confint.mmrm <- function(object, parm, level = 0.95, ...) {
443476# ' # If a model was created with a different data set, refit = TRUE is needed.
444477# ' anova(fit_sex_ar1, fit_sex_race_toeph_sub, fit_interaction_us, refit = TRUE)
445478anova.mmrm <- function (object , ... , test = TRUE , refit = FALSE ) {
446-
447479 assert_class(object , " mmrm" )
448480
449481 fits <- list (object , ... )
450482
451483 if (length(fits ) == 1L ) {
452484 out <- h_anova_single_mmrm_model(object )
453-
454485 } else {
455-
456486 # Ensure all objects in ... are mmrm fits.
457487 lapply(fits [- 1L ], assert_class , classes = " mmrm" , .var.name = " ..." )
458488
@@ -498,7 +528,6 @@ anova.mmrm <- function(object, ..., test = TRUE, refit = FALSE) {
498528 )
499529
500530 if (test ) {
501-
502531 h_assert_lrt_suitability(fits , refit , dfs = out $ df , is_reml = out $ REML )
503532
504533 model_indices_except_last <- out $ Model [- length(fits )]
@@ -508,7 +537,8 @@ anova.mmrm <- function(object, ..., test = TRUE, refit = FALSE) {
508537 # first element to be NA because a pair of models is the previous row's
509538 # model plus the current row's model.
510539 out $ test <-
511- c(NA_character_ ,
540+ c(
541+ NA_character_ ,
512542 paste(model_indices_except_last , " vs" , model_indices_except_first )
513543 )
514544
@@ -524,7 +554,6 @@ anova.mmrm <- function(object, ..., test = TRUE, refit = FALSE) {
524554
525555 fit_calls <- lapply(fits , component , " call" )
526556 out $ call <- vapply(fit_calls , deparse1 , FUN.VALUE = character (1L ))
527-
528557 }
529558
530559 class(out ) <- union(" anova.mmrm" , class(out ))
0 commit comments