Description Usage Arguments Details Author(s) Examples

View source: R/classBayesianOutput.R

Extracts the sample from a bayesianOutput

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | ```
getSample(sampler, parametersOnly = T, coda = F, start = 1,
end = NULL, thin = 1, numSamples = NULL, whichParameters = NULL,
includesProbabilities = F, reportDiagnostics = FALSE, ...)
## S3 method for class 'matrix'
getSample(sampler, parametersOnly = T, coda = F,
start = 1, end = NULL, thin = "auto", numSamples = NULL,
whichParameters = NULL, includesProbabilities = F,
reportDiagnostics = F, ...)
## S3 method for class 'double'
getSample(sampler, parametersOnly = T, coda = F,
start = 1, end = NULL, thin = "auto", numSamples = NULL,
whichParameters = NULL, includesProbabilities = F,
reportDiagnostics = F, ...)
## S3 method for class 'integer'
getSample(sampler, parametersOnly = T, coda = F,
start = 1, end = NULL, thin = "auto", numSamples = NULL,
whichParameters = NULL, includesProbabilities = F,
reportDiagnostics = F, ...)
## S3 method for class 'data.frame'
getSample(sampler, parametersOnly = T, coda = F,
start = 1, end = NULL, thin = "auto", numSamples = NULL,
whichParameters = NULL, includesProbabilities = F,
reportDiagnostics = F, ...)
## S3 method for class 'list'
getSample(sampler, parametersOnly = T, coda = F,
start = 1, end = NULL, thin = "auto", numSamples = NULL,
whichParameters = NULL, includesProbabilities = F,
reportDiagnostics = F, ...)
## S3 method for class 'mcmc'
getSample(sampler, parametersOnly = T, coda = F,
start = 1, end = NULL, thin = "auto", numSamples = NULL,
whichParameters = NULL, includesProbabilities = F,
reportDiagnostics = F, ...)
## S3 method for class 'mcmc.list'
getSample(sampler, parametersOnly = T, coda = F,
start = 1, end = NULL, thin = "auto", numSamples = NULL,
whichParameters = NULL, includesProbabilities = F,
reportDiagnostics = F, ...)
## S3 method for class 'MCMC'
getSample(sampler, parametersOnly = T, coda = F,
start = 1, end = NULL, thin = "auto", numSamples = NULL,
whichParameters = NULL, includesProbabilities = F,
reportDiagnostics = F, ...)
## S3 method for class 'MCMC_refClass'
getSample(sampler, parametersOnly = T,
coda = F, start = 1, end = NULL, thin = "auto",
numSamples = NULL, whichParameters = NULL,
includesProbabilities = F, reportDiagnostics = F, ...)
``` |

`sampler` |
an object of class mcmcSampler, mcmcSamplerList, smcSampler, smcSamplerList, mcmc, mcmc.list, double, numeric |

`parametersOnly` |
if F, likelihood, posterior and prior values are also provided in the output |

`coda` |
works only for mcmc classes - provides output as a coda object. Note: if mcmcSamplerList contains mcmc samplers such as DE that have several chains, the internal chains will be collapsed. This may not be the desired behavior for all applications. |

`start` |
for mcmc samplers start value in the chain. For SMC samplers, start particle |

`end` |
for mcmc samplers end value in the chain. For SMC samplers, end particle |

`thin` |
thinning parameter. Either an integer determining the thinning intervall (default is 1) or "auto" for automatic thinning. |

`numSamples` |
sample size (only used if thin = 1). If you want to use numSamples set thin to 1. |

`whichParameters` |
possibility to select parameters by index |

`includesProbabilities` |
applies only to getSample.Matrix. logical, determining whether probabilities should be included in the result. |

`reportDiagnostics` |
logical, determines whether settings should be included in the output |

`...` |
further arguments |

If thin is greater than the total number of samples in the sampler object the first and the last element (of each chain if a sampler with multiples chains is used) are sampled. If numSamples is greater than the total number of samples all samples are selected. In both cases a warning is displayed.

If thin and numSamples is passed, the function will use the thin argument if it is valid and greater than 1, else numSamples will be used.

Florian Hartig

Florian Hartig

Tankred Ott

Tankred Ott

Tankred Ott

Tankred Ott

Tankred Ott

Tankred Ott

Tankred Ott

Tankred Ott

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ```
ll = function(x) sum(dnorm(x, log = TRUE))
setup = createBayesianSetup(ll, lower = c(-10,-10), upper = c(10,10))
settings = list(nrChains = 2, iterations = 1000)
out <- runMCMC(bayesianSetup = setup, sampler = "DEzs", settings = settings)
# population MCMCs divide the interations by the number of internal chains,
# so the end of the 3 chains is 1000/3 = 334
sample <- getSample(out, start = 100, end = 334, thin = 10)
# sampling with number of samples instead of thinning and
# returning a coda object
sample <- getSample(out, start = 100, numSamples = 60, coda = TRUE)
plot(sample)
# MCMC with a single chain:
settings_2 <- list(nrChains = 1, iterations = 1000)
out_2 <- runMCMC(setup, sampler = "Metropolis", settings = settings_2)
sample_2 <- getSample(out_2, numSamples = 100)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.