10.07.2015 Views

Using R for Introductory Statistics : John Verzani

Using R for Introductory Statistics : John Verzani

Using R for Introductory Statistics : John Verzani

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Two extensions of the linear model 329Figure 12.1 Graph of logisticfunction, m(x)=e x /(1+e x ). Theinflection point is marked with asquare.This log term is called the log-odds ratio. The odds associated to some probability arep/(1−p) , which is evident if we understand that an event having odds a to b means that ina+b i.i.d. trials we expect a wins. Thus the probability of success should be a/(a+b).Reversing, if the probability of success is a/(a+b), then the ratio becomes(a/(a+b))/(1−a/(a+b)) or a/b, which is the ratio of the odds.To finish the model, we need to specify the distribution of Y i . It is Bernoulli withsuccess probability π i , so that no extra parameters, such as a standard deviation, areneeded.12.1.1 Generalized linear modelsLogistic regression is an example of a generalized linear model. The key ingredients areas above: a response variable Y and some predictor variables x 1 , x 2 ,…,x p . The predictorsenter into the model via a single linear function:η=β 0 +β 1 x 1 + …+β p x p .The mean of Y given the x values is related to η by an invertible link function m() asµ=m(η) or m −1 (µ)=η. Finally, the distribution of Y is given in terms of its mean and,perhaps, a scale parameter such as σ.Thus, the model is specified by the coefficients β i , a link function m(), and aprobability distribution that may have an additional scale parameter.12.1.2 Fitting the model using glm()Generalized linear models are fit in R using the glm() function. Its usage is similar to thatof lm(), except that we need to specify the probability distribution and the link function.A template <strong>for</strong> usage is

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!