Introduction to Statistics (MAT/SST 115.03 2008S)
Primary: [Front Door] [Syllabus] [Current Outline] [R] - [Academic Honesty] [Instructions]
Groupings: [Applets] [Assignments] [Data] [Examples] [Handouts] [Labs] [Outlines] [Projects] [Readings] [Solutions]
External Links: [R Front Door] [SamR's Front Door]
I will gather your sleep time data at the start of class and enter them into a file. You can read them into a table with
SleepData = read.csv("/home/rebelsky/Stats115/Data/SleepData.csv")
SleepTimes = SleepData$HoursSlept
The second line allows us to refer to the vector as SleepTimes.
You should refer to activity 19-3 c for ideas of graphical displays.
You can get sample size, sample mean, and sample standard deviation with
length(SleepTimes) mean(SleepTimes) sd(SleepTimes)
Since we have all of the original data, the easiest way to get
the confidence interval is to use the t.test
function.
You should substitute your own guess as to the mean hours
slept (in place of 6).
t.test(SleepTimes, mu=6, conf.level=.90)
Of course, you might also want to provide R with step-by-step instructions.
x_bar = mean(SleepTimes) n = length(SleepTimes) s = sd(SleepTimes) t_star = qt(0.95, n-1) ci_lower = x_bar - t_star*s/sqrt(n) ci_upper = x_bar + t_star*s/sqrt(n) c(ci_lower, ci_upper)
Rather than counting values by hand, you can get R to produce a vector of the times in this interval with
NearMedian = SleepTimes[(SleepTimes > ci_lower) & (SleepTimes < ci_upper)] length(NearMedian)
Primary: [Front Door] [Syllabus] [Current Outline] [R] - [Academic Honesty] [Instructions]
Groupings: [Applets] [Assignments] [Data] [Examples] [Handouts] [Labs] [Outlines] [Projects] [Readings] [Solutions]
External Links: [R Front Door] [SamR's Front Door]
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.