SSE: Sum of squared errors

Description Usage Arguments Value References See Also Examples

View source: R/SSE.R

Description

SSE() computes the sum of squared errors.

Usage

1
SSE(obs, pred, na.rm = FALSE, weighted = FALSE, n = NULL, ...)

Arguments

obs

A numeric vector or matrix, the observed data. Can be continuous values or dicrete. Can be aggregated, and if so you must supply n (see below). The default assumes raw data.

pred

A numeric vector or matrix with predictions, in the same order as obs.

na.rm

(optional) Logical (default FALSE). TRUE removes all NA rows in pred or obs jointly (list-wise removal).

weighted

(optional) Logical (dfault FALSE), if TRUE variance-weighted sums of squares are calculated, otherwise unweighted sums of squares.

n

(optional), number of integer vector, required if weighted = TRUE. Number of observations underlying each entry in obs. One number if each entry in obs is the aggregate of the same number, a vector if different numbers of observations underly entries in codeobs.

...

Other parameters to be passed to the methods

Value

Sum of squared deviations between obs and pred, or weighted sum of squared deviations.

References

Busemeyer, J. R., & Diederich, A. (2010). Nonlinear parameter estimation. In Cognitive Modeling (pp. 43–84). Thousand Oaks, CAL: SAGE Publications.

See Also

Other goodness of fit functions: APE(), Accuracy(), MAPE(), MDAPE(), MSE(), RMSE(), gof()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Example from Busemeyer & Diederich (2010), p. 55 - 56
# Observed relative frequencies of choices as proportions of choice 1, split up by 11 conditions
obs <- c(.9538, .9107, .9204, .9029, .8515, .9197,
          .7970, .8228, .8191, .7277, .7276)
# Predictions for each of the 11 conditions
pred <- c(.9526, .9168, .8721, .8229, .7736, .7277,
          .6871, .6523, .6232, .5993, .5798)
n <- 200 # all  or n = rep(200, 11) # number of observations per condition

sse <- SSE(obs = obs, pred = pred)
# Sum of squared errors (SSE) in paper equals 0.1695
# all.equal(sse, 0.1695, 0.001) # TRUE

wsse <- SSE(obs = obs, pred = cbind(pred, 1-pred), weighted = TRUE, n = 200)
# Weighted sum of squared errors (WSSE) in paper equals 158.4059
# all.equal(wsse, 158.4059, 0.001) TRUE
# minute difference is due to rounding

JanaJarecki/cognitiveutils documentation built on Sept. 9, 2020, 9:11 a.m.