Statstics
GIS 470 Statistics for Geographers Assignment #5: Difference-of-Means Test in R
Introduction This assignment is an opportunity to showcase your knowledge of one- and two-sample hypothesis testing and analysis of variance testing using R. Here, we will be building from our in-class lab exercise from April 11, manipulating the code that we worked with the iris data set. We will then run some additional statistical tests based on the class survey data, which will require you to input and manipulate the survey data in R. Be sure to document your work as best you can to maximize your opportunities to earn points. You are welcome to use any resources you like to complete the assignment, including the many excellent online tutorials and resources for using R. If you need to make reasonable assumptions, do so, but be sure to write out those assumptions as part of your response. The sampling distribution for all problems can be assumed to be normal.
How to complete this assignment You should upload two files to receive full credit:
1) This assignment worksheet with answers to each question typed or written by hand
2) A copy of your R code (saved as a .R file)
You are welcome to ask classmates for help, but each student should submit their own original work and code. Please check that you can access R and successfully import the class survey data for analysis sooner rather than later (as this could be the major bottleneck for some of you).
There are five questions that total 100 points, plus opportunities for bonus points.
This assignment is due by 5pm on Wednesday, April 18. The assignment should be submitted electronically via Blackboard.
Good luck!
1. [20 points] There are four attributes in the iris dataset: sepal length, sepal width, petal length, and petal width. In class we learned that each species’ petal length is statistically different from the overall mean petal length of the same (3.758 cm). Let’s now examine petal width.
What is the mean petal width for the entire sample?
What is the mean petal width for each individual species?
setosa - versicolor - virginica –
Run a one-sample t-test to determine if any of the individual species’ mean petal widths are statistically greater than the overall mean for the entire sample.
What is the null hypothesis for each of your tests? (You can write an equation or use words)
Fill in the table below with output from the statistical test for each species:
|
Species |
T |
Degrees of freedom |
p-value |
Reject null hypothesis? (Y/N) |
|
setosa |
|
|
|
|
|
versicolor |
|
|
|
|
|
virginica |
|
|
|
|
Do any of the species have a mean petal width that is statistically greater than the overall sample mean petal width? If so, which species?
2. [20 points] Let’s now have a closer look at the differences between the virginica and versicolor species. First off, let’s be sure we know what we are talking about for these problems – what colors are common for these flowers?
What is the geographic range where these flowers tend to be found? Is the range the same for both species?
As you might’ve gathered from your online reading in answering the questions above, there are some interesting differences between these two species. Let’s use some two-sample testing to determine if any of the four parameters in the iris data set are statistically significantly different between the two.
For which of the four parameters in the iris data set are the means between the two species most statistically similar? How do you know? (Hint: report the T statistic and p value to help make your case).
For which of the four parameters in the iris data set are the means between the two species most statistically different? How do you know? (Hint: report the T statistic and p value to help make your case).
For how many of the four parameters do the means statistically differ between virginica and versicolor?
3. [20 points] A senior researcher in an iris laboratory is in the process of training new scientists. She gives each of the two new scientists a different sample of plants – one receives the first five of each of the three plants in the iris data set, and the other receives the second five of each of the tree plants. The senior researcher asks them to measure sepal length and sepal width and report back if they reach similar or different conclusions regarding any statistical differences between the three different species.
Assume that the measurements that the scientists record are accurate and are the values contained in the appropriate rows of the iris dataset. Do the two researchers reach the same conclusions about differences between the three samples’ sepal length? How about sepal width? Explain your answer, ideally by reporting some of the output from analysis of variance tests.
(Hint: you will need to use the “rbind” function to create new data frames that contain parts of the original iris data set. The first researcher receives plants that are represented by the 1st through 5th, 51st through 55th, and 101st through 105th row of data, and the second receives rows 6–10, 56–60, and 106–110. If I wanted to combine the first two rows for each species, I would use the syntax rbind(iris[1:2,],iris[51:52,],iris[101:102,] ).
4. [20 points] Import the class survey data into R. Remember to remove all of the extra rows at the bottom of the data set that contain only “NA” values, either by selecting the subset of the data for rows 1–31 or by using the na.omit function. Once you are confident you have the data loaded correctly, answer the following questions using one-sample tests. Be sure to report a T statistic and p-value for each question. There is sample code available on Blackboard for importing and cleaning the class survey data. As you work through this exercise, it will be helpful to have the Excel file open with the class survey data to be able to reference the metadata for variable names and codes.
a. A survey conducted in 2007 found that the majority of Americans thought the “ideal” number of children per family was 2, implying that each child would have one sibling. Is there a statistical difference between the number of siblings our class members have and the “ideal” number of 1.0?
b. There is some interesting scientific debate about the “right” number of meals to eat per day, but most of our social systems remain designed around a convention of three meals per day. Do members of our class, on average, eat statistically fewer than 3.0 meals per day? (Hint: be sure to remove missing values from these data!)
c. The National Sleep Foundation recommends that younger adults (18–25) and adults (26–64) get 7–9 hours of sleep per night. Is our class average statistically lower than the minimum recommended sleep time of 7.0 hours? (Don’t forget to check for missing values…and perhaps any outliers or possible errors in data entry.)
d. According to my Arizona driver’s license, I am 76 inches tall. Was the average guess of students in class statistically different from my actual height? (Again, don’t forget to look for missing values).
5. [20 points] Most of the students in class identified with one of three political orientations: Republican, Democrat, or Independent.
How many students identified with each of those three options?
Use an analysis of variance test to determine if participation in the 2016 November presidential election varied between the three political orientations in our class sample. Although this is conceptually a “proportions” problem, it is okay to treat the data as continuous values – the mean response to Q53 per group is equal to the percentage of students that voted in the election within that group divided by 100. For example, if there are ten students in a group, of which three voted and seven did not, the mean for that group is 0.3. You can compare these means between the three groups just as we did earlier in this assignment for the iris measurements. Report the following values for the ANOVA test:
-Null hypothesis:
-Mean for each sample:
-Variance for each sample:
-F statistic (note: do not calculate the F statistic by hand, because this problem has an unbalanced design):
-P-value:
-Should you reject the null hypothesis?
6. [1 bonus point if you make a prediction] This assignment will be scored out of 100 total points. How many points do you think you earned?
GIS 470 Statistics for Geographers Assignment #5, page 6