Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/nimble/R/options.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ nimOptimMethod("bobyqa",
MCMCwarnUnsampledStochasticNodes = TRUE,
MCMCRJcheckHyperparam = TRUE,
MCMCenableWAIC = FALSE,
MCMCuseBarkerAsDefaultMV = FALSE,
MCMCuseBarkerAsDefaultMV = FALSE,
parameterTransformWarnUserDists = TRUE,
useClearCompiledInADTesting = TRUE,
unsupportedDerivativeHandling = 'error', # default is error, other options are 'warn' and 'ignore'. Handled in updateADproxyModelMethods in cppDefs_nimbleFunction.R
errorIfMissingNFVariable = TRUE,
Expand Down
22 changes: 17 additions & 5 deletions packages/nimble/R/parameterTransform.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ parameterTransform <- nimbleFunction(
## 3: scalar interval-constrained (0, 1)
## 4: scalar semi-interval (-Inf, b) or (a, Inf)
## 5: scalar interval-constrained (a, b)
## 6: multivariate {normal, t, CAR}
## 6: multivariate {normal, t, CAR} and multivariate user-defined distributions
## 7: multivariate {wishart, inverse-wishart}
## 8: multivariate dirichlet
## 9: LKJ
Expand Down Expand Up @@ -171,15 +171,27 @@ parameterTransform <- nimbleFunction(
if(length(all.vars(lowerBdExpr)) > 0) stop('Node ', node, ' appears to have a non-constant lower bound, which cannot be used in parameterTransform.')
if(length(all.vars(upperBdExpr)) > 0) stop('Node ', node, ' appears to have a non-constant upper bound, which cannot be used in parameterTransform.')
} else { ## some other distribution with finite support
message(' [Warning] `parameterTransform` system cannot process the ', dist, ' distribution of node ', node, '.\n The upper and lower bounds of the ', dist, ' distribution must be constant.\n If you\'re uncertain about this, please get in touch with the NIMBLE development team.')
messageIfVerbose(' [Warning] `parameterTransform` system cannot process the `', dist, '`\n',
' distribution for node `', node, '. The upper and lower bounds\n',
' of `', dist, '` must be constant.\n')
}
transformType[i] <- 5L
transformData[i,DATA1] <- bounds[1] ## formerly lowerBound
transformData[i,DATA2] <- bounds[2] - bounds[1] ## formerly range
next }
stop(paste0('`parameterTransform` system doesn\'t have a transformation for the bounds of node: ', node, ', which are (', bounds[1], ', ', bounds[2], ')'))
stop('`parameterTransform` system doesn\'t have a transformation for the bounds of node: ', node, ', which are (', bounds[1], ', ', bounds[2], ')')
} else { ## multivariate
if(dist %in% c('dmnorm', 'dmvt', 'dcar_normal', 'dcar_proper')) { ## 6: multivariate {normal, t, CAR}; also set for non-scalar determ nodes when allowDeterm is TRUE
if(dist %in% c('dmnorm', 'dmvt', 'dcar_normal', 'dcar_proper') || ## 6: multivariate {normal, t, CAR},
isUserDefined(dist)) ## all multivariate user-defined distributions,
{ ## and non-scalar determ nodes when allowDeterm is TRUE
if(isUserDefined(dist) && getNimbleOption('parameterTransformWarnUserDists'))
messageIfVerbose(
' [Warning] `parameterTransform` system detected multivariate user-defined\n',
' distribution `', dist, '`. No transformation will be applied\n',
' to any dimension of the `x` values of `', dist, '`.\n',
' If some values of `x` are not valid, you may encounter errors.\n',
' This warning can be disabled using\n',
' `nimbleOptions(parameterTransformWarnUserDists = FALSE)`.')
transformType[i] <- 6L
d <- length(model$expandNodeNames(node, returnScalarComponents = TRUE))
transformData[i,NIND2] <- transformData[i,NIND1] + d - 1
Expand Down Expand Up @@ -211,7 +223,7 @@ parameterTransform <- nimbleFunction(
transformData[i,DATA1] <- d
transformData[i,DATA2] <- p
next }
stop(paste0('parameterTransform doesn\'t handle \'', dist, '\' distributions.'), call. = FALSE)
stop('parameterTransform doesn\'t handle \'', dist, '\' distributions.', call. = FALSE)
}
}
if(nNodes == 0) {
Expand Down
Loading