Questions tagged [tmb]

Questions relating to the R Template Model Builder package

Questions relating to the R Template Model Builder package:

https://github.com/kaskr/adcomp
https://cran.r-project.org/web/packages/TMB/index.html

32 questions
4
votes
1 answer

TMB c++ code in R package and CRAN checks

I am working on an R package to include c++ templates created in TMB. Using the helpful guidelines shared in this suggestion, I managed to come a very long way. At the moment, I'm using 2 c++ templates ("kglmer.cpp" and "nglmer.cpp") and the…
4
votes
1 answer

How do I see and replicate the R default Makevars configuration?

I do not have a ~/.R/Makevars file and > tools::makevars_user() character(0) > tools::makevars_site() character(0) Yet, R must be reading the configuration from somewhere as .cpp files containing Rcpp exports in the package src subdirectory…
Alex
  • 15,186
  • 15
  • 73
  • 127
3
votes
2 answers

Guidelines for including TMB c++ code in an R package

I've recently discovered the wonders of TMB and I'm working on a package which would ideally include TMB c++ templates in it for rather computationally expensive models. I'm assuming that there's a possibility of: Automatically compiling the TMB…
RTbecard
  • 868
  • 1
  • 8
  • 23
2
votes
0 answers

Using splines in TMB models

I have a nonlinear mixed-effects model that I have implemented in nlme that I would like to implement in TMB to decrease computation times and hopefully some occasional convergence issues. In its simplest form, the model is given by y_ij = f((1 -…
Lars Lau Raket
  • 1,905
  • 20
  • 35
2
votes
0 answers

Why does calling dyn.load in a for loop crash my R session?

R (3.3.2, Windows 7) crashes after about 1000 iterations of dyn.load() being used in a for loop. This does not happen in Ubuntu. This behaviour is observed for dll files created from Rcpp and TMB code, but I don't think it is related to either of…
Alex
  • 15,186
  • 15
  • 73
  • 127
2
votes
0 answers

Distributing TMB functions in R package and CRAN checks

I have 9 cpp files in /src - 8 from Rcpp and 1 from TMB. I can compile all and run code successfully OR get passed the CRAN checks. But not both. Method 1 Let R compile all cpp files and generate a single DLL: 'mypackage.dll' and TMB::MakeADfun(...,…
Adrian
  • 684
  • 3
  • 20
2
votes
2 answers

Exporting g++ compilation error messages from TMB library to a text file

I'm trying to compile a model with gcc (c++) in R (using the TMB package). The errors are so numerous that in Rstudio, I can't even scroll up to see the beginning of them. Therefore, I would like to print everything in the console (messages, errors…
Wave
  • 1,216
  • 1
  • 9
  • 22
1
vote
1 answer

glmmTMB_phylo: Error in Matrix::rankMatrix(TMBStruc$data.tmb[[whichX]]) : length(d <- dim(x)) == 2 is not TRUE

I am trying to run the following model: mod1<- phylo_glmmTMB(response ~ sv1 + # sampling variables sv2 + sv3 + sv4 + sv5 + sv6 + sv7 + (1|phylo) + (1|reference_id), #random effects ziformula = ~ 0, #ar1(pos + 0| group) # spatial autocorrelation…
1
vote
1 answer

Why am getting the following error when adjusting a glmm with the "glmmTMB" function and I try to obtain the confidence intervals?

I am trying to run the following model: Mm3znb<-glmmTMB(total~ Geopolitical-1 + offset(logha) + YearCollected + tmn + (tmn|Site/Plot), ziformula = ~1, data = mc3m, family="nbinom2") but when I try to obtain the confidence intervals am getting this…
1
vote
1 answer

How to do a matrix * vector multiplication and pass this result to a vector in TMB in R?

I need to do a matrix * vector multiplication, which generates only a single number, and pass it to a vector (but it doesn't work in the commented code below). What I have so far is: cpp code #include template Type…
1
vote
0 answers

How to debug my .cpp file using `gdbsource` function in TMB in R?

I am writing to implement a Simplex regression in this file (simplex_reg.cpp): // Simplex Regression #include template Type objective_function::operator() () { // Data provided from user DATA_VECTOR(Y); …
1
vote
1 answer

C++ for TMB but not Rcpp in knitr

I'm writting a document using knitr that includes C++ code. This code is to be used with the R package TMB. I am using a .Rnw document. My main problem is that I do not know what to specify for the code chunk engine. I have read a few questions…
Marie Auger-Methe
  • 808
  • 1
  • 8
  • 20
1
vote
1 answer

What is this outermgc message while optimising with TMB?

After producing the objective function and gradient with TMB, and calling the optim function, I get a sequence of reports printed in my console that seems to of the form "outer mgc: ": outer mgc: 56.54273 outer mgc: 56.51064 outer mgc: 56.96065…
Alex
  • 15,186
  • 15
  • 73
  • 127
1
vote
2 answers

How do I include more objective functions in my TMB .cpp file?

The TMB objective functions are seemingly defined in one function block that is saved to a .cpp file. Then, after compiling the file, each objective function is accessed by loading with the command dyn.load(dynlib()). Is it possible to…
Alex
  • 15,186
  • 15
  • 73
  • 127
0
votes
0 answers

Possible bias when fitting linear regression with errors in variables using TMB

I am new to template model builder (TMB), and I am trying to use it to fit a simple linear regression with errors in variables as a learning exercise. My ultimate goal is to apply this to more complex models. I am using the formulation: Formulae and…
Darren G
  • 1
  • 2
1
2 3