SlideShare uma empresa Scribd logo
1 de 3
Baixar para ler offline
STATISTICS 225 – Fall 2018
Homework 1 - solutions
HW is graded at 5 points per problem. I will try to provide detailed solutions. I will provide my R code for solving
the computational problems – you should not assume that my code is the most efficient way to get the answer.
1. Loss functions – This was reasonably straightforward. One minor point is that you should check that your
solution does, in fact, minimize the expected loss.
(a) L(θ, a) = (θ − a)2
:
E(L|y) =
Z
(θ − a)2
p(θ|y)dθ
dE(L|y)
da
= −2
Z
(θ − a)p(θ|y)dθ = 2a − 2E(θ|y)
Setting the first derivative to zero yields a = E(θ|y). Note that the 2nd derivative is positive so this is a
minimizer.
(b) L(θ, a) = |θ − a| = (θ − a)I(θ ≥ a) + (a − θ)I(θ < a):
E(L|y) =
Z a
−∞
(a − θ)p(θ|y)dθ +
Z ∞
a
(θ − a)p(θ|y)dθ
dE(L|y)
da
=
Z a
−∞
p(θ|y)dθ −
Z ∞
a
p(θ|y)dθ
= 2
Z a
−∞
p(θ|y)dθ − 1 ( add and subtract
Z a
−∞
p(θ|y)dθ)
Note that the derivatives here are complicated because a appears in the limits of integration and in the
integrand. Fortunately all the messy stuff drops out. Setting the derivative to zero indicates that we should
find a such that posterior cdf is 1/2, i.e., a posterior median. The second derivative is not informative here
but we can see that the first derivative is negative for smaller values of a and positive for bigger values of
a which makes this a minimum.
2. Prior distributions for the Poisson
(a) The calculations below demonstrate that the kernel of the posterior distribution is that of a
Gamma(
P
i yi + α, n + β) distribution so the gamma is a conjugate prior distribution.
p(λ|y) ∝ p(y|λ)p(λ) ∝ λ
P
i
yi
e−nλ
λα−1
e−βλ
= λ
P
i
yi+α−1
e−(n+β)λ
(b) There is not a unique right answer. In the conjugate (Gamma) family, the mean of the distribution is
α/β. The expert tells us that they would guess the rate is around 1 which suggests choosing α = β. The
expert also believes that it would not be surprising to find the rate is between (.1 and 10). Thus we want
most of our prior probability in this range (how much? Perhaps .80 or .90 or .95.). You can play around
with the gamma distribution in R. pgamma is the cdf function. It takes a shape parameter and a scale
or rate parameter. The form of the density that I’ve given above has β as a rate parameter (and thus
1/β as a scale parameter). The Gamma(1,1) distribution has probability .9 between .1 and 10 so may
be appropriate. Many of you noticed though that just about all of the probability here is well less than
10 so this prior essentially rules out values bigger than 10. Choosing a smaller shape parameter (say .1)
provides for a longer tail. Unfortunately it also puts a lot of probability near zero.
I played around a bit (more than I would expect you to) and discovered that α = β may not be ideal after
all. A gamma distribution with shape α = .7 and inverse scale (rate) β = .3 has .025 percentile equal to
.014, median equal to 1.27 and .975 percentile equal to 8.92. That comes somewhat close to the expert’s
views.
(c) Noninformative prior distributions
i. The flat prior distribution is not a proper distribution since it does not have a finite integral over
the positive half of the real line. If p(λ) ∝ 1, then p(λ|y) ∝ λ
P
i
yi
e−nλ
which is the kernel of a
Gamma(
P
i yi + 1, n) distribution. Thus the flat prior leads to a proper posterior distribution.
ii. To find Jeffrey’s prior we need the Fisher information. We need to compute E(−d2
logp(y|λ)
dλ2 |λ). The log
of the Poisson distribution is
P
i yi log λ−nλ. The negative 2nd derivative is
P
i yi/λ2
. Finally J(λ) =
E(
P
i yi/λ2
|λ) = n/λ. Jeffrey’s prior is proportional to the square root of the Fisher information which
is λ−1/2
.
iii. If φ =
√
λ, then the inverse transformation is λ = φ2
. The density of φ is derived as
pφ(φ) = pλ(φ2
)|dλ/dφ| ∝ (φ2
)−1/2
2φ ∝ constant
iv. The Jeffreys’ prior, p(λ) ∝ 1/
√
λ, is not a proper prior distribution. Once again it does not integrate
to a finite number on the positive half of the real line.
v. If we use p(λ) ∝ 1/
√
λ, then the posterior distribution is Gamma(
P
i yi + 1/2, n) which is a proper
distribution. (My hint was incorrect. Sorry about that.)
3. Weibull (conjugate case):
(a) The calculations below demonstrate that the kernel of the posterior distribution is that of a
Gamma(n + α,
P
i y2
i + β) distribution so the gamma is a conjugate prior distribution.
p(θ|y) ∝ p(y|θ)p(θ) ∝ θn
e−
P
i
y2
i θ
θα−1
e−βθ
= θn+α−1
e−(
P
i
y2
i +β)θ
(b) The problem statement tells you that the yi’s are conditionally independent given θ. Now consider the
marginal distribution (where I’m no longer ignoring constants!):
p(y) =
Z
p(y|θ)p(θ)dθ =
Z
2n
θn
(
Y
i
yi)e−
P
i
y2
i θ βα
Γ(α)
θα−1
e−βθ
dθ
= 2n
Y
i
yi
βα
Γ(α)
Z
θα+n−1
e−θ(β+
P
i
y2
i )
dθ =
2n
(
Q
i yi)βα
Γ(α + n)
(β +
P
i y2
i )n+αΓ(α)
where the final equality comes from completing the gamma density. The marginal can not be factored
as a product of the marginal distribution of each yi hence the yi’s are not independent in the marginal
distribution.
(c) R commands/programs and output are provided on a separate sheet. A key point is that the Gamma(1.4,2)
prior distribution appears to concentrate on θ from 0 to 3 (95% central prior interval runs from .04 to 2.24;
99% central prior interval runs from .01 to 3.10). Note that θ = 3 corresponds to a Weibull distribution
for which the mean of y is equal to 0.5 (the lower limit suggested by our prior information) and that
θ = .03 corresponds to a Weibull distribution with mean of y equal to 5 (the upper limit suggested by our
prior information). Thus the chosen prior makes sense.
(d) Here we can use theory rather than simulation. The posterior distribution of θ is Gamma(11.4, 11.377)
which has mean 1.002 and variance 0.088. The 95% posterior interval for θ (see output) is (.507, 1.662).
(e) The best prediction of the lifetime of a new part depends on the loss function (as we showed in the first
problem). I didn’t specify a loss function here. Most people usually think of the posterior mean as the
natural estimate. Here we actually want the posterior mean of the expected lifetime E(Y ) which is a
function of θ (recall that E(Y ) = .886θ−0.5
). This is easiest to obtain by simulation. I simulated 1000
draws from the posterior distribution of θ, computed .886θ−0.5
for each one, and then took the mean of
these values to come up with an estimate of .9155. To get a predictive interval, simulate 1000 draws from
the posterior distribution of θ and then for each draw simulate a random variable y from the Weibull
distribution with that θ (see code). The predictive interval from my simultations is (.139, 2.086).
4. Mixtures of conjugate priors
(a) From the definition:
p(θ|y) =
p(y|θ)p(θ)
R
p(y|θ)p(θ)
=
Pk
m=1 λmp(y|θ)pm(θ)
Pk
m=1
R
λmp(y|θ)pm(θ)dθ
=
Pk
m=1 λmpm(y)pm(θ|y)
Pk
m=1 λmpm(y)
where the last equality comes from recognizing that p(y|θ)pm(θ) = pm(θ|y)pm(y) and that
pm(y) =
R
p(y|θ)pm(θ)dθ. Notice that the final expression is a mixture of pm(θ|y), m = 1, . . . , k which is
of the same form as the prior (since each pm(θ|y) is of the same form as pm(θ)).
(b) From the last expression it is clear that the mixture proportion for component m is λmpm(y)/(
P
k λkpk(y)).
(c) i. This prior distribution reflects the facts provided in the introductory paragraph. Specifically, normal
coins (approximately 80% of the total) land heads more often than tails (75/25) which is conveyed in the
Beta(6,2) mixture component. The other 20% are counterfeit and land tails more than heads (conveyed
in the Beta(2,6) mixture component). The prior distribution is displayed in the accompanying R output.
(c) ii. The sampling distribution is binomial ... p(y|θ) ∝ θy
(1 − θ)n−y
. If pm(θ) = Beta(a, b), then pm(θ|y) =
Beta(a + 4, b + 6) and pm(y) = 10
4
 Γ(a+b)
