View source: R/infillMatrices.R
infill | R Documentation |
This function infills matrices based on observed geometric mean abundances and relative size of other CUs. In other words abundance is a function of average stock size and the observed return to observed stocks in a given year.
infill(mat)
mat |
A matrix of observed abundances with |
Generally used with stocks that have gappy data, particularly in recent years because the closed-loop simulation model requires a seamless tran- sition between retrospective and forward simulated data.
Depends on helper function geoMean
used to calculate geometric means.
Returns a matrix of the same dimensions with NAs replaced by infilled values
set.seed(123)
#matrix of random time series representing stock abundance
popDat <- cbind(popA = round(exp(rnorm(20, 7, 1))),
popB = round(exp(rnorm(20, 8, 1))),
popC = round(exp(rnorm(20, 9, 1)))
)
#remove 20% of values
gaps <- floor(runif(n = 0.2 * length(popDat), min = 1, max = length(popDat)))
popDat[gaps] <- NA
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.