A class for storing lists of IncidenceMatrices
A matrix containing a single sample. By default, it is the first sample. See self$sample
for how to change it.
Return a random sample from the simulations. Alternatively, select a sample to use with self$mat
by assigning a value.
The simulations this structure is responsible for. This is another name for self$arr
.
This function adds columns to self$simulations
columns | - | The number of columns to add. |
Add error to the simulations according to a distribution.
type | - | The type of distribution as a string. Currently 'Poisson' is allowed. |
rows | - | Which rows to affect. |
cols | - | Which columns to affect. |
mutate | - | Whether to modify this object, or create and return a modified object. |
If mutate=FALSE
, a clone of this object will run the method and be returned. Otherwise, there is no return.
This function adds rows to self$simulations
rows | - | The number of rows to add. |
This function replaces the matrix value at column i with the differences between the values at column i
and i-lag
.
lag | - | How far back to diff. |
mutate | - | Whether to modify this object, or create and return a modified object. |
If mutate=FALSE
, a clone of this object will run the method and be returned. Otherwise, there is no return.
Take the first k
slices of self$simulations
k | - | How many slices to keep |
direction | - | Which dimension to take a subset of. 1 is rows, 2 is columns, 3 is simulations |
mutate | - | Whether to modify this object, or create and return a modified object. |
If mutate=FALSE
, a clone of this object will run the method and be returned. Otherwise, there is no return.
Create a new SimulatedIncidenceMatrix.
data | - | The data to use for the simulation. Can be a list of IncidenceMatrices, or a single IncidenceMatrix. |
nsim | - | The number of simulations. If data is a list, this should be the length of the list. If data is an IncidenceMatrix, this is the number of times the IncidenceMatrix is replicated.
|
This function replaces the current matrix with a new matrix with one column for every column, and a row for every row/index combination. The column corresponding to the row and index will have the value of the original matrix in the same row, but index columns previous.
indices | - | A sequence of lags to use as part of the data. Note that unless this list contains 0 , the data will all be shifted back by one year.
|
mutate | - | Whether to modify this object, or create and return a modified object. |
na.rm | - | Whether to remove the NA columns that result where the lag goes off the edge of self$simulations. |
If mutate=FALSE
, a clone of this object will run the method and be returned. Otherwise, there is no return.
This function replaces the current array with a new array with one column for every column, and a row for every row/index combination. The column corresponding to the row and index will have the value of the original array in the same row, but index columns ahead.
indices | - | A sequence of leads to use as part of the data. Note that unless this list contains 0 , the data will all be shifted back by at least one year.
|
mutate | - | Whether to modify this object, or create and return a modified object. |
na.rm | - | Whether to remove the NA columns that result where the lead goes off the edge of self$simulations. |
If mutate=FALSE
, a clone of this object will run the method and be returned. Otherwise, there is no return.
Compute the mean over all simulations.
An IncidenceMatrix where return$mat is the elementwise mean of self$arr
Compute the median over all simulations.
An IncidenceMatrix where return$mat is the elementwise median of self$arr
This function changes the information stored in self$simulations
rows | - | The rows to change. |
cols | - | The columns to change. |
sims | - | Which simulations to affect. |
data | - | The data to change to. Can be either array-like or matrix-like. If its matrix-like it will overwrite all of the dimensions. |
This function rescales each element of our object according to a function.
f | - | The function we rescale by. This function takes in a number and outputs a rescaled version of that number. |
mutate | - | Whether to modify this object, or create and return a modified object. |
If mutate=FALSE
, a clone of this object will run the method and be returned. Otherwise, there is no return.
Choose only some of the simulations.
simulations | - | Which simulations to keep |
mutate | - | Whether to modify this object, or create and return a modified object. |
If mutate=FALSE
, a clone of this object will run the method and be returned. Otherwise, there is no return.
Take a subset of the object as though it were a matrix.
rows | - | Numeric, named, or logical denoting which rows to select |
cols | - | Numeric, named, or logical denoting which columns to select |
mutate | - | Whether to modify this object, or create and return a modified object. |
If mutate=FALSE
, a clone of this object will run the method and be returned. Otherwise, there is no return.
Apply a function to every simulation.
FUNC | - | The function to apply. |
... | - | Any arguments to FUNC other than the matrix.
|
An IncidenceMatrix where return$mat[i,j]
is the same as FUNC(self$arr[i,j,])
Take the last k
slices of self$simulations
k | - | How many slices to keep |
direction | - | Which dimension to take a subset of. 1 is rows, 2 is columns, 3 is simulations |
If mutate=FALSE
, a clone of this object will run the method and be returned. Otherwise, there is no return.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.