The data are y = (y₁,...,n), a sample from a negative binomial distribution with parameters q and r, where r is assumed to be known. A Beta(a,ß) prior distribution is assigned to q. Apart from part (c), the answers do not need any numerical calculations. In the following R code, the data y is denoted by y in the code, r is the known parameter, and alpha and beta are the prior parameters. The posterior distribution for q is Beta(a, b). r = 2 alpha= 4 beta = 4 a = r*length(y) + alpha b = sum(y) + beta qbeta(0.5, shapel-a, shape2=b) qbeta(c(0.025, 0.975), shapel-a, shape2=b) (a) In statistical terms, what will the second-to-last line of code output? (b) In statistical terms, what will the last line of code output? The R code below follows on from the code above. q_sim rbeta (2000, shapel-a, shape2=b) x = rnbinom (length (q_sim), size=r, prob=q_sim) mean(x<3) (d) When this code has run, what will q_sim contain? What will x contain? (e) What quantity will the last line of code output (in statistical terms)?

Calculus For The Life Sciences
2nd Edition
ISBN:9780321964038
Author:GREENWELL, Raymond N., RITCHEY, Nathan P., Lial, Margaret L.
Publisher:GREENWELL, Raymond N., RITCHEY, Nathan P., Lial, Margaret L.
Chapter13: Probability And Calculus
Section13.CR: Chapter 13 Review
Problem 6CR
icon
Related questions
Question

answer all parts

The data are y = (y₁,...,n), a sample from a negative binomial distribution with parameters q
and r, where r is assumed to be known. A Beta(a,ß) prior distribution is assigned to q. Apart
from part (c), the answers do not need any numerical calculations.
In the following R code, the data y is denoted by y in the code, r is the known parameter, and
alpha and beta are the prior parameters. The posterior distribution for q is Beta(a, b).
r = 2
alpha= 4
beta = 4
a = r*length(y) + alpha
b = sum(y) + beta
qbeta(0.5, shapel-a, shape2=b)
qbeta(c(0.025, 0.975), shapel-a, shape2=b)
(a) In statistical terms, what will the second-to-last line of code output?
(b) In statistical terms, what will the last line of code output?
The R code below follows on from the code above.
q_sim rbeta (2000, shapel-a, shape2=b)
x = rnbinom (length (q_sim), size=r, prob=q_sim)
mean(x<3)
(d) When this code has run, what will q_sim contain? What will x contain?
(e) What quantity will the last line of code output (in statistical terms)?
Transcribed Image Text:The data are y = (y₁,...,n), a sample from a negative binomial distribution with parameters q and r, where r is assumed to be known. A Beta(a,ß) prior distribution is assigned to q. Apart from part (c), the answers do not need any numerical calculations. In the following R code, the data y is denoted by y in the code, r is the known parameter, and alpha and beta are the prior parameters. The posterior distribution for q is Beta(a, b). r = 2 alpha= 4 beta = 4 a = r*length(y) + alpha b = sum(y) + beta qbeta(0.5, shapel-a, shape2=b) qbeta(c(0.025, 0.975), shapel-a, shape2=b) (a) In statistical terms, what will the second-to-last line of code output? (b) In statistical terms, what will the last line of code output? The R code below follows on from the code above. q_sim rbeta (2000, shapel-a, shape2=b) x = rnbinom (length (q_sim), size=r, prob=q_sim) mean(x<3) (d) When this code has run, what will q_sim contain? What will x contain? (e) What quantity will the last line of code output (in statistical terms)?
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Recommended textbooks for you
Calculus For The Life Sciences
Calculus For The Life Sciences
Calculus
ISBN:
9780321964038
Author:
GREENWELL, Raymond N., RITCHEY, Nathan P., Lial, Margaret L.
Publisher:
Pearson Addison Wesley,
Glencoe Algebra 1, Student Edition, 9780079039897…
Glencoe Algebra 1, Student Edition, 9780079039897…
Algebra
ISBN:
9780079039897
Author:
Carter
Publisher:
McGraw Hill