Γ(a)Γ(b)
Γ(a+4)Γ(b+6)
Γ(a+b+10) . From parts (a) and (b) the posterior is a mixture
of the Beta posteriors that correspond to these data with mixing proportions propotional to λmpm(y).
Let c1 = 10
4
 Γ(8)
Γ(6)Γ(2)
Γ(10)Γ(8)
Γ(18) = 0.04535171 and c2 = 10
4
 Γ(8)
Γ(2)Γ(6)
Γ(6)Γ(12)
Γ(18) = 0.1187783. Then
p(θ|y) = (0.8c1Beta(10, 8) + 0.2c2Beta(6, 12)) /(0.8c1 + 0.2c2) = .604 Beta(10, 8) + .396 Beta(6, 12)
The posterior distribution is now peaked around 0.5 representing the compromise between our prior opinion
(θ ≈ 0.75) and the data (which suggests θ ≈ 0.4).
(c) iii. Let ỹ = 1 if the next toss is a head and zero otherwise. We want Pr(ỹ = 1|y) =
R
p(ỹ =
1|θ, y)p(θ|y)dθ =
R
θp(θ|y)dθ where the last equality indicates that given θ the probability of heads
on the next trial is θ regardless of what data y are observed. The last calculation is Pr(ỹ = 1|y) =
.604 ∗ (10/18) + .396 ∗ (6/18) = 0.47.

