Question
The next exercises will have to run simulations in RStudio. Conveniently, R can generate values from any common probability distribution. Exercise 6. What is the
The next exercises will have to run simulations in RStudio. Conveniently, R can generate values from any common probability distribution.
Exercise 6. What is the probability a random draw from the standard normal distribution is smaller than 1.96? What is the probability a random draw lies between1.96 and 1.96? Use R code to generate your answers. Hint: Use the pnorm() command.
Before the next exercises, run the command set.seed(123).
Exercise 7. Create the matrix, "mat", of all NA (missing values) with 100 rows and 100 columns.
Exercise 8. Replace each row in the matrix with a vector of 100 random draws from a Poisson distribution with mean= 2.5. Hint: Use the rpois() command, together with a for loop, so for(i in 1:100)... and each time the loop iterates, you want to replace the row mat[i,] with a vector of random values from rpois().
Exercise 9. Create the vector, "vec", that contains the mean of each row in "mat".
Exercise 10. Plot a histogram of "vec". Hint: Use the hist() function. Does the histogram look like a normal distribution? Repeat exercises 7-9 with a matrix of 1,000 rows and columns (and vectors of 1,000 random draws from the Poisson distribution). Does the new histogram look more like a normal distribution than the old one?
Note; I need the answers done using RStudio programing language. As is is the main tool used in the Econometrics course.
I have asked a similar question to this earlier however it was moves to "probability and statistical analysis" and have yet to receive an answer.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started