Learn R Programming

grt (version 0.1.0)

glc: General Linear Classifier

Description

Fit a general linear classifier (a.k.a. linear decison-bound model).

Usage

glc(formula, data, category, par = list(), zlimit = Inf,
    covstruct=c("unstructured", "scaledIdentity", "diagonal", "identity"),
    fixed = list(), opt = c("nlminb", "optim"), 
    lower=-Inf, upper=Inf, control=list())

Arguments

formula
A formula of the form response ~ x1 + x2 + ..., where the response specifies the grouping factor (generally a participant's response) and the right hand side specifies the variables of the classified stimuli.
data
A data frame from which variables specified in formula are taken.
category
(Optional.) A factor specifying the true category menbership of the stimuli.
par
object of class glcStruct or named list containing a set of initial parameters (i.e., noise, coeffs, bias) used to fit the data.
zlimit
numeric. The z-scores (or discriminant scores) beyound the speficied value will be truncated. Default to Inf.
covstruct
An optional charactor string. Only used when the initial parameters are not fully specified. see ldb.
fixed
A named list of logical vectors specifying whether each of noise, coeffs, and bias parameters should be fixed to the initial value. Default to list(noise=FALSE, coeffs=FALSE, bias=FALSE. A fatal error wi
opt
A character string specifying the optimizer to be used: either nlminb (the default) or optim. If optim, L-BFGS-B method is use
lower, upper
Bounds on the parameters. see Details for default values.
control
A list of control parameters passed to the internal optimization function. See Details of nlminb or optim.

Value

  • object of the class glc, i.e., a list containing the following components:
  • termsthe terms object used.
  • callthe matched call.
  • modelthe design matrix used to fit the model.
  • categorythe category vector as specified in the input.
  • initparthe initial parameter used to fit the model.
  • parthe fitted parameter.
  • logLikthe log-likelihood at convergence.

Details

If par is not fully specified in the argument, the function attemps to calculate the initial parameter values by internally calling the functions mcovs and ldb. If category is also not specified, the response specified in the formula is used as the grouping factor in mcovs.

The default lower and upper values vary depending on the dimension of the model (i.e., the number of variables in the right hand side of formula). In all cases, default lower and upper values for the noise parameter is .001 and 500 respectively. In cases when an one-dimensional model is fitted, lower and upper bounds for the bias parameters are selected based on the range of the data input so that the decision bound is found within the reasonable range of the data and convergence can be reached. In all other cases, coeffs and bias has no limits.

When an one-dimensional model is being fit, fixed$coeffs always becomes TRUE.

References

Alfonso-Reese, L. A. (2006) General recognition theory of categorization: A MATLAB toolbox. Behavior Research Methods, 38, 579-583. Ashby, F. G., & Gott, R. E. (1988). Decision rules in the perception and categorization of multidimensional stimuli. Journal of Experimental Psychology: Learning, Memory, & Cognition, 14, 33-53.

Ashby, F. G. (1992) Multidimensional models of perception and cognition. Lawrence Erlbaum Associates.

See Also

gqc, ldb, logLik.glc, coef.glc, predict.glc, scale.glc, plot.glc, plot3d.glc

Examples

Run this code
data(subjdemo_2d)
d2 <- subjdemo_2d
#fit a 2d suboptimal model
fit.2dl <- glc(response ~ x + y, data=d2, category=d2$category, zlimit=7)
#fit a 1d model (on the dimention 'y') on the same dataset
fit.1dy <- glc(response ~ y, data=d2, category=d2$category, zlimit=7)
#or using update()
#fit.1dy <- update(fit.2dl, . ~ . -x)

#fit a 2d optimal model
fit.2dlopt <- glc(response ~ x + y, data=d2, category=d2$category, zlimit=7, 
    fixed=list(coeffs=TRUE, bias=TRUE))

#calculate AIC and compare
AIC(fit.2dl, fit.1dy, fit.2dlopt)

Run the code above in your browser using DataLab