Statistics 503
R Lecture
Download and Install R
Go to:
http:/cran.r-project.org/
Click on Windows 95 and then base
Click Icon
Open R
Iris Data
Fisher (1936)
50 specimens for each of three species (setosa, versicolor, virginica) of Iris
were collected
Overview/Review
Regression 545
Department of Statistics
West Virginia University
Fall Semester/ 2012
Overview
Statistics starts with a problem
Proceed to data collection
Move to data analysis
Provide conclusions
Considerations
In working towards these obj
Linear Algebra Review
Linear Algebra Review
Regression 545
Department of Statistics
West Virginia University
Fall Semester/ 2012
Statistics
Applied Regression Analysis
Linear Algebra Review
Notations
a1 , ., ap be a sequence of n-vectors
a1i
.
ai = . for
Estimation
Estimation
Regression 545
Department of Statistics
West Virginia University
Estimation
Set-Up
Linear model
y1
.
Y =.
.
response
yn
and data vectors (predictors)
x11
x12
.
. , X2 = . ,
X1 = .
.
.
xn1
xn2
x13
.
and X3 = .
.
xn3
Estimation
Linear
Condence Intervals for
Regression 545
Department of Statistics
West Virginia University
Condence Intervals for
Condence Intervals essentially provide an approach to quantify
the outcome of an entire range of hypotheses.
Any point within the region corre
Examples of
Regression 545
Department of Statistics
West Virginia University
Interesting Examples
1
When y = 0 + , we have that X = 1 = 1 (columns of 1s
of length n)
X T X = 1T 1
1
= 1T y
n
=y
so
=n
2
When
yi = 0 + 1 xi +
i
= + 1 (xi x ) +
where = 0 +
Testing Examples
Testing Examples
Regression 545
Department of Statistics
West Virginia University
Testing Examples
Testing just One Predictor
Dene RSS as the large models RSS and RSS as that for he
smaller model, in this case the model without predictor
Lecture 2: Matrix Representation
Regression 545
Department of Statistics
West Virginia University
Set-Up
the n p matrix such that
x11 x1p
.
.
.
.
.
.
.
.
xn1 xnp
= X+
0 + 1 x11 + + p x1p
.
.
X is a vector with X =
.
0 + 1 xn1 + + p xnp
Let X
be
1
.
X =
Identiability
Identiability
Regression 545
Department of Statistics
West Virginia University
Fall Semester/ 2012
Identiability
So far.
We have observed that the least squares estimator is the
solution to: X T X = X T y .
We require that X T X is nonsingul
Statistics 545
Group Assignment 4
Name:
1. Simulate the model y = 1 + 0.5x1 0.5x2 + where N (0, 2 ).
Here is the initial R-code:
>
>
>
>
>
>
set.seed(100)
n=50
x1=runif(n,1,2)
x2=runif(n,0,1)
sigsq=1 # this will change
y=1+0.5*x1-0.5*x2+rnorm(n,0,sigsq)
F
Statistics 545
Group Assignment 5
Name:
1. The chocolate candy bar data set from Assignment 2 is available
on eCampus.
(a) Fit the model with Price as the response and the other seven
numerical variables as the predictors. Test the hypothesis
H0 : Sodium
Statistics 545
Group Assignment 6
Name:
1. Load sat data in the faraway package in R and t math expend
+ salary + ratio +takers.
(a) Denote expend as A, salary as B, ratio as C, takers as D. Put
an X in table below if the interval results in a signicant t
Statistics 545
Group Assignment 3
Name:
1. The data set prostate in the faraway package comes from a study
of 97 men with prostate cancer who were due to receive a radical
prostatecomy. Let lpsa be the response.
(a) Fill in the following table where RSE i
Statistics 545
Group Assignment 2
Name:
1. The data set consists of chocolate candy bars available in Queensland Australia stores in 2002. The data is available on eCampus
and use the read.csv command to read it in R. The following
information is availabl
Statistics 545
Group Assignment 1
Name:
Answer each question with a check mark indicating that your group
did it.
1. Ice Breakers: Everyone in your group, introduce yourself, say
your major, and briey say what fun thing you did over break.
2. Get the uswa