invQ {Qest}R Documentation

Inverse of Quantile Function

Description

Auxiliary function to compute cumulative distribution function (CDF) by inverting a quantile function.

Usage

invQ(Q, theta, y, data, n.it = 17)

Arguments

Q

any parametric quantile function of the form Q(theta, tau, data).

theta

a vector of model parameters.

y

vector of observations to evaluate the CDF.

data

data frame containing the variables used in the Q() function.

n.it

the number of iterations (see “details”).

Details

Given a parametric quantile function Q(\tau | \theta), the CDF is defined as F(y | \theta) = Q^{-1}(y | \theta). Alternatively, F(y | \theta) corresponds to the value \tau* such that Q(\tau* | \theta) = y. Starting from \tau = 0.5, a bisection algorithm is used to evaluate numerically \tau*. The maximum error is given by 1/2^(n.it + 1).

Value

a vector of CDF values.

Author(s)

Maintainer: Gianluca Sottile <gianluca.sottile@unipa.it>

See Also

Qest

Examples

# Ex. 1 Normal model

# Quantile function of a linear model.
Qlinmod <- function(theta, tau, data){
  sigma <- exp(theta[1])
  beta <- theta[-1]
  X <- model.matrix( ~ x1 + x2, data = data)
  qnorm(tau, X %*% beta, sigma)
}

n <- 100
x1 <- rnorm(n)
x2 <- runif(n,0,3)
theta <- c(1,4,1,2)

# generate the data
U <- runif(n)
y <- Qlinmod(theta, U, data.frame(x1,x2))

# Given y and theta, evaluate U = F(y)
invQ(Qlinmod, theta, y, data.frame(x1,x2))


[Package Qest version 1.0.1 Index]