Not logged in
Talk
Contributions
Create account
Log in
Navigation
Main page
About
People
Publications
Teaching
Resources
Research Blog
Wiki Functions
Recent changes
Help
Licensing
Page
Discussion
Edit
View history
Editing
Statistics and Statistical Programming (Fall 2020)/pset4
(section)
From CommunityData
Jump to:
navigation
,
search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Programming Challenges (thinly disguised Statistical Questions) == This week the programming challenges will focus on the full population ("Chicago bikeshare") dataset from which I drew the 20 group samples you analyzed in Problem Sets 1 and 2. With the possible exception of the simulation in PC6 (which is "recommended"), nothing here should require anything totally new to you in R. Instead, a lot of the focus is on illustrating statistical concepts using relatively simple code. The emphasis is on material covered in ''OpenIntro'' §5 and, for PC 6, programming material introduced in the [https://communitydata.science/~ads/teaching/2020/stats/r_tutorials/w05-R_tutorial.html Week 5 R tutorial]. === PC1. Import the data === The dataset for this week is available in yet another plain text format: a "tab-delimited" (a.k.a., tab-separated or TSV) file. You can find it in the <code>week_06</code> subdirectory in the [https://communitydata.science/~ads/teaching/2020/stats/data data repository for the course]. Go ahead and inspect the data and load it into R (''Hint:'' You can use either the tidyverse <code>read_tsv()</code> function or the Base R <code>read.delim()</code> function to do this). You'll also want to make sure you have the data (and especially your friendly <code>x</code> variable) from [[Statistics_and_Statistical_Programming_(Fall_2020)/pset2|Problem Set 2]] handy once again. === PC2. Compare the means === Calculate the mean of the variable <code>x</code> in the aggregate (this week's) dataset. Go back to [[Statistics_and_Statistical_Programming_(Fall_2020)/pset2|Problem Set 2]] and revisit the mean you calculated for <code>x</code>. ==== Interpret the comparison ==== Knowing that the data you analyzed in Problem Set 2 was a random 5% sample from the dataset distributed for the present Problem Set, explain the ''conceptual'' relationship of these two means to each other. === PC3. Confidence interval of a mean === Again, using the variable <code>x</code> from your Problem Set 2 data, compute the 95% confidence interval for the mean of this vector "by hand" (i.e., in R) using the normal formula for the [https://en.wikipedia.org/wiki/Standard_error#Standard_error_of_the_mean standard error of a mean]: <math>(\frac{\sigma}{\sqrt{n}})</math>, where <math>\sigma</math> is the standard deviation of the sample and <math>n</math> is the number of observations (''Bonus:'' Do this by writing a function.). ==== Compare and explain ==== Compare the mean of <code>x</code> from your Problem Set 2 data—and your confidence interval from PC3—to the mean of <code>x</code> in the dataset for the present Problem Set. Is the mean for the aggregate dataset (this week's data) within the confidence interval for your Problem Set 2 data? Do you find this surprising? Why or why not? Explain the conceptual relationship of these values to each other. === PC4. Compare distributions === Let's go beyond the mean alone. Compare the distribution from your Problem Set 2 <code>x</code> vector to the aggregate version of <code>x</code> in this week's data. Draw histograms (or density plots) and compute other descriptive and summary statistics. ==== Interpret the comparison ==== What do you notice? Identify (and interpret) any differences. === PC5. Standard deviation of conditional means === Calculate the mean of <code>x</code> for each of the groups in the dataset for this week (within each <code>group</code> in the aggregate dataset) and the standard deviation of this distribution of means. ==== Compare and explain ==== Compare the standard deviation of the means across all groups that you just calculated to the standard error you calculated in PC3 above. Discuss and explain the relationship between these values. === (Recommended) PC6. A simulation === Let's conduct a simulation that demonstrates a fundamental principle of statistics. Please see the [https://communitydata.science/~ads/teaching/2020/stats/r_tutorials/w05-R_tutorial.html R tutorial materials from last week] for useful examples that can help you do this. :* (a) Create a vector of 10,000 randomly generated numbers that are uniformly distributed between 0 and 9. :* (b) Calculate the mean of the vector you just created. Plot a histogram of the distribution. :* (c) Create 100 random samples of 2 items each from your randomly generated data and take the mean of each sample. Create a new vector that contains those means. Describe/display the distribution of those means. :* (d) Do (c) except make the items 10 items in each sample instead of 2. Then do (c) again except with 100 items. Be ready to describe how the histogram changes as the sample size increases. (''Bonus challenge:'' Write a function to complete this part.) ==== Compare and explain the simulation ==== Compare the results from PC6 with those in the example simulation from [https://communitydata.science/~ads/teaching/2020/stats/r_tutorials/w05-R_tutorial.html last week's R tutorial]. What fundamental statistical principle is illustrated by these simulations? Why is this an important simulation for thinking about hypothesis testing?
Summary:
Please note that all contributions to CommunityData are considered to be released under the Attribution-Share Alike 3.0 Unported (see
CommunityData:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:
Cancel
Editing help
(opens in new window)
Tools
What links here
Related changes
Special pages
Page information