run_metropolis_MCMC: Runs the Metropolis-MCMC algorithm for weibull4 package

Description Usage Arguments Value Author(s) References Examples

View source: R/weibull4.r

Description

This is an internal function of the weibull4 package

Usage

1
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)

Author(s)

Florian Hartig - Theoretical Ecology

References

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

Examples

 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)
  }

weibull4 documentation built on Jan. 26, 2021, 1:06 a.m.