next_inactive up previous
Up: Practicalities and Logistics Previous: Logistics

Subsections

Labs and Discussion Groups

Discussion Group Times and Rooms

Discussion section attendance is mandatory for students taking the class for 5 units.

Now fixed as:
Monday 5, Room 60-61A (Inner quad, Archaelogy building)
Tuesday 3, Room 540-108 (Earthquake engineering)
Wednesday 5, Room 60-61A (Inner quad, Archaelogy building)

R Labs

Second R Labs: Thursday Oct.21 at 4.00pm and Friday, Oct. 22 at 2.00pm in Sequoia 211.

Forth R Labs: Thursday November 18th at 3.15 and Friday November 19th at 2.00pm

If you are having trouble using either the install.packages command or downloading the binary from its original website (http://cran.r-project.org/src/contrib/Descriptions/ISwR.html), you can cut and paste the file from a text file saving the text file locally on your computer (say as kfm.txt) and making sure you give the right path to it type in R:

kfm=read.table('/Users/susan/Desktop/kfm.txt',header=T) [for a mac]
or
kfm=read.table('C:\MyFiles\kfm.txt',header=T) [for a pc]

Link to the file:kfm.txt

There is also a link to the file:kfm.save
if you choose to use that file, all you need to do is write:

load('C:\MyFiles\kfm.save') [for a pc]
or
load('/Users/susan/Desktop/kfm.save') [for a mac]

Books:

What is R?

R is a free software package available from CRAN - Network and on the leland machines by typing R.

The commercial version is called Splus and is also available from leland machines, at our level there are no differences between the two and the documentations are interchangeable.

Elizabeth Purdom's R Help Pages

Bret Larget's R Help

Note on using R with a Mac

Mac OS X R FAQ

After downloading X11 from the Apple website at http://www.apple.com/macosx/x11/download/

Helpful note on X servers and windows

From Katharine Kripke:
I was able to install MI/X (available online for $25, with a free trial period) as an x server for windows, login to the leland system, and see the graphics for matlab. steps involved:
1) download program from http://www.microimages.com/www/html/freestuf/mix/
2) install and run it.
3) at the top of the window, it will say "microimages x server" and then a bunch of numbers. these numbers are your ip address. you will need your ip address for the next step.
4) open a leland session using pc-samson
5) at the prompt, type:

setenv display [ip address]:0.0 [return]

for example:

elaine0:~> setenv display 171.23 45.789:0.0 7) start R
8) switch over to the mix window on your computer, and R will be displayed there, complete with menus, graphics, etc.
9) yes!
note: if mix quits when you start R, open the mix preferences by left clicking on the mix icon in the upper left corner, open the tab called "other" and make sure "exit when all windows closed" is not checked.

Using Private libraries of R packages

To install to another tree (e.g., your private one), use 

$ R CMD INSTALL -l lib pkg_version.tar.gz

where lib gives the path to the library tree to install to. 

To use them you have to have installed a variable:

R_LIBS="$HOME/lib/R:/usr/local/lib/R-contrib"; export R_LIBS

You can directly indicate a path for instance in R write:
> library(ISwR,lib.loc='/afs/ir/class/stats141/lib/')

will enable to load the library from the class directory.

Prerequisites

Some calculus see the mathematics sheet I handed out the first day.

Class attendanceAttendance is compulsory.

Homeworks

General instructions:
Do not give them in late because the solutions will be posted on the web, so there will be NO credit for late homeworks. If you are having trouble with a lecture or a homework, come to office hours as soon as possible. Many trouble students have is due to backlog. If you cannot do all of a problem, you should still hand in what you have done.

Homework 1 due in class Thursday October, 7th

Do the following problems from the book: 2.36, 2.56, 2.60, 2.63, 2.74 (should include any graphs used), 2.77.

Here is the text with the data of some of these so you can cut and
paste:

Here are the 20 measurements of preening time reported in Exercise
2.12 for 2.63:

34 24 10 16 52
76 33 31 46 24
18 26 57 32 25
48 22 48 29 19

a. Determine the median and the quartiles.
b. Determine the interquartile range.
c. Construct a (modified) boxplot of the data.

2.74
The carbon monoxide in cigarettes is thought to be hazardous to the
fetus of a pregnant woman who smokes. In a study of this theory, blood
drawn from pregnant women before and after smoking a
cigarette. Measurements were made of the percent of blood hemoglobin
bound to carbon monoxide as carboxyhemoglobin (COHb). The results for
ten women are shown the table.

        Blood COHb (%)
Subject   Before   After   Increase

1           1.2     7.6     6.4
2           1.4     4.0     2.6
3           1.5     5.0     3.5
4           2.4     6.3     3.9
5           3.6     5.8     2.2
6           0.5     6.0     5.5
7           2.0     6.4     4.4
8           1.5     5.0     3.5
9           1.0     4.2     3.2
10          1.7     5.2     3.5

a. Calculate the mean and standard deviation of the INCREASE in COHb.

b. Calculate the mean COHb before and the mean after. Is the mean
increase equal to the increase in means?

c. Construct a stem-and-leaf diagram of the increase in COHb. Use the
diagram to determine the median increase.

Homework 2 due in class Thursday October, 14th

Text (3rd ed): 3.3, 3.9, 3.12, 3.16, 3.18, 3.31, 3.34.
This should be handed in printed out before class. Hint: You can use the function runif to generate random numbers between 0 and 1, or sample to generate numbers among a certain vector.

Homework 3 due in class Thursday October, 21st

Chapter 4:4.2, 4.7, 4.18, 4.26, 4.36, 4.41, 4.43 from 3ed

Homework 4 due in class Thursday October, 28th

Chapter 5:5.18, 5.22, 5.23, 5.43, 5.56 from 3ed.

Homework 5 due in class Thursday November, 4th

Chapter 7: 7.9, 7.10, 7.31, 7.37,7.38, 7.45, 7.51 from 3ed.
Use R for questions 7.9, 7.37, 7.38, 7.51 here are the data:
7.9 and 7.37:soap.txt (save to file and use soap=read.table('soap.txt',header=T))
colonies        groups
6       soap
16      soap
26      soap
27      soap
30      soap
46      soap
76      soap
21      control
30      control
35      control
36      control
38      control
45      control
63      control
66      control
7.38:fertiliz.txt (save to file and use fertiliz=read.table('fertiliz.txt',header=T))
height  group
3.4     control
4.4     control
3.5     control
2.9     control
2.7     control
2.6     control
3.7     control
2.7     control
2.3     control
2       control
1.8     control
2.3     control
2.4     control
2.5     control
1.6     control
2.9     control
2.3     control
2.8     control
2.5     control
2.3     control
1.6     control
1.6     control
3       control
2.3     control
3.2     control
2       control
2.6     control
2.4     control
2.8     fertilized
1.9     fertilized
3.6     fertilized
1.2     fertilized
2.4     fertilized
2.2     fertilized
3.6     fertilized
1.2     fertilized
0.9     fertilized
1.5     fertilized
2.4     fertilized
1.7     fertilized
1.4     fertilized
1.8     fertilized
1.9     fertilized
2.7     fertilized
2.3     fertilized
1.8     fertilized
2.7     fertilized
2.6     fertilized
1.3     fertilized
3       fertilized
1.4     fertilized
1.2     fertilized
2.6     fertilized
1.8     fertilized
1.7     fertilized
1.5     fertilized
7.51: hypnosis.txt (save to file and use hypnosis=read.table('hypnosis.txt',header=T))
liters  group
5.32    experimental
5.60    experimental
5.74    experimental
6.06    experimental
6.32    experimental
6.34    experimental
6.79    experimental
7.18    experimental
4.50    control
4.78    control
4.79    control
4.86    control
5.41    control
5.70    control
6.08    control
6.21    control

Homework 6 due in class Tuesday November, 23rd

Data Sets: RATOZONE.txt
pigeon.dat
  1. A plant physiologist investigated the effect of flooding on root metabolism in two tree species: flood-tolerant river birch and the intolerant European birch. Four seedlings of each species were flooded for one day and four were used as controls. The concentration of adenosine triphosphate (ATP) in the roots of each plant are measured. The data (nmol ATP per mg tissue) are shown. For these data,
    SS(between) = 4.5530 and SS(within) = .47438
    River Birch / Flooded: 1.45, 1.19, 1.05, 1.07
    Rive Birch / Control: 1.70 2.04 1.49 1.91
    European Birch / Flooded: .21 .58 .11 .27
    European Birch / Control: 1.34 .99 1.17 1.30
    (see exercices in R lab 4)

    (a) Construct the ANOVA table and carry out the $ F$ test at $ \alpha =
