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)?

MATLAB: An Introduction with Applications
6th Edition
ISBN:9781119256830
Author:Amos Gilat
Publisher:Amos Gilat
Chapter1: Starting With Matlab
Section: Chapter Questions
Problem 1P
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
MATLAB: An Introduction with Applications
MATLAB: An Introduction with Applications
Statistics
ISBN:
9781119256830
Author:
Amos Gilat
Publisher:
John Wiley & Sons Inc
Probability and Statistics for Engineering and th…
Probability and Statistics for Engineering and th…
Statistics
ISBN:
9781305251809
Author:
Jay L. Devore
Publisher:
Cengage Learning
Statistics for The Behavioral Sciences (MindTap C…
Statistics for The Behavioral Sciences (MindTap C…
Statistics
ISBN:
9781305504912
Author:
Frederick J Gravetter, Larry B. Wallnau
Publisher:
Cengage Learning
Elementary Statistics: Picturing the World (7th E…
Elementary Statistics: Picturing the World (7th E…
Statistics
ISBN:
9780134683416
Author:
Ron Larson, Betsy Farber
Publisher:
PEARSON
The Basic Practice of Statistics
The Basic Practice of Statistics
Statistics
ISBN:
9781319042578
Author:
David S. Moore, William I. Notz, Michael A. Fligner
Publisher:
W. H. Freeman
Introduction to the Practice of Statistics
Introduction to the Practice of Statistics
Statistics
ISBN:
9781319013387
Author:
David S. Moore, George P. McCabe, Bruce A. Craig
Publisher:
W. H. Freeman