DBerr: DB error

Description Usage Arguments Value Examples

View source: R/efficiency_criterions.R

Description

Function to calculate the DB-error given a design, and parameter values.

Usage

1
DBerr(par.draws, des, n.alts, weights = NULL, mean = TRUE)

Arguments

par.draws

Numeric matrix in which each row is a draw from a multivariate parameter distribution.

des

A design matrix in which each row is an alternative.

n.alts

Numeric value indicating the number of alternatives per choice set.

weights

A numeric vector containing weights of par.draws. The default is NULL.

mean

A logical value indicating whether the mean (DB) error should be returned or not. Default = TRUE.

Value

Numeric value indicating the DB-error of the design given the parameter draws.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
des <- example_design
mu = c(-1, -1.5, -1, -1.5, 0.5, 1)
Sigma = diag(length(mu))
par.draws <- MASS::mvrnorm(100, mu = mu, Sigma = Sigma)
n.alts = 2
DBerr(par.draws = par.draws, des = des, n.alts = n.alts)

mu = c(-0.5, -1, -0.5, -1, 0.5, 1)
Sigma = diag(length(mu))
par.draws <- MASS::mvrnorm(100, mu = mu, Sigma = Sigma)
DBerr(par.draws = par.draws, des = des, n.alts = n.alts)

Example output

Loading required package: shiny
[1] 3.261682
[1] 3.013401

idefix documentation built on Nov. 27, 2020, 1:07 a.m.