Skip to contents

make_parspace() makes a n x 4 matrix with the parameter bounds, starting value, and no-effect value of parameters

Usage

make_parspace(...)

Arguments

...

Parameters and their ranges, e.g., make_parspace(theta = c(ub=-1, lb=1, init=0, na=0), gamma = c(0,2,1,NA)). See details and examples. The general schema per parameter is a named vector parametername = c(ub = #, lb = #, init = #, na = #).

"lb"

Lower limit, smallest allowed value

"ub"

Upper limit, highest allowed value

"start" (optional)

Initial value for estimation of parameters

"na" (optional)

Value the parameter takes if it should have no effect, can be 'NA'

Value

A matrix with as many rows as parameters, in which the rownames are the parameter names, and four columns lb, ub, init, na that define the lower limit, upper limit, initial value and null-effect-value (optional) for each parameter.

Details

"na" is an optional value a parameter takes such that this parameter has no effect.

To define a parameter \(\alpha\) with \(0 \le \alpha \le 1\) use one argument, alpha = c(0,1). To define an additional parameter \(\beta\) with \(2 \le \beta \le 9\) use two arguments, alpha = c(0,1), beta = c(2,9), and so forth. You can specify an initial value for the parameter used in fitting as third element of vectors.

Examples

## Define a parameter "p" that can range from 0-1
make_parspace(p = c(0,1))
#>   lb ub start na
#> p  0  1   0.5 NA
makeparspapce(p = c(lb=0, ub=2)) # the same
#> Error in makeparspapce(p = c(lb = 0, ub = 2)): could not find function "makeparspapce"

# Note:
# Initial value will be the mean of 0 and 1.


## Define a parameter "zeta" from 0-5
## and set the initial value to 2
make_parspace(zeta = c(lb=0, ub=5, init=2))
#>      lb ub start na
#> zeta  0  5     2 NA
make_parspace(zeta = c(0,5,2)) # the same
#>      lb ub start na
#> zeta  0  5     2 NA
make_parspace(zeta = c(ub=5,lb=0,init=2)) #the same
#> Error: Lower bound of parameter space cannot be greater than upper bound, but lb > ub for each of the parameters (lb > ub):
#>   * zeta: 5 > 0
#>   -> Check parspace. Ensure the lb < ub, e.g. 'make_parspace(a = c(0, 1, 0.5))'.


## Define one parameter "expon" from 0-2 with initial value 0.5
## and a value of 1 making it have no effect
make_parspace(expon = c(0,2,1,1))
#>       lb ub start na
#> expon  0  2     1  1
make_parspace(expon = c(lb=0,ub=2,init=1,na=1)) #the same
#>       lb ub start na
#> expon  0  2     1  1


## Define four parameter alpha, beta, gamma, delta
make_parspace(alpha = c(lb=0,ub=1,init=0.5,na=0),
                beta = c(1,10,5,NA),
                gamma = c(lb=1,ub=2,init=0,na=1),
                delta = c(1,2,0))
#> Error in make_parspace(alpha = c(lb = 0, ub = 1, init = 0.5, na = 0),     beta = c(1, 10, 5, NA), gamma = c(lb = 1, ub = 2, init = 0,         na = 1), delta = c(1, 2, 0)): Initial value < lower limit for the parameter: [“gamma”, “delta”]. Ensure "start" is > "lb"), e.g. make_parspace(a = c(0, 1, 0.5)).

## Dynamically define new parameter "gamma" and "delta"
## with the same definition (ub, lb, init, na)
def <- c(lb = 0, ub = 1, init = 0.5, na = 0)
deflist <- list("gamma" = def, "delta" = def)
do.call(make_parspace, deflist)
#>       lb ub start na
#> gamma  0  1   0.5  0
#> delta  0  1   0.5  0