Mais conteúdo relacionado

Semelhante a STATA Homework Help

Complex analysis notes
Complex analysis notesComplex analysis notes
Complex analysis notesPrakash Dabhi
 
Number Theory for Security
Number Theory for SecurityNumber Theory for Security
Number Theory for SecurityAbhijit Mondal
 
Convergence of ABC methods
Convergence of ABC methodsConvergence of ABC methods
Convergence of ABC methodsChristian Robert
 
Last+minute+revision(+Final)+(1) (1).pptx
Last+minute+revision(+Final)+(1) (1).pptxLast+minute+revision(+Final)+(1) (1).pptx
Last+minute+revision(+Final)+(1) (1).pptxAryanMishra860130
 
Cheatsheet supervised-learning
Cheatsheet supervised-learningCheatsheet supervised-learning
Cheatsheet supervised-learningSteve Nouri
 
NCE, GANs & VAEs (and maybe BAC)
NCE, GANs & VAEs (and maybe BAC)NCE, GANs & VAEs (and maybe BAC)
NCE, GANs & VAEs (and maybe BAC)Christian Robert
 
Proof of Fermat's Last Theorem (Using 6 Methods)
Proof of Fermat's Last Theorem (Using 6 Methods)Proof of Fermat's Last Theorem (Using 6 Methods)
Proof of Fermat's Last Theorem (Using 6 Methods)nikos mantzakouras
 
Introduction to modern Variational Inference.
Introduction to modern Variational Inference.Introduction to modern Variational Inference.
Introduction to modern Variational Inference.Tomasz Kusmierczyk
 
Probability and Stochastic Processes A Friendly Introduction for Electrical a...
Probability and Stochastic Processes A Friendly Introduction for Electrical a...Probability and Stochastic Processes A Friendly Introduction for Electrical a...
Probability and Stochastic Processes A Friendly Introduction for Electrical a...KionaHood
 
Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programmingDamian T. Gordon
 
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoidFourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoidXavier Davias
 

Semelhante a STATA Homework Help (20)

Complex analysis notes
Complex analysis notesComplex analysis notes
Complex analysis notes
 
stochastic processes assignment help
stochastic processes assignment helpstochastic processes assignment help
stochastic processes assignment help
 
