Transcribed TextTranscribed Text

Q1 One way to generate a continuous random variable X with a given distribution function (edf) Fx(x) is to generate a uniform random variable U ~ U(0,1) and then define x = Fx(U). Consider In(x°+z+1) In3 < x < 1, Qli Fx (x; A) = 0, otherwise Here. 0 0 18 an unknown parameter. (a) There is no simple formuls for the inverse edl Fx in this case, as it is usually the case for many distributions We can use R to compute Fx'(x.0) numerically. For 0 < q < 1 and 0 0. write a function in R that returns I that gives the of the following objective function: 9(I.4.6) - ((xx(x)0)-4)2, You can use function optin or nlm in R. The minimum should be zero and the value x that minimites this functioni is x = Fx 1(g:8). Use this function to generale a sample of size n = 100 from the edf Fx(x;8) with 8 = 2. Include the histogram of the generated data in your report. (b) The maximum likelihood estimate cannot be obtained in a simple form for this distribution so we call use numerical methods Write a function in R that finds the maximium likelihood estimate for the generated data n. 2100- The function should return 0 <8<1 that maximizes the log likelihood 6(I, 7100 @) ==1 where (x(x:0) is the pdf of X. Again, you can use funition optim or aln to lind the Include the estimate in your report. Q2 Consider the linear regression model: Q2c when I- In are some constants and Em are independent random vari- ables and & ~ N(1,02). (a) Generate a sample of size 12 = 20 from this model, Y1, Y2, with or = 1, 8 = 3 and of = 0.5 and I, = i/10, i = 1. 20. Plot the values Y against Ii (b) Write a function in R that finds the maximum likelihood estimate of a.B and o' for the gemerated data 3/1- 1/20 The function should return n. B and of > 0 that maximise the log likelihood where is the density of Y, (c) What is the predicted value of response variable Y if x = 3?

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

# Q1
## (a)
Fx <- function(x, theta) {
log(x^theta+x+1) / log(3)

fx <- function(x, theta) {
(theta*x^(theta-1)+1) / (x^theta+x+1) / log(3)

g <- function(x, q, theta) {
Fx <- log(x^theta+x+1) / log(3)
(Fx - q)^2

invFx <- function(q, theta) {
output <- optim(par=0.5,
                fn=g, q=q, theta=theta, method="Brent",
                lower=0, upper=1000)

n <- 100
theta <- 2.0

# generate random outcomes
x <- vector(length=n)...
$23.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Statistics-R Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats