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?
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
Get Answers For Free
Most questions answered within 1 hours.