threshold: Threshold Model

View source: R/model-treshold.R

thresholdR Documentation

Threshold Model

Description

treshold() fits a threshold model with the threshold as free parameter.

  • treshold_c() models continuous responses in form of the distance to a threshold

  • treshold_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 data to be modeled. For example, y ~ x1 models 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 are nu (see details - model parameters).

  • list(nu = 0.62) sets parameter nu equal 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, or list(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.

Details

Given the formula y ~ a the model predicts y = 1 for a >= nu and y = 0 for a < nu

Value

A model of class "treshold".

Model Parameters

  • nu: the threshold.

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

Author(s)

Jana B. Jarecki, jj@janajarecki.com

Jana B. Jarecki

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
anova(M)                                       # anova-like table
summary(M)                                     # summarize

M <- threshold_d(y ~ a, D, fix="start")        # fixed par. to start values
predict(M)                                     # predict dist. to threshold
anova(M)                                       # anova-like table
summary(M)                                     # summarize
M$MSE()                                        # mean-squared error   

### Binary response given a threshold
# --------------------------------------------
M <- threshold(y ~ a, D, fix="start", choicerule = "softmax")
predict(M)                       #  --"--  maximum posterior
anova(M)                                       # anova-like table
summary(M)                                     # summarize
M$MSE()                                        # mean-squared error    


### 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.,
                                                  # and fits none 
threshold(y ~ a , D, list(nu=2), "softmax")       # fix threshold nu to 2
threshold(y ~ a, D, list(tau=0.5), "softmax")     # fix soft-max tau to 1   
threshold(y ~ a, D, choicerule = "softmax")       # nu and tau free param   


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