Skip to content

Commit

Permalink
adding rescale func
Browse files Browse the repository at this point in the history
  • Loading branch information
quantifish committed Dec 12, 2024
1 parent 20bc454 commit 9998088
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
6 changes: 3 additions & 3 deletions R/plot-compare.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ plot_compare <- function(fits, labels = NULL, year = NULL,
gm1 <- geo_mean(df1$Mean)
gm2 <- geo_mean(df2$Mean)
fout$Mean <- fout$Mean / gm2 * gm1
fout$Qlower <- fout$Qlower / gm2 * gm1
fout$Qupper <- fout$Qupper / gm2 * gm1
fout$Median <- fout$Median / gm2 * gm1
fout$Qlower <- fout$Qlower / gm2 * gm1
fout$Qupper <- fout$Qupper / gm2 * gm1
fout$Median <- fout$Median / gm2 * gm1
df0[[i]] <- fout
}
}
Expand Down
18 changes: 16 additions & 2 deletions R/rescale-index.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,22 @@
#' @import dplyr
#' @export
#'
rescale_index <- function(idx1, idx2) {
rescale_index <- function(fit1, fit2, rescale_series = 1) {

for (i in 1:length(fits)) {
if (i != rescale_series) {
fout <- df0[[i]]
df1 <- df0[[rescale_series]] %>% filter(Year %in% fout$Year)
df2 <- df0[[i]] %>% filter(Year %in% df1$Year)
gm1 <- geo_mean(df1$Mean)
gm2 <- geo_mean(df2$Mean)
fout$Mean <- fout$Mean / gm2 * gm1
fout$Qlower <- fout$Qlower / gm2 * gm1
fout$Qupper <- fout$Qupper / gm2 * gm1
fout$Median <- fout$Median / gm2 * gm1
df0[[i]] <- fout
}
}


return(coefs)
}

0 comments on commit 9998088

Please sign in to comment.