coef_simu {cirls}R Documentation

Simulate coefficients, calculate Confidence Intervals and Variance-Covariance Matrix for a cirls object.

Description

confint computes confidence intervals for one of more parameters in a GLM fitted via cirls.fit. vcov compute the variance-covariance matrix of the parameters. Both methods are based on coef_simu that simulates coefficients from a Truncated Multivariate Normal distribution. These methods supersede the default confint and vcov methods for cirls objects.

Usage

coef_simu(object, nsim = 1000)

## S3 method for class 'cirls'
confint(object, parm, level = 0.95, nsim = 1000, ...)

## S3 method for class 'cirls'
vcov(object, nsim = 1000, ...)

Arguments

object

A fitted cirls object.

nsim

The number of simulations to consider. Corresponds to n in rtmvnorm. See details().

parm

A specification of which parameters to compute the confidence intervals for. Either a vector of numbers or a vector of names. If missing, all parameters are considered.

level

The confidence level required.

...

Further arguments passed to or from other methods. Currently ignored.

Details

These functions are custom methods for cirls objects to supersede the default methods used for glm objects.

Both methods rely on the fact that C\hat{\beta} (with C the constraint matrix) follows a Truncated Multivariate Normal distribution

C\hat{\beta} \sim TMVN(C\beta, CVC^T), l, u

where TMVN represents a truncated Multivariate Normal distribution. C is the constraint matrix (object$control$Cmat) with bound l and u, while V is the unconstrained variance-covariance matrix (such as returned by vcov.glm).

coef_simu simulates from the TMVN above and transforms back the realisations into the coefficients space. These realisations are then used by the confint and vcov methods which compute empirical quantiles and variance-covariance matrix, respectively. coef_simu is called internally by confint and vcov and doesn't need to be used directly, but it can be used to check other summaries of the coefficients distribution.

Value

For confint, a two-column matrix with columns giving lower and upper confidence limits for each parameter.

For vcov, a matrix of the estimated covariances between the parameter estimates of the model.

For coef_simu, a matrix with nsim rows containing simulated coefficients.

Note

These methods only work when Cmat is of full row rank. If not the case, Cmat can be inspected through check_cmat().

References

Geweke, J.F., 1996. Bayesian Inference for Linear Models Subject to Linear Inequality Constraints, in: Lee, J.C., Johnson, W.O., Zellner, A. (Eds.), Modelling and Prediction Honoring Seymour Geisser. Springer, New York, NY, pp. 248–263. doi:10.1007/978-1-4612-2414-3_15

Botev, Z.I., 2017, The normal law under linear restrictions: simulation and estimation via minimax tilting, Journal of the Royal Statistical Society, Series B, 79 (1), pp. 1–24.

See Also

rtmvnorm for the underlying routine to simulate from a TMVN. check_cmat() to check if the contraint matrix can be reduced.

Examples

####################################################
# Isotonic regression

#----- Perform isotonic regression

# Generate data
set.seed(222)
p1 <- 5; p2 <- 3
x1 <- matrix(rnorm(100 * p1), 100, p1)
x2 <- matrix(rnorm(100 * p2), 100, p2)
b1 <- runif(p1) |> sort()
b2 <- runif(p2)
y <- x1 %*% b1 + x2 %*% b2 + rnorm(100, sd = 2)

# Fit model
Ciso <- diff(diag(p1))
resiso <- glm(y ~ x1 + x2, method = cirls.fit, Cmat = list(x1 = Ciso))

#----- Extract uncertainty

# Extract variance covariance
vcov(resiso)

# Extract confidence intervals
confint(resiso)

# We can extract the usual unconstrained vcov
summary(resiso)$cov.scaled
all.equal(vcov(resiso), summary(resiso)$cov.scaled)

# Simulate from the distribution of coefficients
sims <- coef_simu(resiso, nsim = 10)

# Check that all simulated coefficient vectors are feasible
apply(resiso$Cmat %*% t(sims) >= resiso$lb, 2, all)

[Package cirls version 0.3.1 Index]