

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


beta^
dbeta Cauchy^
dcauchy chisquare
dchisq exponential
dexp F^
df gamma^
dgamma logistic
dlogis lognormal
dlnorm normal^
dnorm t^
dt uniform
dunif weibull
dweibull poisson
dpois binomial
dbinom For each of the distributions 4 functions are available, which differ only by their firstletter:^ d^
-- density or probability mass function (example: dbeta, dbinom)p -- cumulative density or cumulative probability mass function (example: pbeta, pbinom)q --^ quantiles (example:
qbeta, qbinom)
r --^ generate a random sample (example: rbeta, rbinom) You can get detailed documentation on all four of the functions for any of thedistributions by entering ”help(name of one of the functions)”. For example help(dgamma) will produce documentation on all 4 of the functions for the gamma distribution.To get used to using the documentation and using the functions, use the functionsto get answers to the following questions. You will need to be able to do these kindsof things to solve real problems on an upcoming homework assignment.
p^ =^ .4 takes on a value less than or equal to 4. Whenever you are using software to do things with probability distributions, it isimportant to know what parameterization the software package uses for the distri-bution of interest.
For example, there are two different parameterizations of the gamma distribution in common use. Let’s find out whether R uses the same param-eterization as that given in the GCSR table of distributions.1. Note the formulas for the mean and variance of a gamma random variablegiven in the table.2. Now we will generate a random sample of 1000 values from a gamma( 2, 10)distribution and will calculate their mean and variance.
gammasamp <- rgamma(1000, 2, 10)
mean(gammasamp)
var(gammasamp)
rm(gammasamp)
If you’re not sure,
c:
temp. Then in R^ s138.pbetap <- source("c:\temp\pbetap")$value You must provide the arguments to this function in parentheses when you call thefunction. The arguments are:^ •^ the alpha parameter of the beta posterior distribution
-^ the beta parameter of the beta posterior distribution •^ the sample size in the future sample for which you wish to compute posteriorprobabilities •^ a vector of the numbers of successes for which you wish to compute posteriorprobabilitiesFor example, suppose I was trying to estimate a population proportion
p.^ I had
used a uniform prior and I observed 6 successes and 4 failures. Thus, my posteriordistribution is:
p(p|y) =^
Beta(7,^ 5)
I plan to conduct a new study with sample size
∗^ n= 10. If
∗^ ydenotes the number of
successes in the hypothetical future study, I want to compute the posterior predictiveprobabilities of three possible values of
∗^ y— 6, 7, and 8. The following call will do
this:^ s138.pbetap( 7, 5, 10, 6:8) Note that the last argument (”6:8”), is Splus’s notation for a sequence.
It means
the integers 6 through 8 inclusive.1. Suppose you had carried out our survey of UI students.
You had used a
uniform prior and had gotten 7 yeses and 43 nos in your survey.(a) What is your posterior distribution for the population proportion
p?
(b) You are considering carrying out a follow-up survey of 25 more students.Use the function to compute the posterior predictive probabilities of eachof the possible numbers of yeses in the follow-up study.(c) What is the most likely number of yeses in the new study?