Created
February 8, 2015 10:39
-
-
Save romunov/b8da2cbab959b3690c5e to your computer and use it in GitHub Desktop.
crayfish data analysis using TMB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is what i have so far | |
require(TMB) | |
rak <- read.table("./data/master_all_r3.txt", dec = ".", header = TRUE, sep = "\t") | |
# prepare the data | |
rakdat <- na.omit(rak[, c("vrsta", "tw", "ETS_t_1000")]) | |
xvar <- rakdat[, "tw"] | |
yvar <- rakdat[, "ETS_t_1000"] | |
inter.new <- seq(from = min(xvar), to = max(xvar), by = 0.1) | |
extra.new <- seq(from = 0, to = 40, by = 0.1) | |
# construct model matrix | |
rakdat.mm <- model.matrix( ~ 0 + vrsta, data = rakdat) | |
# compile code | |
compile("./cpp_source//ricker_compare_lvls.cpp") | |
dyn.load("./cpp_source/ricker_compare_lvls") | |
# prepare parameters for the model | |
model.data <- list(x = xvar, y = yvar, inter_new = inter.new, | |
extra_new = extra.new, mm = rakdat.mm) | |
nspp <- ncol(rakdat.mm) | |
model.parameters <- list(a = rep(0.001, nspp), b = rep(-0.5, nspp), c = rep(100, nspp), logsigma = 3) | |
# full model | |
full.model <- MakeADFun(data = model.data, parameters = model.parameters, | |
DLL = "ricker_compare_lvls") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the C++ function that crashes R.