Class Notes Example

Danny Kaplan
May 14, 2013

  1. Including math notation in your notes
  2. Including R in your notes
  3. Including the mosaic package
  4. The SE of the difference between two means

Including math notation via Latex markup

The next slides are about putting some math notation and R calculations in your slides, not about the best way to teach about the standard error of the mean.

Background

You're already familiar with the formula for the standard error of the mean.

  • Calculation: \( s/\sqrt{n} \) where \( s \) is the sample standard deviation
  • Uses: Construct a 95\% confidence interval.
    • The margin of error is \( \pm 2 \times s/\sqrt{n} \)
  • Distribution: t distribution with \( n-1 \) df

Including R

Your R computations can be added to the presentation by including them in fences

    ` ``{r}
    3+2
    ```

This will appear in your finished document like this:

3+2
[1] 5

Using `mosaic`

Each document must be self-contained.

This means that you should include the mosaic package (typically at the top of the document):

require(mosaic)

Use the include=FALSE flag, e.g. {r include=FALSE} to supporess printing.

Calculation in R

The wage data: CPS85

nrow(CPS85)
[1] 534
mean(wage, data=CPS85)
[1] 9.024
sd(wage, data=CPS85)
[1] 5.139

The standard error of the mean is:

sd(wage, data=CPS85)/sqrt(nrow(CPS85)-1)
[1] 0.2226

SE of the Difference of Two Means

Starting data:

mean(wage ~ sex, data=CPS85)
    F     M 
7.879 9.995 
sd(wage ~ sex, data=CPS85)
    F     M 
4.720 5.286 
tally(~sex, data=CPS85)

    F     M Total 
  245   289   534 

Now Write Your Notes!

You take it from here on.

Do the calculation. Then compare it to the result you get in the t-test:

t.test(wage~sex, data=CPS85)