logo

Bayesian Approach Assignment

   

Added on  2023-05-29

11 Pages1406 Words202 Views
Surname 1
Bayesian Approach Assignment
Student Name
Course
Instructor
Date

Surname 2
1. (Using R) the following probability is calculated from the variable Z along the normal
distribution.
(a) Calculate the probability using the Monte Carlo method.
#inputting in variables
z<-4.5
#calculating probability when z=4.5
pnorm(z)
[1] 0.9999966
(b) Calculate the probability using the importance sampling method.
#assumption 1
Z1<-4.0
#assumption 2
Z2<-5.0
#calculating the probability for assumption 1
Prob1<-pnorm(Z1)
#calculating probability for assumption 2
Prob2<-pnorm(Z2)
#Averaging the p-values
Sum<-Prob1+Prob2
probability <-Sum/2
probability
[1] 0.999984

Surname 3
[2-3] Assume that μ=5 ,σ 2=2 , n=200, and extract the sample and compare it with the
result of R code.
R code
#assumptions
Pop.mean<-5
Pop.variance<-2
n<-200
Pop.SD<-sqrt(2)
#Generating normally distributed random numbers with mean=5 , n=200, and sd=1.414
Normaldist<-rnorm(200,5,1.414)
#returning 200 generated random values
Normaldist
#extracting 50 samples
set.seed(1)
Extract<-sample(normaldist,50,replace =TRUE)
#returning extracted 50 samples
Extract
#calculating descriptive statistics of population
mean(Extract, trim = 0, na.rm = FALSE)
variance<-var(Extract)
variance
Output

Surname 4
The population (n=200) mean and variance is 5 and 2 respectively while the mean and
variance of the extracted sample is 5.03 and 1.62 respectively. The Sample mean and variance
are unbiased estimators of population mean and population variance respectively.1 The values
are very close to the actual population suggesting that mean and variance are unbiased
estimators of population mean and variance.
2. (Using R) If the X1 , , Xn N (μ , σ 2), and then consider a non-informative prior
distribution as the prior distribution of μ and σ 2. Let the prior distribution of μ and σ 2as
π ( μ , σ2 ) 1/σ 2.
(a) Find the entire conditional posterior distribution of σ 2and β.
Assuming π ( μ , σ2 ) 1/σ 2
Then conditional posterior distribution is calculated as:
π(μ , σ2|X) 1
σn2 e
1
2 σ 2
i=1
n
(X iμ)2
1 Brani Vidakovic, Handout 5 (2018)

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Stock Price Simulation and Option Pricing
|7
|1286
|142

The Central Limit Theorem
|10
|1749
|257

Math 243 Group Project - Probability Distribution, Mean, Standard Deviation, Binomial Distribution, Sample Proportion
|6
|604
|89

Assignment on Business Statistics in Organization
|11
|1850
|39

Solutions to Assignment
|9
|1717
|78

Quantitative Methods for Accounting & Finance
|8
|1656
|306