boolprep {boolean} | R Documentation |
Takes as arguments the logical form of a Boolean model, the
dependent variable, and sets of independent variables, and
produces a functional form necessary for inclusion in a
boolean
command.
boolprep(FORM, DEPVAR, ...)
FORM |
Form of Boolean model, e.g., "a&b" ,
"a&(b|c)" , etc. Unlike previous versions of this package,
you are not restricted to single letters. For example,
"(lucky|good)" is now allowed as well. However, FORM
must be a character string. |
DEPVAR |
Dependent variable, which must be a logical vector or a numeric vector with zeroes and ones only, or the name of such a dependent variable can be given as a character string. |
... |
If there are n logical operators in FORM, users are
required to pass n+1 arguments through the dots. These n+1
arguments should be one-sided formulas and follow the same
syntax as in the glm() function (see formula ),
such as ~ x1 + x2 . Note that if FORM = "(lucky|good)" ,
then the required arguments would take a form such as
lucky = ~x1, good = ~x2 . |
Because the structure of a Boolean binary choice model can
be arbitrarily complex, the layering of parentheses soon becomes
tedious and unnecessarily difficult. To make life easier, the
boolprep
command automates the task of creating the
appropriate argument and checks for syntactical errors.
An object of class boolprep with the structure of the model and the
appropriate formulas as list elements, none of which are expected to be
accessed by the user. However, boolean
requires that a
boolprep object be passed to it.
Bear F. Braumoeller, Harvard University, bfbraum@fas.harvard.edu
Ben Goodrich, Harvard University, goodrich@fas.harvard.edu, and
Jacob Kline, Harvard University, jkline@fas.harvard.edu
Braumoeller, Bear F. (2003) "Causal Complexity and the Study of Politics." Political Analysis 11(3): 209-233.
y <- rbinom(1000, 1, 0.5) bp <- boolprep("a & b", "y", a = ~x1+x2, b = ~x3+x4+x5) bp <- boolprep("rich | (smart & diligent)", y, rich = ~ x1+x2+x3, smart = ~ x4+x5, diligent = ~ x6) bp <- boolprep("(a|b|c)&(d|e)&f", y, a=~x1+x2, b = ~x3+x4+x5, c = ~x6, d = ~x7+x8, e = ~x9+x10+x11, f = ~x12+x13)