Skip to content

Commit

Permalink
version 1.1-2
Browse files Browse the repository at this point in the history
  • Loading branch information
Glen Meeden authored and gaborcsardi committed Mar 20, 2012
1 parent a4c3502 commit 579abc3
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 121 deletions.
5 changes: 5 additions & 0 deletions .Rinstignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
doc/Makefile
doc/.*[.]tex
doc/.*[.]bbl
doc/Rplots.pdf
doc/pp1.bbl
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: polyapost
Version: 1.1-1
Date: 2011-04-01
Version: 1.1-2
Date: 2012-03-20
Imports: boot
Title: Simulating from the Polya posterior
Author: Glen Meeden <glen@stat.umn.edu> and Radu Lazar
Expand All @@ -9,6 +9,6 @@ Maintainer: Glen Meeden <glen@stat.umn.edu>
Description: Generate dependent samples from a non-full dimensional
polytope via a Markov Chain sampler
License: GPL (>= 2)
Packaged: 2011-04-01 20:29:19 UTC; glen
Packaged: 2012-03-20 21:43:39 UTC; geyer
Repository: CRAN
Date/Publication: 2011-04-03 07:43:21
Date/Publication: 2012-03-21 07:59:39
16 changes: 7 additions & 9 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
e4022fef5870806939a1fc873e43a34e *DESCRIPTION
6dfb3163322449f6682c7b130ccabcd6 *DESCRIPTION
c76df6367ec5ce07212d916fcc833e16 *NAMESPACE
af205ca09fab4fe4f460b9c4348eb85d *R/checkconstr.R
a24b9132c8639e5deaee307bc7fe9e23 *R/constrmat.R
Expand All @@ -14,18 +14,16 @@ a1a00e355ceb163ef53365bfca339836 *R/polyap.R
2be02f772609a4f9913e4bf2a30c876d *R/probvect.R
d2d0660f39acf21c1149c4945c4c8b48 *R/probvect1.R
be39dcf61a777387307071ea97d954aa *R/wtpolyap.R
29087fe69e156c49e2c6d99b3ad427de *inst/doc/Makefile
61d6d43b57b59b11a6a859d41bece14e *inst/doc/Rplots.pdf
102bd55bba8f8b4ea8c0e7c76a2ffb8d *inst/doc/Makefile
134ca7abd4d89854e6f9a5e4c4e57ff5 *inst/doc/pp1.Rnw
50e24be4edb99c0d664dba4a5b8c5f59 *inst/doc/pp1.bbl
94fa437f955b148e68f52a7530d3c10d *inst/doc/pp1.pdf
0e923672b7bf7907f550f8cc5ade10d0 *inst/doc/pp1.tex
60cf84f029be4a5325c1528e9e60e3ec *inst/doc/pp1.pdf
806f3ce1d990b0032ff600dbc273a15c *inst/doc/pp1.tex
4388f62ae698c61d4700c06f5e555ecc *inst/doc/ref.bib
3b716132aa2bd8685f02914ffd67b2c1 *man/constrppmn.Rd
bfe800f8e58196f92238b7c95ea743a1 *man/constrppprob.Rd
5b6324e86f7901e956c84d1c78909919 *man/feasible.Rd
70a66177a47ae41060719beac631cc0d *man/polyap.Rd
f3306aed9f43d4ce80ac07816b69a2ed *man/wtpolyap.Rd
98c43e79badf466e944c7eaa15f04f9b *src/cwpolya.c
604cba68ca5c4315ae59cf46bb70a2f6 *src/means.c
e6d55970077153a349b21108fb1da02e *src/probvect.c
acc74c55459b9a9eeec62c095169c1cb *src/cwpolya.c
d067003129a24718720d6524880cdf08 *src/means.c
3210d9b6a13447a22754e5819e7cb2dc *src/probvect.c
8 changes: 7 additions & 1 deletion inst/doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@ all: pp1.pdf clean
pp1.tex: pp1.Rnw
$(R_HOME)/bin/R CMD Sweave pp1.Rnw

pp1.pdf: pp1.tex ref.bib
pdflatex pp1
bibtex pp1
pdflatex pp1
pdflatex pp1

clean:
rm -f *.aux *.log *.dvi *.blg pp1-*.eps pp1-*.pdf Rplots.ps pp1.blg
rm -f *.aux *.log *.dvi *.blg *.bbl pp1-*.pdf Rplots.pdf
Binary file removed inst/doc/Rplots.pdf
Binary file not shown.
42 changes: 0 additions & 42 deletions inst/doc/pp1.bbl

This file was deleted.

