
Threshold Model
threshold.Rdtreshold() fits a threshold model with the threshold as free parameter.
treshold_c()models continuous responses in form of the distance to a thresholdtreshold_d()models discrete choices given the distance to a threshold
Usage
threshold(
formula,
data,
fix = list(),
choicerule = NULL,
mode,
discount = 0L,
options = list(),
...
)
threshold_c(
formula,
data,
fix = list(),
choicerule = NULL,
discount = 0,
options = list(),
...
)
threshold_d(
formula,
data,
fix = list(),
choicerule = "softmax",
discount = 0,
options = list(),
...
)Arguments
- formula
A formula, the variables in
datato be modeled. For example,y ~ x1models response y as function of one stimulus value x1.- data
A data frame, the data to be modeled.
- fix
(optional) A list with parameter-value pairs of fixed parameters. If missing all free parameters are estimated. If set to
"start"all parameters are fixed to their start values. Model parameter names arenu(see details - model parameters).list(nu = 0.62)sets parameternuequal to 0.62."start"sets all parameters equal to their initial values (estimates none). Useful for building a first test model.
- discount
A number, how many initial trials to not use during parameter fitting.
- options
(optional) A list, list entries change the modeling procedure. For example,
list(lb = c(k=0))changes the lower bound of parameter k to 0, orlist(fit_measure = "mse")changes the goodness of fit measure in parameter estimation to mean-squared error, for all options, see cm_options.- ...
other arguments, ignored.
Value
A model of class "treshold".
Returns a cognitive model object, which is an object of class cm. A model, that has been assigned to m, can be summarized with summary(m) or anova(m). The parameter space can be viewed using pa. rspace(m), constraints can be viewed using constraints(m).
See also
Other cognitive models:
baseline_const_c(),
bayes(),
choicerules,
cpt,
ebm(),
hm1988(),
shift(),
shortfall,
utility
Examples
D <- data.frame(
y = rep(0:1, each=5),
a = 1:10)
M <- threshold_c(y ~ a, D, fix="start") # fixed par. to start values
predict(M) # predict dist. to threshold
#> [1] -4.5 -3.5 -2.5 -1.5 -0.5 0.5 1.5 2.5 3.5 4.5
anova(M) # anova-like table
#> Sum Sq. Table
#> N Par Sum Sq Mean Sq
#> 0 62.5 6.25
summary(M) # summarize
#>
#> Model:
#> with no choice rule
#> Call:
#> y ~ a
#>
#> No Free Parameters
#>
#> Fit Measures:
#> MSE: 6.2, LL: -127, AIC: 255, BIC: 255
#>
M <- threshold_d(y ~ a, D, fix="start") # fixed par. to start values
predict(M) # predict dist. to threshold
#> [1] 2.061154e-09 1.125352e-07 6.144175e-06 3.353501e-04 1.798621e-02
#> [6] 5.000000e-01 9.820138e-01 9.996646e-01 9.999939e-01 9.999999e-01
anova(M) # anova-like table
#> Sum Sq. Table
#> N Par Sum Sq Mean Sq
#> 0 0.25065 0.025065
summary(M) # summarize
#>
#> Model:
#> with no choice rule
#> Call:
#> y ~ a
#>
#> No Free Parameters
#>
#> Fit Measures:
#> MSE: 0.025, LL: -0.73, AIC: 1.5, BIC: 1.5
#>
M$MSE() # mean-squared error
#> [1] 0.02506472
### Binary response given a threshold
# --------------------------------------------
M <- threshold(y ~ a, D, fix="start", choicerule = "softmax")
#> Error in match.arg(mode, c("continuous", "discrete")): argument "mode" is missing, with no default
predict(M) # --"-- maximum posterior
#> [1] 2.061154e-09 1.125352e-07 6.144175e-06 3.353501e-04 1.798621e-02
#> [6] 5.000000e-01 9.820138e-01 9.996646e-01 9.999939e-01 9.999999e-01
anova(M) # anova-like table
#> Sum Sq. Table
#> N Par Sum Sq Mean Sq
#> 0 0.25065 0.025065
summary(M) # summarize
#>
#> Model:
#> with no choice rule
#> Call:
#> y ~ a
#>
#> No Free Parameters
#>
#> Fit Measures:
#> MSE: 0.025, LL: -0.73, AIC: 1.5, BIC: 1.5
#>
M$MSE() # mean-squared error
#> [1] 0.02506472
### Parameter specification and fitting
----------------------------------------
# Use a response variable, y, to which we fit parameter
threshold(y ~ a, D, fix = "start", "softmax") # "start" fixes all par.,
#> Error in match.arg(mode, c("continuous", "discrete")): argument "mode" is missing, with no default
# and fits none
threshold(y ~ a , D, list(nu=2), "softmax") # fix threshold nu to 2
#> Error in match.arg(mode, c("continuous", "discrete")): argument "mode" is missing, with no default
threshold(y ~ a, D, list(tau=0.5), "softmax") # fix soft-max tau to 1
#> Error in match.arg(mode, c("continuous", "discrete")): argument "mode" is missing, with no default
threshold(y ~ a, D, choicerule = "softmax") # nu and tau free param
#> Error in match.arg(mode, c("continuous", "discrete")): argument "mode" is missing, with no default