Description Usage Arguments Value Author(s) References Examples
This is an internal function of the weibull4 package
1 | run_metropolis_MCMC(x, y, startvalue, iterations, modes)
|
x |
Vector with the x values |
y |
Vector with the y values |
startvalue |
Vector with starting shape, scale, location, area and SD values for Metropolis-MCMC calculations |
iterations |
Number of iterations to be performed in MCMC simulation |
modes |
Sets unimodal (modes=1) or bimodal (modes=2) Weibull's distribution |
Matrix with 5 columns and iterations rows with Markov chains for shape, scale, location, area and SD parameters)
Florian Hartig - Theoretical Ecology
https://theoreticalecology.wordpress.com/2010/09/17/metropolis-hastings-mcmc-in-r/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function (startvalue, iterations)
{
chain <- array(dim = c(iterations + 1, 5))
chain[1, ] <- startvalue
for (i in 1:iterations) {
proposal <- proposalfunction(chain[i, ])
probab <- exp(posterior(proposal) - posterior(chain[i,
]))
if (runif(1) < probab) {
chain[i + 1, ] <- proposal
}
else {
chain[i + 1, ] <- chain[i, ]
}
}
return(chain)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.