MSE: MSE (Mean Squared Error)

Description Usage Arguments Details Value Examples

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

1
2
3
4
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

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

StatisticsNZ/dembase documentation built on Dec. 25, 2021, 4:49 p.m.