extract_sparse_matrix | R Documentation |
This helper function allows the extraction of a sparse matrix from a matrix
using a similar approach to that implemented in
rstan::extract_sparse_parts()
and returns these elements in a named
list for use in stan. This function is used in the construction of the
expectation model (see enw_expectation()
).
extract_sparse_matrix(mat, prefix = "")
mat |
A matrix to extract the sparse matrix from. |
prefix |
A character string to prefix the names of the returned list. |
A list representing the sparse matrix, containing:
nw
: Count of non-zero elements in mat
.
w
: Vector of non-zero elements in mat
. Equivalent to the numeric
values from mat
excluding zeros.
nv
: Length of v.
v
: Vector of row indices corresponding to each non-zero element in w
.
Indicates the row location in mat
for each non-zero value.
nu
: Length of u.
u
: Vector indicating the starting indices in w
for non-zero elements
of each row in mat
. Helps identify the partition of w
into different
rows of mat
.
enw_expectation()
Helper functions for model modules
add_max_observed_delay()
,
add_pmfs()
,
convolution_matrix()
,
enw_reference_by_report()
,
enw_reps_with_complete_refs()
,
extract_obs_metadata()
,
latest_obs_as_matrix()
,
simulate_double_censored_pmf()
mat <- matrix(1:12, nrow = 4)
mat[2, 2] <- 0
mat[3, 1] <- 0
extract_sparse_matrix(mat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.