Question: 1 ) Compile your R script and save it as a docx / html / pdf file using compile function in RStudio. Upload the compiled

1) Compile your R script and save it as a docx/html/pdf file using compile function in RStudio. Upload the compiled file (2 points).
2) Grade:
Set directory: 1 point
Compiled file that includes all the steps implemented correct: 2 points
Task 1: 5 points
Task 2: 5 points
HINT: This Lab is to practice what you have learn in Chapter 9. The majority of the required materials to do this Lab is in Chapter 9 of your textbook as well as materials presented to cover Chapter 9.
=====================================
A key focus of our class this week has been distributions. A distribution is simply an arrangement of values of a variable such as the population size of a state. A probability distribution is an arrangement of all the values (potential outcomes) of a variable that reflect the frequency of those values in nature. A distribution can either be empirical, which means that it is an actual bunch of numbers, or it can be theoretical, in which case we are just imagining an ideal arrangement of numbers. The normal or bell curve is just such a theoretical distribution.
The R open source statistical system is great at creating empirical distributions that are made up of randomly generated numbers. In Chapter 9, the book includes several commands and explanations of randomly generated distributions. Chapter 9 decided that the distribution of the population sizes of states was geometric, and while this is one possibility, a better choice would be the so-called Pareto distribution. We can use R to generate a Pareto distribution of state populations that may be quite similar to the populations of the actual U.S. states. In other words, we can generate random numbers for the sizes of the Fictional States of America.
#####Set the directory (1 point)#########################################
Task 1: Write, test, and submit the necessary code in R to accomplish the following:
1. Generate a normal distribution, or 1,000 samples, with a mean of 80.
2. Write a function that takes three variables a vector, a min and a max and returns the number of elements in the vector that are between the min and max (including the min and max).
*** HINT: Plug in XXX below to create the function.
myFunction <-function(vector, min, max)
{b <- length(XXX[(XXX>= XXX) & (XXX <= XXX)])
return(b)
}
3. Use the function to see how many of your normal distribution samples are within the range of 79 to 81. Pass the "distribution" as the vector parameter, 79 as the minimum parameter, and 81 as the maximum parameter.
4. Repeat 3 times (creating a normal distribution and then calling your function) to see if the results vary.
Task 2: Write, test, and submit the necessary code in R to accomplish the following:
Install actuar OR VGAM package and load the actuar OR VGAM package. Either one of these packages will work. Just use whatever works for you.
1. Generate 51 random numbers in a Pareto distribution and assign them to a variable called FSApops.** shape and scale arguments will be explained in 2.
2. Specify a scale and a shape for your Pareto distribution that makes it as similar as possible to the actual distribution of state populations on page 90 of the textbook.
# rpareto(n, m, s): generating random numbers that fit a Pareto distribution
# n -- generate 51 values; m -- location parameter (set it to be about the population size of Wyoming);
# s -- vector of dispersion parameters.
3. Create a histogram that shows the distribution of values in FSApops.
4. Use a command to report the actual mean and standard deviation of the 51 values stored in FSApops.
5. Use a command to report the minimum and maximum value of FSApops.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!