This is a constructor for a single Tempered Partition MCMC step. The function constructs an environment with the proposal, inverse temperature, and verbose flag. It then returns a function that takes the current_state and a scorer object. This only allows the scores to be raised to a constant temperature for every step.
Usage
PartitionMCMC(
proposal = DefaultProposal(),
temperature = 1,
prerejection = TRUE,
verbose = TRUE
)
Arguments
- proposal
Proposal function. Default is the DefaultProposal.
- temperature
Numeric value representing the temperature to raise the score to. Default is 1.
- prerejection
Boolean flag to discard proposals due to the proposal disobeying the black or white lists. Setting this to TRUE disobeys detailed balance but can be useful for debugging. Default is FALSE.
- verbose
Flag to pass MCMC information.
Examples
dag <- UniformlySampleDAG(c('A', 'B', 'C', 'D', 'E', 'F'))
partitioned_nodes <- DAGtoPartition(dag)
scorer <- CreateScorer(
scorer = BNLearnScorer,
data = bnlearn::learning.test
)
current_state <- list(
state = partitioned_nodes,
log_score = ScoreLabelledPartition(partitioned_nodes, scorer)
)
pmcmc <- PartitionMCMC(proposal = DefaultProposal(), temperature = 1.0)
pmcmc(current_state, scorer)
#> $state
#> partition node
#> 1 1 E
#> 2 2 F
#> 3 3 B
#> 4 3 C
#> 5 4 A
#> 6 5 D
#>
#> $log_score
#> [1] -24020.94
#>
#> $proposal_info
#> $proposal_info$proposal_used
#> [1] "node_move"
#>
#>
#> $mcmc_info
#> $mcmc_info$accept
#> [1] FALSE
#>
#> $mcmc_info$white_obeyed
#> [1] TRUE
#>
#> $mcmc_info$black_obeyed
#> [1] TRUE
#>
#> $mcmc_info$jac
#> [1] 0
#>
#> $mcmc_info$mhr
#> [1] -126.6712
#>
#>