# bias: Compute (relative/standardized) bias summary statistic In SimDesign: Structure for Organizing Monte Carlo Simulation Designs

## 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

 `1` ```bias(estimate, parameter = NULL, type = "bias") ```

## 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; otherwise, each element will be associated with each respective column in the `estimate` input. If `NULL` then it will be assumed that the `estimate` input is in a deviation form (therefore `mean(estimate))` will be returned) `type` type of bias statistic to return. Default (`'bias'`) computes the standard bias (average difference between sample and population), `'relative'` computes the relative bias statistic (i.e., divide the bias by the value in `parameter`; note that multiplying this by 100 gives the "percent bias" measure), and `'standardized'` computes the standardized bias estimate (standard bias divided by the standard deviation of the sample estimates)

## Value

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

## Author(s)

Phil Chalmers [email protected]

## 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. doi: 10.1080/10691898.2016.1246953

`RMSE`
 ``` 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``` ```pop <- 2 samp <- rnorm(100, 2, sd = 0.5) bias(samp, pop) bias(samp, pop, type = 'relative') bias(samp, pop, type = 'standardized') 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) bias(mat, parameter = 2, type = 'relative') bias(mat, parameter = 2, type = 'standardized') # different parameter associated with each column mat <- cbind(M1=rnorm(1000, 2, sd = 0.25), M2 = rnorm(1000, 3, sd = .25)) bias(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)) bias(df, parameter = c(2,2)) # parameters of the same size parameters <- 1:10 estimates <- parameters + rnorm(10) bias(estimates, parameters) ```