General discussion, documentation and team work
flr / fla4a Goto Github PK
View Code? Open in Web Editor NEWThe repository for the JRC initiative on stock assessment
Home Page: https://fishreg.jrc.ec.europa.eu/web/a4a
The repository for the JRC initiative on stock assessment
Home Page: https://fishreg.jrc.ec.europa.eu/web/a4a
check layout
For now the default models are set up inside the fitting functions and retro. It would be better to have these specified by specific methods so that changes in defaults could be controlled.
Iter does not subset lists within the objects. May be changed in FLCore or else we'll have to overload the method for a4aFit.
Need to develop a method that shows the residuals of the S/R function fit. One possibility is to generate a FLSR from a a4aFit and use the FLR methods. This one would be usefull for MSE.
data(ple4)
bioidx <- FLIndex(FLQuant(NA, dimnames=list(age="all", year=range(ple4)["minyear"]:range(ple4)["maxyear"])))
index(bioidx) <- stock(ple4)_0.001
index(bioidx) <- index(bioidx)_exp(rnorm(index(bioidx), sd=0.1))
fit <- sca(ple4, FLIndices(bio=bioidx), qmodel=list(~1))
ple4+fit # this works
fit <- sca(ple4, FLIndices(bio=bioidx), qmodel=list(~1), fit="assessment")
ple4+fit # this one doesn't
I computed the no. pars as nage+2*ny+fk+qk . It seems to be missing the variance model parameters.
at the moment '+' adds when a a4aFit is used and simulates when a a4aFitSA is present, by calling '*'. but if a a4aFit with iters is used and the FLStock doesn't have iters the method fails and asks the user provide a FLStock with iters ... could be smarter.
should work the same as when ADMB fails to return the hessian, produce a fit with NA
This method is not using the list names to get the parameters' values. Need checking.
The application of l2a with simulations to all quants in a stock can generate inconsistent F,N,C . Converting 2 of these 3 and computing the third could sort out this problem
simulate
predict
+
all of these have bugs ...
try instead:
grep('executable', system(paste("file", paste(a4a.dir(), "a4a",
sep='/')), inter=TRUE))
that would return 1 if 'executable' is found in the output of file,
which I read always says so in any architecture and unix shell
Cheers,
Iago
it would allow runs with simulations to carry on instead of stopping.
One single method that uses weights. The default should use AIC or BIC, but leave the possibility of using "expert" knowledge.
The getX method fails because it's passing the name of the model and not the parameters
library(FLa4a)
data(ple4)
data(ple4.index)
fit <- sca(ple4, FLIndices(ple4.index), qmodel=list(~s(age, k=4)), fit="assessment")
fit <- simulate(fit, 2)
dims(stkmodel(pars(fit)))["iter"]
Which one should we use ? import in NAMESPACE or depends on DESCRIPTION ?
Method to predict the major variables, including Q.
a4aSCA works fine.
library(FLa4a)
data(ple4)
data(ple4.indices)
fit <- sca(ple4, ple4.indices, fit="assessment")
flqs <- predict(fit)
sfrac <- mean(range(ple4.indices[[1]])[c("startf", "endf")])
Z <- (m(ple4) + harvest(fit))_sfrac
lst <- dimnames(fit@index[[1]])
lst$x <- stock.n(fit)_exp(-Z)
stkn <- do.call("trim", lst)
qhat <- index(fit)[[1]]/stkn
all.equal(c(qhat), c(flqs$qmodel[[1]]))
need to check why it's failing when catch.n is FLQuantDistr
Boudaries in Q log(]0,1]) and F log(]0,2]) shouldn't be too difficult to include and I guess they will help a lot the minimization.
If several models have the same parameter, e.g. k, only one value should be allowed to avoid inconsistencies. The varcov could be tweaked to use one single set of correlations with the parameters of the distinct models.
Should output a FLQuants with residuals for catch and Q and S/R
It must be ~1 and remove the age factor
being "all" or a single age should plot the time series instead of ahe by year, which results in empty plots with one dot per panel.
dispatch on numeric
We can have an index of biomass that relates with a limited number of ages. The loop in ADMB would need to go between the age range on the index and not on the stock. The problem is that we're identifying the index by the number of ages it has. We could overcome this by creating an extended index for biomass cases, which would make it easier for other bits of the code.
In some classes it's pars in others params ... shold be better to use only one of them.
iter is used to subset but it should be done with trim or [ . seed will allow to control the simulation and is in agreement with the definition of the generic method.
Needs fixing. Results are wrong.
Set up the ADMB model to use distinct phases for minimization. The first could be Q, which is the most difficult one, then variance and finnaly S/R and C.
It will give the opportunity to understand what's wrong with hessian and prevents the inversion to compute sd.
see tests for +
The techdoc must be updated with a example models. In particular more advanced models including replace age, covariates, etc. Later we may split that document in several vignettes.
indices residuals are biased
fmodel <- ~ s(age, k=4) + s(year, k = 20)
qmodel <- list( ~ s(age, k=4) + year)
srmodel <- ~s(year, k=20)
fit <- a4aSCA(ple4, ple4.indices[1], fmodel, qmodel, srmodel)
fits <- simulate(fit, 25)
stks <- ple4 + fits
idxs <- ple4.indices[1]
index(idxs[[1]]) <- index(fits)[[1]]
fits <- a4aSCA(stks, idxs, fmodel, qmodel, srmodel, fit="MP")
fits <- a4aSCA(stks, ple4.indices[1], fmodel, qmodel, srmodel, fit="MP")
Some bugs that were already fixed (0.9.3) surfaced (0.9.5). It's risky and more work to keep two repositories.
I guess I need to import qqmath from lattice
the best way is to allow for a list of models that have distinct ks or else use substitute ??
srmodel looks for the covariate in the environment instead of using the covar argument. It's not safe, it should use the covar as the other variables.
sel.pattern shouldn't be computed, same problems as F
q should be weighted
variance must be computed using the write formula var((x+y)/2) = [var(x)+var(y)]*(1/2)^2
library(FLa4a)
data(ple4)
data(ple4.indices)
fit <- sca(ple4, ple4.indices, fit="assessment")
flqs <- predict(fit)
sfrac <- mean(range(ple4.indices[[1]])[c("startf", "endf")])
Z <- (m(ple4) + harvest(fit))_sfrac
lst <- dimnames(fit@index[[1]])
lst$x <- stock.n(fit)_exp(-Z)
stkn <- do.call("trim", lst)
qhat <- index(fit)[[1]]/stkn
all.equal(c(qhat), c(flqs$qmodel[[1]]))
It would make it easier to distribute documentation and would be used for testing automagically
It's buggy. In a4aFitSA there is no index but the coefficients are in pars. In a4aFit version 0.9.5 there is no index too.
A wireframe plot with [C], [N], [F]
stk2 <- ple4
idx2 <- ple4.index
catch.n(stk2) <- genFLQuant(catch.n(stk2), 0.1, niter=nits)
index(idx2) <- genFLQuant(index(fit0)[[1]], 0.1, niter=nits)check iters match
fit <- a4aSCA(stk2, FLIndices(idx2))
fit0 <- a4aSCA(ple4, FLIndices(ple4.index))
Note: The following observations are treated as being missing at random:
fleet year age
BTS-Isis 1997 1
BTS-Isis 1997 2
Predictions will be made for missing observations.
fitSumm(fit0)
iters
1
nopar 1.20000e+02
nlogl 1.70697e+02
maxgrad 2.42845e-03
nobs 7.10000e+02
fitSumm(fit)
iters
1 2
nopar 1.20000e+02 1.20000e+02
nlogl -2.42417e+02 -2.30977e+02
maxgrad 6.76072e-03 3.14076e-03
nobs 7.12000e+02 7.12000e+02
dispatch not working
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.