Description Usage Arguments Details Value Author(s) References See Also Examples
Performs a fit of a boolean model as specified by boolprep
.
1 |
obj |
boolean model object as produced by |
method |
string (or string vector) specifying the method(s) of
estimation. The specified method(s) should be one of those available from
the |
start |
numeric vector specifying starting values for each parameter in
the model. Must have a length equal to the number of parameters being
estimated. Defaults to |
... |
additional arguments to be passed on to optimizers. Each optimizer provides numerous optional parameters to help improve estimation results. See the provided examples and the documentation for the estimation method of interest. |
boolean
performs a fit of a boolean model as specified by
boolprep
.
A boolean model object containing the fit results (detailed results
available in the model.fit
slot).
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 boolprep
for model setup, boolean
the snow
package for details on clustering (useful when using
genoud
). See optimx
, optim
, and
genoud
for detailed documentation on the estimation methods
available.
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 39 40 41 42 43 44 45 46 47 48 49 50 | ## 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")))
## Fit a model using the nlminb optimizer (the default). Verbose output is
## requested by specifying trace=1 as a control parameter.
(fit <- boolean(mod.OR, method="nlminb", control=list(trace=1)))
## Multiple optimizers can be specified in a single call to boolean. Here
## we fit with the nlm and nlminb optimizers.
(fit1 <- boolean(mod.OR, method=c("nlm", "nlminb")))
## The summary function will report the detailed results for each
## optimization method.
summary(fit1)
|
## ------------------------------------------------------------------
## boolean3: Modeling Causal Complexity
## Version: 3.1.6
## Built: 2014-11-15
## When using this package, please cite:
## Braumoeller, Bear F. (2003) 'Causal Complexity and the Study
## of Politics'. Political Analysis 11(3): 209-233.
## boolean3 was developed by Jason W. Morgan under the direction
## of Bear Braumoeller with support from The Ohio State University's
## College of Social and Behavioral Sciences. The package represents
## a significant re-write of the original boolean implementation
## developed by Bear Braumoeller, Ben Goodrich, and Jacob Kline.
## Please see the release notes and accompanying documentation for
## details regarding changes made in this version.
## ------------------------------------------------------------------
Loading required package: mvtnorm
fn is fn
Looking for method = nlminb
Function has 7 arguments
Analytic gradient not made available.
Analytic Hessian not made available.
Scale check -- log parameter ratio= 2.069957 log bounds ratio= NA
Method: nlminb
0: 2035.0322: 0.555932 0.00473222 0.0518577 0.0496661 0.555932 0.314324 -0.0401190
1: 1125.8726: -0.128002 0.0388608 0.148522 0.127276 -0.0324267 0.721923 -0.0984183
2: 842.16854: -0.894107 0.0450575 0.220895 0.294603 0.0566570 1.33118 -0.124427
3: 801.45277: -1.16971 0.0904748 0.304796 0.364513 -0.181651 1.54390 -0.197683
4: 793.97922: -1.20286 0.147914 0.450047 0.558016 0.0953275 1.78334 -0.178614
5: 780.71673: -1.44471 0.189016 0.538420 0.765386 -0.198236 1.79638 -0.181454
6: 775.40425: -1.51478 0.180762 0.546683 0.747108 -0.0165509 1.79489 -0.229489
7: 774.57448: -1.57276 0.182887 0.545728 0.743597 -0.0714208 1.78130 -0.190647
8: 773.65776: -1.60590 0.198898 0.574778 0.783028 -0.0163173 1.74617 -0.198394
9: 773.45521: -1.67407 0.202747 0.586465 0.808583 -0.0539769 1.72187 -0.223385
10: 773.01515: -1.71678 0.200876 0.598546 0.838030 -0.0208752 1.72345 -0.159004
11: 772.50230: -1.72318 0.206564 0.606078 0.846533 -0.0158345 1.72432 -0.200933
12: 772.18615: -1.78954 0.231403 0.641644 0.890728 -0.0149773 1.74469 -0.180529
13: 771.89408: -1.85032 0.220442 0.644317 0.940352 -0.00765292 1.69664 -0.201119
14: 771.82964: -1.85752 0.227057 0.652232 0.940174 0.00321909 1.70914 -0.192294
15: 771.80805: -1.86904 0.234335 0.658831 0.936482 -0.00922196 1.71128 -0.202710
16: 771.77148: -1.87385 0.245676 0.671659 0.936851 0.000202090 1.70546 -0.194253
17: 771.73610: -1.88836 0.239128 0.666674 0.949032 -0.000940577 1.71251 -0.199984
18: 771.73251: -1.89568 0.239325 0.673716 0.966180 0.00207749 1.70995 -0.190095
19: 771.69796: -1.91188 0.246202 0.678637 0.968548 0.000991846 1.69952 -0.197925
20: 771.68769: -1.91635 0.246152 0.679387 0.968981 0.00465919 1.70560 -0.195222
21: 771.68585: -1.92140 0.245884 0.681943 0.970631 -0.000299101 1.70718 -0.199282
22: 771.67581: -1.92565 0.249539 0.682440 0.975775 0.00323916 1.70555 -0.197015
23: 771.67138: -1.93310 0.248427 0.685082 0.977665 0.00545697 1.70803 -0.197441
24: 771.66787: -1.93884 0.251033 0.686586 0.982438 0.00259209 1.70576 -0.196928
25: 771.66514: -1.94283 0.249067 0.691544 0.986161 0.00555102 1.70248 -0.197780
26: 771.66252: -1.94927 0.253216 0.688489 0.988282 0.00637389 1.70450 -0.196715
27: 771.66179: -1.94944 0.252735 0.690798 0.989860 0.00511699 1.70388 -0.197933
28: 771.66159: -1.95076 0.251943 0.692557 0.990545 0.00589386 1.70451 -0.195792
29: 771.66071: -1.95311 0.252593 0.692510 0.991241 0.00686319 1.70299 -0.197144
30: 771.66048: -1.95352 0.252644 0.692539 0.991436 0.00603405 1.70315 -0.197014
31: 771.66035: -1.95391 0.252808 0.692812 0.992089 0.00645060 1.70345 -0.197050
32: 771.66010: -1.95539 0.253107 0.692929 0.993199 0.00597076 1.70363 -0.197060
33: 771.65989: -1.95682 0.253096 0.693676 0.993688 0.00655998 1.70289 -0.196863
34: 771.65976: -1.95821 0.253571 0.694613 0.994382 0.00638021 1.70290 -0.197326
35: 771.65960: -1.95958 0.253689 0.694372 0.995706 0.00653702 1.70291 -0.197075
36: 771.65960: -1.96080 0.254736 0.695276 0.996153 0.00683790 1.70302 -0.196829
37: 771.65953: -1.96146 0.254388 0.695466 0.996634 0.00680004 1.70275 -0.197050
38: 771.65952: -1.96214 0.254131 0.695666 0.997187 0.00694445 1.70257 -0.196938
39: 771.65952: -1.96244 0.254218 0.695360 0.997339 0.00691471 1.70251 -0.197034
40: 771.65951: -1.96232 0.254197 0.695433 0.997375 0.00695641 1.70256 -0.197022
41: 771.65951: -1.96229 0.254187 0.695531 0.997304 0.00688192 1.70252 -0.196965
42: 771.65951: -1.96218 0.254148 0.695478 0.997251 0.00687032 1.70257 -0.197023
43: 771.65951: -1.96217 0.254157 0.695485 0.997223 0.00691356 1.70257 -0.197018
44: 771.65951: -1.96218 0.254158 0.695484 0.997245 0.00689404 1.70257 -0.197017
45: 771.65951: -1.96218 0.254156 0.695483 0.997242 0.00689386 1.70257 -0.197018
Post processing for method nlminb
Successful convergence!
Compute Hessian approximation at finish of nlminb
Compute gradient approximation at finish of nlminb
Save results from method nlminb
$par
(Intercept) x1 x2 x3 (Intercept) x4
-1.962176237 0.254156284 0.695483160 0.997241971 0.006893857 1.702573794
x5
-0.197017528
$message
[1] "relative convergence (4)"
$convcode
[1] 0
$value
[1] 771.6595
$fevals
function
56
$gevals
gradient
450
$nitns
[1] 45
$kkt1
[1] TRUE
$kkt2
[1] TRUE
$xtimes
user.self
0.416
Assemble the answers
==========================================================================
Boolean model estimate
Model specification:
y.OR ~ (a | b)
a ~ x1 + x2 + x3
b ~ x4 + x5
Observations 2000
Parameters 7
nlminb
(Intercept)_a -1.96e+00
x1_a 2.54e-01
x2_a 6.95e-01
x3_a 9.97e-01
(Intercept)_b 6.89e-03
x4_b 1.70e+00
x5_b -1.97e-01
Log-likelihood -7.72e+02
AIC 1.56e+03
BIC 1.60e+03
==========================================================================
==========================================================================
Boolean model estimate
Model specification:
y.OR ~ (a | b)
a ~ x1 + x2 + x3
b ~ x4 + x5
Observations 2000
Parameters 7
nlm nlminb
(Intercept)_a -1.96e+00 -1.96e+00
x1_a 2.54e-01 2.54e-01
x2_a 6.95e-01 6.95e-01
x3_a 9.97e-01 9.97e-01
(Intercept)_b 6.89e-03 6.89e-03
x4_b 1.70e+00 1.70e+00
x5_b -1.97e-01 -1.97e-01
Log-likelihood -7.72e+02 -7.72e+02
AIC 1.56e+03 1.56e+03
BIC 1.60e+03 1.60e+03
==========================================================================
==========================================================================
Boolean model estimate
Observations 2000
Parameters 7
------------------------------
Estimation method: nlm
------------------------------
Coef SE z p.val
(Intercept)_a -1.962 0.208 -9.414 0.000
x1_a 0.254 0.099 2.577 0.005
x2_a 0.695 0.110 6.306 0.000
x3_a 0.997 0.145 6.857 0.000
(Intercept)_b 0.007 0.048 0.145 0.442
x4_b 1.703 0.081 20.893 0.000
x5_b -0.197 0.043 -4.622 0.000
Log-likelihood AIC BIC
-771.6595 1557.3190 1596.5253
------------------------------
Estimation method: nlminb
------------------------------
Coef SE z p.val
(Intercept)_a -1.962 0.208 -9.414 0.000
x1_a 0.254 0.099 2.577 0.005
x2_a 0.695 0.110 6.306 0.000
x3_a 0.997 0.145 6.857 0.000
(Intercept)_b 0.007 0.048 0.145 0.442
x4_b 1.703 0.081 20.893 0.000
x5_b -0.197 0.043 -4.622 0.000
Log-likelihood AIC BIC
-771.6595 1557.3190 1596.5253
==========================================================================
Warning: boolean likelihood functions are often *highly* irregular,
thus normal-theory p-values are suspect. Bootstrapped confidence
intervals should be used for inference.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.