Skip to content

Commit

Permalink
Pass quantile() directly to apply()
Browse files Browse the repository at this point in the history
  • Loading branch information
Bisaloo authored and ntorresd committed Dec 15, 2023
1 parent 9346f6a commit cdc0db9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions R/modelling.R
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ get_foi_central_estimates <- function(seromodel_object,
# generates central estimations
foi_central_estimates <- data.frame(
year = cohort_ages$birth_year,
lower = apply(foi, 2, function(x) quantile(x, lower_quantile)),
upper = apply(foi, 2, function(x) quantile(x, upper_quantile)),
medianv = apply(foi, 2, function(x) quantile(x, medianv_quantile))
lower = apply(foi, 2, quantile, lower_quantile),
upper = apply(foi, 2, quantile, upper_quantile),
medianv = apply(foi, 2, quantile, medianv_quantile)
)
return(foi_central_estimates)
}
Expand Down Expand Up @@ -444,11 +444,11 @@ get_prev_expanded <- function(foi,
prev_pn[i, ] <- 1 - exp(-exposure_expanded %*% foi_expanded[i, ])
}

lower <- apply(prev_pn, 2, function(x) quantile(x, 0.1))
lower <- apply(prev_pn, 2, quantile, 0.1)

upper <- apply(prev_pn, 2, function(x) quantile(x, 0.9))
upper <- apply(prev_pn, 2, quantile, 0.9)

medianv <- apply(prev_pn, 2, function(x) quantile(x, 0.5))
medianv <- apply(prev_pn, 2, quantile, 0.5)

predicted_prev <- data.frame(
age = 1:age_max,
Expand Down

0 comments on commit cdc0db9

Please sign in to comment.