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

Updated some functions starting with b and c. #256

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
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
8 changes: 4 additions & 4 deletions BayesianTools/R/blockUpdate.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

#' Determine the groups of correlated parameters
#' @author Stefan Paul
#' @param chain MCMC chain including only the parameters (not logP,ll, logP)
#' @param blockSettings list with settings
#' @param blockSettings a list with settings
#' @return groups
#' @keywords internal
updateGroups <- function(chain,blockSettings){
Expand Down Expand Up @@ -60,7 +59,7 @@ getBlock <- function(blockSettings){


#' getblockSettings
#' @description Transforms the original settings in settings used in the model runs
#' @description Transforms the original settings to settings used in the model runs
#' @param blockUpdate input settings
#' @return list with block settings
#' @keywords internal
Expand Down Expand Up @@ -88,4 +87,5 @@ getBlockSettings <- function(blockUpdate){
return(list(blockUpdateType = blockUpdateType, h = h, k = k, pSel = pSel,
pGroup = pGroup, groups = groups))
}



12 changes: 4 additions & 8 deletions BayesianTools/R/codaFunctions.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#' Function to combine chains
#'
#' @param x a list of MCMC chains
#' @param merge logical determines whether chains should be merged
#' @param merge logical, should chains be merged? (T or F)
#' @return combined chains
#'
#' @note to combine several chains to a single McmcSamplerList, see \code{\link{createMcmcSamplerList}}
#'
#' @keywords internal
combineChains <- function(x, merge = T){

Expand Down Expand Up @@ -40,14 +37,13 @@ combineChains <- function(x, merge = T){
}



#' Helper function to change an object to a coda mcmc class,
#'
#' @param chain mcmc Chain
#' @param start for mcmc samplers start value in the chain. For SMC samplers, start particle
#' @param end for mcmc samplers end value in the chain. For SMC samplers, end particle
#' @param start for MCMC samplers, the initial value in the chain. For SMC samplers, start particle
#' @param end for MCMC samplers, the end value in the chain. For SMC samplers, end particle.
#' @param thin thinning parameter
#' @return object of class coda::mcmc
#' @return object an object of class coda::mcmc
#' @details Very similar to coda::mcmc but with less overhead
#' @keywords internal
makeObjectClassCodaMCMC <- function (chain, start = 1, end = numeric(0), thin = 1){
Expand Down
19 changes: 7 additions & 12 deletions BayesianTools/R/convertCoda.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@

#' Convert coda::mcmc objects to BayesianTools::mcmcSampler
#' @description Function is used to make the plot and diagnostic functions
#' available for coda::mcmc objects
#' @param sampler An object of class mcmc or mcmc.list
#' @param names vector giving the parameter names (optional)
#' @param info matrix (or list with matrices for mcmc.list objects) with three coloumns containing log posterior, log likelihood and log prior of the sampler for each time step (optional; but see Details)
#' @param likelihood likelihood function used in the sampling (see Details)
#' @details The parameter 'likelihood' is optional for most functions but can be needed e.g for
#' using the \code{\link{DIC}} function.
#'
#' Also the parameter info is optional for most uses. However for some functions (e.g. \code{\link{MAP}})
#' the matrix or single coloumns (e.g. log posterior) are necessary for the diagnostics.
#' @description Function to support plotting and diagnostic functions for coda::mcmc objects.
#' @param sampler an object of class mcmc or mcmc.list
#' @param names a vector with parameter names (optional)
#' @param info a matrix (or list with matrices for mcmc.list objects) with three columns containing log posterior, log likelihood and log prior of the sampler for each time step (optional; but see Details)
#' @param likelihood likelihood function used for sampling (see Details)
#' @details The parameter 'likelihood' is optional for most functions but can be needed e.g for \code{\link{DIC}} function.
#' Also, the parameter information is typically optional for most uses. However, for certain functions (e.g. \code{\link{MAP}}), the matrix or single columns (e.g. log posterior) are necessary for diagnostics.
#' @export

convertCoda <- function(sampler, names = NULL, info = NULL, likelihood = NULL){
Expand Down
2 changes: 1 addition & 1 deletion BayesianTools/man/combineChains.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 7 additions & 11 deletions BayesianTools/man/convertCoda.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion BayesianTools/man/getBlockSettings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions BayesianTools/man/makeObjectClassCodaMCMC.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion BayesianTools/man/updateGroups.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading