Lower-level, non-exported functions to be called by the main tapnet functions
internalFunctions()bjornloglik(web, P)
fit_abund(tapnet)
pems_from_tree(tree)
select_relevant_pems(tree, species)
tmatch(delta_t, type = "normal", width = 1, shift = 0, xi = 1, err = 1e-05)
param_vec2list(params, n, m, fit.delta = FALSE)
loglik_tapnet(
params,
networks,
tmatch_type_pem,
tmatch_type_obs,
TmatchMatrixList = NULL,
lambda = 0,
obj_function = "multinom",
fit.delta = TRUE
)
latent_cor(true_pars, fitted_pars, pems_low, pems_high)
web_indices(web, web_dim, indices)
refit_params(tapnet, fit, fitted_I_mat)
data for an interaction network in vector form, e.g. from predict_tapnet;
matrix of same size as observed web, summing to 1, representing something like the probability of selecting a link; typically constructed as part of tapnet, i.e. the I-mat of fit_tapnet;
a tapnet object;
phylogenetic tree in phylo format;
a named vector of species, representing (some of) the tips of the phylogenetic tree;
vector of pairwise trait differences (higher - lower);
trait matching function: either "normal" or "shiftlnorm";
width parameter of trait matching function, similar to sd in the normal;
shift parameter (optimum trait distance), currently ignored in fitting;
penalty for increasing the width of the (unstandardised) trait-matching function; defaults to 1 (implying a quadratically increasing weight of width in the optimisatino function, i.e. strongly acting against large values of sigma)
"baseline" probability of match, even if traits do not match at all;
parameter vector with setting for tapnet simulation;
number of latent trait linear combination parameters (lower level);
number of latent trait linear combination parameters (higher level);
logical; should the trait-weighting exponent delta be fitted?
the "networks" part of a tapnet object;
type of trait matching function for latent traits;
type(s) of trait matching functions for observed traits; can be a vector as long as there are traits;
list of independent trait-matching matrices (one per network);
LASSO shrinkage parameter to avoid collinearity issues when observed traits are phylogenetically correlated;
objective function, either "multinom" or "least squares" (leads to OLS fitting) or "bjorn" (leading to use of a somewhat weird but in some opinion the correct way to compute the likelihood);
parameters used for simulating the network;
parameters estimated by fit_tapnet;
phylogenetic eigenvectors for the lower trophic level;
phylogenetic eigenvectors for the higher trophic level;
vector of two numbers indicating the rows and column of the network matrix;
vector of names of network indices to compute; see networklevel for what is available;
a fitted tapnet;
the fitted I-matrix of a fitted tapnet object.
Gita Benadi <gita.benadi@biom.uni-freiburg.de>, Carsten Dormann <carsten.dormann@biom.uni-freiburg.de> and Jochen Fründ <jochen.fruend@biom.uni-freiburg.de>
They do roughly the following:
bjornloglikcomputes likelihood of obtaining the observed interaction matrix, given some expected matrix of interaction propabilities (P). In contrast to the multinomial, this function assumes that the marginal totals of P constrain the probabilities. Hence, if all observations for one column (or row) have been evaluated for their probabilities, any new observation cannot come from this column (or row) anymore. This means, the probabilities in that "depleted" column (or row) have to be proportionally distributed over the other rows (or columns). There are ongoing discussions among the authors, when this is the right approach. Function written by Björn Reineking, ISRAE Grenoble (many thanks!), hence the name.
fit_abundcomputes expected P-matrix of observed interactions based only on abundances; if no external abundances are provided in the tapnet-object, it will use the marginal totals of the network(s) instead.
pems_from_treecomputes phylogenetic eigenvectors from a phylogenetic tree;
select_relevant_pemsidentifies those phylogenetic eigenvectors (PEMs) of the full tree most relevant for a network containing only a subset of species;
tmatchcalculates interaction probabilities based on trait matching;
param_vec2listconverts a vector of parameters (for trait matching and latent trait combinations) into a named list;
loglik_tapnetthe (negative!) log-likelihood function for fitting the tapnet model; actually quite an important function, easy to break, so not for the user to easily access;
latent_corcomputes correlation of fitted latent with true constructed traits for simulated data;
web_indicescomputes the specified network indices for the provided network, after turning the prediction vector into a matrix;
refit_paramsSimulate new networks from a fitted tapnet object, re-fit on the simulated network and output the parameter values.
Benadi et al. in prep