lab8_CI - # This lab looks long, but it's not! # Most of...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
# This lab looks long, but it's not! # Most of the material is on the web, where you can cut/paste from. # The majority of this document is explanations - lots of it. So, # read carefuly. # 1) Last time, we computed CIs in three ways: a) Using the formula for CI, # b) Using the function t.test(), and c) using bootstrap, i.e., literally # doing the resampling and building the empirical sampling distribution # for the parameter of interest. The 1st method is based on the normal # distribution. Now, we will do the same thing, but with the t-distribution. # Three different ways of computing CIs based on t-distribution. # Copy/paste the next block from the web: # http://www.stat.washington.edu/marzban/390/lab_CI_supp.txt . rm(list=ls(all=TRUE)) set.seed(123) samp.size = 30 # Take a SMALL sample of size 30, x = rnorm(samp.size,0,1) # from a normal population with mean=0, sd=1. # Note: last time, we made a non-normal population and then took samples # from it. This time, though, we are taking a sample from a Normal # population, because that's the only population for which the t.test() # applies. ################################################################### ## First way: using the formulas that apply to a single sample mean only. ## Note: last week, we computed the z-interval, and so we needed quantiles ## of the normal distribution, i.e. qnorm(). This time, we are building ## t-intervals, and so we use qt(), which gives quantiles of the t-distribution. lower = mean(x) + qt(0.05/2,samp.size-1)*sd(x)/sqrt(samp.size) upper = mean(x) - qt(0.05/2,samp.size-1)*sd(x)/sqrt(samp.size) c(lower,upper) ################################################################### ## Second way: t.test itself, which does exactly what the first way does. ## Obviously, this is the easiest way, but make sure you know what ## assumptions underlie it. t.test(x) # Here is the portion of the output which we need for todays lab: # TAs explain these quantities. # t = -0.263, df = 29, # The observed t-value, and the df. # 95 percent confidence interval:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

lab8_CI - # This lab looks long, but it's not! # Most of...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online