Econ 3818 Fall 2018
R exercise 2
Due September 18th 5pm via Desire to Learn Dropbox as a pdf file.
- Write up your answers and paste the R code used in a word document.
- Separate the R code above and below by three asterisk (***).
- Copy and paste all plots generated into the word document.
- Saved the document as a pdf and submit it via Desire to Learn.
You may work in groups of three (but no more than three!). Please put the name of all group members at the top of the text file.
R has several functions built-in that can be used to calculate probabilities associated with known probability distributions. When in doubt, don’t forget that you can always type help(“function”) into the console for documentation! For example, help(dbinom) might help for problem 1.
- You flip an unbalanced coin 100 times. The probability that the coin lands on heads is 0.3. Using the dbinom() function in R, calculate the probability that the coin lands on the heads side exactly 30 times out of the possible 100.
- You are teaching a class of eighty students. From experience, you know the probability that any one student passes the course is 0.95. Further, you assume that one student passing is independent from any other student passing. Using the pbinom() function in R, calculate the probability that the number of students (out of eighty) that fail the course is greater than or equal to five students.
- Use the rbinom() function to create a vector of 10 random observations from the binomial distribution with n=100 and probability of success is equal to 0.4.
a. Calculate the mean and standard deviation statistics for this vector of random draws using the mean() and sd() commands.
b. How does the sample mean and standard deviation found in 2a compare to the theoretical population mean and standard deviation of the binomial distribution when 𝑛 = 100 and 𝜋 = 0.4? If they are different, why?
c. Make a histogram of this vector using the hist() command.
- Repeat question 3 but with 1,000 random draws. Comment on how the new sample mean compares to the population mean and the old sample mean. How does the histogram differ?
1
- Use the pnorm() function in R to verify the empirical rule.
Note that pnorm(x) calculates left tail probability of the standard normal distribution for x- 68% of observations are within 1 standard deviation of the mean
- 95% of observations are within 2 standard deviations of the mean
- 99.7% of observations are within 3 standard deviations of the mean
- You and a friend take a statistics exam. The teacher tells you the exam grades were normally distributed with a mean of 72 and a standard deviation of 8. Your friend seems happy about their exam, but they won’t tell you their exact score. Instead they tell you that their grade is in the top 1% of all grades. Using the qnorm() function, calculate what their grade must be.
- In preparation for the R data project, write 1-2 sentences about a topic that interests you. Try to think of something that you will likely find data on. Each member of the group must do this separately, but you can list them all in the same document.
2