.05$.
    (b) Assuming that each of the four populations has the same standard deviation, use the data to calculate an estimate of that standard deviation.
    (c) Prepare an interaction graph.

  2. An experiment was conducted in which the antiviral medication zanamivir was given to patients who had the flu. The length of time until the alleviation of major flu symptoms was measured for three groups: 85 patients who were given inhaled zanamivir, 88 patients who were given inhaled intranasal zanamivir, and 89 patients who were given a placebo. Summary statistics are given. The ANOVA SS(between) is 53.67 and the SS(within) is 2034.52.

    Inhaled Zanamivir: mean = 5.4, SD = 2.7, n = 85
    Inhaled intranasal Zanamivir: mean = 5.3, SD = 2.8, n = 88
    Placebo: mean = 6.3, SD = 2.9, n = 89

    (a) State the null hypothesis in words, in the context of this setting.
    (b) State the null hypothesis in symbols.
    (c) Construct the ANOVA table and test the null hypothesis. Let $ \alpha = 0.05$.
    (d)Calculate the pooled standard deviation, $ s_{pooled}$.

  3. An experiment was done to measure the effects of ozone, a component of smog. A group of 22 70-day-old rats were kept in an environment containing ozone for 7 days, and their weight gains were recorded. Another group of 23 rats of a similar age were kept in an ozone-free environment for a similar time, and their weight gains were recorded. The data (in grams) are given below.
    Using R find out whether the two groups have different variances?
    Use your result to implement a t-test to test whether there is a difference in weight gain between the two groups.
    Compare to the Wilcoxon test.
    Group       WtGain
    Control     41.0
    Control     38.4
    Control     24.9
    ....
    Ozone       44.1 
    Ozone       -9.0 
    Ozone       -9.0
    

    Use the command
    ozone=read.table(``www-stat.stanford.edu/~susan/courses/s141/RATOZONE.txt'',header=T) to download the data.

  4. The following data are measurements of five random samples of 20 domestic pigeons collected during the months of January, February, March, April and May in Chicago in 1955. The variable is the length from the anterior end of the narial opening to the tip of the bony beak and is recorded in millimeters. Are the five samples homogeneous?



    Length Sample
       5.4      1
       5.3      1
       5.2      1
       4.5      1
    ....
       5.1      5 
       4.8      5 
       4.9      5
    

    Use the command
    pigeon=read.table(``http://www-stat.stanford.edu/~susan/courses/s141/pigeon.dat'',header=T) to download the data.

  5. A study examined the survival times of goldfish (in minutes) when placed in colloidal silver suspensions. Experiment no. 1 of 5 goldfish & experiment no. 2 of 10 goldfish were under similar chemical conditions, while the 3rd experiment with 10 goldfish had the addition of urea, NaCl, and $ Na_2S$. Is there a difference between experiment 1 & 2? (ignore the third group or you can use it to improve the estimate of the residual (within SS), Hint: you can't do that automatically with R)
    Is there a difference between the experiment with the addition of salts compared with the (average) of experiment 1 & 2? (You can either use the notion of contrasts or you can just replace the mean and sd of the Group 1 & 2 grouped, in this case you cannot just plug it into R, you also have to do all the intermediary calcualtions by hand)

    What problems might there be with this ANOVA setup?

    Compare ANOVA results with those obtained using Kruskal-Wallis test by typing:
    kruskal.test(survival~experiment,data=goldfish.df).



    Experiment 1
    210 180 240 210 210
    
    Experiment 2
    150 180 210 240 240 120 180 240 120 150
    
    Salts Added
    330 300 300 420 360 270 360 360 300 120
    

    Enter the data using a cut and paste of the following:

    survival=c(210, 180, 240, 210, 210,
    150, 180, 210, 240, 240, 120, 180, 240, 120, 150,
    330, 300, 300, 420, 360, 270, 360, 360, 300, 120)
    experiment=factor(c(rep('expt1',5),rep('expt2',10),rep('expt3',10)))
    goldfish.df=data.frame(survival,experiment)
    

Homework 7 due in class Thursday December, 2nd

Datasets:
Leucine: http://www-stat.stanford.edu/~susan/courses/s141/leucine.txt
Ethanol: http://www-stat.stanford.edu/~susan/courses/s141/ethanol.txt
Cob-wt: http://www-stat.stanford.edu/~susan/courses/s141/cob-wt.txt

Problems: 12.3,12.19, 12.4, 12.13, 12.5,12.14 from the text.


next_inactive up previous
Up: Practicalities and Logistics Previous: Logistics
Susan Holmes 2004-12-07