Editing Statistics and Statistical Programming (Winter 2017)/R lecture outline: Week 5

From CommunityData

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.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 2: Line 2:


first, lets make two datasets:
first, lets make two datasets:
# Lets download this dataset of births in North Carolina: http://www.openintro.org/stat/data/nc.RData ([https://htmlpreview.github.io/?https://github.com/andrewpbray/oiLabs-base-R/blob/master/inf_for_numerical_data/inf_for_numerical_data.html documentation is here])
# lets work with rivers. but i'll add some random noise: new.rivers <- rivers: rnorm(n=length(rivers), mean=100, sd=100)
# Lets also continue to work with rivers. I want to first add some random noise: new.rivers <- rivers: rnorm(n=length(rivers), mean=100, sd=100)
# lets also download this file: http://www.openintro.org/stat/data/nc.RData ([https://htmlpreview.github.io/?https://github.com/andrewpbray/oiLabs-base-R/blob/master/inf_for_numerical_data/inf_for_numerical_data.html documentation is here])


* unpaired t-test with two vectors: just t.test()
* paired t-test:
** i'm not going to walk through doing it by hand this week. i trust you can translate the equations in the book into R at this point
** compare our two rivers datasets using t.test()
* unpaired t-test with two vectors
** works with the rivers examples in the same way
** works with the rivers examples in the same way
** we can also do it with birthweight boys and girls in the nc.dataset by splitting into two vectors
** we can also do it with birthweight boys and girls in the nc.dataset by splitting into two vectors
* paired t-tests with t.test(paired=TRUE):
** i'm not going to walk through doing it by hand this week. i trust you can translate the equations in the book into R at this point
* unpaired t-test with the formula notation: t.test(mpg ~ am, data=mtcars) # manual versus automatic transmission
* unpaired t-test with the formula notation: t.test(mpg ~ am, data=mtcars) # manual versus automatic transmission
* anova: aov(), we'll be talking about anova() later!
* anova: aov(), we'll be talking about anova() later!
** returns an aov object. we can save that and then use the summary() function to give us more useful information
** returns a anova object. we can save that and then use the summary() function to give us more useful information
** we can see that the results are very similar with the two group example!
** we can see that the results are very similar with the two group example!


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)