Skip to content

Commit

Permalink
minor cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-buerkner committed Mar 19, 2024
1 parent d002b66 commit 85030d9
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions R/rename_pars.R
Original file line number Diff line number Diff line change
Expand Up @@ -566,10 +566,6 @@ do_renaming <- function(x, y) {
return(x)
}
chains <- length(x$fit@sim$samples)
# temporary fix for issue #387 until fixed in rstan
for (i in seq_len(chains)) {
x$fit@sim$samples[[i]]$lp__.1 <- NULL
}
for (i in seq_along(y)) {
x <- .do_renaming(x, y[[i]])
}
Expand Down Expand Up @@ -637,13 +633,13 @@ compute_xi.brmsfit <- function(x, ...) {
if (!any(grepl("^tmp_xi(_|$)", variables(x)))) {
return(x)
}
draws <- try(extract_draws(x))
if (is_try_error(draws)) {
prep <- try(prepare_predictions(x))
if (is_try_error(prep)) {
warning2("Trying to compute 'xi' was unsuccessful. ",
"Some S3 methods may not work as expected.")
return(x)
}
compute_xi(draws, fit = x, ...)
compute_xi(prep, fit = x, ...)
}

#' @export
Expand All @@ -668,7 +664,7 @@ compute_xi.brmsprep <- function(x, fit, ...) {
y <- matrix(x$data$Y, dim(mu)[1], dim(mu)[2], byrow = TRUE)
bs <- -1 / matrixStats::rowRanges((y - mu) / sigma)
bs <- matrixStats::rowRanges(bs)
tmp_xi <- as.vector(as.matrix(fit, pars = tmp_xi_name))
tmp_xi <- as.vector(as.matrix(fit, variable = tmp_xi_name))
xi <- inv_logit(tmp_xi) * (bs[, 2] - bs[, 1]) + bs[, 1]
# write xi into stanfit object
xi_name <- paste0("xi", resp)
Expand Down

0 comments on commit 85030d9

Please sign in to comment.