Number Theory for Security
Number Theory for SecurityNumber Theory for Security
Number Theory for Security
 
Convergence of ABC methods
Convergence of ABC methodsConvergence of ABC methods
Convergence of ABC methods
 
Last+minute+revision(+Final)+(1) (1).pptx
Last+minute+revision(+Final)+(1) (1).pptxLast+minute+revision(+Final)+(1) (1).pptx
Last+minute+revision(+Final)+(1) (1).pptx
 
Cheatsheet supervised-learning
Cheatsheet supervised-learningCheatsheet supervised-learning
Cheatsheet supervised-learning
 
CDT 22 slides.pdf
CDT 22 slides.pdfCDT 22 slides.pdf
CDT 22 slides.pdf
 
Chris Sherlock's slides
Chris Sherlock's slidesChris Sherlock's slides
Chris Sherlock's slides
 
MUMS: Bayesian, Fiducial, and Frequentist Conference - Objective Bayesian Ana...
MUMS: Bayesian, Fiducial, and Frequentist Conference - Objective Bayesian Ana...MUMS: Bayesian, Fiducial, and Frequentist Conference - Objective Bayesian Ana...
MUMS: Bayesian, Fiducial, and Frequentist Conference - Objective Bayesian Ana...
 
Stochastic Processes Homework Help
Stochastic Processes Homework Help Stochastic Processes Homework Help
Stochastic Processes Homework Help
 
Equivariance
EquivarianceEquivariance
Equivariance
 
CLIM Fall 2017 Course: Statistics for Climate Research, Nonstationary Covaria...
CLIM Fall 2017 Course: Statistics for Climate Research, Nonstationary Covaria...CLIM Fall 2017 Course: Statistics for Climate Research, Nonstationary Covaria...
CLIM Fall 2017 Course: Statistics for Climate Research, Nonstationary Covaria...
 
NCE, GANs & VAEs (and maybe BAC)
NCE, GANs & VAEs (and maybe BAC)NCE, GANs & VAEs (and maybe BAC)
NCE, GANs & VAEs (and maybe BAC)
 
Math
MathMath
Math
 
Proof of Fermat's Last Theorem (Using 6 Methods)
Proof of Fermat's Last Theorem (Using 6 Methods)Proof of Fermat's Last Theorem (Using 6 Methods)
Proof of Fermat's Last Theorem (Using 6 Methods)
 
Introduction to modern Variational Inference.
Introduction to modern Variational Inference.Introduction to modern Variational Inference.
Introduction to modern Variational Inference.
 
Probability and Stochastic Processes A Friendly Introduction for Electrical a...
Probability and Stochastic Processes A Friendly Introduction for Electrical a...Probability and Stochastic Processes A Friendly Introduction for Electrical a...
Probability and Stochastic Processes A Friendly Introduction for Electrical a...
 
Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programming
 
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoidFourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid
 
kactl.pdf
kactl.pdfkactl.pdf
kactl.pdf
 

Mais de Statistics Homework Helper

📊 Conquer Your Stats Homework with These Top 10 Tips! 🚀
📊 Conquer Your Stats Homework with These Top 10 Tips! 🚀📊 Conquer Your Stats Homework with These Top 10 Tips! 🚀
📊 Conquer Your Stats Homework with These Top 10 Tips! 🚀Statistics Homework Helper
 
Your Statistics Homework Solver is Here! 📊📚
Your Statistics Homework Solver is Here! 📊📚Your Statistics Homework Solver is Here! 📊📚
Your Statistics Homework Solver is Here! 📊📚Statistics Homework Helper
 
Top Rated Service Provided By Statistics Homework Help
Top Rated Service Provided By Statistics Homework HelpTop Rated Service Provided By Statistics Homework Help
Top Rated Service Provided By Statistics Homework HelpStatistics Homework Helper
 
Statistics Multiple Choice Questions and Answers
Statistics Multiple Choice Questions and AnswersStatistics Multiple Choice Questions and Answers
Statistics Multiple Choice Questions and AnswersStatistics Homework Helper
 

Mais de Statistics Homework Helper (20)

