forked from philchalmers/SimDesign
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRMSE.Rd
91 lines (77 loc) · 3.17 KB
/
RMSE.Rd
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/summary_functions.R
\name{RMSE}
\alias{RMSE}
\title{Compute the (normalized) root mean square error}
\usage{
RMSE(estimate, parameter = NULL, type = "RMSE", MSE = FALSE,
percent = FALSE)
}
\arguments{
\item{estimate}{a \code{numeric} vector or \code{matrix}/\code{data.frame} of parameter estimates.
If a vector, the length is equal to the number of replications. If a
\code{matrix}/\code{data.frame}, the number of rows must equal the number of replications}
\item{parameter}{a \code{numeric} scalar/vector indicating the fixed parameter values.
If a single value is supplied and \code{estimate} is a \code{matrix}/\code{data.frame} then
the value will be recycled for each column; otherwise, each element will be associated
with each respective column in the \code{estimate} input.
If \code{NULL} then it will be assumed that the \code{estimate} input is in a deviation
form (therefore \code{sqrt(mean(estimate^2))} will be returned)}
\item{type}{type of deviation to compute. Can be \code{'RMSE'} (default) for the root mean square-error,
\code{'NRMSE'} for the normalized RMSE (RMSE / (max(estimate) - min(estimate))),
\code{'NRMSE_SD'} for the normalized RMSE with the standard deviation (RMSE / sd(estimate)),
\code{'CV'} for the coefficient of variation, or \code{'RMSLE'} for the root mean-square log-error}
\item{MSE}{logical; return the mean square error equivalent of the results instead of the root
mean-square error (in other words, the result is squared)? Default is \code{FALSE}}
\item{percent}{logical; change returned result to percentage by multiplying by 100?
Default is FALSE}
}
\value{
returns a \code{numeric} vector indicating the overall average deviation in the estimates
}
\description{
Computes the average deviation (root mean square error; also known as the root mean square deviation)
of a sample estimate from the parameter value. Accepts estimate and parameter values,
as well as estimate values which are in deviation form.
}
\examples{
pop <- 1
samp <- rnorm(100, 1, sd = 0.5)
RMSE(samp, pop)
dev <- samp - pop
RMSE(dev)
RMSE(samp, pop, type = 'NRMSE')
RMSE(dev, type = 'NRMSE')
RMSE(dev, pop, type = 'NRMSE_SD')
RMSE(samp, pop, type = 'CV')
RMSE(samp, pop, type = 'RMSLE')
# percentage reported
RMSE(samp, pop, type = 'NRMSE')
RMSE(samp, pop, type = 'NRMSE', percent = TRUE)
# matrix input
mat <- cbind(M1=rnorm(100, 2, sd = 0.5), M2 = rnorm(100, 2, sd = 1))
RMSE(mat, parameter = 2)
RMSE(mat, parameter = c(2, 3))
# different parameter associated with each column
mat <- cbind(M1=rnorm(1000, 2, sd = 0.25), M2 = rnorm(1000, 3, sd = .25))
RMSE(mat, parameter = c(2,3))
# same, but with data.frame
df <- data.frame(M1=rnorm(100, 2, sd = 0.5), M2 = rnorm(100, 2, sd = 1))
RMSE(df, parameter = c(2,2))
# parameters of the same size
parameters <- 1:10
estimates <- parameters + rnorm(10)
RMSE(estimates, parameters)
}
\references{
Sigal, M. J., & Chalmers, R. P. (2016). Play it again: Teaching statistics with Monte
Carlo simulation. \code{Journal of Statistics Education, 24}(3), 136-156.
\doi{10.1080/10691898.2016.1246953}
}
\seealso{
\code{\link{bias}}
MAE
}
\author{
Phil Chalmers \email{[email protected]}
}