Binary file modified inst/doc/pp1.pdf
Binary file not shown.
114 changes: 55 additions & 59 deletions inst/doc/pp1.tex
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ \section{Simulating from the Polya posterior}
\begin{Sinput}
> set.seed(313)
> library(polyapost)
> ysamp <- c(0, 1)
> K <- 10 - 2
> polyap(ysamp, K)
> ysamp<-c(0,1)
> K<-10-2
> polyap(ysamp,K)
\end{Sinput}
\begin{Soutput}
[1] 0 1 0 0 1 0 1 1 0 1
Expand All @@ -99,27 +99,25 @@ \section{Simulating from the Polya posterior}

\begin{Schunk}
\begin{Sinput}
> y <- rgamma(500, 5)
> y<-rgamma(500,5)
> mean(y)
\end{Sinput}
\begin{Soutput}
[1] 5.021535
\end{Soutput}
\begin{Sinput}
> samp <- sample(1:500, 25)
> ysamp <- y[samp]
> samp<-sample(1:500,25)
> ysamp<-y[samp]
> mean(ysamp)
\end{Sinput}
\begin{Soutput}
[1] 5.737207
\end{Soutput}
\begin{Sinput}
> K <- 500 - 25
> simmns <- rep(0, 10)
> for (i in 1:10) {
+ simmns[i] <- mean(polyap(ysamp, K))
+ }
> round(simmns, digits = 2)
> K<-500-25
> simmns<-rep(0,10)
> for(i in 1:10){simmns[i]<-mean(polyap(ysamp,K))}
> round(simmns,digits=2)
\end{Sinput}
\begin{Soutput}
[1] 5.62 5.47 5.55 5.56 6.44 5.55 5.29 6.54 5.33 6.82
Expand Down Expand Up @@ -190,9 +188,9 @@ \subsection{The basic idea}

\begin{Schunk}
\begin{Sinput}
> x <- sort(rgamma(500, 10))
> y <- rnorm(500, 20 + 2 * x, 3)
> cor(x, y)
> x<-sort(rgamma(500,10))
> y<-rnorm(500,20 + 2*x,3)
> cor(x,y)
\end{Sinput}
\begin{Soutput}
[1] 0.8966712
Expand All @@ -204,7 +202,7 @@ \subsection{The basic idea}
[1] 39.87462
\end{Soutput}
\begin{Sinput}
> mnx <- mean(x)
> mnx<-mean(x)
> mnx
\end{Sinput}
\begin{Soutput}
Expand All @@ -224,9 +222,9 @@ \subsection{The basic idea}

\begin{Schunk}
\begin{Sinput}
> samp <- sort(c(sample(1:250, 8), sample(251:500, 17)))
> ysamp <- y[samp]
> xsamp <- x[samp]
> samp<-sort(c(sample(1:250,8),sample(251:500,17)))
> ysamp<-y[samp]
> xsamp<-x[samp]
> mean(ysamp)
\end{Sinput}
\begin{Soutput}
Expand All @@ -239,12 +237,12 @@ \subsection{The basic idea}
[1] 10.87586
\end{Soutput}
\begin{Sinput}
> A1 <- rbind(rep(1, 25), c(rep(1, 8), rep(0, 17)))
> b1 <- c(1, 0.5)
> A2 <- rbind(xsamp, -diag(25))
> b2 <- c(10, rep(0, 25))
> A3 <- matrix(xsamp, 1, 25)
> b3 <- 9.7
> A1<-rbind(rep(1,25),c(rep(1,8),rep(0,17)))
> b1<-c(1,0.5)
> A2<-rbind(xsamp,-diag(25))
> b2<-c(10.0,rep(0,25))
> A3<-matrix(xsamp,1,25)
> b3<-9.7
\end{Sinput}
\end{Schunk}

Expand Down Expand Up @@ -274,9 +272,9 @@ \subsection{The basic idea}

\begin{Schunk}
\begin{Sinput}
> eps <- 0.001
> initsol <- feasible(A1, A2, A3, b1, b2, b3, eps)
> initsol[c(3, 9, 25)]
> eps<-0.001
> initsol<-feasible(A1,A2,A3,b1,b2,b3,eps)
> initsol[c(3,9,25)]
\end{Sinput}
\begin{Soutput}
[1] 0.0010000 0.3107501 0.1742499
Expand Down Expand Up @@ -323,10 +321,9 @@ \subsection{The basic idea}

\begin{Schunk}
\begin{Sinput}
> burnin <- 1
> reps <- 200001
> out <- constrppmn(A1, A2, A3, b1, b2, b3, initsol, reps, ysamp,
+ burnin)
> burnin<-1
> reps<-200001
> out<-constrppmn(A1,A2,A3,b1,b2,b3,initsol,reps,ysamp,burnin)
> mean(out[[1]])
\end{Sinput}
\begin{Soutput}
Expand Down Expand Up @@ -356,13 +353,13 @@ \subsection{The basic idea}

\begin{Schunk}
\begin{Sinput}
> out[[2]]
> out[[2]]
\end{Sinput}
\begin{Soutput}
[1] 39.81557
\end{Soutput}
\begin{Sinput}
> out[[3]]
> out[[3]]
\end{Sinput}
\begin{Soutput}
2.5% 97.5%
Expand Down Expand Up @@ -408,21 +405,20 @@ \subsubsection{How long to run the chain}

\begin{Schunk}
\begin{Sinput}
> A1 <- rbind(rep(1, 25))
> A2 <- -diag(25)
> b1 <- 1
> b2 <- rep(0, 25)
> initsol <- rep(0.04, 25)
> reps <- 1000001
> out <- constrppmn(A1, A2, NULL, b1, b2, NULL, initsol, reps,
+ ysamp, burnin)
> A1<-rbind(rep(1,25))
> A2<--diag(25)
> b1<-1
> b2<-rep(0,25)
> initsol<-rep(0.04,25)
> reps<-1000001
> out<-constrppmn(A1,A2,NULL,b1,b2,NULL,initsol,reps,ysamp,burnin)
> mean(out[[1]])
\end{Sinput}
\begin{Soutput}
[1] 42.04514
\end{Soutput}
\begin{Sinput}
> subseq <- seq(1, 1000001, by = 1000)
> subseq<-seq(1,1000001,by=1000)
> mean(out[[1]][subseq])
\end{Sinput}
\begin{Soutput}
Expand Down Expand Up @@ -455,10 +451,10 @@ \subsubsection{How long to run the chain}

\begin{Schunk}
\begin{Sinput}
> K <- 500 - 25
> simmns <- rep(0, 1000)
> for (i in 1:1000) {
+ simmns[i] <- mean(polyap(ysamp, K))
> K<-500-25
> simmns<-rep(0,1000)
> for(i in 1:1000){
+ simmns[i]<-mean(polyap(ysamp,K))
+ }
> mean(simmns)
\end{Sinput}
Expand Down Expand Up @@ -498,15 +494,15 @@ \subsubsection{Estimating parameters other than the mean}

\begin{Schunk}
\begin{Sinput}
> A1 <- rbind(rep(1, 6), 1:6)
> A2 <- rbind(c(2, 5, 7, 1, 10, 8), diag(-1, 6))
> A3 <- matrix(c(1, 1, 1, 0, 0, 0), 1, 6)
> b1 <- c(1, 3.5)
> b2 <- c(6, rep(0, 6))
> b3 <- 0.45
> initsol <- rep(1/6, 6)
> out <- constrppprob(A1, A2, A3, b1, b2, b3, initsol, 2000, 5)
> round(out, digits = 5)
> A1<-rbind(rep(1,6),1:6)
> A2<-rbind(c(2,5,7,1,10,8),diag(-1,6))
> A3<-matrix(c(1,1,1,0,0,0),1,6)
> b1<-c(1,3.5)
> b2<-c(6,rep(0,6))
> b3<-0.45
> initsol<-rep(1/6,6)
> out<-constrppprob(A1,A2,A3,b1,b2,b3,initsol,2000,5)
> round(out,digits=5)
\end{Sinput}
\begin{Soutput}
[,1] [,2] [,3] [,4] [,5] [,6]
Expand Down Expand Up @@ -541,9 +537,9 @@ \subsubsection{The weighted Polya posterior}

\begin{Schunk}
\begin{Sinput}
> ysamp <- c(1, 2, 3)
> wts <- c(1, 2, 3)
> wtpolyap(ysamp, wts, 25)
> ysamp<-c(1,2,3)
> wts<-c(1,2,3)
> wtpolyap(ysamp,wts,25)
\end{Sinput}
\begin{Soutput}
[1] 1 2 3 3 3 3 3 3 3 3 2 3 3 3 3 2 3 3 3 3 3 3 3 3 2 3 3 3
Expand Down
2 changes: 0 additions & 2 deletions src/cwpolya.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

#include <stdio.h>
#include <float.h>
#include <R.h>

void cwpolya(double *x, double *w, int *nin, int *Nin)
Expand Down
4 changes: 2 additions & 2 deletions src/means.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*Computes the Markov chain of means for the constrained Polya method*/
/*for combined equality and inequality constraints A1x=b1,A2x<=b2. It returns all values.*/
#include <stdio.h>
#include <float.h>

#include <R.h>

double sum( double x[], int vectsize )
{
double s;
Expand Down
3 changes: 1 addition & 2 deletions src/probvect.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*Computes the Markov chain of the points in the polytope*/
/*for combined equality and inequality constraints A1x=b1,A2x<=b2. It returns the last value.*/
#include <stdio.h>
#include <float.h>

#include <R.h>
double sum1( double x[], int vectsize )
{
Expand Down

0 comments on commit 579abc3

Please sign in to comment.