Description Usage Arguments Value Examples
View source: R/predictive_recursion.R View source: R/core.R
Predictive recursion by Newton (2002)
1 | predictive_recursion(x, k)
|
x |
a sequence of chi-squared test statistics |
k |
degrees of freedom |
a list: null proportion, prior probability, and lambda-mesh values
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | set.seed(2021)
p = 1000
k = 7
# the prior distribution for lambda
alpha = 2
beta = 10
# lambda
lambda = rep(0, p)
pi_0 = 0
p_0 = floor(p*pi_0)
p_1 = p-p_0
lambda[(p_0+1):p] = stats::rgamma(p_1, shape = alpha, rate=1/beta)
# Generate a Poisson RV
J = sapply(1:p, function(x){rpois(1, lambda[x]/2)})
X = sapply(1:p, function(x){rchisq(1, k+2*J[x])})
out = predictive_recursion(X, k)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.