Describe a varying parameter for use within the nested pmcmc. Note that the name is not set here, but will end up being naturally defined when used with pmcmc_parameters_nested, which collects these together for use with pmcmc().

pmcmc_varied_parameter(
name,
populations,
initial,
min = -Inf,
max = Inf,
discrete,
integer = FALSE,
prior = NULL
)

## Arguments

name

Name for the parameter (a string)

populations

The name of the populations for which different values of the parameter are being estimated for, length n_pop.

initial

Initial value(s) for the parameter. Must be either length n_pop or 1, in which case the same value is assumed for all populations.

min

Optional minimum value(s) for the parameter (otherwise -Inf). If given, then initial must be at least this value. Must be either length n_pop or 1, in which case the same value is assumed for all populations.

max

Optional max value for the parameter (otherwise Inf). If given, then initial must be at most this value. Must be either length n_pop or 1, in which case the same value is assumed for all populations.

discrete

Deprecated; use integer instead.

integer

Logical, indicating if this parameter is integer. If TRUE then the parameter will be rounded after a new parameter is proposed.

prior

A prior function (if not given an improper flat prior is used - be careful!). It must be a function that takes a single argument, being the value of this parameter. If given, then prior(initial) must evaluate to a finite value. Must be either length n_pop or 1, in which case the same value is assumed for all populations.

## Examples

mcstate::pmcmc_varied_parameter(
name = "size",
populations = c("Europe", "America"),
initial = c(100, 200),
min = 0,
max = Inf,
integer = TRUE,
prior = list(dnorm, dexp))
#> $Europe #>$name
#> [1] "size"
#>
#> $initial #> [1] 100 #> #>$min
#> [1] 0
#>
#> $max #> [1] Inf #> #>$integer
#> [1] TRUE
#>
#> $prior #> function (x, mean = 0, sd = 1, log = FALSE) #> .Call(C_dnorm, x, mean, sd, log) #> <bytecode: 0x12c258e10> #> <environment: namespace:stats> #> #>$mean
#> [1] 100
#>
#> attr(,"class")
#> [1] "pmcmc_parameter"
#>
#> $America #>$name
#> [1] "size"
#>
#> $initial #> [1] 200 #> #>$min
#> [1] 0
#>
#> $max #> [1] Inf #> #>$integer
#> [1] TRUE
#>
#> $prior #> function (x, rate = 1, log = FALSE) #> .Call(C_dexp, x, 1/rate, log) #> <bytecode: 0x139c200d8> #> <environment: namespace:stats> #> #>$mean
#> [1] 200
#>
#> attr(,"class")
#> [1] "pmcmc_parameter"
#>
#> attr(,"class")
#> [1] "pmcmc_varied_parameter"