Description Usage Arguments Details Value Author(s) References See Also Examples
Construct a boolean object that can then be fit with boolean
.
1 2 |
... |
formula specification for boolean model. See the details and examples sections below. |
data |
|
subset |
select subset of data. See |
weights |
specify model weights (not implemented). |
na.action |
set |
offset |
specify an offset. Offsets are not implemented and this parameter is simply ignored. |
family |
a model |
boolprep
sets up a boolean model object that can then be fit with
boolean
. A properly specified model (contained in ...
)
will contain at least three components. The first component must specify the
boolean logic to be employed. For instance, the y ~ (a | b)
formula
would indicate a logical or
between the a
and b
submodels, while y ~ (a & b)
would indicate a logical
and
. y
is the name of the response variable of
interest. Logical operators can be nested; e.g., y ~ (a | (b & c))
is
valid. The second and third components are submodels and are specified as
usual: a ~ x1 + x2
and b ~ x3 + x4 + x5
, where are the
x
-variables are covariates. a
, b
, and c
are
labels indicating the submodel position in the boolean specification.
boolprep
returns a boolean-class
object
containing the model components needed to estimate a boolean model.
Jason W. Morgan (morgan.746@osu.edu)
Braumoeller, Bear F. (2003) “Causal Complexity and the Study of Politics.” Political Analysis 11(3): 209–233.
See boolean
for model estimation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ## Generate some fake data
require(mvtnorm)
set.seed(12345)
N <- 2000
Df <- cbind(1, rmvnorm(N, mean=rep(0, 5)))
## Set coefficients
beta.a <- c(-2.00, 0.33, 0.66, 1.00)
beta.b <- c(0.00, 1.50, -0.25)
## Generate path probabilities following a normal model.
y.a <- as.vector(pnorm(tcrossprod(beta.a, Df[, 1:4])))
y.b <- as.vector(pnorm(tcrossprod(beta.b, Df[, c(1, 5, 6)])))
## AND and OR-model
or <- function(x, y) { x + y - x * y }
and <- function(x, y) { x * y }
y.star.OR <- or(y.a, y.b)
y.star.AND <- and(y.a, y.b)
## Observed responses
y.OR <- rbinom(N, 1, y.star.OR)
y.AND <- rbinom(N, 1, y.star.AND)
## Set up data.frame for estimation
Df <- cbind(1, Df)
Df <- as.data.frame(Df)
Df[,1] <- y.OR
Df[,2] <- y.AND
names(Df) <- c("y.OR", "y.AND", "x1", "x2", "x3", "x4", "x5")
## Before estimating, boolean models need to be specified using the
## boolprep function.
## OR model, specified to use a probit link for each causal path. This
## matches the data generating process above.
mod.OR <- boolprep(y.OR ~ (a | b), a ~ x1 + x2 + x3, b ~ x4 + x5,
data = Df, family=list(binomial("probit")))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.