Skip to content

Commit

Permalink
Better deals with iters
Browse files Browse the repository at this point in the history
  • Loading branch information
iagomosqueira committed Oct 31, 2024
1 parent 25e0288 commit a69d2d3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions R/ind.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,15 @@ cpue.ind <- function(stk, idx, nyears=5, ayears=3, index=1, args, tracking) {

# WEIGHTED average index of last ayears: 0.50 for last year, 0.50 others
ywts <- c(0.50 * seq(1, ayears - 1) / sum(seq(1, ayears - 1)), 0.50)
wmean <- expand(yearSums(tail(met, ayears) * ywts), year=ay - dlag)
wmean <- expand(seasonMeans(yearSums(tail(met, ayears) * ywts)), year=ay - dlag)

# AVERAGE index
mean <- expand(yearMeans(tail(met, ayears)), year=ay - dlag)
mean <- expand(seasonMeans(yearMeans(tail(met, ayears))), year=ay - dlag)

# SLOPE by iter
dat <- data.table(as.data.frame(met))

slope <- dat[, .(data=coef(lm(log(data + 1e-22) ~ year))[2]), by=iter]
slope <- FLQuant(slope$data, dimnames=dimnames(mean), units="")
slope <- FLQuant(slope$data, dimnames=dimnames(mean)[-4], units="")

# OUTPUT
ind <- FLQuants(wmean=wmean, slope=slope, mean=mean)
Expand Down

0 comments on commit a69d2d3

Please sign in to comment.