Open paciorek opened 2 years ago
Note that if each element of x
is multivariate, then we'd have the situation that the indexing relates to the elements of the multivariate vector and not to time. This would be fine, unless the model were defined on, say, x[time, 2:3]
, in which case the 2:3 would not carry over to the modelValues naming.
At least for the scalar case, we could get around this by instantiating the modelValues based on a symbolTable rather than {vars,types,sizes}, giving sizes
as numeric(0), as is what happens when setting up modelValues for MCMC.
However, this seems to require using nimble:::symbolTable
, which is not exported...
This was my attempt at this (in BootstrapFilter.R
where mv{E,}Wsamples
is created if saveAll=FALSE
.
for(i in seq_along(modelSymbolObjects))
if(is.null(dim( modelSymbolObjects[[i]]$size))) {
modelSymbolObjects[[i]]$size <- numeric(0)
modelSymbolObjects[[i]]$nDim <- 0
} else modelSymbolObjects[[i]]$size = as.numeric(dims[[1]])
symTab <- nimble:::symbolTable(symbols = modelSymbolObjects)
mvEWSamples <- modelValues(modelValuesConf(symTab))
symTab$addSymbol(nimble:::symbolBasic(name = 'wts',type='double',size=numeric(0), nDim = 0))
mvWSamples <- modelValues(modelValuesConf(symTab))
however, internally we do some checking for inconsistent dimensions and this warning is triggered:
Confused in varAndInds2MapParts: nDim != varAndInds.indices.size()
presumably because of a mismatch of the dimension of the latent vector compared to the modelValues representation of it.
So I'm just going to leave things as they are.
when saveAll = FALSE, only a single time step is saved, namely the last time step. However the column name in the mv objects will have [1]. E.g., if the variable is 'x', it will be x[1].
Given modelValues are designed to save entire variables, not clear there is an easy way to fix this.