bic_oc: Compute the BIC of an order-constrained model.

View source: R/BIC_orderconstraints.R

bic_ocR Documentation

Compute the BIC of an order-constrained model.

Description

bic_oc computes the order-constrained BIC for a fitted model object (e.g., lm-object, a glm-object, or a coxph-object) with order constraints on certain effects.

Usage

bic_oc(object, constraints = NULL, complement = FALSE, N = NULL)

Arguments

object

A fitted model object, such as a glm-object

constraints

A string specifying order constraints on certain effects of the modeling object. The ampersant (&) can be used to specify separate constraints. If the value is NULL the ordinary BIC is computed.

complement

A logical scalar that specifies if the order-constrained subspace is considered (FALSE) or its complement (TRUE). Default is FALSE.

N

The sample size that was used to fit the model object. If it is left empty (NULL), then the sample size will be determine based on the dimension of the fitted.values element of object.

Value

The output is an object of class BIC_OC. The object has elements:

  • BIC_OC The order-constrained BIC.

  • BIC_unc The BIC when the constraints are ignored.

  • postprob The posterior probability that the constraints hold under the unconstrained model.

  • priorprob The prior probability that the constraints hold under the unconstrained model assuming a prior that is centered on the boundary of the constrained subspace (Mulder and Raftery, 2022).

  • constraints The constraints as specified in the constraints argument.

  • complement A logical that specifies if the complement is considered in the complement argument.

  • call The function call.

References

Mulder, J., and Raftery, A.E. (2022). BIC Extensions for Order-constrained Model Selection. Sociological Methods & Research, 51 (2), 471-498. DOI:10.1177/0049124119882459

Examples


n <- 100
x1 <- rnorm(n)
x2 <- rnorm(n)
y <- 1 + .5 * x1 + 1 * x2 + rnorm(n)
df <- data.frame(y=y,x1=x1,x2=x2)
glm1 <- lm(y ~ 1 + x1 + x2, data=df)
# Compute the BIC of the fitted model `glm1' with order constraints that state that
# the effect of 'x2' on 'y' is larger than the effect of 'x1' on 'y', and both effects
# are assumed positive.
bic_oc(glm1,"x2 > x1 > 0")
# the same result would be obtained by separating the constraints with a '&'
bic_oc(glm1,"x2 > x1 & x1 > 0")

# a model where both coefficients are assumed to be positive
bic_oc(glm1,"x2 > & x1 > 0")
# the same model where both coefficients are assumed to be positive using the brackets notation
bic_oc(glm1,"(x2 , x1 ) > 0")


jomulder/BICpack documentation built on Oct. 24, 2023, 10:30 p.m.