 Okay, so I started off by having OR opened. I've changed my working directory and I've run these two lines of code, which are loading up the both set package and then pulling up the health file for binomial data. So my likelihood is a binomial and beta prior BP. It brings up the health file as following the function name and the package just here and here. A brief description of the prior and its usage, which is the first thing you'll need to be familiar with. So your number of successes, as of n, your number of trials, a equals 1, b equals 1 are the default, which is a very actually going to be a beta 1, 1 prior, so the default will be contained. And these are the values of what it calls five, but what we've been calling how to avoid confusion with the number pipe and by default you see the process goes through. And if you scroll down, you will always get just some examples. So back in OR, the first part of question one would use the uniform 0, 1 prior for how, but beta AB prior will give this form and of course it's AB to 1, 1 prior is the exact same as the uniform 0, 1. We've shown this previously in class. So I have observed six successes in 15 trials and A is 1 and B is 1. So I've run this line of code and saved it in a variable called 2, 8, 6, 2, 1, 8, the tutorial 8, question 1, 8. And the resulting, this is the prior, the slot prior in the range and then a 0, this is so that's the 0, 1 uniform for a beta 1, 1 and my resulting posterior distribution. If I want to see what's stored in this variable, I can run a tribute and it tells me the names of everything that's stored in this variable. And then I can pull out, for example, the mean, which answers part of question one C and the standard deviation in the varying. Doing a little bit of math, you can figure out what the parameters of your resulting posterior will be. So you know that, so here I'm using A new and B new to represent the A, B of the posterior distribution. So you know that the sum of them is equal to this and that you can then use that to calculate what the, each of the A and B are of the posterior distribution. And I'm storing them, deliberately I'm storing them. If I want to pull them up, I would type it in to the console window and I see that my A and B of my posterior distribution are, it's the beta 7th and posterior. I would also now like to find my median because I have already found my mean, my standard deviation on my variance. So my median, I find the 50th quantile of the beta distribution with these parameters until my median value is just over 0.4. I'll find my 95% credible interval using a normal approximation. So that's the mean, plus or minus 1.96, that's the 97.6 percentile of a standard normal distribution times your standard deviation. And that gets you your lower band and your upper band. And you can find the exact, or exact within a how accurate or is using the Q beta function and the parameters of your distribution. And you can compare the two to see how accurate is your approximation using a normal approximation to the actual value coming out. Now that's question one part A through to D. Part E said to repeat question A to D using Jeffery's prior, the real difference here is that a Jeffery's prior is not a beta 11, it's a beta 0.5.5. So A is 0.5 and B is 0.5 are the real differences in this part of the code. In this part of the code. So I'm just going to run it again at the chunk of code. And you can see that's what my Jeffery's prior looks like here and what the resulting posterior looks like. Part F was to repeat part B for D using a beta 2.4 prior. So again, the real change is here. And then everything else is just being consistent with your naming scheme. I'm then asked to plot all three on the one plot. So as I've been going along, I've been monitoring which is the highest and I figured out actually that the last one was the highest value. So I would plot this one first and then overlay the others on. Otherwise, you just have to be careful about setting your limits here. You would have to explicitly set them as being y lim equals the 0 because that's the lowest possible value you can have and some value above the highest possible value. So I feed in my what or is calling pi values, what we've called how along the x axis and this is the value on the y axis. I tell it type equals L. Generally, the rule of thumb within OR is if it's in inverted commas, it's a letter, not a number. X label, I'm telling it that my label of my x axis, I want it to be tau. I put inside the expression to indicate it's going to be in mathematical fonts. My y label is going to be density and this LAS equals 1 will change the direction of the numbers on the y axis so that they'll also be horizontal. So if I run that line of code, this is across two lines here, you'll see that our density is my y label, tau is my x label and my numbers are horizontal. And then I add in the extra line. So the pi values, they just indicate the x values and the y values for each of my two other posterior distributions that I've calculated. So the red one here was the first one that was using the uniform prior. The blue one was using the Jeffreece prior. And then I put in a legend. In this picture, I've already looked at it before deciding where to put the legend. I'm putting it into my top right hand corner over here. And then I tell it that the legend is the beta 11 prior, the beta 0.5, 0.5 prior and beta 24 prior. And then I need to be careful that the beta 11 was the blue line. The beta 0.5, 0.5 was the red line and the beta 24 with the black line. And I also tell us that I do not want to bend inbox around this legend. So I select this and run and that adds my legend to it. Now question one part H was a trickier problem because this sets you the binodecp prior. So this is where you might want to pull up the help function on the binodecp either by question mark binodecp or that you've already have the help function for the binobp. You'll see the C also and you can click through. So by default, identity is uniform, but we're going to be changing that. And you see the density may be one of beta exponential normal students uniform or user. We're going to be using the user and this is where you really get to put in a numeric prior. So we to construct our prior. I'm avoiding the very end point. It just makes the plotting and slightly nicer. And it matches up with the default. So I use the default values for Tau that match up with what was in the option above. This is mainly to mean that the plus will think up nicely. And then I started off by setting that my prior is zero everywhere. And then for convenience, I'm working backwards. So I'm starting by saying everything less than point five is going to be point five minus Tau. However, I'm going to overwrite something of that and I'm going to say everything less than point three is going to be said equal to point two. And then I'll overwrite again, everything that's less than or equal to point two is going to be said as being the Tau. I know here I have to subset my Tau each time I bring it into play. So it's saying only use these values. You will get an error message if you don't use that. Now I've set up my prior. I can run my data. So that's the six successes out of 15 trials. I specify user prior, my prior, my P. So that represents my x-axis is stored in the variable called Tau. And my prior is stored in my powder prior. So you can see here that this is what the prior looks like. And this is what my posterior looks like. So it's quite a piece per posterior. It goes up to five. So I'm going to plot them all on the one graph. I'm going to again plot the one with the highest value first. So that in this case is going to be this last one. So I've plotted essentially the same. I just have to add in an extra line of code and also add in an extra piece here. And so I'm plotting four graphs. First one, this is my based on my numeric prior that I've constructed. Then overlayed on top of that in red was the part B or the second option, which is a Jeffreeze prior. Part A, which is in blue, was the uniform prior. And part C was the fetus 24. And I put in my legend into that top corner again. And you can compare of four posterior. And then you can save it as using file, save up once this is active. And as a JPEG, you can specify the quality. You can also specify a number of different other files. And that is how I would have tackled question one.