MSE {dembase} | R Documentation

## MSE (Mean Squared Error)

### Description

Mean Squared Error, or MSE, measures the extent to which point estimates (including forecasts) from a model come close to the truth. It is commonly used in simulation studies, where the true values are generated by the analyst, and hence known.

### Usage

    MSE(point, truth)

    ## S4 method for signature 'DemographicArray,DemographicArray'
    MSE(point, truth)

### Arguments

`point` | A `DemographicArray` containing the point estimates.
`truth` | A `DemographicArray` containing the true values.

### Details

If `p` is a point estimate and `t` is the truth then the MSE is `(p - t)^2`.

`MSE` is stricter about the compatibility of its arguments than most functions in `dembase`. Although it reorders dimensions and categories in `point` and `truth`, it does not collapse or expand dimensions, or drop any levels.

### Value

An object with the same class as `truth`.

### Examples

    point <- Values(array(c(10.2, 8.7, 3.4, 8.1),
                          dim = c(2, 2),
                          dimnames = list(region = c("A", "B"),
                                          sex = c("F", "M"))))
    truth <- Values(array(c(9.8, 8.3, 3.7, 7.9),
                          dim = c(2, 2),
                          dimnames = list(region = c("A", "B"),
                                          sex = c("F", "M"))))
    point
    truth
    MSE(point = point,
        truth = truth)

    ## calculations with MSE
    m <- MSE(point = point,
             truth = truth)
    class(m) # same as 'truth'
    ## mean
    collapseDimension(m,
                      dimension = "sex",
                      weights = 1)
    ## sum
    m <- as(m, "Counts")
    collapseDimension(m,
                      dimension = "sex")

[Package dembase version 0.0.0.119 Index]