Learn R Programming

SimDesign (version 1.1)

bias: Compute (relative) bias summary statistic

Description

Computes the (relative) bias of a sample estimate from the parameter value. Accepts estimate and parameter values, as well as estimate values which are in deviation form. If relative bias is requested the estimate and parameter inputs are both required.

Usage

bias(estimate, parameter = NULL, relative = FALSE)

Arguments

estimate
a numeric vector or matrix/data.frame of parameter estimates. If a vector, the length is equal to the number of replications. If a matrix/data.frame, the number of rows must equal the number of replications
parameter
a numeric scalar/vector indicating the fixed parameters. If a single value is supplied and estimate is a matrix/data.frame then the value will be recycled for each column. If NULL then it will be assumed that the estimate input is in a deviation form (therefore mean(estimate)) will be returned)
relative
logical; compute the relative bias statistic (i.e., divide the bias by the value in parameter)? Default is FALSE

Value

returns a numeric vector indicating the overall (relative) bias in the estimates

See Also

RMSE

Examples

Run this code

pop <- 2
samp <- rnorm(100, 2, sd = 0.5)
bias(samp, pop)
bias(samp, pop, relative = TRUE)

dev <- samp - pop
bias(dev)

# equivalent here
bias(mean(samp), pop)

# matrix input
mat <- cbind(M1=rnorm(100, 2, sd = 0.5), M2 = rnorm(100, 2, sd = 1))
bias(mat, parameter = 2)

# same, but with data.frame
df <- data.frame(M1=rnorm(100, 2, sd = 0.5), M2 = rnorm(100, 2, sd = 1))
bias(df, parameter = c(2,2))

# parameters of the same size
parameters <- 1:10
estimates <- parameters + rnorm(10)
bias(estimates, parameters)


Run the code above in your browser using DataLab