library(magrittr)
st <- g3_stock("fish", c(10, 20, 30)) %>% g3s_age(3,5)
# Generate some random sparsesample samples
obs_df <- data.frame(
# NB: No 1993, we don't have any samples for that year
year = rep(c(1990, 1991, 1992, 1994), each = 2),
step = 1:2 )
obs_df$age = floor(runif(nrow(obs_df), min = 3, max = 5.1))
obs_df$length = floor(runif(nrow(obs_df), min = 10, max = 50))
obs_df$mean = runif(nrow(obs_df), min = 10, max = 1000)
actions <- list(
g3a_time(1990, 1994, c(6,6)),
# Use otherfood to populate abundance / mean weight
g3a_otherfood(st,
quote( age * 100 + stock__minlen ),
quote( cur_year * 1e5 + cur_step * 1e4 + 0 * stock__minlen ) ),
g3l_sparsesample(
"bt",
obs_df,
list(st),
measurement_f = g3_formula(
# Derive blubber thickness from length/weight
((wgt/(wmax.a * length^wmax.b) - 0.5) * 100 - 4.44) / (5693 * (length/wgt)^0.5),
wmax.a = g3_parameterized("wmax.a", by_stock = TRUE),
wmax.b = g3_parameterized("wmax.b", by_stock = TRUE),
end = NULL ),
function_f = g3l_sparsesample_linreg(fit = "linear") ),
NULL )
model_fn <- g3_to_r(c(actions, list(
g3a_report_detail(actions), # TODO: Not reporting anything useful
NULL )))
r <- attributes(model_fn())
colSums(r$dstart_fish__num) # TODO: Report something related
Run the code above in your browser using DataLab