ebm: Exemplar-based Cognitive Models

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/model-ebm.R

Description

ebm() fits an exemplar-based model.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
gcm(
  formula,
  class,
  data,
  choicerule,
  fix = NULL,
  options = NULL,
  similarity = "minkowski",
  ...
)

ebm_j(
  formula,
  criterion,
  data,
  fix = NULL,
  options = NULL,
  similarity = "minkowski",
  ...
)

mem(formula, criterion, data, choicerule, options = NULL, ...)

ebm(formula, criterion, data, mode, fix = NULL, options = NULL, ...)

Arguments

formula

A formula, the variables in data to be modeled. For example, y ~ x1 + x2 | x3 + x4 models response y as function of two stimuli with features x1, x2 and x3, x4 (respectively). Lines | separate stimuli.

class

A formula, the variable in data with the feedback about the true class/category. For example ~ cat. NAs are interpreted as trials without feedback (partial feedback, see details).

data

A data frame, the data to be modeled.

choicerule

A string, the choice rule. Allowed values, see cm_choicerules(): "none" is no choice rule, "softmax" is soft-maximum, "luce" is Luce's axiom.

fix

(optional) A list or the string "start", the fixed model parameters, if missing all parameters are estimated. Model parameter names depend on formula, class and can be x1, x2, lambda, r, q, b0, b1 (see details - model parameters).

  • list(r = 2.70) sets parameter r equal to 2.70.

  • list(r = "q") sets parameter r equal to parameter q (estimates q).

  • list(q = "r", r = 2.70) sets parameter q equal to parameter r and sets r equal to 2.70 (estimates none of the two).

  • list(r = NA) omits the parameter r, if possible.

  • "start" sets all parameters equal to their initial values (estimates none). Useful for building a first test model.

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

similarity

(optional) A string, similarity function, currently only "minkowski".

...

other arguments, ignored.

criterion

A formula, the variable in data with the feedback about the continous criterion. For example, ~ val NAs are interpreted as trials without feedback (partial feedback, see details).

mode

(optional) A string, the response mode, can be "discrete" or "continuous", can be abbreviated. If missing, will be inferred from criterion.

discount

A number, how many initial trials to not use during parameter fitting.

Details

The model can predict new data - predict(m, newdata = ...) - and this is how it works:

Model Parameters

The model has the following free parameters, depending on the model specification (see npar()). A model with formula ~ x1 + x2 has parameters:

Partial Feedback

Regarding NA values in class or criterion: The model takes NA values in the class/criterion variable as trials without feedback, in which a stimulus was shown but no feedback about the class or criterion was given (partial feedback paradigm). The model predicts the class or criterion for such trials without feedback based on the previous exemplar(s) for which feedback was shown. The model ignores the trials without feedback in the prediction of the subsequent trials.

Value

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

References

Medin, D. L., & Schaffer, M. M. (1978). Context theory of classification learning. Psychological Review, 85, 207-238. http://dx.doi.org/10.1037//0033-295X.85.3.207

Nosofsky, R. M. (1986). Attention, similarity, and the identification-categorization relationship. Journal of Experimental Psychology: General, 115, 39-57. http://dx.doi.org/10.1037/0096-3445.115.1.39

Juslin, P., Olsson, H., & Olsson, A.-C. (2003). Exemplar effects in categorization and multiple-cue judgment. Journal of Experimental Psychology: General, 132, 133-156. http://dx.doi.org/10.1037/0096-3445.132.1.133

See Also

Other cognitive models: baseline_const_c(), bayes(), choicerules, cpt, hm1988(), shortfall, utility

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Make some fake data
D <- data.frame(f1 = c(0,0,1,1,2,2,0,1,2),     # feature 1
                f2 = c(0,1,2,0,1,2,0,1,2),     # feature 2
                cl = c(0,1,0,0,1,0,NA,NA,NA),  # criterion/class
                 y = c(0,0,0,1,1,1,0,1,1))     # participant's responses

M <- gcm(y ~ f1+f2, class= ~cl, D, fix="start",
         choicerule = "none")                  # GCM, par. fixed to start val.

predict(M)                                     # predict 'pred_f', pr(cl=1 | features, trial)
M$predict()                                    # -- (same) --
summary(M)                                     # summary
anova(M)                                       # anova-like table
logLik(M)                                      # Log likelihood
M$logLik()                                     # -- (same) --
M$MSE()                                        # mean-squared error
M$npar()                                       # 7 parameters
M$get_par()                                    # parameter values
M$coef()                                       # 0 free parameters


### Specify models
# -------------------------------
gcm(y ~ f1 + f2, class = ~cl, D, 
    choicerule = "none")                          # GCM (has bias parameter)
ebm(y~f1+f2, criterion=~cl, D, mode="discrete",
    choicerule = "none")                          # -- (same) --
ebm_j(y ~ f1 + f2, criterion = ~cl, D)              # Judgment EBM  (no bias par.)
ebm(y~f1+f2, criterion=~cl, D, mode="continuous")   # -- (same) --


### Specify parameter estimation
# -------------------------------
gcm(y~f1+f2, ~cl, D, fix=list(b0=0.5, b1=0.5),
     choicerule = "none")                       # fix 'bias' par. to 0.5, fit 5 par
gcm(y~f1+f2, ~cl, D, fix=list(f1=0.9,f2=0.1),
     choicerule = "none")                       # fix attention 'f1' to 90 %  f1 & fit 5 par
gcm(y~f1+f2, ~cl, D, fix=list(q=2, r=2),
     choicerule = "none")                      # fix 'q', 'q' to 2 & fit 5 par
gcm(y~f1+f2, ~cl, D, fix=list(q=1, r=1),
     choicerule = "none")                      # fix 'q', 'r' to 1 & fit 5 par
gcm(y~f1+f2, ~cl, D, fix=list(lambda=2),
     choicerule = "none")                      # fix 'lambda' to 2 & fit 6 par
gcm(y~f1+f2, ~cl, D, fix="start", 
    choicerule = "none")                        # fix all par to start val. 

JanaJarecki/cogscimodels documentation built on Sept. 8, 2020, 7:28 p.m.