Commit d6d36096 authored by Andreas Tille's avatar Andreas Tille

Import Upstream version 1.4.6

parent ddb22f6f
Package: pscl
Version: 1.04.4
Date: 2012-06-12
Version: 1.4.6
Date: 2014-08-23
Title: Political Science Computational Laboratory, Stanford University
Author: Simon Jackman, with contributions from Alex Tahk, Achim
Zeileis, Christina Maimone and Jim Fearon
Author: Simon Jackman, with contributions from
Alex Tahk, Achim Zeileis, Christina Maimone and Jim Fearon
Maintainer: Simon Jackman <jackman@stanford.edu>
Depends: R (>= 2.10.0), MASS, stats, mvtnorm, coda, gam, vcd
Suggests: MCMCpack, car, lmtest, sandwich, zoo
Enhances: stats, MASS
Imports: lattice
Depends: R (>= 2.10.0), MASS, lattice
Suggests: MCMCpack, car, lmtest, sandwich, zoo, coda, gam, vcd, mvtnorm
Enhances: stats
Description: Bayesian analysis of item-response theory (IRT) models,
roll call analysis; computing highest density regions; maximum
likelihood estimation of zero-inflated and hurdle models for
count data; goodness-of-fit measures for GLMs; data sets used
in writing and teaching at the Political Science Computational
Laboratory; seats-votes curves.
LazyLoad: true
roll call analysis; computing highest density regions; maximum
likelihood estimation of zero-inflated and hurdle models for count
data; goodness-of-fit measures for GLMs; data sets used
in writing and teaching at the Political Science
Computational Laboratory; seats-votes curves.
LazyData: true
License: GPL-2
URL: http://pscl.stanford.edu/
Packaged: 2012-06-13 00:55:00 UTC; jackman
Packaged: 2014-08-25 06:04:42 UTC; jackman
NeedsCompilation: yes
Repository: CRAN
Date/Publication: 2012-06-13 05:44:47
Date/Publication: 2014-08-27 18:02:01
6e55e6571f5729f76216ca3212ad5686 *COPYRIGHTS
4d51503944c3c022c1c4125d45f2e5d0 *DESCRIPTION
f6d779a47ad2a560d95384f8f21f6ed9 *NAMESPACE
0d31362755cad3e709c6ffe6cddda5b5 *NEWS
05e0502270b3b120ed299ff6d13cf936 *DESCRIPTION
df97f4d11c2a3b38575fd9fe3da1c93d *NAMESPACE
705cfb981ccff4c396219d24f9b34bbf *NEWS
e4141b58125086fe7a925a18a27fbf13 *R/betaHPD.r
fa1ccedd12e25d0f4b57c837eee688c5 *R/dropRollCall.r
9136707d4c7f8400c1581139132014eb *R/dropUnanimous.r
......@@ -9,12 +8,12 @@ fa1ccedd12e25d0f4b57c837eee688c5 *R/dropRollCall.r
3a3b87569b3f7fbd008cd1d6553fdb32 *R/hello.r
a68a2ed5e435379d9dbabf719ae32701 *R/hitmiss.R
ed0e60f8f2df4e1f70be74fdff483bd0 *R/hurdle.R
826cd8a86151c764f6179b63f252c5cf *R/ideal.r
744d1af6de3d20aa2928bf77bef07b34 *R/ideal.r
24cfd3cf6b0498e16ab9a08a5ed63fd4 *R/idealHelper.r
57c42afc03bc7b48bf57aad15e6b5696 *R/igamma.r
1069285f3fe6835578a863a1d05ab8db *R/margins.rollcall.r
7f33ab0717237682733911d1f50370b2 *R/ntable.R
93c40e4a84b0d2c4db72b7bb79b26a45 *R/odTest.R
e96a2d20824383196b8b7a6132dcaf2f *R/odTest.R
2ccee1a9ff1cb45ad9c41aa072876814 *R/pi.r
aea47b7871d6bb1fce7c9cc57b864a75 *R/plot.ideal.r
e0d535a36192a68399200a5d7b2a43bd *R/postProcess.r
......@@ -22,23 +21,25 @@ e0d535a36192a68399200a5d7b2a43bd *R/postProcess.r
d3423d8e4fb2d372947e30b5fbf0e0b1 *R/predprob.R
106f115dd003c08e60f45f43c75a3088 *R/predprob.glm.R
a14694458a410c3ff8fd70647009f54f *R/pseudoRSq.R
fa7303f57d5c336c47f05ec5d09f4175 *R/readKH.r
2d8df25eaa983da463b94f1c7d241d77 *R/readKH.r
38612c0cdb48624c5f8e3cb0e2c753c4 *R/restrict.ideal.r
2dbbefb6f9c0b016c711dd8d3a270884 *R/rollcall.r
2327c6ca8e1f51b6c4c594a4d8ddcdec *R/seatsVotes.R
8181536f4cdf5dd0217ad9ead60c3546 *R/summary.ideal.r
582616ad7c65d4a16d29a64d5acbb338 *R/sysdata.rda
0202cd83b23bb8c999f9d270f6e210a9 *R/toMCMC.r
bb44e8325e20f4a6a6e17b1346372eff *R/vuong.R
9aefa6635344ef8c977e224805ded336 *R/zeroinfl.R
1e7b8598728651c32a2b3de1876619cd *R/vuong.R
96200a090cd18b7ded8e555771ff6cab *R/zeroinfl.R
bdfbae70de1517193e1dfb8740fe01e8 *R/zzz.R
53313b6f0b69be68a1fc8770c9ef7eb0 *README
860c7a4542ca222f8a3eaf80940fb625 *TODO
6798db70b41d3e97736df0cc257fb03e *build/vignette.rds
48d5186bc1c850ca764a4428fed72db9 *data/AustralianElectionPolling.rda
c00d0a7d9afc7f549864d9a1c1acc905 *data/AustralianElections.rda
1fd7bdaf9dc34c6a0f335f5b7e45c255 *data/EfronMorris.rda
55d9d1b1379537b08ea76b4334c345f3 *data/RockTheVote.rda
270a8877abcc0eba69a2d4953961fb06 *data/UKHouseOfCommons.rda
f915a5e3e05397653b34f4d496b0a289 *data/absentee.rda
e5cd24045a1b14e06ae00b19dc3429bf *data/absentee.rda
33919d0bbc3570d4a99bae9d1823a374 *data/admit.rda
9bf4f0eae9528dedca5f6aeab65cb552 *data/bioChemists.rda
a1acc98d25d8a34c564522497a6ddc4a *data/ca2006.rda
......@@ -46,7 +47,7 @@ d60b096feabfbb58999ff68355f8faeb *data/iraqVote.rda
a37e4bfd97430c9ea022b616102e2c36 *data/nj07.rda
010a897b9ed96c17484aee8378c27a9a *data/partycodes.rda
4bba832e5f3fe5b936d8a05bfcce9fd5 *data/politicalInformation.rda
47f4a8c0c38c7240989f2574ebb8bdc6 *data/presidentialElections.rda
5545e330d20119064a121af0b57c1ae3 *data/presidentialElections.rda
00a6f68d522e345991ba69ca93ddb171 *data/prussian.rda
773fa6967a9aa1ec5a3e56cfbc60cc7e *data/s109.rda
b51d0806c46e14ed3661fb47d1048087 *data/sc9497.rda
......@@ -54,54 +55,56 @@ b51d0806c46e14ed3661fb47d1048087 *data/sc9497.rda
d7638296db19c4ba7de8ffa89d4d144c *data/unionDensity.rda
497a2fb245ca5588e562ba3efa9fd73f *data/vote92.rda
b1684d7631e2aaf9b870b79adae6832f *inst/CITATION
73fd5542d60b3c0afdf6fd36f0a55ebb *inst/doc/DebTrivedi.rda
6e55e6571f5729f76216ca3212ad5686 *inst/COPYRIGHTS
40e6573aad40b503ce7dc384664fd00a *inst/doc/countreg.R
f0b2acaed3829613387d308477b32cfb *inst/doc/countreg.Rnw
5fbb807bd14a6fa797d43474e73009bb *inst/doc/countreg.bib
492f73850a1b7886092f88d6367254ea *inst/doc/countreg.pdf
79954db5339de91063e891c3fc8c95fc *inst/doc/countreg.pdf
6a339e8576cd23b19769209a0f46d0c6 *inst/extdata/id1.RData
4c24fa4db587d5b00a0b7b935fda0dd6 *inst/extdata/id2.RData
1f374780d3fdab077448b3f8c8ed4535 *man/AustralianElectionPolling.Rd
4c7220ae568fc8650e5a083ecfe61751 *man/AustralianElections.Rd
413c8bb8c2a97bf96a086752b64f9727 *man/EfronMorris.Rd
8d936782297f143d7b583f58fc5b6ac7 *man/RockTheVote.Rd
e530063893fe76e74d0bce2443647932 *man/UKHouseOfCommons.Rd
c129da4f0e4ec6908b9531e176bcc34e *man/absentee.Rd
9f58b0a319641b8780d6717b4189262c *man/admit.Rd
b9cb4d068d5fc84d36ed325816c8a561 *man/admit.Rd
21e2df080979a911fe55565ee1cbb02f *man/betaHPD.Rd
67cb83cb4c84b23f9601d663877deebf *man/bioChemists.Rd
97530d29c9ef5df8617be6703bbcb364 *man/ca2006.Rd
83a1c4252ad2a97f2701495bd0d2d282 *man/computeMargins.Rd
b20779e918ed3190c82eb19a25aab843 *man/constrain.items.Rd
cde2f4e188fbed3a385e6a687faf15b5 *man/constrain.legis.Rd
66c9b2b50681323d41551fa35a474546 *man/constrain.items.Rd
fadebde0593ea59b498a94c0211a12b3 *man/constrain.legis.Rd
3332b1e2c6825660602c04ad75f6392d *man/convertCodes.Rd
5a954aadd19f2814e98c8848232de93e *man/dropRollCall.Rd
1bfa8bbb776eeae989dcb4ffa590a156 *man/dropUnanimous.Rd
2b7432e7385f3582d701153569a1e89f *man/extractRollCallObject.Rd
a20a016755514fd36ab11b3ec8ce07d4 *man/hitmiss.Rd
28ce5c278e745ae69f098c5c531ebaed *man/extractRollCallObject.Rd
8f9d49ad6015aa110605fc21109b1ca5 *man/hitmiss.Rd
edc14a2d7f63d105e16a7224ea866e2b *man/hurdle.Rd
a2cdd121c20655dbec00738598efed1a *man/hurdle.control.Rd
a2fca81930e1f2dc594a7a551bb6488f *man/hurdletest.Rd
33585828c1fea3777ade0fb9fc8a9de5 *man/ideal.Rd
8c6bb8a7e10235c854ebbc2456b69bab *man/idealToMCMC.Rd
ef97a6fcfb782e3b64be0429cf7a7680 *man/hurdletest.Rd
a22f5674eb8deddacfdb9d26e617d38a *man/ideal.Rd
efba2fcd19078b3db9df598784028948 *man/idealToMCMC.Rd
f18d51d590ed9904dfe6e41571fe3903 *man/igamma.Rd
532e377d3f632d4d8d467734b66a7c34 *man/iraqVote.Rd
bf033f0cb311d0b1415b2364e03705b8 *man/iraqVote.Rd
ad0ccd84450a594df90119fa3ef8461e *man/nj07.Rd
078b921a42e58dd7330c8df04d127fed *man/ntable.Rd
a370eb5db65f4fc1aefa6e807facf22e *man/odTest.Rd
ec2940ca232be004fd6148651ce42dbd *man/pR2.Rd
ae425651938177afa50dc1f8e030164c *man/odTest.Rd
748fa0a8a2f3e24b7ad7708726a88da6 *man/pR2.Rd
99951244af04af9a168419c38096b60b *man/partycodes.Rd
549c790a485bfabb8255f84012bc67f6 *man/plot.ideal.Rd
32f60d2b0f1d85b2947891731567f17a *man/plot.predict.ideal.Rd
6c060e244893bb16b4dc5741ac672969 *man/plot.predict.ideal.Rd
cd69945b628a1030c3a361b23b04d75a *man/plot.seatsVotes.Rd
28363c6cffcd612ae93335e9abd066ef *man/politicalInformation.Rd
7a9135f5914b656bc521f8f3333856bf *man/postProcess.Rd
02504e6bd8296294f2ed8ce69334bf30 *man/politicalInformation.Rd
5b2f85ca008eadbd667dbdd478493b69 *man/postProcess.Rd
589a61aaef2ea8a77cada485036f1685 *man/predict.hurdle.Rd
b2ce558820a4ad6140fc82be663d0b37 *man/predict.ideal.Rd
d43b9cc311c2a17ff678c6b1e2fa95e8 *man/predict.zeroinfl.Rd
2cc067fd655c891057604ddecd7f7be2 *man/predprob.Rd
6f0d72cddc3d45b83d09074b77aa7e48 *man/predprob.glm.Rd
9939090df9d59afebb2e2948657c3bf2 *man/predprob.ideal.Rd
b72bec49edb1288224e0b08cf484d4e9 *man/presidentialElections.Rd
95716587f1ef0d16b2e5472f6b6bee5d *man/presidentialElections.Rd
40b952f533b01527691b62c22fa1b757 *man/prussian.Rd
f2e85675a400d5926d06728fd8da5867 *man/readKH.Rd
0f6b51ad8d37d90b677951c4f67c34c7 *man/readKH.Rd
3ed90ebe8e28b86cfff88c7b9d3a1d1f *man/rollcall.Rd
a7eef4fbf81a2e82d8f9d537c99c1811 *man/s109.Rd
020d6e0155cef909fe932536998bc684 *man/sc9497.Rd
......@@ -114,17 +117,17 @@ b997e43520c34b348b421bc09ab0f900 *man/tracex.Rd
2531fcd99d3935897ec347c7d298b84e *man/unionDensity.Rd
77fc48107d0d11045b2db0538a11c58f *man/vectorRepresentation.Rd
e98499c1ce4c6b994fa946375f650bfb *man/vote92.Rd
ff3f06cb610af7bb183235be14b16662 *man/vuong.Rd
6a12cba9f9b223ddc5178fee00e5844d *man/vuong.Rd
0b67233ce3f099152201d376e3adacd9 *man/zeroinfl.Rd
a71cbe2fdb4bfc8d678f4fbfaa36f6ca *man/zeroinfl.control.Rd
411afc0af4307234a6659002f8cb9a5f *src/IDEAL.c
0953c7aa5829590a2617b4dac3014937 *src/IDEAL.c
c1242e2c0dc49254b3103abcaa3fce43 *src/bayesreg.c
84fc8d596f9ed6fff436213f5aa0176b *src/check.c
7827d05ccbfda37a6770d1893ad2657a *src/chol.c
54b5d46b82a2d8d1b711265ae6976ca7 *src/chol.h
27ff6dd23ef01d1b20ebf152634ab2c1 *src/crossprod.c
b5cfc01c17e0d459aea4d5c7a4324059 *src/dmatTOdvec.c
641d96ada563d7b14e368d438c82100b *src/dtnorm.c
a7ecc84c2418f8dc0172832f52b49d0d *src/dtnorm.c
535fd3e635d6d566fe6b826003974385 *src/dvecTOdmat.c
e2caa6a2b8babf8fbddf2a38162dce82 *src/gaussj.c
a0ce9dacf3232a1b44ae9751b3576157 *src/ideal.h
......@@ -132,12 +135,16 @@ a0ce9dacf3232a1b44ae9751b3576157 *src/ideal.h
2ef159d3f034d158763a31e44c334d21 *src/predict.c
75a219a7638c2da5c7412785e9de37cf *src/printmat.c
6481e2946861c489decc8f5cf927a929 *src/renormalize.c
6df18e9e98db01a252f5944670fa0366 *src/rigamma.c
dcd975bec5ddba470e1db440563859b5 *src/rigamma.c
3a9b673c687b42a9a32fda8ee46b0ccc *src/rmvnorm.c
c0fdc0b2f60d730bba7f5fbd6170d4f1 *src/updateb.c
2751e0771f01014a0d856d4057a8ca34 *src/updatex.c
dc84510ecda25f2d02511578e209f40c *src/updatex.c
13831bf39bc2ae096899c94239770c9b *src/updatey.c
419ed48fd112dd27f0dea33ed73b0d5c *src/util.c
4531f2dfbc17c8f2f692de0e7c97b7c7 *src/util.h
5967f2c183b3301343fe317875a181bc *src/xchol.c
21805fdd82f57d48144b119f84e73219 *src/xreg.c
73fd5542d60b3c0afdf6fd36f0a55ebb *vignettes/DebTrivedi.rda
70256dfd22c68f24aba80218cf86496c *vignettes/auto/countreg.el
f0b2acaed3829613387d308477b32cfb *vignettes/countreg.Rnw
5fbb807bd14a6fa797d43474e73009bb *vignettes/countreg.bib
......@@ -29,6 +29,7 @@ export("hitmiss", "pR2")
importFrom("MASS", "glm.nb")
importFrom("stats", "logLik")
importFrom("lattice", "xyplot")
## methods for class zeroinfl
S3method("print", "zeroinfl")
......
1.04.4 * clean up partial matches to args, keeping R check happy
1.4.6 * compliance with CRAN recss/reqs, vignettes sub-dir
* better Imports/Depends/Suggests etc
* dropped redundant "require" in examples etc
* fixed long-standing buglet in Vuong test, AIC type df adjustment to test statistic
* use format.pval for pvalues printing in Vuong output to screen
1.4.5 * better compliance with CRAN reccs/reqs, R 3.0.0 etc
* drop leading zero in version number
* compress PDFs from vignettes
* lazy-loading, so um, lazy-load in readKH.r
1.04.4 * presidentialElections includes 2012
1.04.3 * bug in postProcess, not evaluating args in call of ideal object
......
......@@ -7,7 +7,6 @@ ideal <- function(object,
thin=100,
burnin=5000,
impute=FALSE,
mda=FALSE,
normalize=FALSE,
meanzero=normalize,
priors=NULL,
......@@ -35,8 +34,6 @@ ideal <- function(object,
cl$burnin <- eval(burnin,parent.frame())
if(is.null(cl$impute))
cl$impute <- impute
if(is.null(cl$mda))
cl$mda <- mda
if(is.null(cl$store.item) | is.symbol(cl$store.item))
cl$store.item <- eval(store.item,parent.frame())
if(is.null(cl$normalize))
......@@ -44,6 +41,8 @@ ideal <- function(object,
if(is.null(cl$verbose))
cl$verbose <- verbose
mda <- FALSE
## check validity of user arguments
if (!("rollcall" %in% class(object)))
stop("object must be of class rollcall")
......
......@@ -11,7 +11,7 @@ odTest <- function(glmobj,
poissonGLM <- glm(formula=eval(glmobj$call$formula),
data=eval(glmobj$call$data),
family="poisson")
require(stats)
## require(stats)
llhPoisson <- logLik(poissonGLM)
llhNB <- logLik(glmobj)
......
......@@ -43,7 +43,7 @@ readKH <- function(file,
party <- as.numeric(substring(data,21,23))
## convert party to label
partyfunc <- function(x){
data(partycodes)
##data(partycodes)
party <- partycodes$party[match(x,partycodes$code)]
party[party=="Democrat"] <- "D"
party[party=="Republican"] <- "R"
......@@ -54,7 +54,7 @@ readKH <- function(file,
## convert state ICPSR code to abbreviation
statename <- function(x){
data(state.info)
##data(state.info)
state.info$state[match(x,state.info$icpsr)]
}
state <- as.numeric(substring(data,9,10)) ## icpsr code
......
File added
......@@ -5,18 +5,19 @@
m1n <- length(m1y)
m2n <- length(m2y)
if(m1n==0 | m2n==0)
stop("could not extract dependent variables from models")
stop("Could not extract dependent variables from models.")
if(m1n != m2n)
stop(paste("models appear to have different numbers of observations\n",
"model 1 has ",m1n," observations\n",
"model 2 has ",m2n," observations\n",
stop(paste("Models appear to have different numbers of observations.\n",
"Model 1 has ",m1n," observations.\n",
"Model 2 has ",m2n," observations.\n",
sep="")
)
if(any(m1y != m2y))
stop(paste("models appear to have different values on dependent variables\n"))
if(any(m1y != m2y)){
stop(paste("Models appear to have different values on dependent variables.\n"))
}
whichCol <- match(m1y,min(m1y):max(m1y)) ## which column, matrix of predicted probs
m1p <- rep(NA,m1n)
......@@ -24,13 +25,14 @@
p1 <- predprob(m1) ## likelihood contributions, model 1, cond on MLEs
p2 <- predprob(m2) ## likelihood contributions, model 2
for(i in 1:m1n){
m1p[i] <- p1[i,whichCol[i]] ## pick off correct column
m1p[i] <- p1[i,whichCol[i]] ## pick off correct column, given observed y
m2p[i] <- p2[i,whichCol[i]]
}
m <- log(m1p/m2p) ## vector of likelihood ratios
m <- log(m1p) - log(m2p) ## vector of log likelihood ratios (diffs of log probabilities)
bad <- is.na(m) + is.nan(m) + (m==Inf) + (m==-Inf)
bad <- is.na(m) | is.nan(m) | is.infinite(m)
neff <- sum(!bad)
if(any(bad)){
cat("NA or numerical zeros or ones encountered in fitted probabilities\n")
cat("dropping these cases, but proceed with caution\n")
......@@ -40,10 +42,12 @@
k1 <- length(coef(m1))
k2 <- length(coef(m2))
## test statistic: Long (1997) p248
mbar <- mean(m[!bad])
## test statistic
msum <- sum(m[!bad])
s <- sd(m[!bad])
v <- sqrt(sum(!bad))*mbar/s
v <- msum/(s * sqrt(neff))
adj <- log(neff)*(k1/2 - k2/2) ## adjustment a la AIC, length of model(s)
v <- v - adj
## bundle up for output
cat(paste("Vuong Non-Nested Hypothesis Test-Statistic:",
......@@ -51,15 +55,21 @@
"\n"))
cat("(test-statistic is asymptotically distributed N(0,1) under the\n")
cat(" null that the models are indistinguishible)\n")
if(v>0){
pval <- 1 - pnorm(v)
} else {
pval <- pnorm(v)
}
cat("in this case:\n")
if(v>0)
cat(paste("model1 > model2, with p-value",
signif(1-pnorm(v),digits),
format.pval(pval),
"\n"))
else
cat(paste("model2 > model1, with p-value",
signif(pnorm(v),digits),
format.pval(pval),
"\n"))
invisible(NULL)
......
......@@ -278,15 +278,15 @@ zeroinfl <- function(formula, data, subset, na.action, weights, offset,
ll_new <- loglikfun(c(start$count, start$zero))
ll_old <- 2 * ll_new
if(!require("MASS")) {
ll_old <- ll_new
warning("EM estimation of starting values not available")
}
##if(!require("MASS")) {
## ll_old <- ll_new
## warning("EM estimation of starting values not available")
## }
while(abs((ll_old - ll_new)/ll_old) > control$reltol) {
ll_old <- ll_new
model_count <- suppressWarnings(glm.fit(X, Y, weights = weights * (1-probi),
offset = offsetx, family = negative.binomial(1), start = start$count))
offset = offsetx, family = MASS::negative.binomial(1), start = start$count))
model_zero <- suppressWarnings(glm.fit(Z, probi, weights = weights,
offset = offsetz, family = binomial(link = linkstr), start = start$zero))
start <- list(count = model_count$coefficients, zero = model_zero$coefficients)
......@@ -306,10 +306,10 @@ zeroinfl <- function(formula, data, subset, na.action, weights, offset,
ll_new <- loglikfun(c(start$count, start$zero, log(start$theta)))
ll_old <- 2 * ll_new
if(!require("MASS")) {
ll_old <- ll_new
warning("EM estimation of starting values not available")
}
## if(!require("MASS")) {
## ll_old <- ll_new
## warning("EM estimation of starting values not available")
## }
## offset handling in glm.nb is sub-optimal, hence...
offset <- offsetx
......
No preview for this file type
This diff is collapsed.
No preview for this file type
......@@ -30,7 +30,6 @@
\examples{
data(admit)
summary(admit)
require(MASS)
## ordered probit model
op1 <- polr(score ~ gre.quant + gre.verbal + ap + pt + female,
Hess=TRUE,
......
......@@ -11,7 +11,6 @@
\usage{
constrain.items(obj, dropList = list(codes = "notInLegis", lop = 0),
x, d = 1)
}
\arguments{
......@@ -80,26 +79,18 @@ constrain.items(obj, dropList = list(codes = "notInLegis", lop = 0),
\code{\link{constrain.legis}}
}
\examples{
## run ideal with the default parameters
data(s109)
\dontrun{
## run a 1d model, look for lack of fit
id1 <- ideal(s109,
d=1,
meanzero=TRUE,
store.item=TRUE,
maxiter=1e5,
burnin=1e3,
thin=1e2)
data(s109)
f <- system.file("extdata","id1.Rdata",package="pscl")
load(f)
id1sum <- summary(id1,include.beta=TRUE)
suspect1 <- id1sum$bSig[[1]]=="95% CI overlaps 0"
close60 <- id1sum$bResults[[1]][,"Yea"] < 60
close40 <- id1sum$bResults[[1]][,"Yea"] > 40
suspect <- suspect1 & close60 & close40
id1sum$bResults[[1]][suspect,]
suspectVotes <- dimnames(id1sum$bResults[[1]][suspect,])[[1]]
}
## constraints on 2d model,
## close rollcall poorly fit by 1d model
......@@ -110,7 +101,6 @@ cl <- constrain.items(s109,
"2-169"=c(7,0)),
d=2)
\dontrun{
id1Constrained <- ideal(s109,
d=2,
meanzero=TRUE,
......@@ -121,7 +111,6 @@ id1Constrained <- ideal(s109,
thin=1e2)
summary(id1Constrained,include.beta=TRUE)
}
}
\keyword{datagen}
......@@ -112,14 +112,15 @@ cl <- constrain.legis(s109,
"ENZI"=1),
d=1)
## short run for examples
\dontrun{
## too long for examples
id1Constrained <- ideal(s109,
d=1,
priors=cl, ## use cl
startvals=cl, ## use cl
maxiter=500,
burnin=100,
thin=10)
maxiter=5000,
burnin=500,
thin=25)
summary(id1Constrained)
cl2 <- constrain.legis(s109,
......@@ -128,8 +129,7 @@ cl2 <- constrain.legis(s109,
"CHAFEE"=c(0,-.5)),
d=2)
\dontrun{
## too long for examples
id2Constrained <- ideal(s109,
d=2,
priors=cl2, ## priors (w constraints)
......@@ -138,17 +138,8 @@ id2Constrained <- ideal(s109,
maxiter=5000,
burnin=500,
thin=25)
}
## short run for examples
id2Constrained <- ideal(s109,
d=2,
priors=cl2, ## priors (w constraints)
startvals=cl2, ## start value (w constraints)
store.item=TRUE,
maxiter=500,
burnin=100,
thin=10)
summary(id2Constrained,include.items=TRUE)
}
}
\keyword{datagen}
......@@ -29,13 +29,8 @@ extractRollCallObject(object)
details on the form of a \code{dropList}.}
\examples{
data(s109)
id1 <- ideal(s109,
d=1,
normalize=TRUE,
maxiter=500, ## short run for demo purposes
burnin=100,
thin=10)
f = system.file("extdata","id1.RData",package="pscl")
load(f)
tmp <- extractRollCallObject(id1)
summary(tmp)
v <- convertCodes(tmp) ## roll call matrix per se
......
......@@ -60,7 +60,6 @@ hitmiss(obj, digits = max(3, getOption("digits") - 3), ...)
\examples{
data(admit)
require(MASS)
## ordered probit model
op1 <- polr(score ~ gre.quant + gre.verbal + ap + pt + female,
Hess=TRUE,
......
......@@ -50,7 +50,7 @@ Cambridge: Cambridge University Press.
\examples{
data("bioChemists", package = "pscl")
fm <- hurdle(art ~ ., data = bioChemists, dist = "negbin", zero = "negbin")
if(require("car")) hurdletest(fm)
hurdletest(fm)
}
\keyword{regression}
......@@ -5,8 +5,7 @@
\description{
Analysis of \code{rollcall} data via the spatial voting model;
analogous to fitting educational testing data via an item-response
model. Model fitting via Markov chain Monte Carlo (MCMC).
equivalent to a 2 parameter item-response model to educational testing data. Model fitting via Markov chain Monte Carlo (MCMC).
}
\usage{
......@@ -14,7 +13,6 @@ ideal(object, codes = object$codes,
dropList = list(codes = "notInLegis", lop = 0),
d = 1, maxiter = 10000, thin = 100, burnin = 5000,
impute = FALSE,
mda = FALSE,
normalize = FALSE,
meanzero = normalize,
priors = NULL, startvals = "eigen",
......@@ -34,9 +32,9 @@ ideal(object, codes = object$codes,
listing voting decisions, legislators and/or votes to be dropped
from the analysis; see \code{\link{dropRollCall}} for details.}
\item{d}{numeric, (small) positive integer (defaults to 1).}
\item{d}{numeric, (small) positive integer (default = 1), dimensionality of the ability space (or "policy space" in the rollcall context).}
\item{maxiter}{numeric, positive integer, multiple of \code{thin}}
\item{maxiter}{numeric, positive integer, multiple of \code{thin}, number of MCMC iterations}
\item{thin}{numeric, positive integer, thinning interval used for
recording MCMC iterations.}
......@@ -48,9 +46,6 @@ ideal(object, codes = object$codes,
\item{impute}{\code{\link{logical}}, whether to treat missing entries
of the rollcall matrix as missing at random, sampling from the
predictive density of the missing entries at each MCMC iteration.}
\item{mda}{\code{\link{logical}}, do parameter expansion/marginal data augmentation (see
Details); default is \code{FALSE} (experimental)}
\item{normalize}{\code{\link{logical}}, impose identification with
the constraint that the ideal points have mean zero and
......@@ -66,12 +61,11 @@ ideal(object, codes = object$codes,
precision 1 for the ideal points (ability parameters) and mean zero and
precision .04 (variance 25) for the bill parameters (item discrimination and difficulty parameters). If not \code{NULL}, \code{priors} must be a
\code{list} with as many as four named components \code{xp, xpv, bp,
bpv}, where
bpv}:
\describe{
\item{\code{xp}}{a \code{n} by \code{d} matrix
of prior \emph{means} for the legislators' ideal points;
or alternatively, a scalar, which will be replicated to fill a \code{n}
by \code{d} matrix.}
or alternatively, a scalar, which will be replicated to fill a \code{n} by \code{d} matrix.}
\item{\code{xpv}}{a \code{n} by \code{d} matrix of prior
\emph{precisions} (inverse variances);
or alternatively, a scalar, which will be replicated to fill a \code{n}
......@@ -91,8 +85,8 @@ ideal(object, codes = object$codes,
values described above.}
\item{startvals}{either a string naming a method for generating start
values, valid options are \code{"eigen"} (the default) or
\code{"random"}; or a \code{list} containing start values for
values, valid options are \code{"eigen"} (the default),
\code{"random"} or a \code{list} containing start values for
legislators' ideal points and item parameters. See Details.}
\item{store.item}{\code{\link{logical}}, whether item discrimination
......@@ -121,12 +115,14 @@ ideal(object, codes = object$codes,
the ideal points are observationally equivalent, via offsetting
transformations of the item parameters. It is the user's
responsibility to impose these identifying restrictions if
desired; the following brief discussion provides some guidance.
desired. The following brief discussion provides some guidance.
For one-dimensional models (i.e., \code{d=1}), a simple route to
identification is the \code{normalize} option, which guarantees
identification is the \code{normalize} option, by imposing the restriction that the means of the posterior densities of the ideal points (ability parameters) have mean zero and standard deviation one, across legislators (test-takers). This normalization supplies
\emph{local} identification (identification up to a 180 rotation of
the recovered dimension). Near-degenerate \dQuote{spike} priors
the recovered dimension).
Near-degenerate \dQuote{spike} priors
(priors with arbitrarily large precisions) or the
\code{constrain.legis} option on any two legislators' ideal points
ensures \emph{global} identification in one dimension.
......@@ -363,9 +359,9 @@ ideal(object, codes = object$codes,
}
\examples{
\dontrun{
## long run, many iterations
data(s109)
## ridiculously short run for examples
n <- dim(s109$legis.data)[1]
x0 <- rep(0,n)
x0[s109$legis.data$party=="D"] <- -1
......@@ -373,26 +369,12 @@ x0[s109$legis.data$party=="R"] <- 1
id1 <- ideal(s109,
d=1,
startvals=list(x=x0),
startvals=list(x=x0),
normalize=TRUE,
store.item=TRUE,
maxiter=100,
burnin=0,
thin=10,
verbose=TRUE)
summary(id1)
\dontrun{
## more realistic long run
idLong <- ideal(s109,
d=1,
priors=list(xpv=1e-12,bpv=1e-12),
normalize=TRUE,
store.item=TRUE,
maxiter=260E3,
burnin=10E3,
thin=100)
maxiter=260E3,
burnin=10E3,
thin=100)
}
}
\keyword{models}
......@@ -39,15 +39,10 @@ idealToMCMC(object, burnin=NULL)
\examples{
data(s109)
id1 <- ideal(s109,
d=1,
normalize=TRUE,
maxiter=1100, ## short run for demo purposes
burnin=100,
thin=10)
f = system.file("extdata",package="pscl","id1.RData")
load(f)
id1coda <- idealToMCMC(id1)
summary(id1coda)
}
\keyword{classes}
......@@ -38,14 +38,5 @@ data(iraqVote)
glm1 <- glm(y ~ gorevote + rep,
data=iraqVote,
family=binomial(link=probit))
\dontrun{
require(MCMCpack)
albertChib <- MCMCprobit(y ~ gorevote + rep,
data=iraqVote,
burnin=0,
B0=1e-3,
mcmc=1e4,
verbose=0)
}
}
\keyword{datasets}
......@@ -59,7 +59,6 @@ odTest(glmobj, alpha=.05, digits = max(3, getOption("digits") - 3))
\examples{
data(bioChemists)
require(MASS)
modelnb <- glm.nb(art ~ .,
data=bioChemists,
trace=TRUE)
......
......@@ -40,7 +40,6 @@ pR2(object, ...)
\seealso{\code{\link{extractAIC}}, \code{\link{logLik}}}
\examples{
data(admit)
require(MASS)