MakeTmbList_Fn: Make a tagged list of inputs for TMB

Usage Arguments Examples

View source: R/MakeTmbList_Fn.R

Usage

1
MakeTmbList_Fn(Version, Model, Fix_Q, ErrorModel_CatchRates, ErrorModel, Smooth_F, n_j, n_i, n_s, n_t, DF_input, C_t, mesh_stations, spde_stations, Area_i, alpha_g, ro, w_k, M, k, CV_c, CV_w, q_I)

Arguments

Version
Model
Fix_Q
ErrorModel_CatchRates
ErrorModel
Smooth_F
n_j
n_i
n_s
n_t
DF_input
C_t
mesh_stations
spde_stations
Area_i
alpha_g
ro
w_k
M
k
CV_c
CV_w
q_I

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (Version, Model, Fix_Q, ErrorModel_CatchRates, ErrorModel, 
    Smooth_F, n_j, n_i, n_s, n_t, DF_input, C_t, mesh_stations, 
    spde_stations, Area_i, alpha_g, ro, w_k, M, k, CV_c, CV_w, 
    q_I) 
{
    F_t = rep(0.1, n_t)
    if (Version == "delay_difference_v4d") {
        Error_Model = ErrorModel_CatchRates
        Data = list(Error_Model = Error_Model, Smooth_F = Smooth_F, 
            n_j = n_j, n_i = n_i, n_s = n_s, n_t = n_t, I_j = DF_input[, 
                "I_j"], W_j = DF_input[, "W_j"], AreaSwept_j = DF_input[, 
                "AreaSwept_j"], Station_j = DF_input[, "Station_j"] - 
                1, Year_j = DF_input[, "Year_j"] - 1, C_t = C_t, 
            meshidxloc = mesh_stations$idx$loc - 1, G0 = spde_stations$param.inla$M0, 
            G1 = spde_stations$param.inla$M1, G2 = spde_stations$param.inla$M2, 
            Area_i = Area_i, alpha_g = alpha_g, ro = ro, w_k = w_k, 
            M = M, k = k, CV_c = CV_c, CV_w = CV_w)
        Parameters = list(log_F_sd = log(1), log_F_equil = log(F_t[1]), 
            log_F_t_input = log(F_t), log_q_I = log(q_I), beta = c(0), 
            log_tau_E = 0, log_tau_O = 0, log_kappa = 0, ln_VarInfl = c(0, 
                0), Epsilon_input = matrix(0, spde_stations$n.spde, 
                n_t), Omega_input = rep(0, spde_stations$n.spde))
    }
    if (Version == "delay_difference_v6c") {
        Data = list(ModelType = ifelse(Model == "Spatial", 1, 
            2), ErrorModel_CatchRates = ErrorModel_CatchRates, 
            ErrorModel_MeanWeight = ErrorModel_MeanWeight, Smooth_F = Smooth_F, 
            n_j = n_j, n_i = n_i, n_s = n_s, n_t = n_t, I_j = DF_input[, 
                "I_j"], W_j = DF_input[, "W_j"], AreaSwept_j = DF_input[, 
                "AreaSwept_j"], Station_j = DF_input[, "Station_j"] - 
                1, Year_j = DF_input[, "Year_j"] - 1, C_t = C_t, 
            meshidxloc = mesh_stations$idx$loc - 1, G0 = spde_stations$param.inla$M0, 
            G1 = spde_stations$param.inla$M1, G2 = spde_stations$param.inla$M2, 
            Area_i = Area_i, alpha_g = alpha_g, ro = ro, w_k = w_k, 
            M = M, k = k, CV_c = CV_c, CV_w = CV_w)
        Parameters = list(log_F_sd = log(1), log_F_equil = log(F_equil), 
            log_F_t_input = log(F_t), log_q_I = log(q_I), beta = c(0), 
            log_tau_E = 0, log_tau_O = 0, log_kappa = 0, ln_VarInfl = c(0, 
                0), log_extraCV_w = log(0.05), log_tau_N = log(1), 
            Epsilon_input = matrix(0, spde_stations$n.spde, n_t), 
            Omega_input = rep(0, spde_stations$n.spde), Nu_input = rep(0, 
                n_t))
    }
    if (Version == "delay_difference_v8d") {
        Data = list(ModelType = ifelse(Model == "Spatial", 1, 
            2), ErrorModel_CatchRates = ErrorModel_CatchRates, 
            ErrorModel_MeanWeight = ErrorModel_MeanWeight, Smooth_F = Smooth_F, 
            n_j = n_j, n_i = n_i, n_s = n_s, n_t = n_t, I_j = DF_input[, 
                "I_j"], W_j = DF_input[, "W_j"], AreaSwept_j = DF_input[, 
                "AreaSwept_j"], Station_j = DF_input[, "Station_j"] - 
                1, Year_j = DF_input[, "Year_j"] - 1, C_t = C_t, 
            IndexMat = IndexMat, meshidxloc = mesh_stations$idx$loc - 
                1, G0 = spde_stations$param.inla$M0, G1 = spde_stations$param.inla$M1, 
            G2 = spde_stations$param.inla$M2, Area_i = Area_i, 
            alpha_g = alpha_g, ro = ro, w_k = w_k, M = M, k = k, 
            CV_c = CV_c, CV_w = CV_w)
        Parameters = list(log_F_sd = log(1), log_F_t_input = log(c(F_equil, 
            F_t)), log_q_I = log(q_I), beta = log_mu_alpha, log_tau_E = 0, 
            log_tau_O = 0, log_kappa = 0, ln_VarInfl = c(0, 0), 
            log_extraCV_w = log(0.05), log_tau_N = log(1), log_extraCV_Index = rep(log(0.1), 
                2), Epsilon_input = matrix(0, spde_stations$n.spde, 
                n_t), Omega_input = rep(0, spde_stations$n.spde), 
            Nu_input = rep(0, n_t))
    }
    if (Model == "Spatial") {
        if (Smooth_F == 0) 
            Random = c("Epsilon_input", "Omega_input")
        if (Smooth_F != 0) 
            Random = c("Epsilon_input", "Omega_input", "log_F_equil")
    }
    if (Model == "Nonspatial") {
        if (Smooth_F == 0) 
            Random = c("Nu_input")
        if (Smooth_F != 0) 
            Random = c("Nu_input", "log_F_t_input")
    }
    if (Model == "Index") {
        if (Smooth_F == 0) 
            Random = c("Nu_input")
        if (Smooth_F != 0) 
            Random = c("Nu_input", "log_F_t_input")
    }
    Map = list()
    if (Smooth_F == 0) 
        Map[["log_F_sd"]] = factor(NA)
    if (ErrorModel_CatchRates == 0) 
        Map[["ln_VarInfl"]] = factor(c(NA, NA))
    if (ErrorModel_MeanWeight == 0) 
        Map[["log_extraCV_w"]] = factor(NA)
    if (Model == "Spatial") {
        Map[["log_tau_N"]] = factor(NA)
        Map[["Nu_input"]] = factor(rep(NA, n_t))
        Map[["log_extraCV_Index"]] = factor(rep(NA, 2))
        Map[["log_F_t_input"]] = factor(c(1, 1:n_t))
    }
    if (Model == "Nonspatial") {
        Map[["log_tau_E"]] = factor(NA)
        Map[["log_tau_O"]] = factor(NA)
        Map[["Epsilon_input"]] = factor(rep(NA, length(Parameters$Epsilon_input)))
        Map[["Omega_input"]] = factor(rep(NA, length(Parameters$Omega_input)))
        Map[["log_kappa"]] = factor(NA)
        Map[["log_extraCV_Index"]] = factor(rep(NA, 2))
        Map[["log_F_t_input"]] = factor(c(1, 1:n_t))
    }
    if (Model == "Index") {
        Map[["log_tau_E"]] = factor(NA)
        Map[["log_tau_O"]] = factor(NA)
        Map[["Epsilon_input"]] = factor(rep(NA, length(Parameters$Epsilon_input)))
        Map[["Omega_input"]] = factor(rep(NA, length(Parameters$Omega_input)))
        Map[["log_kappa"]] = factor(NA)
        Map[["ln_VarInfl"]] = factor(c(NA, NA))
        Map[["log_extraCV_w"]] = factor(NA)
        Map[["log_F_t_input"]] = factor(c(1, 1:n_t))
    }
    if (Fix_Q == TRUE) 
        Map[["log_q_I"]] = factor(NA)
    Return = list(Parameters = Parameters, Data = Data, Map = Map, 
        Random = Random)
    return(Return)
  }

James-Thorson/spatial_delay-difference documentation built on May 7, 2019, 10:20 a.m.