Question 3 Programming exercise for R Studio This question requires the use of the software R Studio. Specifically, you need to create a short R script. Please attach your R script and outputs to your Assignment. Please perform 2 Monte Carlo Experiments and investigate the behaviour of the sum of all the sample data. Consider the example of rolling a dice four times in a row. A sample now consists of four independent random draws from the set {1,2,3,4,5,6). For instance, your sample set may be {2,5,1,1). It is apparent that the sum of these four random variables (2+5+1+1=9) is also a random variable. We can use R's random number generation to learn more about the distribution of the sample sum. The basic idea is to simulate outcomes of the true distribution repeatedly drawing random samples of 4 observation (rolling the dice four times). To perform these simulations in R, please proceed as follows: 2 1. Set the sample size equal 4 and the number of samples (repetitions) to be drawn accord- ing to your own preference. You could use for instance 50, 200; 10,000 or 500,000 etc. Make sure to choose a smaller number of repetitions (< 500) for the first experiment and a larger number of repetitions (>5,000) for the second experiment. 2. Set a random seed equal to your student number. For instance, if your student number is: 1,2,3,4,5,6 then set.seed(123456). Also make sure that your student number appears in the title of the histogram. You can do so by adding the command line main="Student Number 123456", after hist(sample.sums,...) = 3. Use the function replicate() in conjunction with sample() to draw random observations. Note: the outcome of replicate() is a matrix. It contains the drawn samples as columns. 4. Compute sample sums using the command colSums (). This function computes the sum of each column, i.e., of each sample and returns a vector. 5. Plot the computed vector of sums in a histogram. Keep the number of bins of the histogram equal to 25 for the two experiments. Carefully describe what you see in the first experiment (smaller number of repetitions) and in the second experiment (larger number of repetitions). Carefully compare the two histograms and explain what you see!

ENGR.ECONOMIC ANALYSIS
14th Edition
ISBN:9780190931919
Author:NEWNAN
Publisher:NEWNAN
Chapter1: Making Economics Decisions
Section: Chapter Questions
Problem 1QTC
icon
Related questions
Question
Question 3 Programming exercise for R Studio
This question requires the use of the software R Studio. Specifically, you need to create a
short R script. Please attach your R script and outputs to your Assignment.
Please perform 2 Monte Carlo Experiments and investigate the behaviour of the sum of all
the sample data. Consider the example of rolling a dice four times in a row. A sample now
consists of four independent random draws from the set {1,2,3,4,5,6). For instance, your
sample set may be {2,5,1,1). It is apparent that the sum of these four random variables
(2+5+1+1=9) is also a random variable.
We can use R's random number generation to learn more about the distribution of the
sample sum. The basic idea is to simulate outcomes of the true distribution repeatedly
drawing random samples of 4 observation (rolling the dice four times).
To perform these simulations in R, please proceed as follows:
2
1. Set the sample size equal 4 and the number of samples (repetitions) to be drawn accord-
ing to your own preference. You could use for instance 50, 200; 10,000 or 500,000 etc.
Make sure to choose a smaller number of repetitions (< 500) for the first experiment
and a larger number of repetitions (>5,000) for the second experiment.
2. Set a random seed equal to your student number. For instance, if your student number
is: 1,2,3,4,5,6 then set.seed(123456). Also make sure that your student number appears
in the title of the histogram. You can do so by adding the command line main="Student
Number 123456", after hist(sample.sums,...)
=
3. Use the function replicate() in conjunction with sample() to draw random observations.
Note: the outcome of replicate() is a matrix. It contains the drawn samples as columns.
4. Compute sample sums using the command colSums (). This function computes the
sum of each column, i.e., of each sample and returns a vector.
5. Plot the computed vector of sums in a histogram. Keep the number of bins of the
histogram equal to 25 for the two experiments.
Carefully describe what you see in the first experiment (smaller number of repetitions) and in
the second experiment (larger number of repetitions). Carefully compare the two histograms
and explain what you see!
Transcribed Image Text:Question 3 Programming exercise for R Studio This question requires the use of the software R Studio. Specifically, you need to create a short R script. Please attach your R script and outputs to your Assignment. Please perform 2 Monte Carlo Experiments and investigate the behaviour of the sum of all the sample data. Consider the example of rolling a dice four times in a row. A sample now consists of four independent random draws from the set {1,2,3,4,5,6). For instance, your sample set may be {2,5,1,1). It is apparent that the sum of these four random variables (2+5+1+1=9) is also a random variable. We can use R's random number generation to learn more about the distribution of the sample sum. The basic idea is to simulate outcomes of the true distribution repeatedly drawing random samples of 4 observation (rolling the dice four times). To perform these simulations in R, please proceed as follows: 2 1. Set the sample size equal 4 and the number of samples (repetitions) to be drawn accord- ing to your own preference. You could use for instance 50, 200; 10,000 or 500,000 etc. Make sure to choose a smaller number of repetitions (< 500) for the first experiment and a larger number of repetitions (>5,000) for the second experiment. 2. Set a random seed equal to your student number. For instance, if your student number is: 1,2,3,4,5,6 then set.seed(123456). Also make sure that your student number appears in the title of the histogram. You can do so by adding the command line main="Student Number 123456", after hist(sample.sums,...) = 3. Use the function replicate() in conjunction with sample() to draw random observations. Note: the outcome of replicate() is a matrix. It contains the drawn samples as columns. 4. Compute sample sums using the command colSums (). This function computes the sum of each column, i.e., of each sample and returns a vector. 5. Plot the computed vector of sums in a histogram. Keep the number of bins of the histogram equal to 25 for the two experiments. Carefully describe what you see in the first experiment (smaller number of repetitions) and in the second experiment (larger number of repetitions). Carefully compare the two histograms and explain what you see!
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Similar questions
Recommended textbooks for you
ENGR.ECONOMIC ANALYSIS
ENGR.ECONOMIC ANALYSIS
Economics
ISBN:
9780190931919
Author:
NEWNAN
Publisher:
Oxford University Press
Principles of Economics (12th Edition)
Principles of Economics (12th Edition)
Economics
ISBN:
9780134078779
Author:
Karl E. Case, Ray C. Fair, Sharon E. Oster
Publisher:
PEARSON
Engineering Economy (17th Edition)
Engineering Economy (17th Edition)
Economics
ISBN:
9780134870069
Author:
William G. Sullivan, Elin M. Wicks, C. Patrick Koelling
Publisher:
PEARSON
Principles of Economics (MindTap Course List)
Principles of Economics (MindTap Course List)
Economics
ISBN:
9781305585126
Author:
N. Gregory Mankiw
Publisher:
Cengage Learning
Managerial Economics: A Problem Solving Approach
Managerial Economics: A Problem Solving Approach
Economics
ISBN:
9781337106665
Author:
Luke M. Froeb, Brian T. McCann, Michael R. Ward, Mike Shor
Publisher:
Cengage Learning
Managerial Economics & Business Strategy (Mcgraw-…
Managerial Economics & Business Strategy (Mcgraw-…
Economics
ISBN:
9781259290619
Author:
Michael Baye, Jeff Prince
Publisher:
McGraw-Hill Education