Statistics 8701 (Geyer, Spring 2003) Homework No. 1

You must be able to accomplish the following tasks by yourself. You may discuss the tasks with other students or with the instructor, either in class or outside class. You may even watch someone else do a task. But eventually you must do it each at least once all by yourself with no help.

I would prefer that you do all of these tasks on a Linux box. Linux (or any Unix) makes these tasks straightforward. Microsoft or Apple boxes, make them much more difficult. If you want to do it the hard way, I will try to be supportive, but I can't promise to make it easy.

You should be finished all tasks by Wednesday, Jan 29, 2003. You will be asked to demonstrate one for the instructor.

Task 1

Compile and run a C program. Any C program, even the hello world program.

If you are new to C, you may use the version of the hello world program at the URL below

http://www.stat.umn.edu/geyer/8701/hw1/hello.c

Task 2

Fire up the R statistical computing environment and figure out how to do linear regression. Make a nice printout of the regression coefficients, their standard errors etc. (R has a function to do this) and make a normal Q-Q plot of the studentized residuals.

Use the data in the file

http://www.stat.umn.edu/geyer/8701/hw1/somedata.txt

If you are cool, you use the read.table and url functions in R to read in the data, but TMTOWTDI (there's more than one way to do it).

If you have never used R before, you will need some help from the Introduction to R book.

Task 3

Write an R function (using the R function function). Any function at all, even one that just squares its argument. And use it to see that it works.

Task 4

Write an R function (using the R .C function) that calls a C function to do its work. Any function at all, even one that just squares its argument. And use it to see that it works.

The section on System and foreign language interfaces of the Writing R Extensions book explains how to do this.

If you want a simpler example than the one in the book, try the following R function and corresponding C function

http://www.stat.umn.edu/geyer/8701/hw1/square.R
http://www.stat.umn.edu/geyer/8701/hw1/square.c

Note: If you are are Fortran fan you can do Fortran instead of C. The corresponding files are

http://www.stat.umn.edu/geyer/8701/hw1/squarf.R
http://www.stat.umn.edu/geyer/8701/hw1/squarf.f

Task 5

Install and use an R package. A simple package that implements the squaring function from the preceding task is

http://www.stat.umn.edu/geyer/8701/hw1/square_0.1.tar.gz

The Writing R Extensions book explains how to do this. Oops! No it doesn't.

This is explained in the section on installing packages in the R Installation and Administration book.