当前位置:天才代写 > R语言代写 > R code代写 gamma distributed代写 numerical integration代写

R code代写 gamma distributed代写 numerical integration代写

2020-12-29 17:53 星期二 所属: R语言代写 浏览:80

R code代写

Obligatory assignment 2 MSA101/MVE187, autumn 2018

R code代写 In the answers to the questions below, you should include your R code so that I can check that you have done correctly.

Petter Mostad September 19, 2019

In the answers to the questions below, you should include your R code so that I can check that you have done correctly.R code代写

1.The amount of electrical power P (v) produced by a wind turbine for a given wind speed v is described by the power curve of the turbine.  R code代写

For  a  2MW turbine we approximate the power curve with

"<yoastmark

(b)Computeby simulation the expected value, together with an approx- imate 95% confidence interval for the simulation accuracy, for the amount of power generated by the wind turbine. Show how your results depend on the sample size you choose.

(c)Compute the result of (b),  now using numerical integration,  either   by using discretization or the R functionintegrate.R code代写

(d)Toimprove on the accuracy in (b) you would like to use importance sampling. Make a plot that is relevant for choosing a proposal density (instrumental density), and make such a choice.R code代写

(e)Nowrepeat (b) using importance sampling with your chosen proposal Compare the results with those of (b).R code代写

(f)Use importance sampling to estimate the variance of the power pro- duction,Var(P (v)): Start by writing down the integral you woud like to compute.

R code代写
R code代写

2.In a study of the number of death notices in the London Times on each dayin the interval 1910-1912 for women aged 80 and over, R code代写

it was noticed that the number of deaths did not follow a Poisson distribution as was expected. The counts Yi of days with i death notices is given in the table below:

Daily death notices (i) 0 1 2 3R code代写 4 5 6 7 8 9
Day count (Yi) 162 267 271 185 111 61 27 8 3 1

(a)Assuming that the deaths each day follow a Poisson distribution,R code代写

writedown the likelihood function for the Poisson density λ in terms of the observations Yi  Compute the maximum likelihood esti- mate for λ. Plot the predicted counts using this λ together with the actual counts.R code代写

(b)As a small extension of the model above, we instead assume that, each day, R code代写

there is a choice between two Poisson distributions, one withintensity λ1 and the other with intensity λ2. The probabilityfor choosing λ1 is p and the probability for choosing λ2 is 1 p. We now have a model with the three parameters, λ1, λ2, p. In order to work with this model, we add also variables Z0, Z1, . . . , Z9, where Zi is the (unobserved) count of days where λ1 is used and where i deaths are observed. Thus 0  Zi  Yi for i = 0, . . . , 9. Write down (a function proportional to) the likelihood for Y0, . . . , Y9, Z0, . . . , Z9 given the parameters λ1, λ2, p.R code代写

(c)We  now assume we  have  a prior for the parameters p, λ1, λ2that    is a product of a uniform distribution on [0, 1] for p, a prior λ1 Gamma(1, 1) for λ1, and a prior λ2   Gamma(1, 1) for λ2.  Write down the posterior1 for p given all the other observations and vari-ables.

(d)Find the posteriors for λ1given all the other variables and pararme- ters, and similar for λ2.R code代写

(e)Prove that the distribution of Zigiven all parameters, all Y0, . . . , Y9, and all other Zi variables, is Binomial. Find the parameters of this distribution.R code代写

(f)Implmement a Gibbs sampler for the extended model above.   Use   the implementation to produce an approximate sample for the poste- rior distribution of the parameters p, λ1, λ2given the data y0,. . . , y9.

1The expressions ”write down the posterior” or ”find the posterior” mean that you should write down the formula for a function that is proportional to the posterior density, and, in the cases where the posterior is a distribution in a known parametric family, identify this family    and the correponding values of the parameters.R code代写

Visualize your results. Estimate the expected values of each of the parameters in this posterior.R code代写

(g)(OPTIONAL) Use the expected values found above to simulatenew data, i.e., new deaths, for the same number of days as in the real data. Compare the predictions you get to the predictions obtained with the model in (a), and to the real data.

R code代写
R code代写

其他代写:考试助攻 计算机代写 java代写 algorithm代写 assembly代写 function代写paper代写 金融经济统计代写 web代写 编程代写 report代写 algorithm代写 数学代写 finance代写 [r代写

合作平台:天才代写 幽灵代写 写手招聘 Essay代写

 

天才代写-代写联系方式