Lower-level, non-exported functions to be called by the main tapnet functions
internalFunctions()pems_from_tree(tree)
select_relevant_pems(tree, species)
tmatch(delta_t, type = "normal", width = 1, shift = 0, err = 1e-05)
param_vec2list(params, n, m, fit.delta = FALSE)
loglik_tapnet(
params,
networks,
tmatch_type_pem,
tmatch_type_obs,
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)
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;
"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;
LASSO shrinkage parameter to avoid collinearity issues when observed traits are phylogenetically correlated;
objective function, either "multinom" or anything else (currently anything else leads to OLS fitting);
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;
data for an interaction network in vector form, e.g. from predict_tapnet;
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 tapnet object;
a fitted tapnet;
the fitted I-matrix of a fitted tapnet object (I think).
They do roughly the following:
pems_from_tree
computes phylogenetic eigenvectors from a phylogenetic tree;
select_relevant_pems
identifies those phylogenetic eigenvectors (PEMs) of the full tree most relevant for a network containing only a subset of species;
tmatch
calculates interaction probabilities based on trait matching;
param_vec2list
converts a vector of parameters (for trait matching and latent trait combinations) into a named list;
loglik_tapnet
the 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_cor
computes correlation of fitted latent with true constructed traits for simulated data;
web_indices
computes the specified network indices for the provided network, after turning the prediction vector into a matrix;
refit_params
Simulate new networks from a fitted tapnet object, re-fit on the simulated network and output the parameter values.
Benadi et al. in prep