Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

column names in mv{E,}WSamples for filters with saveAll = FALSE are confusing #7

Open
paciorek opened this issue Dec 4, 2021 · 3 comments
Labels

Comments

@paciorek
Copy link
Contributor

paciorek commented Dec 4, 2021

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.

@paciorek
Copy link
Contributor Author

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.

@paciorek
Copy link
Contributor Author

However, this seems to require using nimble:::symbolTable, which is not exported...

@paciorek
Copy link
Contributor Author

paciorek commented Aug 14, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant