Skip to contents

Maps a parameter vector that corresponds to sampled parameters of the cognitive model back to the experimental design. The parameter vector can be created using sampled_p_vector(). The returned matrix shows whether/how parameters differ across the experimental factors.

Usage

mapped_par(
  p_vector,
  design,
  model = NULL,
  digits = 3,
  remove_subjects = TRUE,
  covariates = NULL,
  ...
)

Arguments

p_vector

A parameter vector. Must be in the form of sampled_p_vector(design)

design

A design list. Created by design

model

Optional model type (if not already specified in design)

digits

Integer. Will round the output parameter values to this many decimals

remove_subjects

Boolean. Whether to include subjects as a factor in the design

covariates

Covariates specified in the design can be included here.

...

optional arguments

Value

Matrix with a column for each factor in the design and for each model parameter type (p_type).

Examples

# First define a design:
design_DDMaE <- design(data = forstmann,model=DDM,
                           formula =list(v~0+S,a~E, t0~1, s~1, Z~1, sv~1, SZ~1),
                           constants=c(s=log(1)))
#> Parameter(s) st0 not specified in formula and assumed constant.
#> 
#>  Sampled Parameters: 
#> [1] "v_Sleft"     "v_Sright"    "a"           "a_Eneutral"  "a_Eaccuracy"
#> [6] "t0"          "Z"           "sv"          "SZ"         
#> 
#>  Design Matrices: 
#> $v
#>      S v_Sleft v_Sright
#>   left       1        0
#>  right       0        1
#> 
#> $a
#>         E a a_Eneutral a_Eaccuracy
#>     speed 1          0           0
#>   neutral 1          1           0
#>  accuracy 1          0           1
#> 
#> $t0
#>  t0
#>   1
#> 
#> $s
#>  s
#>  1
#> 
#> $Z
#>  Z
#>  1
#> 
#> $sv
#>  sv
#>   1
#> 
#> $SZ
#>  SZ
#>   1
#> 
#> $st0
#>  st0
#>    1
#> 
# Then create a p_vector:
p_vector=c(v_Sleft=-2,v_Sright=2,a=log(1),a_Eneutral=log(1.5),a_Eaccuracy=log(2),
          t0=log(.2),Z=qnorm(.5),sv=log(.5),SZ=qnorm(.5))
# This will map the parameters of the p_vector back to the design
mapped_par(p_vector,design_DDMaE)
#>          E     S  v   a  sv  t0 st0 s   Z  SZ    z   sz
#> 1    speed  left -2 1.0 0.5 0.2   0 1 0.5 0.5 0.50 0.50
#> 2  neutral  left -2 1.5 0.5 0.2   0 1 0.5 0.5 0.75 0.75
#> 3 accuracy  left -2 2.0 0.5 0.2   0 1 0.5 0.5 1.00 1.00
#> 4    speed right  2 1.0 0.5 0.2   0 1 0.5 0.5 0.50 0.50
#> 5  neutral right  2 1.5 0.5 0.2   0 1 0.5 0.5 0.75 0.75
#> 6 accuracy right  2 2.0 0.5 0.2   0 1 0.5 0.5 1.00 1.00