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.
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
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(SimDesign)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SimDesign/bias.Rd_%03d_medium.png", width=480, height=480)
> ### Name: bias
> ### Title: Compute (relative) bias summary statistic
> ### Aliases: bias
>
> ### ** Examples
>
>
> pop <- 2
> samp <- rnorm(100, 2, sd = 0.5)
> bias(samp, pop)
[1] -0.01781103
> bias(samp, pop, relative = TRUE)
[1] -0.008905515
>
> dev <- samp - pop
> bias(dev)
[1] -0.01781103
>
> # equivalent here
> bias(mean(samp), pop)
[1] -0.01781103
>
> # matrix input
> mat <- cbind(M1=rnorm(100, 2, sd = 0.5), M2 = rnorm(100, 2, sd = 1))
> bias(mat, parameter = 2)
M1 M2
0.11549677 0.07795448
>
> # 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))
M1 M2
-0.05818709 0.05027303
>
>
>
>
>
>
>
> dev.off()
null device
1
>