b-dev-fit-model.Rmd
library(FishMap)
An example of the function. Only use to remove source inside the
function fm_fit_model
## Settings all params
SE <- 1
data_source <- 1
data_obs <- 2
samp_process <- 0
b_constraint <- 2
const_spphab <- 1
cov_samp_process <- 0
biomass_temporal <- 1
sampling_temporal <- 0
anisotropy <- 0
lf_link <- 0
ref_data <- "com"
EM <- "est_b"
month_ref <- 1
compute_sd <- FALSE
fm_data_inputs <- readr::read_rds(system.file("examples", "part1_output_small.rds", package = "FishMap"))
species <- fm_data_inputs[["species"]]
b_com_i <- fm_data_inputs[["b_com_i"]]
mesh <- fm_data_inputs[["mesh"]]
time.step_df <- fm_data_inputs[["time.step_df"]]
loc_x <- fm_data_inputs[["loc_x"]]
y_com_i <- fm_data_inputs[["y_com_i"]]
y_sci_i <- fm_data_inputs[["y_sci_i"]]
cov_x_com <- fm_data_inputs[["cov_x_com"]]
cov_x_sci <- fm_data_inputs[["cov_x_sci"]]
c_com_x <- fm_data_inputs[["c_com_x"]]
t_com_i <- fm_data_inputs[["t_com_i"]]
t_sci_i <- fm_data_inputs[["t_sci_i"]]
spde <- fm_data_inputs[["spde"]]
Aix_ij_com <- fm_data_inputs[["Aix_ij_com"]]
Aix_w_com <- fm_data_inputs[["Aix_w_com"]]
Aix_ij_sci <- fm_data_inputs[["Aix_ij_sci"]]
Aix_w_sci <- fm_data_inputs[["Aix_w_sci"]]
cov_x_pred <- fm_data_inputs[["cov_x_pred"]]
Aix_ij_pred <- fm_data_inputs[["Aix_ij_pred"]]
Aix_w_pred <- fm_data_inputs[["Aix_w_pred"]]
W <- fm_data_inputs[["W"]]
n_survey <- fm_data_inputs[["n_survey"]]
MeshList_aniso <- fm_data_inputs[["MeshList_aniso"]]
xfb_x <- NULL # TO DELETE
weights_com <- 1 # TO DELETE
result <- fm_build_data_params_map(
SE = SE,
data_source = data_source,
data_obs = data_obs,
samp_process = samp_process,
b_constraint = b_constraint,
cov_samp_process = cov_samp_process,
const_spphab = const_spphab,
biomass_temporal = biomass_temporal,
sampling_temporal = sampling_temporal,
anisotropy = anisotropy,
lf_link = lf_link,
b_com_i = b_com_i,
mesh = mesh,
time.step_df = time.step_df,
loc_x = loc_x,
y_com_i = y_com_i,
y_sci_i = y_sci_i,
cov_x_com = cov_x_com,
cov_x_sci = cov_x_sci,
xfb_x = xfb_x,
c_com_x = c_com_x,
t_com_i = t_com_i,
weights_com = weights_com,
t_sci_i = t_sci_i,
spde = spde,
Aix_ij_com = Aix_ij_com,
Aix_w_com = Aix_w_com,
Aix_ij_sci = Aix_ij_sci,
Aix_w_sci = Aix_w_sci,
cov_x_pred = cov_x_pred,
Aix_ij_pred = Aix_ij_pred,
Aix_w_pred = Aix_w_pred,
W = W,
n_survey = n_survey,
MeshList_aniso = MeshList_aniso,
EM = EM,
ref_data = ref_data,
month_ref = month_ref,
Version = Version
)
fm_fit_model()
: compile model and fit to data
This function will fit the model to the observation data. It will
compile the model cpp file. It will fit the model to the input data
generated from fm_load_data()
and provide the results as a
named list.
# run part 2
fm_data_inputs <- readr::read_rds(
system.file("examples", "part1_output_small.rds",
package = "FishMap")
)
fm_model_results <- fm_fit_model(fm_data_inputs = fm_data_inputs,
SE = 1,
data_source = 1,
data_obs = 2,
samp_process = 0,
b_constraint = 2,
cov_samp_process = 0,
biomass_temporal = 1,
sampling_temporal = 0,
lf_link = 0,
ref_data = "com",
EM = "est_b",
month_ref = 1)