Skip to content

Commit

Permalink
Update to accommodate frailty SD in print functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromafonso committed Feb 9, 2022
1 parent 8fa62b1 commit a08aad4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion R/basic_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ summary.jm <- function (object, ...) {
families = families, respVars = respVars,
events = object$model_data$delta,
control = object$control, time = object$running_time,
call = object$call)
call = object$call, recurrent = object$model_info$recurrent)
tab_f <- function(name) {
out <- data.frame(Mean = object$statistics$Mean[[name]],
StDev = object$statistics$SD[[name]],
Expand Down Expand Up @@ -163,6 +163,7 @@ summary.jm <- function (object, ...) {
}
}
out$Survival <- do.call(rbind, list(tab_f("gammas"), tab_f("alphas")))
out$sigmaF <- tab_f("sigmaF")[c(1, 3, 4)]
out$fit_stats <- object$fit_stats
class(out) <- "summary.jm"
out
Expand Down Expand Up @@ -211,6 +212,10 @@ print.summary.jm <- function (x, digits = max(4, getOption("digits") - 4), ...)
rownames(mat) <- rownames(D)
}
print(noquote(mat), digits = digits)
if(x$recurrent) {
cat("\nFrailty standard deviation:\n")
print(round(x[["sigmaF"]], digits))
}
cat("\nSurvival Outcome:\n")
print(round(x[["Survival"]], digits))
n_outcomes <- length(x$families)
Expand Down Expand Up @@ -262,6 +267,10 @@ print.jm <- function (x, digits = max(4, getOption("digits") - 4), ...) {
rownames(mat) <- rownames(D)
}
print(noquote(mat), digits = digits)
if(xx$recurrent) {
cat("\nFrailty standard deviation:\n")
print(round(xx[["sigmaF"]], digits))
}
cat("\nSurvival Outcome:\n")
print(round(xx[["Survival"]], digits))
n_outcomes <- length(xx$families)
Expand Down
1 change: 1 addition & 0 deletions R/jm_fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ jm_fit <- function (model_data, model_info, initial_values, priors, control) {
colnames(out[[i]][["mcmc"]][["sigmas"]]) <-
paste0("sigmas_",
seq_along(out[[i]][["mcmc"]][["sigmas"]][1, ]))
colnames(out[[i]][["mcmc"]][["sigmaF"]]) <- "sigma_frailty"
}
# drop sigmas that are not needed
has_sigmas <- initial_values$log_sigmas > -20.0
Expand Down

0 comments on commit a08aad4

Please sign in to comment.