Fit_model | R Documentation |
Fit_model
estimates parameters and predicts values from a multivariate random-walk model for fish traits
Fit_model(
text = NULL,
Database = FishLife::FishBase_and_RAM,
tree = Database$tree,
Y_ij = Database$Y_ij,
Z_ik = Database$Z_ik,
Use_REML = TRUE,
N_factors = 0,
N_obsfactors = 0,
min_replicate_measurements = 0,
SR_obs = Database$SR_obs,
StockData = Database$StockData,
group_j = 1:ncol(Y_ij) - 1,
Version = "Taxon_v3_0_0",
TmbDir = system.file("executables", package = "FishLife"),
RunDir = tempfile(pattern = "run_", tmpdir = tempdir(), fileext = "/"),
verbose = FALSE,
debug_mode = FALSE,
j_SR = ncol(Y_ij) - 3:1,
additional_variance = c(0, 0),
SD_b_stock = 10,
b_type = 0,
Turn_off_taxonomy = FALSE,
Pen_lowvar_lnRhat = 1,
lowerbound_MLSPS = 1,
Use_RAM_Mvalue_TF = TRUE,
rho_space = "natural",
n_sims = 1000,
n_batches = NULL,
include_r = TRUE,
PredTF_stock = NULL,
extract_covariance = FALSE,
run_model = TRUE,
multinomial_for_factors = FALSE,
Params = "Generate",
Random = "Generate",
Map = "Generate",
add_predictive = FALSE,
...
)
text |
structural equation model structure, passed to either |
Database |
Whether to use results for both adult and stock-recruit parameters, |
tree |
phylogenetic structure, using class |
Y_ij |
a data frame of trait values (perhaps log-scaled) with rows for records, and tagged-columns for traits |
Z_ik |
a data frame of taxonomic classification for each row of |
Use_REML |
OPTIONAL boolean whether to use maximum marginal likelihood or restricted maximum likelihood (termed "REML") |
N_factors |
Number of factors in decomposition of covariance for random-walk along evolutionary tree (0 means a diagonal but unequal covariance; negative is the sum of a factor decomposition and a diagonal-but-unequal covariance) |
N_obsfactors |
Number of factors in decomposotion of observation covariance (same format as |
min_replicate_measurements |
specified threshold for the number of measurements for a given continuous traits, where any continuous trait having fewer replicated measurements for at least one taxon will have the measurement variance fixed at an arbitrarily low value, such that estimated traits are forced to approach the unreplicated measurements |
SR_obs |
Stock-recruit records from RAM Legacy stock-recruit database |
StockData |
Auxiliary information for every stock with stock-recruit information |
Version |
TMB version number |
TmbDir |
Directory containing pre-compiled TMB script |
RunDir |
Directory to use when compiling and running TMB script (different to avoid problems with read-write restrictions) |
verbose |
Boolean whether to print diagnostics to terminal |
run_model |
Boolean indicating whether to run the model or just return the built TMB object |
Params |
optional list of parameter estimates to use as starting values (Default |
... |
other paramers passed to |
Process_cov |
Whether process-error covariance is equal or differs multiplicatively for different taxonomic levels (Options: "Equal" or "Unequal") |
Tagged list containing objects from FishLife run (first 9 slots constitute list 'Estimate_database' for archiving results)
The phylogenetic tree used for analysis, whether inputted or generated from taxonomy based on Z_ik
The phylogenetic tree used for analysis, whether inputted or generated from taxonomy based on Z_ik
Number of factors used for evolution in life-history model
Number of factors used for measurent-error in life-history model
Boolean, whether REML was used for model
Covariance among traits for every taxon in tree
Record of taxonomic tree
Parameter estimates and predictions
Associates every observation with a level of the taxonomic tree
Raw data
Taxonomy for each datum
The built TMB object
Output from optimization
tagged list of report-file from TMB
Estimated/predicted standard errors for fixed/random effects
## Not run:
# Load data set
library(FishLife)
# Simulate data
tree = ape::rtree(n=100)
xfit = x = 1 + 0.3 * phylolm::rTrait(n = 1, phy=tree)
yfit = y = 2 + 1*x + 0.3 * phylolm::rTrait(n = 1, phy=tree)
drop_x = sample( 1:ape::Ntip(tree), replace=FALSE, size=round(ape::Ntip(tree)*0.3) )
xfit[drop_x] = NA
drop_y = sample( 1:ape::Ntip(tree), replace=FALSE, size=round(ape::Ntip(tree)*0.3) )
yfit[drop_y] = NA
# Fit model
Fit = Fit_model(
text = "x -> y, p",
Database = NULL,
Use_REML = FALSE,
Y_ij = data.frame( x=xfit, y=yfit ),
tree = tree,
min_replicate_measurements = Inf )
# S3-defaults
print(Fit)
coef(Fit)
# Convet and plot using sem
mysem = as(Fit,"sem")
sem::pathDiagram( model = mysem,
style = "traditional",
edge.labels = "values" )
myplot = semPlot::semPlotModel( as(Fit,"sem") )
semPlot::semPaths( myplot,
nodeLabels = myplot@Vars$name )
# Convert and plot using phylobase / phylosignal
library(phylobase)
plot( as(Fit,"phylo4d") )
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.