Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This problem is for you to see what two-dimensional plots of data will look like

ID: 3171453 • Letter: T

Question

This problem is for you to see what two-dimensional plots of data will look like when the data are sampled from a variety of distributions. For this problem you will need a computer program that allows you to generate random numbers from given distributions. In each of the cases below, set the number of observations n = 300, and draw the indicated graphs. Few programs have easy-to-use functions to generate bivariate random numbers, so in this problem you will generate first the predictor X. then the response Y given X. Generate X and e to be independent standard normal random vectors of length n. Compute Y = 2 + 3X + sigma e, where in this problem we take sigma = 1. Draw the scatterplot of Y versus X, add the true regression line Y = 2 + 3X, and the OLS regression line. Verify that the scatter of points is approximately elliptical, and the regression line is similar to, but not exactly the same as, the major axis of the ellipse. Repeat Problem 4.12.1 twice, first set sigma = 3 and then repeat again with sigma = 6. How does the scatter of points change as sigma changes? Repeat Problem 4.12.1. but this time set X to have a standard normal distribution and e to have a Cauchy distribution (set sigma = 1). They easy way to generate a Cauchy is to generate two vectors V_1 and V_2 of standard normal random numbers, and then set e = V_1/V_2. With this setup, the values you generate are not bivariate normal because the Cauchy does not have a population mean or variance.

Explanation / Answer

The following R code is given below:

f=function(s)

{
x=rnorm(300)
e=rnorm(300)
y=2+3*x+s*e
y1=2+3*x

plot(x,y)

t=predict(lm(y~x))
lines(x,t,col=2)
lines(x,y1,col=3)
abline(h=0)
abline(v=0)

#col=2 :ols regression and col=3: true regression
}
f(1)
f(3)
f(6)
#thus as sigma increases scaterness of the points increases and is in getting centered around(x,y)=(0,0)

x=rnorm(300)
x1=rnorm(300)
x2=rnorm(300)
e=rnorm(300)
s=x1[x2!=0]/x2[x2!=0]
y=2+3*x+s*e
y1=2+3*x

plot(x,y)

t=predict(lm(y~x))
lines(x,t,col=2)
lines(x,y1,col=3)
abline(h=0)
abline(v=0)

shapiro.test(y)


#Thus p value is very low leading to the acceptance of null that y is not a normal distribution hence (x,y) is not from a bivariate normal distribution

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote