Learn R Programming

weibull4 (version 1.0.0)

run_metropolis_MCMC: Runs the Metropolis-MCMC algorithm for weibull4 package

Description

This is an internal function of the weibull4 package

Usage

run_metropolis_MCMC(x, y, startvalue, iterations, modes)

Arguments

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

Value

Matrix with 5 columns and iterations rows with Markov chains for shape, scale, location, area and SD parameters)

References

https://theoreticalecology.wordpress.com/2010/09/17/metropolis-hastings-mcmc-in-r/

Examples

Run this code
# NOT RUN {
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)
  }
# }

Run the code above in your browser using DataLab