Learn R Programming

SimDesign (version 1.14)

RD: Compute the relative difference

Description

Computes the relative difference statistic of the form (est - pop)/ pop, which is equivalent to the form est/pop - 1. If matrices are supplied then an equivalent matrix variant will be used of the form (est - pop) * solve(pop). Values closer to 0 indicate better relative parameter recovery.

Usage

RD(est, pop, as.vector = TRUE)

Arguments

est

a numeric vector or matrix containing the parameter estimates

pop

a numeric vector or matrix containing the true parameter values. Must be of the same dimensions as est

as.vector

logical; always wrap the result in a as.vector function before returning?

Value

returns a vector or matrix depending on the inputs and whether as.vector was used

References

Sigal, M. J., & Chalmers, R. P. (2016). Play it again: Teaching statistics with Monte Carlo simulation. Journal of Statistics Education, 24(3), 136-156. 10.1080/10691898.2016.1246953

Examples

Run this code
# NOT RUN {
# vector
pop <- seq(1, 100, length.out=9)
est1 <- pop + rnorm(9, 0, .2)
(rds <- RD(est1, pop))
summary(rds)

# matrix
pop <- matrix(c(1:8, 10), 3, 3)
est2 <- pop + rnorm(9, 0, .2)
RD(est2, pop, as.vector = FALSE)
(rds <- RD(est2, pop))
summary(rds)


# }

Run the code above in your browser using DataLab