View source: R/BIC_orderconstraints.R
bic_oc | R Documentation |
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.
bic_oc(object, constraints = NULL, complement = FALSE, N = NULL)
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 ( |
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 |
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.
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
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.