predict_MRFnetworks {MRFcov} | R Documentation |
Extract predicted network metrics for observations in a given dataset using
equations from a fitted MRFcov
object
Description
This function uses outputs from fitted MRFcov
and bootstrap_MRF
models to
generate linear predictions for each observation in data
and
calculate probabilistic network metrics from weighted adjacency matrices.
Usage
predict_MRFnetworks(
data,
MRF_mod,
cutoff,
omit_zeros,
metric,
cached_predictions = NULL,
prep_covariates,
n_cores,
progress_bar = FALSE
)
Arguments
data |
Dataframe. The sample data where the
left-most variables are variables that are represented by nodes in the graph.
Colnames from this sample dataset must exactly match the colnames in the dataset that
was used to fit the |
MRF_mod |
A fitted |
cutoff |
Single numeric value specifying the linear prediction threshold. Species whose
linear prediction is below this level for a given observation in |
omit_zeros |
Logical. If |
metric |
The network metric to be calculated for each observation in |
cached_predictions |
Use if providing stored predictions from |
prep_covariates |
Logical flag stating whether to prep the dataset
by cross-multiplication ( |
n_cores |
Positive integer stating the number of processing cores to split the job across.
Default is |
progress_bar |
Logical. Progress bar in pbapply is used if |
Details
Interaction parameters are predicted for each observation in data
and then converted into a weighted, undirected adjacency matrix
using graph.adjacency
. Note that the network is probabilistic,
as node occurrences/abundances are predicted using fitted model equations from
MRF_mod
. If a linear prediction for a given observation falls below the
user-specified cutoff
, the node is considered absent from the community and cannot
participate in the network. After correcting for the linear predictions,
the specified network metric (degree centrality,
eigencentrality, or betweenness) for each observation in data
is then calculated and returned in a matrix
. If metric
is not
supplied, the weighted, undirected adjacency matrices are returned in a list
Value
Either a matrix
with nrow = nrow(data)
,
containing each species' predicted network metric at each observation in data
, or
a list
with length = nrow(data)
containing the weighted, undirected
adjacency matrix predicted at each observation in data
See Also
MRFcov
, bootstrap_MRF
, degree
,
eigen_centrality
, betweenness
Examples
data("Bird.parasites")
CRFmod <- MRFcov(data = Bird.parasites, n_nodes = 4,
family = "binomial")
predict_MRFnetworks(data = Bird.parasites[1:200, ],
MRF_mod = CRFmod, metric = "degree",
cutoff = 0.25)