Commit 657a49ad authored by Andreas Tille's avatar Andreas Tille

Import Upstream version 1.4.9

parent 1bca908a
Package: pscl
Version: 1.4.8
Date: 2015-01-21
Version: 1.4.9
Date: 2015-03-29
Title: Political Science Computational Laboratory, Stanford University
Author: Simon Jackman, with contributions from
Alex Tahk, Achim Zeileis, Christina Maimone and Jim Fearon
......@@ -19,6 +19,6 @@ LazyData: true
License: GPL-2
URL: http://pscl.stanford.edu/
NeedsCompilation: yes
Packaged: 2015-01-23 19:59:54 UTC; jackman
Packaged: 2015-03-29 07:15:16 UTC; jackman
Repository: CRAN
Date/Publication: 2015-01-24 06:45:25
Date/Publication: 2015-03-29 11:23:22
43e79a8ef077fbf41b5a5c6830083cd1 *DESCRIPTION
c82002c333d2b8313f8cca109cc65ef7 *DESCRIPTION
89628c3574f457f849e2ed6718891e58 *NAMESPACE
cc1aeb8117df184ea9888c8f8e18c6de *NEWS
d80b59b563986c00ea2ad72a3e60de93 *NEWS
e4141b58125086fe7a925a18a27fbf13 *R/betaHPD.r
fa1ccedd12e25d0f4b57c837eee688c5 *R/dropRollCall.r
9136707d4c7f8400c1581139132014eb *R/dropUnanimous.r
......@@ -28,18 +28,18 @@ a14694458a410c3ff8fd70647009f54f *R/pseudoRSq.R
8181536f4cdf5dd0217ad9ead60c3546 *R/summary.ideal.r
582616ad7c65d4a16d29a64d5acbb338 *R/sysdata.rda
0202cd83b23bb8c999f9d270f6e210a9 *R/toMCMC.r
0e293b70ae0e789dfea1b28f9da5fd5a *R/vuong.R
c382518d31b626e00f1b3bf60698ba28 *R/vuong.R
96200a090cd18b7ded8e555771ff6cab *R/zeroinfl.R
bdfbae70de1517193e1dfb8740fe01e8 *R/zzz.R
53313b6f0b69be68a1fc8770c9ef7eb0 *README
860c7a4542ca222f8a3eaf80940fb625 *TODO
6798db70b41d3e97736df0cc257fb03e *build/vignette.rds
e72d658a9d75cee50f1c4419ba07cdcf *build/vignette.rds
48d5186bc1c850ca764a4428fed72db9 *data/AustralianElectionPolling.rda
c00d0a7d9afc7f549864d9a1c1acc905 *data/AustralianElections.rda
1fd7bdaf9dc34c6a0f335f5b7e45c255 *data/EfronMorris.rda
55d9d1b1379537b08ea76b4334c345f3 *data/RockTheVote.rda
270a8877abcc0eba69a2d4953961fb06 *data/UKHouseOfCommons.rda
e5cd24045a1b14e06ae00b19dc3429bf *data/absentee.rda
b3d8f78c1f755e7cf3e7e9133a53d02c *data/absentee.rda
33919d0bbc3570d4a99bae9d1823a374 *data/admit.rda
9bf4f0eae9528dedca5f6aeab65cb552 *data/bioChemists.rda
a1acc98d25d8a34c564522497a6ddc4a *data/ca2006.rda
......@@ -58,14 +58,14 @@ d7638296db19c4ba7de8ffa89d4d144c *data/unionDensity.rda
6e55e6571f5729f76216ca3212ad5686 *inst/COPYRIGHTS
40e6573aad40b503ce7dc384664fd00a *inst/doc/countreg.R
f0b2acaed3829613387d308477b32cfb *inst/doc/countreg.Rnw
29d5bfaff9d65c4dece16ac2f9d2bb21 *inst/doc/countreg.pdf
66b1e3f5b1653f99deee747b56793f03 *inst/doc/countreg.pdf
6a339e8576cd23b19769209a0f46d0c6 *inst/extdata/id1.rda
4c24fa4db587d5b00a0b7b935fda0dd6 *inst/extdata/id2.rda
241e9b4fa6479e6a2797caa63de9474e *man/AustralianElectionPolling.Rd
4c7220ae568fc8650e5a083ecfe61751 *man/AustralianElections.Rd
413c8bb8c2a97bf96a086752b64f9727 *man/EfronMorris.Rd
8d936782297f143d7b583f58fc5b6ac7 *man/RockTheVote.Rd
e530063893fe76e74d0bce2443647932 *man/UKHouseOfCommons.Rd
8070055487c7b2d621e323f9679713a8 *man/UKHouseOfCommons.Rd
c129da4f0e4ec6908b9531e176bcc34e *man/absentee.Rd
29d9d91a13b93cea56ea59556ab7c042 *man/admit.Rd
21e2df080979a911fe55565ee1cbb02f *man/betaHPD.Rd
......@@ -86,7 +86,7 @@ c4c622f7c88d1002e816748a4119c3d1 *man/ideal.Rd
3600fd3654a969adad8579f652d31f6b *man/idealToMCMC.Rd
f18d51d590ed9904dfe6e41571fe3903 *man/igamma.Rd
bf033f0cb311d0b1415b2364e03705b8 *man/iraqVote.Rd
ad0ccd84450a594df90119fa3ef8461e *man/nj07.Rd
6e3abcdabb86ae8f30d60c8d2c475091 *man/nj07.Rd
078b921a42e58dd7330c8df04d127fed *man/ntable.Rd
d5c363e1fe405fbf6195e5c9eefaccc9 *man/odTest.Rd
69f6ccaf04208df5fe3928e50d083c0c *man/pR2.Rd
......@@ -104,14 +104,14 @@ d43b9cc311c2a17ff678c6b1e2fa95e8 *man/predict.zeroinfl.Rd
48f1b6ea440c1204bd0174b5797117a2 *man/predprob.ideal.Rd
a22a7a5aa542cb93ec7faec4bc5c2b7e *man/presidentialElections.Rd
40b952f533b01527691b62c22fa1b757 *man/prussian.Rd
152237c0100227ababd000ed34b6a0d8 *man/readKH.Rd
1975cd064669f4759c95bbc50de0d8bc *man/readKH.Rd
3ed90ebe8e28b86cfff88c7b9d3a1d1f *man/rollcall.Rd
72a08641f0d2079920248278a9939a43 *man/s109.Rd
020d6e0155cef909fe932536998bc684 *man/sc9497.Rd
b72ce8933d92ee28c1a4fa7cf7eb6b6e *man/seatsVotes.Rd
23bff5995d683d5bf95bce59ca47fa86 *man/simpi.Rd
c351971ed35a4a7c1e81d26048e239a9 *man/state.info.Rd
09ea85f6b8ef9bfa80769c827be48770 *man/summary.ideal.Rd
3ce725eb8ff7a940f67d0432ad3a6f4c *man/summary.ideal.Rd
69d21844fd8dd6c2a445302c84d210ff *man/summary.rollcall.Rd
69035aa534f90a3b5108811e91b19ff1 *man/tracex.Rd
2531fcd99d3935897ec347c7d298b84e *man/unionDensity.Rd
......
1.4.8 * package dependcies handled better
1.4.9 * fixed bug in AIC correct in Vuong test
1.4.8 * package dependencies handled better
* slight tweeks to ideal help
* CRAN compliance
* addressing memory leak issues revealed by valgrind in ideal's mallocs
......
......@@ -18,45 +18,61 @@
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
p1 <- predprob(m1) ## likelihood contributions, model 1, cond on MLEs
p2 <- predprob(m2) ## likelihood contributions, model 2
if(!all(colnames(p1)==colnames(p2))){
stop("Models appear to have different values on dependent variables.\n")
}
whichCol <- match(m1y,colnames(p1)) ## which column, matrix of predicted probs
whichCol2 <- match(m2y,colnames(p2))
if(!all(whichCol==whichCol2)){
stop("Models appear to have different values on dependent variables.\n")
}
m1p <- rep(NA,m1n)
m2p <- rep(NA,m2n)
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, given observed y
m1p[i] <- p1[i,whichCol[i]] ## pick off correct predicted probabilty, for observed y
m2p[i] <- p2[i,whichCol[i]]
}
## gather up degrees of freedom
k1 <- length(coef(m1))
k2 <- length(coef(m2))
m <- log(m1p) - log(m2p) ## vector of log likelihood ratios (diffs of log probabilities)
lm1p <- log(m1p)
lm2p <- log(m2p)
m <- lm1p - lm2p ## vector of log likelihood ratios (diffs of log probabilities)
bad <- is.na(m) | is.nan(m) | is.infinite(m)
bad1 <- is.na(lm1p) | is.nan(lm1p) | is.infinite(lm1p)
bad2 <- is.na(lm2p) | is.nan(lm2p) | is.infinite(lm2p)
bad3 <- is.na(m) | is.nan(m) | is.infinite(m)
bad <- bad1 | bad2 | bad3
neff <- sum(!bad)
if(any(bad)){
cat("NA or numerical zeros or ones encountered in fitted probabilities\n")
cat(paste("dropping these",sum(bad),"cases, but proceed with caution\n"))
}
aic.factor <- (k1-k2)/neff
bic.factor <- (k1-k2)/2 * log(neff)
print(bic.factor)
aic.factor <- (k1-k2)/neff
bic.factor <- (k1-k2)/(2*neff) * log(neff)
## test statistics
## 3 test statistics
v <- rep(NA,3)
L1 <- sum(log(m1p[!bad]))
L2 <- sum(log(m2p[!bad]))
num <- rep(L1-L2,3) - c(0,aic.factor,bic.factor)
s <- sd(m[!bad])
v <- num/(s*sqrt(neff))
arg1 <- matrix(m[!bad],nrow=neff,ncol=3,byrow=FALSE)
arg2 <- matrix(c(0,aic.factor,bic.factor),nrow=neff,ncol=3,byrow=TRUE)
num <- arg1 - arg2
s <- apply(num,2,sd)
numsum <- apply(num,2,sum)
v <- numsum/(s*sqrt(neff)) ## Vuong
names(v) <- c("Raw","AIC-corrected","BIC-corrected")
print(v)
print(s)
print(num)
##print(v)
##print(s)
##print(num)
## bundle up for output
pval <- rep(NA,3)
......
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -38,7 +38,7 @@
\source{
Jonathan Katz; Gary King. 1999. "Replication data for: A Statistical Model of Multiparty Electoral Data", \url{http://hdl.handle.net/1902.1/QIGTWZYTLZ}
Martin Baxter. \url{http://www.electoralcalculus.co.uk/electdata_1992ob.txt}
%%Martin Baxter. \url{http://www.electoralcalculus.co.uk/electdata_1992ob.txt}
}
\references{
Katz, Jonathan and Gary King. 1999. ``A Statistical Model for
......
......@@ -21,8 +21,7 @@
Keith Poole's web site:
\url{http://voteview.com/senate110.htm}
Originally scraped from the Senate's web site by Jeff Lewis: see
\url{http://adric.sscnet.ucla.edu/rollcall/static/S110.ord}
Originally scraped from the Senate's web site by Jeff Lewis.
Josh Clinton compiled the list of \emph{National Journal} key votes.
}
......
......@@ -86,7 +86,7 @@ readKH(file,
members of the Senate}
\item{\code{icpsrLegis}}{a unique numeric identifer for each
legislator assigned by the ICPSR, as corrected by Poole and
Rosenthal, see \url{http://voteview.com/icpsr.htm}}
Rosenthal.}
\item{\code{partyName}}{character string, the name of each legislator's
political party}
\item{\code{party}}{numeric, code for each legislator's political
......
......@@ -89,21 +89,8 @@
\author{Simon Jackman \email{jackman@stanford.edu}}
\examples{
## fake example
set.seed(314159265)
fakeData <- matrix(sample(x=c(0,1),size=1000,replace=TRUE),
10,100)
rc <- rollcall(fakeData)
## short-run for demo purposes
idFake <- ideal(rc,maxiter=500,burnin=100,thin=10)
summary(idFake)
## Supreme Court Example
data(sc9497)
rc <- rollcall(data=sc9497$votes,
legis.names=sc9497$legis.names,
desc=sc9497$desc)
id1 <- ideal(rc)
f <- system.file("extdata","id1.rda",package="pscl")
load(f)
summary(id1)
\dontrun{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment