Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
daccdff
commit fd36a16
Showing
95 changed files
with
2,494 additions
and
552 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
Package: BayesGOF | ||
Type: Package | ||
Title: Bayesian Modeling via Goodness of Fit | ||
Version: 1.4 | ||
Date: 2018-01-02 | ||
Version: 2.1 | ||
Date: 2018-02-08 | ||
Author: Subhadeep Mukhopadhyay, Douglas Fletcher | ||
Maintainer: Doug Fletcher <tug25070@temple.edu> | ||
Description: Non-parametric method for learning prior distribution starting with parametric (subjective) prior. It performs four interconnected tasks: (i) characterizes the uncertainty of the elicited prior; (ii) exploratory diagnostic for checking prior-data conflict; (iii) computes the final statistical prior density estimate; and (iv) performs macro- and micro-inference. Primary reference is Mukhopadhyay, S. and Fletcher, D. (2017, Technical Report). | ||
Description: A Bayesian data modeling scheme that performs four interconnected tasks: (i) characterizes the uncertainty of the elicited parametric prior; (ii) provides exploratory diagnostic for checking prior-data conflict; (iii) computes the final statistical prior density estimate; and (iv) executes macro- and micro-inference. Primary reference is Mukhopadhyay, S. and Fletcher, D. (2018, Technical Report, <arXiv:1802.00474>). | ||
Depends: orthopolynom, VGAM | ||
Suggests: knitr, rmarkdown | ||
VignetteBuilder: knitr | ||
License: GPL-2 | ||
NeedsCompilation: no | ||
Packaged: 2018-01-03 14:43:19 UTC; Doug | ||
Packaged: 2018-02-08 16:34:52 UTC; Doug | ||
Repository: CRAN | ||
Date/Publication: 2018-01-05 19:00:44 UTC | ||
Date/Publication: 2018-02-08 17:23:47 UTC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,108 @@ | ||
ff715b03553ac6270dbb83c08e7f16df *DESCRIPTION | ||
a4f3d575676f1b80e1058c92810fd2b7 *NAMESPACE | ||
e8cdb771de69edc672a7aac8d9440bb9 *R/BetaBinoMLE.R | ||
fe43131dc70d9bfb435a4e0dcd3ae58d *R/ConMean.prt.2.R | ||
f534a2cee775d2300a120951ff633f4a *R/DS.PostMean.R | ||
6f77a33e7e6f0fa1184b966f73dae483 *R/DS.PostMean.reduce.R | ||
df69695935b3e562e17b49c8223033a9 *R/DS.macro.inf.R | ||
d7e1d4d09924ca058faacdad2455fa6d *R/DS.micro.inf.R | ||
60be8417bea981f785e722ec25c278b9 *R/DS.mode.map.R | ||
03be355b3798c6a69b97548e5eee3926 *R/DS.mode.reduce.R | ||
8f5455dc47b5866c8c6423ee6b5f83ab *R/DS.prior.R | ||
8c77c3c19d95daffd0bf9cce56bff017 *DESCRIPTION | ||
388fd6d9b2d5c4ac4f8c83332bd163ba *NAMESPACE | ||
e8874fa248257c1fde8bcc55c8c64103 *R/ConMean.prt.2.bb.R | ||
dd9822d2b54974880c9801edc44b662f *R/ConMean.prt.2.nn.R | ||
3eb68f5507e9d541427effca082ff250 *R/ConMean.prt.2.pg.R | ||
f210a56b1292fb4ddaaed0cebe0d8e2a *R/DS.PostMean.R | ||
26410766099872ebc468aa5bd229a0eb *R/DS.PostMean.bbu.R | ||
e425b9419c3889396aa84b80125fe188 *R/DS.PostMean.nnu.R | ||
94c22af206dd01d07486ed9edd463d43 *R/DS.PostMean.pge.R | ||
7c0476b19773fdb2396929384a31ded3 *R/DS.PostMean.pgu.R | ||
ed4741f3f4462ab382c358f42a5fcdeb *R/DS.PostMean.reduce.R | ||
177dc6c20a6d45fd3aaaa2d95fe6fb24 *R/DS.PostMean.reduce.bbu.R | ||
11cc03c067f4ab80bc1962b8bf485e73 *R/DS.PostMean.reduce.nnu.R | ||
4e294de31b7f0428d6e512b1dec4a774 *R/DS.PostMean.reduce.pgu.R | ||
35ce329a6610dd7a4383a9e9926556e3 *R/DS.PostMode.R | ||
5e05ecb42d278459380074c28a111d6c *R/DS.PostMode.reduce.R | ||
642e34bded52c4dc9533784e965491f8 *R/DS.macro.inf.R | ||
c00328ab3fb487244b8db34262a7476a *R/DS.macro.inf.bbu.R | ||
4ddabf948f321d35aeea31963be13d80 *R/DS.macro.inf.nnu.R | ||
f2d0cd7ad4e53783ac25c1fb701ff374 *R/DS.macro.inf.pge.R | ||
d7993cbcdadf2772361f3fefa6f60cdb *R/DS.macro.inf.pgu.R | ||
131c10e579f32e6a389065b197fb24b1 *R/DS.micro.inf.R | ||
748eefb997234943c67f195b94ddde43 *R/DS.micro.inf.bbu.R | ||
f4c077d4bd0724119a1d209023ccca6c *R/DS.micro.inf.nnu.R | ||
0f58226b46c55f3dcae5e6d0f46daa97 *R/DS.micro.inf.pge.R | ||
b2cbba64c9b9d39ee7e75e4227b3bfd5 *R/DS.micro.inf.pgu.R | ||
b9408cd72a0a4304f50a7aeb87ba0be4 *R/DS.mode.map.bbu.R | ||
fb3141620abc5147dcb0dd42e9cd12d7 *R/DS.mode.map.nnu.R | ||
34c4cb9aebfdc34b6e4b01a570f7ee2c *R/DS.mode.map.pgu.R | ||
3fb4119ff1202e4db7ba525244522a55 *R/DS.mode.reduce.bbu.R | ||
a03ddf0bf44d6dadad746616c3e2c7ca *R/DS.mode.reduce.nnu.R | ||
45588e46af107453e3098d2f6d54619e *R/DS.mode.reduce.pgu.R | ||
a45d1342794901bb53f82d3ef23a3486 *R/DS.prior.R | ||
276cde93a9e1361ac97e61d2dd67cf8c *R/DS.prior.bbu.R | ||
792fbc5b79305a01ccef789f3725f6d2 *R/DS.prior.nnu.R | ||
840689ac8dc209ea2b686b46b1d55c05 *R/DS.prior.pgu.R | ||
59761b704e4c2594809a9bc6bdb6ab0d *R/DS.sampler.R | ||
79c5ea8e557814c77ab4f8114ba3e650 *R/DS.sampler.post.R | ||
e5354a65b65d2c5b81582559ee7a1030 *R/EXP.denom.R | ||
5ded1e76591fbd05471de371c5261042 *R/EXP.num.1.R | ||
cd2cdbd50f105ec57eb2fd32efc9630d *R/EXP.num.2.R | ||
399a1ec91a0e02f8186b74648054c169 *R/EXP.score.R | ||
e04999cc772d27e577942b140b77ef24 *R/LP.basis.beta.R | ||
9bb3353c77f1bcb5c1e5dc9c1780c1a3 *R/EXP.score.R | ||
e1b8297394b2aeb30dac851894205ece *R/LP.basis.beta.R | ||
b8b1dbd2309ba601d7188a889c96b9ca *R/LP.basis.gamma.R | ||
ec871cf587588dc9330a3f9d1420f9f8 *R/LP.basis.norm.R | ||
0488b1290b901beda5de0d54c6000679 *R/LP.smooth.R | ||
6b2a90b2028ddec70ff0a68fa1a519e0 *R/Local.Mode.R | ||
cc0c13114ef93fab90e4634341fa76ce *R/Reduce.LP.coef.R | ||
51d4b6e256174f370f2e8c7e3586c693 *R/Reduce.LP.coef.univ.R | ||
0d6ac55da028d87e14a5035e36d16232 *R/gLP.basis.R | ||
d4a2a8031c684b6364d3d6f442a7829e *R/gMLE.bb.R | ||
43e47e540af3ec33f977cd5475c20953 *R/gMLE.nn.R | ||
06c0cb40197d168f55c0b86a50c92bdc *R/gMLE.pg.R | ||
4575aa9706b6a5fd8ed35464a098852c *R/lambda.i.R | ||
7fa03fde303c925b5de4e3fa82bfe8a4 *R/mom.est.R | ||
71c42d22a062530811bf5774eab9b56f *R/plot.DS_GF.R | ||
1f8be9e42445840b66f7f2457fa95f15 *R/plot.DS_GF_macro_mean.R | ||
22ffc8f09ab875efedf86b9f35707f27 *R/plot.DS_GF_macro_mode.R | ||
ca68dbc678d9f573c109a904b2ac29fb *R/plot.DS_GF_micro.R | ||
aa58cc42ac6447acbd5611010a75dc02 *R/plot.DS_GF.R | ||
c7d0dfb2d0f4407384c763d664ac2584 *R/plot.DS_GF_macro_mean.R | ||
dbf1a306ed4278f8e312298804a1ff12 *R/plot.DS_GF_macro_mode.R | ||
4657fd0fb50bdca21802f2e910b5be47 *R/plot.DS_GF_micro.R | ||
32731dab82fe5d939ab07f068eece6e5 *R/print.DS_GF.R | ||
847051f9d55ea4d3df293cbe661e8fb7 *R/print.DS_GF_macro_mean.R | ||
5d2acbda0d40b6b8ea5074459f8916ba *R/print.DS_GF_macro_mode.R | ||
9a2ea0cbaae526bf289d047e08c484c2 *R/print.DS_GF_micro.R | ||
c5751d11df67d3e13765bb79a0ed8cdf *R/rDS.R | ||
904d66c45aae0007a9a9790007834619 *R/rDS.posterior.R | ||
43346db63edf02693e6dc6cde4561463 *R/weight.fun.beta.R | ||
52e60785b26ceed34594689813d7cde2 *build/partial.rdb | ||
e41c1edfd9b441d09fe161602ec14b6b *R/rDS.bbu.R | ||
1187f5e7ee3a75125383a9f35c4f3d46 *R/rDS.nnu.R | ||
9f50dd2ce26a87e2d93c8538ade2a216 *R/rDS.pgu.R | ||
e50e2e8cbcc87458078edb6758f4772c *R/rDS.post.bbu.R | ||
e756da3965695fb702859d9ab16c8948 *R/rDS.post.nnu.R | ||
cda2b544f890d24da352497f088fedb3 *R/rDS.post.pgu.R | ||
e8dd3d9cdc01501517963ff94c6fa5b9 *R/weight.fun.univ.R | ||
c6ebf4aa378cdb5bbbb6ab4d7f5a6421 *build/partial.rdb | ||
32bb6c15cc261cc5a800feaef03df159 *build/vignette.rds | ||
2235da02896248caee37a6bfd8f1675e *data/AutoIns.rda | ||
890414d6043ab45f0fc2d487c774eb93 *data/ChildIll.rda | ||
5597ec356f1189688b399a8835e03316 *data/CorbBfly.rda | ||
b4ec2d57f4f400e72d9bf5026e030d42 *data/NorbergIns.rda | ||
f66e2bfb6773231c37acda708ae6f320 *data/arsenic.rda | ||
4eb418b2906c27f4d7c4f1820cdfef39 *data/rat.rda | ||
86f2e44eba816a17d1c21b98238eb0f9 *data/ship.rda | ||
2ea567712e420d7dad930065d164f0ea *data/surg.rda | ||
b2cc985b167635ee9460b40031cb97b1 *data/tacks.rda | ||
d5e17a0af9b0f694d178a824213f7f04 *data/terb.rda | ||
b6b93be51774b48490af693f8da7b977 *inst/doc/vignette_BayesGOF.R | ||
cbd58b4bd918f85fd591770a32884297 *inst/doc/vignette_BayesGOF.Rmd | ||
e4d0976b6350f76127b0c4229a87fbc2 *inst/doc/vignette_BayesGOF.html | ||
f602b20ce666636fd4ce1fe3e2e4b14f *man/BayesGOF-package.Rd | ||
d5fe161c86340df185b1bf8722ed3244 *man/BetaBinoMLE.Rd | ||
b14a54fa25faf8496826ef5e2a0938aa *man/DS.PostMean.Rd | ||
f212f760e4377b14adde601a86a6c06b *man/DS.macro.inf.Rd | ||
323c51a0c260a624791b4c2a5cd96081 *man/DS.micro.inf.Rd | ||
883a6c582feafd1a0c212e75a234c579 *man/DS.prior.Rd | ||
80f2637e9f992da56001c6e04a910c57 *man/LP.basis.beta.Rd | ||
c5ae2041c3448673d570d4f62292a08a *man/rDS.Rd | ||
d0e4b41b002567b8dd89ece7943ad973 *man/rat.Rd | ||
036e74bea69c9cb18ce9435abda7a77d *man/ship.Rd | ||
cc1812eb703a57cffe97326febc8574e *data/ulcer.rda | ||
aae646e1ab0b14b61ce2c13c3e9798b9 *inst/doc/vignette_BayesGOF.R | ||
00477fab27864a039894e86b46e073b8 *inst/doc/vignette_BayesGOF.Rmd | ||
fa7e4dd971125091a2fb354d13fdcb9d *inst/doc/vignette_BayesGOF.html | ||
a41b5099796db2c2d56fe2f6db433a2c *man/AutoIns.Rd | ||
4568ed5c592b8b291f9b7f667c19f786 *man/BayesGOF-package.Rd | ||
e1aa854297548a3d819cf1107e552745 *man/ChildIll.Rd | ||
69425426d612b0624b71ba777c13ce8a *man/CorbBfly.Rd | ||
d225ad0e6c5fa07a33d7de5e3c88af24 *man/DS.PostMean.Rd | ||
173b507c0652bdefb19c078df65ba3a7 *man/DS.PostMode.Rd | ||
c62d319e6dd8a42576930e2d7b8c56c2 *man/DS.macro.inf.Rd | ||
a4fe6f3b4a2a9b557d737718a459a232 *man/DS.micro.inf.Rd | ||
1dec0080725d7f66422d830c83c287a1 *man/DS.prior.Rd | ||
8f2b93605ca690f4dd8fcba1e84cdb3e *man/DS.sampler.Rd | ||
1ab0aed54cbe4c0ca2c93ff114f4a254 *man/NorbergIns.Rd | ||
381f94e2b04e233cef79447defd45cbc *man/arsenic.Rd | ||
3bb7991e0dfb8defa05a1ff8c2bcc556 *man/gLP.basis.Rd | ||
a9fe0929f4db5dc101a80867382678e2 *man/gMLE.bb.Rd | ||
e829cd658710bb200b205aa6cd258a21 *man/gMLE.nn.Rd | ||
c5dfe04006698e33388e22b6a83dc1a0 *man/gMLE.pg.Rd | ||
acbf247e0e7ceb171e4b9d88059ddca3 *man/rat.Rd | ||
5df7768440e333efe4171b7830520775 *man/ship.Rd | ||
1a4578d3061e06f366a3a81187e2d7bb *man/surg.Rd | ||
7df318a497e78c94fafa22de2db27802 *man/tacks.Rd | ||
9081a09d6db42cfda219ec187d66122d *man/tacks.Rd | ||
e260deea72882c143a52313389aa8b6d *man/terb.Rd | ||
cbd58b4bd918f85fd591770a32884297 *vignettes/vignette_BayesGOF.Rmd | ||
b2b1af83da55655cd17d0886f6090b71 *man/ulcer.Rd | ||
00477fab27864a039894e86b46e073b8 *vignettes/vignette_BayesGOF.Rmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
ConMean.prt.2 <- | ||
ConMean.prt.2.bb <- | ||
function(c.vec, weight, leg.mat, u, par1, par2){ | ||
#### theta is G inv u = qnorm(u,muhat,tauhat) | ||
#### theta is G inv u = qbeta(u,par1, par2) | ||
inner.part <- qbeta(u, par1, par2)*leg.mat | ||
v <-(t(inner.part)%*% weight)/nrow(leg.mat) | ||
num.2 <- as.vector(v) %*% c.vec | ||
return(num.2) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
ConMean.prt.2.nn <- | ||
function(c.vec, weight, leg.mat, u, par1, par2){ | ||
#### theta is G inv u = qnorm(u,muhat,tauhat) | ||
inner.part <- qnorm(u, par1, sd=sqrt(par2))*leg.mat | ||
v <-(t(inner.part)%*% weight)/nrow(leg.mat) | ||
num.2 <- as.vector(v) %*% c.vec | ||
return(num.2) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
ConMean.prt.2.pg <- | ||
function(c.vec, weight, leg.mat, u, par1, par2){ | ||
#### theta is G inv u = qgamma(u,muhat,tauhat) | ||
inner.part <- qgamma(u, par1, scale = par2)*leg.mat | ||
v <-(t(inner.part)%*% weight)/nrow(leg.mat) | ||
num.2 <- as.vector(v) %*% c.vec | ||
return(num.2) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
DS.PostMean <- | ||
function(y.i, n.i, g.par, u, LP.par){ | ||
post.par1.i <- y.i + g.par[1] | ||
post.par2.i <- n.i - y.i + g.par[2] | ||
weight <- weight.fun.beta(u, g.par[1], g.par[2], post.par1.i, post.par2.i) | ||
leg.mat <- LP.basis.beta(u,c(1,1), length(LP.par)) | ||
if(sum(LP.par^2) == 0){ | ||
ConMean.ind <- (post.par1.i)/(post.par1.i + post.par2.i) | ||
function(y.0, n.0 = NULL, g.par, LP.par, B = 250, | ||
family = c("Normal","Binomial", "Poisson"), e.0 = NULL){ | ||
fam = match.arg(family) | ||
u <- seq(1/B, 1-1/B, length.out = B) | ||
switch(fam, | ||
"Normal" = { | ||
DS.PostMean.nnu(y.i = y.0, se.i=n.0, g.par = g.par, u=u,LP.par = LP.par) | ||
}, | ||
"Binomial" = { | ||
DS.PostMean.bbu(y.i = y.0, n.i=n.0,g.par = g.par, u=u,LP.par = LP.par) | ||
}, | ||
"Poisson" = { | ||
if(is.null(e.0) == TRUE){ | ||
DS.PostMean.pgu(x.i = y.0, g.par = g.par , u = u, LP.par = LP.par) | ||
} else { | ||
post.mu <- post.par1.i /(post.par1.i + post.par2.i) | ||
ConMean.ind <- ( post.mu + ConMean.prt.2(LP.par, weight, leg.mat, u, g.par[1], g.par[2]) ) / EXP.denom(LP.par,weight,leg.mat) | ||
DS.PostMean.pge(x.i = y.0, e.i = e.0, g.par = g.par, u = u, LP.par = LP.par) | ||
} | ||
return(ConMean.ind) | ||
} | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
DS.PostMean.bbu <- | ||
function(y.i, n.i, g.par, u, LP.par){ | ||
fam <- "Binomial" | ||
post.par1.i <- y.i + g.par[1] | ||
post.par2.i <- n.i - y.i + g.par[2] | ||
weight <- weight.fun.univ(u, g.par[1], g.par[2], post.par1.i, post.par2.i, family = fam) | ||
leg.mat <- LP.basis.beta(u,c(1,1), length(LP.par)) | ||
if(sum(LP.par^2) == 0){ | ||
ConMean.ind <- (post.par1.i)/(post.par1.i + post.par2.i) | ||
} else { | ||
post.mu <- post.par1.i /(post.par1.i + post.par2.i) | ||
ConMean.ind <- ( post.mu + ConMean.prt.2.bb(LP.par, weight, leg.mat, u, g.par[1], g.par[2]) ) / EXP.denom(LP.par,weight,leg.mat) | ||
} | ||
return(ConMean.ind) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
DS.PostMean.nnu <- | ||
function(y.i, se.i, g.par, u, LP.par){ | ||
fam <- "Normal" | ||
post.mu.i <- lambda.i(se.i, g.par[2]) * g.par[1] + | ||
(1-lambda.i(se.i, g.par[2]))* y.i | ||
post.tau2.i <- (1-lambda.i(se.i, g.par[2]))*se.i^2 #output is VARIANCE | ||
weight <- weight.fun.univ(u, g.par[1], g.par[2], post.mu.i, post.tau2.i, family = fam) | ||
leg.mat <- LP.basis.beta(u,c(1,1), length(LP.par)) | ||
if(sum(LP.par^2) == 0){ | ||
ConMean.ind <- post.mu.i | ||
} else { | ||
ConMean.ind <- ( post.mu.i + ConMean.prt.2.nn(LP.par, weight, leg.mat, u, g.par[1], g.par[2]) ) / EXP.denom(LP.par,weight,leg.mat) | ||
} | ||
return(ConMean.ind) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
DS.PostMean.pge <- | ||
function(x.i, e.i, g.par, u, LP.par){ | ||
fam <- "Poisson" | ||
B <- 250 | ||
post.par1.i <- x.i + g.par[1] | ||
post.par2.i <- g.par[2]/(1+e.i*g.par[2]) | ||
#u <- seq(1/B,1-(1/B), length.out = B) | ||
weight <- weight.fun.univ(u, g.par[1],g.par[2],post.par1.i,post.par2.i, family = fam) | ||
leg.mat <- LP.basis.beta(u, c(1,1), length(LP.par)) | ||
post.mu <- post.par1.i * post.par2.i | ||
ConMean.ind <- (post.mu + ConMean.prt.2.pg(LP.par, weight, leg.mat, u, g.par[1], g.par[2]) ) / EXP.denom(LP.par,weight,leg.mat) | ||
return(ConMean.ind) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
DS.PostMean.pgu <- | ||
function(x.i, g.par, u, LP.par){ | ||
fam <- "Poisson" | ||
post.par1.i <- x.i + g.par[1] | ||
post.par2.i <- g.par[2]/(1+g.par[2]) | ||
weight <- weight.fun.univ(u, g.par[1],g.par[2],post.par1.i,post.par2.i, family = fam) | ||
leg.mat <- LP.basis.beta(u, c(1,1), length(LP.par)) | ||
if(sum(LP.par^2) == 0){ | ||
ConMean.ind <- post.par1.i*post.par2.i | ||
} else { | ||
post.mu <- post.par1.i*post.par2.i | ||
ConMean.ind <- (post.mu + ConMean.prt.2.pg(LP.par, weight, leg.mat, u, g.par[1], g.par[2]) ) / EXP.denom(LP.par,weight,leg.mat) | ||
} | ||
return(ConMean.ind) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
DS.PostMean.reduce <- | ||
function(DS.GF.obj){ | ||
##################################################### | ||
# INPUTS | ||
# DS.GF.obj AutoBayes-DataCorrect object | ||
# OUTPUTS | ||
# ConMean.vec vector of conditional mean of entire sample | ||
y.i <- DS.GF.obj$obs.data[,1] | ||
n.i <- DS.GF.obj$obs.data[,2] | ||
if(sum(DS.GF.obj$LP.par^2) == 0){ | ||
ConMean.vec <- (DS.GF.obj$g.par[1]+y.i)/(DS.GF.obj$g.par[1]+DS.GF.obj$g.par[2]+n.i) | ||
} else { | ||
B <- dim(DS.GF.obj$prior.data)[1] | ||
u <- seq(1/B,1-(1/B), length.out = B) ##unit interval, 0 to 1 | ||
ConMean.vec <- NULL | ||
ConMean.vec <- apply(DS.GF.obj$obs.data, 1, function(x) DS.PostMean(x[1], x[2], DS.GF.obj$g.par, u, DS.GF.obj$LP.par)) | ||
fam = DS.GF.obj$fam | ||
switch(fam, | ||
"Normal" = { | ||
DS.PostMean.reduce.nnu(DS.GF.obj) | ||
}, | ||
"Binomial" = { | ||
DS.PostMean.reduce.bbu(DS.GF.obj) | ||
}, | ||
"Poisson" = { | ||
DS.PostMean.reduce.pgu(DS.GF.obj) | ||
} | ||
) | ||
} | ||
return(ConMean.vec) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
DS.PostMean.reduce.bbu <- | ||
function(DS.GF.obj){ | ||
##################################################### | ||
# INPUTS | ||
# DS.GF.obj AutoBayes-DataCorrect object | ||
# OUTPUTS | ||
# ConMean.vec vector of conditional mean of entire sample | ||
y.i <- DS.GF.obj$obs.data[,1] | ||
n.i <- DS.GF.obj$obs.data[,2] | ||
if(sum(DS.GF.obj$LP.par^2) == 0){ | ||
ConMean.vec <- (DS.GF.obj$g.par[1]+y.i)/(DS.GF.obj$g.par[1]+DS.GF.obj$g.par[2]+n.i) | ||
} else { | ||
B <- dim(DS.GF.obj$prior.fit)[1] | ||
u <- seq(1/B,1-(1/B), length.out = B) ##unit interval, 0 to 1 | ||
ConMean.vec <- NULL | ||
ConMean.vec <- apply(DS.GF.obj$obs.data, 1, function(x) DS.PostMean.bbu(x[1], x[2], DS.GF.obj$g.par, u, DS.GF.obj$LP.par)) | ||
} | ||
return(ConMean.vec) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
DS.PostMean.reduce.nnu <- | ||
function(DS.GF.obj){ | ||
##################################################### | ||
# INPUTS | ||
# DS.GF.obj AutoBayes-DataCorrect object | ||
# OUTPUTS | ||
# ConMean.vec vector of conditional mean of entire sample | ||
y.vec <- DS.GF.obj$obs.data[,1] | ||
se.vec <- DS.GF.obj$obs.data[,2] | ||
if(sum(DS.GF.obj$LP.par^2) == 0){ | ||
ConMean.vec <- lambda.i(se.vec, DS.GF.obj$g.par[2]) * DS.GF.obj$g.par[1] + | ||
(1-lambda.i(se.vec, DS.GF.obj$g.par[2]))* y.vec | ||
} else { | ||
B <- dim(DS.GF.obj$prior.fit)[1] | ||
u <- seq(1/B,1-(1/B), length.out = B) ##unit interval, 0 to 1 | ||
ConMean.vec <- NULL | ||
ConMean.vec <- apply(DS.GF.obj$obs.data, 1, function(x) DS.PostMean.nnu(x[1], x[2], DS.GF.obj$g.par, u, DS.GF.obj$LP.par)) | ||
} | ||
return(ConMean.vec) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
DS.PostMean.reduce.pgu <- | ||
function(DS.GF.obj){ | ||
##################################################### | ||
# INPUTS | ||
# DS.GF.obj AutoBayes-DataCorrect object | ||
# OUTPUTS | ||
# ConMean.vec vector of conditional mean of entire sample | ||
tbl <- table(DS.GF.obj$obs.data) | ||
cnt.vec <- as.integer(unlist(dimnames(tbl))) | ||
if(sum(DS.GF.obj$LP.par^2) == 0){ | ||
ConMean.vec <- (DS.GF.obj$g.par[1]+cnt.vec)*(DS.GF.obj$g.par[2])/(1+DS.GF.obj$g.par[2]) | ||
} else { | ||
B <- dim(DS.GF.obj$prior.fit)[1] | ||
u <- seq(1/B,1-(1/B), length.out = B) ##unit interval, 0 to 1 | ||
ConMean.vec <- NULL | ||
ConMean.vec <- sapply(cnt.vec, function(x) DS.PostMean.pgu(x, DS.GF.obj$g.par, u, DS.GF.obj$LP.par)) | ||
} | ||
return(ConMean.vec) | ||
} |
Oops, something went wrong.