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 help files name starting with mcmc #257

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
typo
  • Loading branch information
TahminaMojumder committed Oct 6, 2023
commit 5a533bcd1992a1444b6ec71bd4ff75985c71f208
1 change: 1 addition & 0 deletions BayesianTools/R/classLikelihood.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#' @param sampler sampler
#' @seealso \code{\link{likelihoodIidNormal}} \cr
#' \code{\link{likelihoodAR1}} \cr
#' @example /inst/examples/createLikelihoodHelp.R
#' @export
createLikelihood <- function(likelihood, names = NULL, parallel = F, catchDuplicates=T,
sampler = NULL, parallelOptions = NULL){
Expand Down
2 changes: 1 addition & 1 deletion BayesianTools/inst/examples/VSEMHelp.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@


## This example shows how to run and calibrate the VSEM model

library(BayesianTools)
Expand Down
1 change: 0 additions & 1 deletion BayesianTools/inst/examples/marginalLikelihoodHelp.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,3 @@ marginalLikelihood(out, method = "HM", numSamples = 500)$ln.ML - theory
marginalLikelihood(out, method = "Bridge", numSamples = 500)$ln.ML - theory



3 changes: 1 addition & 2 deletions BayesianTools/inst/examples/plotSensitivityHelp.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

ll <- testDensityBanana
bayesianSetup <- createBayesianSetup(likelihood = ll, lower = rep(-10, 2), upper = rep(10, 2))

plotSensitivity(bayesianSetup)

3 changes: 2 additions & 1 deletion BayesianTools/inst/examples/plotTimeSeriesResultsHelp.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ likelihood <- function(par, sum = TRUE){
x[parSel] = par
predicted <- VSEM(x[1:11], PAR) # replace here VSEM with your model
predicted[,1] = 1000 * predicted[,1] # this is just rescaling
diff <- c(predicted[,1:4] - obs[,1:4]) # difference betweeno observed and predicted
diff <- c(predicted[,1:4] - obs[,1:4]) # difference between observed and predicted
# univariate normal likelihood. Note that there is a parameter involved here that is fit
llValues <- dnorm(diff, sd = x[12], log = TRUE)
if (sum == FALSE) return(llValues)
Expand Down Expand Up @@ -67,3 +67,4 @@ plotTimeSeriesResults(sampler = out, model = createPredictions, observed = obs[,
error = createError, prior = TRUE, main = "Prior predictive")

}

1 change: 1 addition & 0 deletions BayesianTools/inst/examples/proposalGeneratorHelp.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ testGenerator$returnProposal(testVector)
x <- testGenerator$returnProposalMatrix(testMatrix)
boxplot(x)
table(x[,4])

1 change: 1 addition & 0 deletions BayesianTools/inst/examples/testLinearModel.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

x = c(1,2)
y = testLinearModel(x)
plot(y)
2 changes: 2 additions & 0 deletions BayesianTools/inst/examples/tracePlotHelp.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


# set up and run the MCMC
ll <- function(x) sum(dnorm(x, log = TRUE))
setup <- createBayesianSetup(likelihood = ll, lower = c(-10, -10), upper = c(10,10))
Expand Down
2 changes: 1 addition & 1 deletion BayesianTools/man/VSEM.Rd

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

1 change: 1 addition & 0 deletions BayesianTools/man/createProposalGenerator.Rd

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

5 changes: 2 additions & 3 deletions BayesianTools/man/marginalLikelihood.Rd

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

3 changes: 1 addition & 2 deletions BayesianTools/man/plotSensitivity.Rd

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

1 change: 1 addition & 0 deletions BayesianTools/man/testLinearModel.Rd

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

2 changes: 2 additions & 0 deletions BayesianTools/man/tracePlot.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/vignettes/BayesianTools.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ The prior in the BayesianSetup consists of four parts
- lower / upper boundaries
- Additional info - best values, names of the parameters, ...

These information can be passed by first creating an a extra object, via createPrior, or through the the createBayesianSetup function.
These information can be passed by first creating an extra object, via createPrior, or through the the createBayesianSetup function.

#### Creating priors

Expand All @@ -316,7 +316,7 @@ You have 5 options to create a prior
- Do not set a prior - in this case, an infinite prior will be created
- Set min/max values - a bounded flat prior and the corresponding sampling function will be created
- Use one of the pre-definded priors, see ?createPrior for a list. One of the options here is to use a previous MCMC output as new prior. Pre-defined priors will usually come with a sampling function
- Use a user-define prior, see ?createPrior
- Use a user-defined prior, see ?createPrior
- Create a prior from a previous MCMC sample

#### Creating user-defined priors
Expand Down Expand Up @@ -568,7 +568,7 @@ MCMCs sample the posterior space by creating a chain in parameter space. While t

An alternative to MCMCs are particle filters, aka Sequential Monte-Carlo (SMC) algorithms. See Hartig, F.; Calabrese, J. M.; Reineking, B.; Wiegand, T. & Huth, A. Statistical inference for stochastic simulation models - theory and application Ecol. Lett., 2011, 14, 816-827

### Rejection samling
### Rejection sampling

The easiest option is to simply sample a large number of parameters and accept them according to their posterior value. This option can be emulated with the implemented SMC, setting iterations to 1.

Expand Down