Question

Write an R code that does the following: (a) Generate n samples x from a random...

Write an R code that does the following:

(a) Generate n samples x from a random variable X that has a uniform density on [0,3]. Now generate samples of Y using the equation: y = α/(x + β). For starters, set α = 1, β = 1

The R code:

x=runif(n=1000, min = 0, max = 3)
x

y=1/x+1
y

Please answer the following:

b) Use plot(x,y) to check if you got the right curve.

c) How does the correlation depend on α and how can you make the correlation close to 1?

d) How can you make the correlation close to 0?

e) Can you ever make the correlation positive?

Homework Answers

Answer #1

b) plots of the given R code is-

c) as we increase alpha

for alpha=5, beta=1

for alpha=20, beta=1

what we see, as we increase alpha the curved path increases.it is not possible to make correlation 1 since both x and y are inversely related.

d)correlation will be zero when we get a straight line parallel to x axis.

e) it is possible when alpha take negative value

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I have the following R code n <- 10 samples_0 <- 5 x <- 25 samples...
I have the following R code n <- 10 samples_0 <- 5 x <- 25 samples <- matrix(c(runif(n*samples_0, 0, x)), ncol=n) theta1 <- ((n + 1) / n) * samples theta2 <- (n + 1) * samples var(theta1) var(theta2) If the code above was run on an infinitely large samples_0, what would the values of the variance of theta1 (var(theta1) in code) and theta2 (var(theta2)) be to 11 decimal places?
Use R to code a function to generate a random sample of size n from the...
Use R to code a function to generate a random sample of size n from the Beta(a, b) distribution by the acceptance-rejection method. (1) Generate a random sample of size 3000 from the Beta(4,3) distribution. (2) Graph the histogram of the sample with the theoretical Beta(4,3) density superimposed. Answer the above questions by showing the R codes and results.
How to do the following in R: Write a function to generate a random sample of...
How to do the following in R: Write a function to generate a random sample of size n from the Gamma(α,1) distribution by the acceptance-rejection method. Generate a random sample of size 1000 from the Gamma(3,1) distribution. (Hint: you may use g(x) ∼ Exp(λ = 1/α) as your proposal distribution, where λ is the rate parameter. Figure out the appropriate constant c).
How to do the following in R: Write a function to generate a random sample of...
How to do the following in R: Write a function to generate a random sample of size n from the Gamma(α,1) distribution by the acceptance-rejection method. Generate a random sample of size 1000 from the Gamma(3,1) distribution. (Hint: you may use g(x) ∼ Exp(λ = 1/α) as your proposal distribution, where λ is the rate parameter. Figure out the appropriate constant c).
Use R statistical software to answer the following: Let X1, ..., X6 be a random sample...
Use R statistical software to answer the following: Let X1, ..., X6 be a random sample of size n = 6 from the distribution with pdf f(x) = x / 8 , 0 < x < 4 and 0 otherwise. (a) Use Monte Carlo to calculate Var(Xbar), and knowing that Var(Xbar) = sigma^2 / n, what is the true value of Var(Xbar)? ## use runif() to generate samples
PLEASE USE R CODE!! Continue to generate standard normal random variables until you have generated n...
PLEASE USE R CODE!! Continue to generate standard normal random variables until you have generated n of them, where n≥100 is such that S/sqrt(n) <0.1, where S is the sample standard deviation of the n data value. (a)How many normals do you think will be generated? (b)What is the sample mean of all the normals generated? (c)What is the sample variance?
R Code Directions: All work has to be your own, you may not work in groups....
R Code Directions: All work has to be your own, you may not work in groups. Show all work. Submit your solutions in a pdf document on Moodle. Include your R code (which must be commented and properly indented) in the pdf file. Name this pdf file ‘your last name’-HW5.pdf. Also submit one text file with your R code, which must be commented and properly indented. You may only use ‘runif’ to generate random numbers; other random number generating functions...
R Code Directions: All work has to be your own, you may not work in groups....
R Code Directions: All work has to be your own, you may not work in groups. Show all work. Submit your solutions in a pdf document on Moodle. Include your R code (which must be commented and properly indented) in the pdf file. Name this pdf file ‘your last name’-HW5.pdf. Also submit one text file with your R code, which must be commented and properly indented. You may only use ‘runif’ to generate random numbers; other random number generating functions...
Using R programming language, complete the following. 1. Generate the bivariate normal sample of size 100...
Using R programming language, complete the following. 1. Generate the bivariate normal sample of size 100 with parameters a. marginal mean of X equal to 1, b. marginal mean of Y equal to 2, c. marginal variance of X equal to 3, d. marginal variance of Y equal to 4, e. correlation between X and Y equal to -1/2. You can use the function mvrnorm(), first installing its package by the code if (! require ("MASS")) install.packages("MASS"); library ("MASS") 2....
Write a R script where you answer the following questions: 1. Consider Y ∼ Binom(n =...
Write a R script where you answer the following questions: 1. Consider Y ∼ Binom(n = 10, p = 0.05). Find the following probabilities: (a) P(2 < Y < 5) (b) P(2 ≤ Y ≤ 5) (c) P(Y < 9) 2. Consider Y ∼ P oisson(λ = 0.5). Find the following probabilities: (a) P(Y = 5) (b) P(2 ≤ Y ≤ 5) (c) P(Y < 9) 3. Consider Y ∼ N(µ = 3, σ2 = 1). Find the following probabilities:...