📊 Conquer Your Stats Homework with These Top 10 Tips! 🚀
📊 Conquer Your Stats Homework with These Top 10 Tips! 🚀📊 Conquer Your Stats Homework with These Top 10 Tips! 🚀
📊 Conquer Your Stats Homework with These Top 10 Tips! 🚀
 
Your Statistics Homework Solver is Here! 📊📚
Your Statistics Homework Solver is Here! 📊📚Your Statistics Homework Solver is Here! 📊📚
Your Statistics Homework Solver is Here! 📊📚
 
Probability Homework Help
Probability Homework HelpProbability Homework Help
Probability Homework Help
 
Multiple Linear Regression Homework Help
Multiple Linear Regression Homework HelpMultiple Linear Regression Homework Help
Multiple Linear Regression Homework Help
 
Statistics Homework Help
Statistics Homework HelpStatistics Homework Help
Statistics Homework Help
 
SAS Homework Help
SAS Homework HelpSAS Homework Help
SAS Homework Help
 
R Programming Homework Help
R Programming Homework HelpR Programming Homework Help
R Programming Homework Help
 
Statistics Homework Helper
Statistics Homework HelperStatistics Homework Helper
Statistics Homework Helper
 
Statistics Homework Help
Statistics Homework HelpStatistics Homework Help
Statistics Homework Help
 
Do My Statistics Homework
Do My Statistics HomeworkDo My Statistics Homework
Do My Statistics Homework
 
Write My Statistics Homework
Write My Statistics HomeworkWrite My Statistics Homework
Write My Statistics Homework
 
Quantitative Research Homework Help
Quantitative Research Homework HelpQuantitative Research Homework Help
Quantitative Research Homework Help
 
Probability Homework Help
Probability Homework HelpProbability Homework Help
Probability Homework Help
 
Top Rated Service Provided By Statistics Homework Help
Top Rated Service Provided By Statistics Homework HelpTop Rated Service Provided By Statistics Homework Help
Top Rated Service Provided By Statistics Homework Help
 
Introduction to Statistics
Introduction to StatisticsIntroduction to Statistics
Introduction to Statistics
 
Statistics Homework Help
Statistics Homework HelpStatistics Homework Help
Statistics Homework Help
 
Multivariate and Monova Assignment Help
Multivariate and Monova Assignment HelpMultivariate and Monova Assignment Help
Multivariate and Monova Assignment Help
 
Statistics Multiple Choice Questions and Answers
Statistics Multiple Choice Questions and AnswersStatistics Multiple Choice Questions and Answers
Statistics Multiple Choice Questions and Answers
 
Statistics Homework Help
Statistics Homework HelpStatistics Homework Help
Statistics Homework Help
 
Advanced Statistics Homework Help
Advanced Statistics Homework HelpAdvanced Statistics Homework Help
Advanced Statistics Homework Help
 

Último

Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 

Último (20)

Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 

STATA Homework Help

  • 1. STATISTICS 225 – Fall 2018 Homework 1 - solutions HW is graded at 5 points per problem. I will try to provide detailed solutions. I will provide my R code for solving the computational problems – you should not assume that my code is the most efficient way to get the answer. 1. Loss functions – This was reasonably straightforward. One minor point is that you should check that your solution does, in fact, minimize the expected loss. (a) L(θ, a) = (θ − a)2 : E(L|y) = Z (θ − a)2 p(θ|y)dθ dE(L|y) da = −2 Z (θ − a)p(θ|y)dθ = 2a − 2E(θ|y) Setting the first derivative to zero yields a = E(θ|y). Note that the 2nd derivative is positive so this is a minimizer. (b) L(θ, a) = |θ − a| = (θ − a)I(θ ≥ a) + (a − θ)I(θ < a): E(L|y) = Z a −∞ (a − θ)p(θ|y)dθ + Z ∞ a (θ − a)p(θ|y)dθ dE(L|y) da = Z a −∞ p(θ|y)dθ − Z ∞ a p(θ|y)dθ = 2 Z a −∞ p(θ|y)dθ − 1 ( add and subtract Z a −∞ p(θ|y)dθ) Note that the derivatives here are complicated because a appears in the limits of integration and in the integrand. Fortunately all the messy stuff drops out. Setting the derivative to zero indicates that we should find a such that posterior cdf is 1/2, i.e., a posterior median. The second derivative is not informative here but we can see that the first derivative is negative for smaller values of a and positive for bigger values of a which makes this a minimum. 2. Prior distributions for the Poisson (a) The calculations below demonstrate that the kernel of the posterior distribution is that of a Gamma( P i yi + α, n + β) distribution so the gamma is a conjugate prior distribution. p(λ|y) ∝ p(y|λ)p(λ) ∝ λ P i yi e−nλ λα−1 e−βλ = λ P i yi+α−1 e−(n+β)λ (b) There is not a unique right answer. In the conjugate (Gamma) family, the mean of the distribution is α/β. The expert tells us that they would guess the rate is around 1 which suggests choosing α = β. The expert also believes that it would not be surprising to find the rate is between (.1 and 10). Thus we want most of our prior probability in this range (how much? Perhaps .80 or .90 or .95.). You can play around with the gamma distribution in R. pgamma is the cdf function. It takes a shape parameter and a scale or rate parameter. The form of the density that I’ve given above has β as a rate parameter (and thus 1/β as a scale parameter). The Gamma(1,1) distribution has probability .9 between .1 and 10 so may be appropriate. Many of you noticed though that just about all of the probability here is well less than 10 so this prior essentially rules out values bigger than 10. Choosing a smaller shape parameter (say .1) provides for a longer tail. Unfortunately it also puts a lot of probability near zero. I played around a bit (more than I would expect you to) and discovered that α = β may not be ideal after all. A gamma distribution with shape α = .7 and inverse scale (rate) β = .3 has .025 percentile equal to .014, median equal to 1.27 and .975 percentile equal to 8.92. That comes somewhat close to the expert’s views. (c) Noninformative prior distributions i. The flat prior distribution is not a proper distribution since it does not have a finite integral over the positive half of the real line. If p(λ) ∝ 1, then p(λ|y) ∝ λ P i yi e−nλ which is the kernel of a Gamma( P i yi + 1, n) distribution. Thus the flat prior leads to a proper posterior distribution.
  • 2. ii. To find Jeffrey’s prior we need the Fisher information. We need to compute E(−d2 logp(y|λ) dλ2 |λ). The log of the Poisson distribution is P i yi log λ−nλ. The negative 2nd derivative is P i yi/λ2 . Finally J(λ) = E( P i yi/λ2 |λ) = n/λ. Jeffrey’s prior is proportional to the square root of the Fisher information which is λ−1/2 . iii. If φ = √ λ, then the inverse transformation is λ = φ2 . The density of φ is derived as pφ(φ) = pλ(φ2 )|dλ/dφ| ∝ (φ2 )−1/2 2φ ∝ constant iv. The Jeffreys’ prior, p(λ) ∝ 1/ √ λ, is not a proper prior distribution. Once again it does not integrate to a finite number on the positive half of the real line. v. If we use p(λ) ∝ 1/ √ λ, then the posterior distribution is Gamma( P i yi + 1/2, n) which is a proper distribution. (My hint was incorrect. Sorry about that.) 3. Weibull (conjugate case): (a) The calculations below demonstrate that the kernel of the posterior distribution is that of a Gamma(n + α, P i y2 i + β) distribution so the gamma is a conjugate prior distribution. p(θ|y) ∝ p(y|θ)p(θ) ∝ θn e− P i y2 i θ θα−1 e−βθ = θn+α−1 e−( P i y2 i +β)θ (b) The problem statement tells you that the yi’s are conditionally independent given θ. Now consider the marginal distribution (where I’m no longer ignoring constants!): p(y) = Z p(y|θ)p(θ)dθ = Z 2n θn ( Y i yi)e− P i y2 i θ βα Γ(α) θα−1 e−βθ dθ = 2n Y i yi βα Γ(α) Z θα+n−1 e−θ(β+ P i y2 i ) dθ = 2n ( Q i yi)βα Γ(α + n) (β + P i y2 i )n+αΓ(α) where the final equality comes from completing the gamma density. The marginal can not be factored as a product of the marginal distribution of each yi hence the yi’s are not independent in the marginal distribution. (c) R commands/programs and output are provided on a separate sheet. A key point is that the Gamma(1.4,2) prior distribution appears to concentrate on θ from 0 to 3 (95% central prior interval runs from .04 to 2.24; 99% central prior interval runs from .01 to 3.10). Note that θ = 3 corresponds to a Weibull distribution for which the mean of y is equal to 0.5 (the lower limit suggested by our prior information) and that θ = .03 corresponds to a Weibull distribution with mean of y equal to 5 (the upper limit suggested by our prior information). Thus the chosen prior makes sense. (d) Here we can use theory rather than simulation. The posterior distribution of θ is Gamma(11.4, 11.377) which has mean 1.002 and variance 0.088. The 95% posterior interval for θ (see output) is (.507, 1.662). (e) The best prediction of the lifetime of a new part depends on the loss function (as we showed in the first problem). I didn’t specify a loss function here. Most people usually think of the posterior mean as the natural estimate. Here we actually want the posterior mean of the expected lifetime E(Y ) which is a function of θ (recall that E(Y ) = .886θ−0.5 ). This is easiest to obtain by simulation. I simulated 1000 draws from the posterior distribution of θ, computed .886θ−0.5 for each one, and then took the mean of these values to come up with an estimate of .9155. To get a predictive interval, simulate 1000 draws from the posterior distribution of θ and then for each draw simulate a random variable y from the Weibull distribution with that θ (see code). The predictive interval from my simultations is (.139, 2.086). 4. Mixtures of conjugate priors (a) From the definition: p(θ|y) = p(y|θ)p(θ) R p(y|θ)p(θ) = Pk m=1 λmp(y|θ)pm(θ) Pk m=1 R λmp(y|θ)pm(θ)dθ = Pk m=1 λmpm(y)pm(θ|y) Pk m=1 λmpm(y) where the last equality comes from recognizing that p(y|θ)pm(θ) = pm(θ|y)pm(y) and that pm(y) = R p(y|θ)pm(θ)dθ. Notice that the final expression is a mixture of pm(θ|y), m = 1, . . . , k which is of the same form as the prior (since each pm(θ|y) is of the same form as pm(θ)). (b) From the last expression it is clear that the mixture proportion for component m is λmpm(y)/( P k λkpk(y)).
  • 3. (c) i. This prior distribution reflects the facts provided in the introductory paragraph. Specifically, normal coins (approximately 80% of the total) land heads more often than tails (75/25) which is conveyed in the Beta(6,2) mixture component. The other 20% are counterfeit and land tails more than heads (conveyed in the Beta(2,6) mixture component). The prior distribution is displayed in the accompanying R output. (c) ii. The sampling distribution is binomial ... p(y|θ) ∝ θy (1 − θ)n−y . If pm(θ) = Beta(a, b), then pm(θ|y) = Beta(a + 4, b + 6) and pm(y) = 10 4 Γ(a+b) Γ(a)Γ(b) Γ(a+4)Γ(b+6) Γ(a+b+10) . From parts (a) and (b) the posterior is a mixture of the Beta posteriors that correspond to these data with mixing proportions propotional to λmpm(y). Let c1 = 10 4 Γ(8) Γ(6)Γ(2) Γ(10)Γ(8) Γ(18) = 0.04535171 and c2 = 10 4 Γ(8) Γ(2)Γ(6) Γ(6)Γ(12) Γ(18) = 0.1187783. Then p(θ|y) = (0.8c1Beta(10, 8) + 0.2c2Beta(6, 12)) /(0.8c1 + 0.2c2) = .604 Beta(10, 8) + .396 Beta(6, 12) The posterior distribution is now peaked around 0.5 representing the compromise between our prior opinion (θ ≈ 0.75) and the data (which suggests θ ≈ 0.4). (c) iii. Let ỹ = 1 if the next toss is a head and zero otherwise. We want Pr(ỹ = 1|y) = R p(ỹ = 1|θ, y)p(θ|y)dθ = R θp(θ|y)dθ where the last equality indicates that given θ the probability of heads on the next trial is θ regardless of what data y are observed. The last calculation is Pr(ỹ = 1|y) = .604 ∗ (10/18) + .396 ∗ (6/18) = 0.47.