make_parspace: Define parameter for cognitive models

View source: R/utils.R

make_parspaceR Documentation

Define parameter for cognitive models

Description

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'

Details

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

To define a parameter α with 0 ≤ α ≤ 1 use one argument, alpha = c(0,1). To define an additional parameter β with 2 ≤ β ≤ 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.

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.

Examples

## Define a parameter "p" that can range from 0-1
make_parspace(p = c(0,1))
makeparspapce(p = c(lb=0, ub=2)) # the same

# 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))
make_parspace(zeta = c(0,5,2)) # the same
make_parspace(zeta = c(ub=5,lb=0,init=2)) #the same


## 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))
make_parspace(expon = c(lb=0,ub=2,init=1,na=1)) #the same


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

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

JanaJarecki/cogscimodels documentation built on Nov. 4, 2022, 5:33 p.m.