Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

make_iter_kernel

Create iteration kernels from an IPM object


Description

Creates iteration kernels for IPMs. ipmr does not create these to iterate models, but they may be useful for further analyses.

Usage

format_mega_matrix(ipm, ...)

## Default S3 method:
format_mega_matrix(ipm, mega_mat, ...)

## S3 method for class 'age_x_size_ipm'
format_mega_matrix(ipm, name_ps, f_forms, ...)

make_iter_kernel(ipm, mega_mat = NULL, name_ps = NULL, f_forms = NULL)

Arguments

ipm

Output from make_ipm.

...

Other arguments passed to methods.

mega_mat

A vector with symbols, I's, and/or 0s representing the matrix blocks. They should be specified in ROW MAJOR order! Can also be a character string specifying the call. Hierarchical syntax is supported. When used, format_mega_matrix will produce as many mega-matrices as there are combinations of levels_hier_effs in the proto_ipm.

name_ps

The prefix(es) for the kernel name that correspond to survival and growth/maturation of existing individuals. For the model K = P_age + F_age, this would be "P". Only applies to age X size models. The "_age" suffix is appended automatically, so does not need to be supplied.

f_forms

The names of the kernels that correspond to production of new individuals, and possibly, how they are combined. For example, a model that includes sexual (with an "F" kernel) and asexual reproduction (with a "C" kernel), this would be "F + C". If data come from multiple sites or years, then this information is supplied using the suffix syntax (i.e. f_forms = "F_yr + C_yr"). Only applies to age X size models. The "_age" suffix is appended automatically, so does not need to be supplied.

Details

ipmr does not generate complete iteration kernels, and uses sub-kernels to iterate models. However, some further analyses are just easier to code with a complete iteration kernel. This handles constructing those for simple and general models of all forms. format_mega_matrix is used internally by make_iter_kernel for general IPMs.

I and 0 represent identity matrices and 0 matrices, respectively. They can be used to fill in blocks that represent either, without having to create those separately and append them to the model object. The function will work out the correct dimensions for both internally, and there is no restriction on the number that may be used in a given call.

For age_size_ipms, the correct form of mega_mat is generated internally by creating sub-diagonal matrices for the name_ps kernels, and a top row using the f_forms. If hierarchical effects are part of the model, the suffixes should be attached to the name_ps, f_forms in the function arguments, and the correct block matrices will be generated internally.

Value

A list containing a large matrix or many large matrices (when used with hierarchical syntax). The names in the former case will be "mega_matrix" and in the latter case, "mega_matrix_<hier_effs>" with the levels of the hierarchical effects substituted in.

Examples

data(gen_di_det_ex)

big_k <- make_iter_kernel(gen_di_det_ex,
                            mega_mat = c(0, go_discrete,
                                         leave_discrete, P))

char_call <- c(0, "go_discrete", "leave_discrete", "P")

big_k_c <- make_iter_kernel(gen_di_det_ex, mega_mat = char_call)

# Now, with an Identity matrix instead of a 0

big_k <- make_iter_kernel(gen_di_det_ex,
                            mega_mat = c(I, go_discrete,
                                         leave_discrete, P))

# For simple IPMs with no hierarchical effects, this computes the sum of
# the sub-kernels (i.e. K = P + F)

data(sim_di_det_ex)

simple_k <- make_iter_kernel(sim_di_det_ex)

ipmr

Fits Integral Projection Models Using an Expression Based Framework

v0.0.1
MIT + file LICENSE
Authors
Sam Levin [aut, cre] (<https://orcid.org/0000-0002-3289-9925>), Aldo Compagnoni [aut], Dylan Childs [aut], Sanne Evers [aut], Roberto Salguero-Gomez [aut], Tiffany Knight [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.