if(), abs(),
round(), min(), max() depending
on parameters)library(RTMB) might not work<-[ (see here)
etc.
c() function, or if you
use the diag<- function (which sets the diagonal of a
matrix) or the [<- function (which assigns values within
a matrix), you need to add e.g. ADoverload("[<-") to the
beginning of your functionnumeric(0), not c() or NULL
(i.e. x <- c(); x[1] <- 2 throws an error, but
x <- numeric(0); x[1] <- 2 does work), see here. In
any case it is better practice to preallocate instead of growing
vectors, e.g. x <- numeric(1); x[1] <- 2 (see chapter
2 of the R
Inferno).Matrix::expm()
rather than expm::expm()drop() and as.matrix() to
convert matrices with dimension 1 in some direction (or
Matrix matrices) back to vectors[[-indexing may be much faster than
[-indexing: see here
(and later messages in that thread)cat() or print() to print out
numeric values, the results may not make sense (you’ll see a printout of
RTMB’s internal representation of autodiff-augmented numbers …)%*% (as in base R), not * (as in
C++) for matrix/matrix and matrix/vector multiplicationfor loops) being very slow
relative to vectorized codes. However, vectorized code builds the model
object (i.e. runs MakeADFun) much faster. In addition, you
can control vectorized RTMB code to use more efficient internal
operations e.g. by setting TapeConfig(vectorize="enable").
Comparing natively vectorized code (fastest) to RTMB vectorized or
for-loop code (both a bit slower, but not different from each other) to
native R for-loops (much slower):data argument)broom.mixed package does have a rudimentary
tidy method for TMB objects
(e.g. class(TMBobj) <- c("TMB", class(TMBobj)); broom.mixed::tidy(TMBobj))MakeADFun,
you can use assign(..., environment(objective_function)) to
make sure that the objective function can see any objects it needs to
know about …
Need a high-speed mirror for your open-source project?
Contact our mirror admin team at info@clientvps.com.
This archive is provided as a free public service to the community.
Proudly supported by infrastructure from VPSPulse , RxServers , BuyNumber , UnitVPS , OffshoreName and secure payment technology by ArionPay.