Question

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. Produce scatter plot.


3. Create histogram of a marginal distribution of X. You can use the function hist()


4. Create qq plot (probability plot) of a marginal distribution of X vs normal and comment on it. You can use the function qqnorm().


5. Compute sample means and sample variances of X and Y marginal distributions, and sample correlation between X and Y. You can use the functions mean(), var(), cor().

Homework Answers

Answer #1

3.

4.

As from QQ plot we can see that the points follow linear line so we can say that X and Y come from normal distribution.

(5)
[1] 1.245655
[1] 2.053158
> var(X);var(Y)
[1] 3.048119
[1] 3.305575
> cor(X,Y)
[1] -0.09814289

The code that we used are below.

library(MASS)
mu=c(1,2)
Sigma=matrix(c(3,-.5,-.5,4),2,2)
xx=mvrnorm(n = 100, mu, Sigma, tol = 1e-6, empirical = FALSE, EISPACK = FALSE)
X=xx[,1];Y=xx[,2]
plot(x,xlab = "X",ylab = "Y")
hist(X)
hist(Y)

qqnorm(X,main = "Normal QQ Plot of X")
qqnorm(Y,main = "Normal QQ Plot of Y")

mean(X);mean(Y)
var(X);var(Y)
cor(X,Y)

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
Use the programming language R to code the following project.. * Make sure you turn in...
Use the programming language R to code the following project.. * Make sure you turn in your code and answers from each question. (not the raw data). 1. Generate 1000 random samples of size 40 from the normal distribution with mean µ = 3 and standard deviation σ = 2. Compute 95% the confidence interval of 1000 samples and find the rate of confidence interval contains the true mean. What did you learn from this simulation study? 2. For each...
USING MATLAB (A) Use the rand command to generate “X” of size [10000 1] and the...
USING MATLAB (A) Use the rand command to generate “X” of size [10000 1] and the command histogram to plot the probability distribution of “X” along with axis labels and a title that includes the mean and variance for “X”. (B) Use a while loop and the rand command to generate “X1”, also of size [10000 1] but with each element of “X1” being the mean of 2 “samples” generated using rand, i.e. a “sample size” of 2 separate numbers...
Using R and install.packages("MASS"), library(MASS) 1. Generate the following vector using at least two methods. 0,...
Using R and install.packages("MASS"), library(MASS) 1. Generate the following vector using at least two methods. 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4 2. Generate the following vector. Apple1, Banana2, Orange3, Cranberry4, Watermelon5 3. Generate the following vector using the “rep” function. a, a, b, b, c, c, a, a, b, b, c, c 4. In vector y = (8, 3, 5, 7, 6, 6, 8, 9, 2, 3, 9, 4, 10, 4, 11), which elements of y contains...
1. Consider the following data that represents a random sample out of a very large population:...
1. Consider the following data that represents a random sample out of a very large population: 0.43, 4.89, 5.29, 5.16, 0.59, 7.50, 4.48, 6.22 (a) Create a QQ plot of the data. Do you think it is reasonable to assume that the population distribution is normal? Explain your answer. (b) Denote µ to be the population mean. Regardless of your answer to (a), use R to perform the bootstrap with 2000 resamplings to create a 90% CI for µ. Since...
1. A pumpkin farmer weighed a simple random sample of size n = 20 pumpkins, with...
1. A pumpkin farmer weighed a simple random sample of size n = 20 pumpkins, with these results: 9.6, 8.8, 5.1, 9.7, 9.1, 8.9, 8, 9.2, 2.7, 9.1, 8.5, 7.3, 9.3, 9.6, 4.1, 9.9, 7.6, 9, 7.2, 8.5 (a) Create a QQ plot of the weights. Do you think it is reasonable to assume that the population distribution is normal? Explain your answer. (b) Regardless of your answer to (a), use R to perform the bootstrap with 2000 resamplings to...
i.Bias of Sample Mean Draw 20 samples from the normal distribution N(5, 4). Compute the mean...
i.Bias of Sample Mean Draw 20 samples from the normal distribution N(5, 4). Compute the mean of your 20 samples. Report the bias of the sample mean ii. Variance of Sample Mean (Continue of problem i) To estimate the variance of the sample mean, we need to draw many different samples of size 20. Now, we draw 1000 times a sample of size 20. Store all the 1000 sample means. Report the variance of the estimated sample mean. Hint: To...
A pumpkin farmer weighed a simple random sample of size n = 20 pumpkins, with these...
A pumpkin farmer weighed a simple random sample of size n = 20 pumpkins, with these results: 9.6, 8.8, 5.1, 9.7, 9.1, 8.9, 8, 9.2, 2.7, 9.1, 8.5, 7.3, 9.3, 9.6, 4.1, 9.9, 7.6, 9, 7.2, 8.5 (a) Create a QQ plot of the weights. Do you think it is reasonable to assume that the population distribution is normal? Explain your answer. (b) Regardless of your answer to (a), use R to perform the bootstrap with 2000 resamplings to create...
Could you please solve these using r code. 1. A pumpkin farmer weighed a simple random...
Could you please solve these using r code. 1. A pumpkin farmer weighed a simple random sample of size n = 20 pumpkins, with these results: 9.6, 8.8, 5.1, 9.7, 9.1, 8.9, 8, 9.2, 2.7, 9.1, 8.5, 7.3, 9.3, 9.6, 4.1, 9.9, 7.6, 9, 7.2, 8.5 (a) Create a QQ plot of the weights. Do you think it is reasonable to assume that the population distribution is normal? Explain your answer. (b) Regardless of your answer to (a), use R...
A sample from a Normal distribution with an unknown mean µ and known variance σ =...
A sample from a Normal distribution with an unknown mean µ and known variance σ = 45 was taken with n = 9 samples giving sample mean of ¯ y = 3.6. (a) Construct a Hypothesis test with significance level α = 0.05 to test whether the mean is equal to 0 or it is greater than 0. What can you conclude based on the outcome of the sample? (b) Calculate the power of this test if the true value...
Creating and interpreting a Normal Quantile-Quantile (Normal Q-Q) plot. The data you will be using is...
Creating and interpreting a Normal Quantile-Quantile (Normal Q-Q) plot. The data you will be using is the distance in miles from home to campus for statistics students. 150      30        105      88        94        15        55        122      45        67        18        126      30 143      98        15        30        62        111      87        38        20        34        39        46        14 144      23        94        44        97        65        120      123      99        45        57        209      20 133      72 Column 1: Sort the data values from least to greatest. Use the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT