Introduction to Statistics (MAT/SST 115.03 2008S)

R Notes for Topic 23: Analyzing Paired Data


R notes for Activity 23-1: Marriage Ages

You can read the data with

MA = read.csv("/home/rebelsky/Stats115/Data/MarriageAges.csv")

23-1 a. A Two-Sample t-test

This is a one-sided t-test, which we can express with

t.test(MA$HusbandAge,MA$WifeAge,alternative="greater")

23-1 b. Computing a Confidence Interval

You should be able to figure out how tocompute this confidence interval based on The R Notes for Topic 22.

23-1 c. Scatterplots

You can produce a similar scatterplot using

plot(MA$WifeAge,MA$HusbandAge)

You can add the “same age” line with

abline(0,1)

23-1 e. A Confidence Intervals for Differences

We can use a one-sample t-test of the difference between the two columns.

t.test(MA$HusbandAge-MA$WifeAge, mu=0, conf.level=.9)

23-1 g. A Paired t-test

Once again, we need to tell R that this is a one-sided t-test.

t.test(MA$HusbandAge-MA$WifeAge, mu=0, alternative="greater")

23-1 i. Exploring Technical Conditions

We might want to make a normal probability plot to see if the data are normal. I'm not sure why, but R gives a somewhat different plot than does the answer key.

> qqnorm(MA$HusbandAge-MA$WifeAge, datax=T)
> qqline(MA$HusbandAge-MA$WifeAge, datax=T)

R notes for Activity 23-2: Melting times

If all goes well, there will be three files of melting time: CChips.csv, BChips.csv, and Chips.csv. You can load them with

CChips = read.csv("/home/rebelsky/Stats115/Data/CChips.csv")
BChips = read.csv("/home/rebelsky/Stats115/Data/BChips.csv")
Chips = read.csv("/home/rebelsky/Stats115/Data/Chips.csv")

You should be able to use your notes on earlier activities to compute the appropriate summaries. Ask for help if you need it.

R notes for Activity 23-5: Muscle Fatigue

Although the book does not provide the data in electronic format, I've put it into the file MuscleFatigue.csv for you. You can load it with

MF = read.csv("/home/rebelsky/Stats115/Data/MuscleFatigue.csv")

To compute the difference between men and women, you would use

MF$Man-MF$Woman

To build a dotplot for these data, you would use

library(BHH2, lib="/home/rebelsky/Stats115/Packages")
dotPlot(MF$Man-MF$Woman)

You should be able to figure out how to do the t-test and confidence interval.

Creative Commons License

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright (c) 2007-8 Samuel A. Rebelsky.

This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/2.5/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.