Generalized Linear Models in R
|
|
- Alice Moody
- 5 years ago
- Views:
Transcription
1 Generalized Linear Models in R NO ORDER Kenneth K. Lopiano, Garvesh Raskutti, Dan Yang last modified
2 Outline 1. Background and preliminaries 2. Data manipulation and exercises 3. Data structures in R 4. Inputting and reading in data 5. R basic graphics 6. Generalized linear models in R 7. Break 8. Variable selection on hurricane data 2
3 Background An implementation of the S programming language (developed at Bell labs in mid 70 s). Programming language for statistical techniques and graphics/data visualization. Free and open source. Extensive statistical capability for small to medium-sized data. Many packages. Interfaces easily with C/C++/Fortran. Interfaces easily with Hadoop (cloud computing). Other statistical software: e.g. SAS, SPSS, STATA and Minitab, commercial, not open source. Mathematical software: Maple, Mathematica, and Matlab. 3
4 Preliminaries Entering and exiting R To begin: Unix or Linux: type R in command line; Windows: click the R icon. To quit: type q(). Need help? help.start(): start the HTML help system. help(): get help for a particular function. e.g. help(sum) Commands and variables in R are case sensitive. 4
5 Data Manipulation Create data object: > y <- 10 > Y = c("a", "b", "d") View an object: > y [1] 10 > Y [1] "a" "b" "d" Matrix: > a = 1:5 > b = 11:15 > newcol = cbind(a,b) ##Appending column vectors > newcol a b [1,] 1 11 [2,] 2 12 [3,] 3 13 [4,] 4 14 [5,] 5 15
6 Data Manipulation Matrix: > M = rbind(a,b) ##Appending row vectors > M [,1] [,2] [,3] [,4] [,5] a b > M[1,] ##Accessing a row [1] > M[2,3] ##Accessing a single element [1] 13 > dimensions = dim(a) ##Finding dimensions of a matrix > dimensions [1] 2 5
7 Data Manipulation Matrix: > M = rbind(a,b) > M [,1] [,2] [,3] [,4] [,5] a b Ex 1: Use R to find the mean and variance for the first row of M. Functions: mean(), var().
8 Data Manipulation Matrix: > M = rbind(a,b) > M [,1] [,2] [,3] [,4] [,5] a b Ex 1: Use R to find the mean and variance for the first row of M. > a = M[1,]; > mean(a) [1] 3 > var(a) [1] 2.5 Ex 2: Use R to find the correlation between the first and second row of M. Function: cor(.,.)
9 Data Manipulation Matrix: > M = rbind(a,b) > M [,1] [,2] [,3] [,4] [,5] a b Ex 1: Use R to find the mean and variance for the first row of M. > a = M[1,] > mean(a) > var(a) Ex 2: Use R to find the correlation between the first and second row of M. > cor(m[1,],m[2,]) [1] 1 > plot(a,b);
10 Matrix multiplication Matrix: > M = rbind(a,b) > M [,1] [,2] [,3] [,4] [,5] a b > M*M [,1] [,2] [,3] [,4] [,5] [1,] [2,] > M%*%t(M) ##t(.) transpose of a matrix [,1] [,2] [1,] [2,] Ex: Use R to find the first diagonal element of M T M.
11 Matrix multiplication Matrix: > M = rbind(a,b) > M [,1] [,2] [,3] [,4] [,5] a b > M*M ##Element-wise multiplication [,1] [,2] [,3] [,4] [,5] [1,] [2,] > M%*%t(M) ##Matrix multiplication [,1] [,2] [1,] [2,] Ex: Use R to find the first diagonal element of M T M. > N = t(m)%*%m; > N[1,1] [1] 122
12 Data structures in R So far we have seen vectors and matrices. Other data structures: Multi-way arrays - array(), tensors and higher-dimensional arrays. Data frames - data.frame(), tables with columns of a particular type. Lists - list(), vector of generic types.
13 Data Input and Data Frame Read data into an object (data frame): read.table() >mydata=read.table(" > mydata time status group a c b a b Show the variable names: > names(mydata) [1] "time" "status" "group" Extracting the component: > mydata$time [1] > mydata[,1] [1]
14 Control Statement Beyond matrix operations. if... else... > x = 5 > if (x>1) { x = x-1 } else { x = x+1 } > x [1] 4 for... > x = 5 > for (i in 1:10) { x = x+1 } > x [1] 15 while... > x = 5 > while (x<10) { x = x+1 } > x [1] 10 14
15 Defining Functions Define a function: myfun = function(t) { b = t*sin(t) ##Other standard functions cos(), exp(), log() return(b) } Call the function: > x=c(1,5,6) > myfun(x) [1]
16 Plot Plot myfun(): > x = seq(0,10,0.1) > y = myfun(x) > plot(x, y, xlab="input", ylab="response", col="blue", + xlim=c(0,10), ylim=c(-5,8)) > lines(x, y, col="red", lwd=2) > points(1:9, -2:6, col=1:9, pch=19) > title("my Function") My Function Response Input
17 Introduction to GLMs Relationship between response y (e.g hurricane counts) and covariates (x 1, x 2,..., x p ) (e.g. amon, dm, etc.). Start with covariates (p = 1). n observations (x i, y i ), i = 1,..., n R we read in the two datasets - Gaussian and Poisson > ### Set library to location on computer where the example datasets are > setwd("k:/short_courses/samsi UG/lessons/r-datasets") > ### Import the datasets pointozone and mi > input.data.gaussian=read.csv("example.gaussian.csv") > input.data.poisson=read.csv("example.poisson.csv") 17
18 Gaussian and Poisson data > head(input.data.gaussian) x y > head(input.data.poisson) x y
19 Motivation for GLMs A general framework for modeling the relationship between two or more variables. A GLM consists of three components. Let µ = E(y): linear predictor, η = β 0 + β 1 x link function,g(µ) = η, where g is a smooth, monotonic function. The random or stochastic component specifies the distribution of the response variable y. The observations y 1,..., y n are assumed to be independent with some density from the exponential family (e.g, Poisson or Gaussian). 19
20 Example 1: Gaussian data First we plot the raw data in Figure 20. Exploratory Scatterplot Gaussian Data y x 20
21 GLM for Gaussian data y i N (µ i, σ 2 ) link functiong(.) = Id, µ i = η i. η i = β 0 + β 1 x i. > glm.gaussian= glm(y~x, family=gaussian, data=input.data.gaussian) 21
22 GLM Output for Gaussian data > summary(glm.gaussian) # summary of the fit Call: glm(formula = y ~ x, family = gaussian, data = input.data.gaussian) Deviance Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error t value Pr(> t ) (Intercept) x <2e-16 *** --- (Dispersion parameter for gaussian family taken to be ) Null deviance: on 99 degrees of freedom Residual deviance: on 98 degrees of freedom AIC: Number of Fisher Scoring iterations: 2 22
23 GLM Outputs cont. > summary(glm.gaussian)$coefficients Estimate Std. Error t value Pr(> t ) (Intercept) e-01 x e-38 > summary(glm.gaussian)$dispersion # dispersion parameter [1] > coefficients(glm.gaussian)# coefficients from the fit (Intercept) x
24 GLM line fit Finally, the raw data and the fit are plotted in Figure1. Scatterplot with Regression Line Gaussian Data y x Figure: Scatterplot of the raw data from the Gaussian example with the estimated regression line. 24
25 Example 2: Poisson data Again we plot the raw data in Figure 2. Exploratory Scatterplot Poisson Data y x Figure: Scatterplot of the raw data from the Poisson example. 25
26 GLM for Poisson data y i Poisson(µ i ) link functiong(.) = log(.), η i = log(µ i ). η i = β 0 + β 1 x i. > glm.poisson= glm(y~x, family=poisson, data=input.data.poisson) 26
27 GLM Output for Poisson data > summary(glm.poisson) Call: glm(formula = y ~ x, family = poisson, data = input.data.poisson) Deviance Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error z value Pr(> z ) (Intercept) <2e-16 *** x <2e-16 *** --- (Dispersion parameter for poisson family taken to be 1) Null deviance: on 99 degrees of freedom Residual deviance: on 98 degrees of freedom AIC: Number of Fisher Scoring iterations: 4 27
28 GLM Poisson fit Finally, the raw data and the fit are plotted. Scatterplot with Regression Line Poisson Data y x 28
29 Prediction from GLM fits Goal of this project is to predict hurricane counts. R creates predictions using predict. > x.pred = data.frame(x=seq(25,60,1)) > predict.gaussian = predict(glm.gaussian, + type="response", + newdata=x.pred, + se.fit=true) > head(predict.gaussian$fit)
30 Variable selection on hurricane data outline Recall goal is to predict hurricane counts from set of environmental features. Adapt to multiple covariate setting (sample 5 variables). Variable/model selection to reduce number of covariates. Two variable selection methods in R: Penalized residuals (AIC, BIC) Cross-validation. 30
31 GLM with multiple variables Suppose there are p predictors (p = 5 in our example): η = g(µ) = β 0 + β 1 x 1 + β 2 x β p x p. For Gaussian or Poisson GLMs, the models are as following respectively. y i N(µ i, σ 2 ) (1) µ i = β 0 + β 1 x i β 5 x i5, (2) y i Poisson(µ i ) (3) log(µ i ) = β 0 + β 1 x i β 5 x i5. (4) 31
32 Sample hurricane data We select hurricane data from region.., level.., July for... years n =..., and we select the following 5 features: Load the data by the following command: > final.data = final.data = read.csv("countscovs.csv") > final.data = final.data[,c("count","amon.csv","limsta.csv", + "dm.csv","ggst.csv","ammsst.csv")] > head(final.data) count amon.csv limsta.csv dm.csv ggst.csv ammsst.csv
33 Scatterplot for features count amon.csv limsta.csv dm.csv ggst.csv ammsst.csv Figure: Scatterplot of the raw data from the Poisson example. 33
34 Histogram of responses y Histogram of final.data$count Frequency final.data$count Figure: Scatterplot of the raw data from the Poisson example. 34
35 Model selection motivation Fit improves with more parameters (i.e, over-fitting) e Model 1: bx Y ae c Model 2: c f X g sin( ) bx Y ae dx Amsterdam04 12 For hurricane prediction, could use all covariates or a subset. Including too many variables will produce a very complicated model and overfit data. Occam s Razor: The simplest explanation is usually the best. 35
36 Model selection motivation cont. Recall that goal is to generalize to future hurricane counts. Relationship between Goodness of Fit and Generalizability Goodness of fit Overfitting Generalizability Model Complexity Amsterdam
37 Model selection by penalized residuals Need to trade off complexity of the model with goodness of fit to data. How to quantify these notions? Penalized residuals framework: n l(y i, ŷ i ) i=1 }{{} Goodness of fit +λ #covariates in model. }{{} Complexity of model y i is actual response and ŷ i is predicted response based on model. l(.,.) is some measure of closeness (e.g. l(y i, ŷ i ) = (y i ŷ i ) 2. λ tradeoff tuning parameter (for AIC λ = 2, for BIC λ = log n ). 37
38 AIC for hurricane data Use AIC in R to determine which of the 5 features to include. Start: AIC= count ~ amon.csv + limsta.csv + dm.csv + ggst.csv + ammsst.csv Df Deviance AIC - ammsst.csv limsta.csv dm.csv ggst.csv <none> amon.csv Step: AIC=
39 AIC for hurricane data Step: AIC= count ~ amon.csv Df Deviance AIC <none> amon.csv ggst.csv dm.csv ammsst.csv limsta.csv Call: glm(formula = count ~ amon.csv, family = poisson, data = final.data) Coefficients: (Intercept) amon.csv Degrees of Freedom: 62 Total (i.e. Null); Null Deviance: Residual Deviance: AIC: Residual 39
40 Cross-validation Cross-validation is alternative approach to cross-validation. Avoids having to determine complexity of model. For k-fold cross-validation: (1) Randomly split the data into k equal (or approximately equal)-sized sets. (2) Select 1 of k sets as test and the remaining k 1 as training. (3) Run GLM on all k 1 sets. (4) Determine ŷ i for each element of test set using output of GLM and determine n i=1 l(y i, ŷ i ). (5) Repeat with each of the k sets as a test set and average residuals. Cross-validation can be used to select the model by choosing the model with the smallest average residuals. 40
41 Using cross-validation for hurricane data > temp.glm1 = glm(count~.,data=final.data, + family=poisson) > temp.glm2 = glm(count~amon.csv,data=final.data, + family=poisson) > temp.glm3 = glm(count~1,data=final.data, + family=poisson) > library(boot) > cost <- function(y,yhat,eps=0.0001) mean((log(y+eps) - log(yhat+eps))^2) > cv.out1 = cv.glm(final.data, + temp.glm1, + cost, + K=10)$delta[1] > cv.out2 = cv.glm(final.data, + temp.glm2, + cost, + K=10)$delta[1] > cv.out3 = cv.glm(final.data, + temp.glm3, + cost, + K=10)$delta[1] > print(c(cv.out1,cv.out2,cv.out3)) [1]
Generalised linear models. Response variable can take a number of different formats
Generalised linear models Response variable can take a number of different formats Structure Limitations of linear models and GLM theory GLM for count data GLM for presence \ absence data GLM for proportion
More informationcor(dataset$measurement1, dataset$measurement2, method= pearson ) cor.test(datavector1, datavector2, method= pearson )
Tutorial 7: Correlation and Regression Correlation Used to test whether two variables are linearly associated. A correlation coefficient (r) indicates the strength and direction of the association. A correlation
More informationRegression models. Generalized linear models in R. Normal regression models are not always appropriate. Generalized linear models. Examples.
Regression models Generalized linear models in R Dr Peter K Dunn http://www.usq.edu.au Department of Mathematics and Computing University of Southern Queensland ASC, July 00 The usual linear regression
More informationPoisson Regression. The Training Data
The Training Data Poisson Regression Office workers at a large insurance company are randomly assigned to one of 3 computer use training programmes, and their number of calls to IT support during the following
More informationGeneralized linear models
Generalized linear models Douglas Bates November 01, 2010 Contents 1 Definition 1 2 Links 2 3 Estimating parameters 5 4 Example 6 5 Model building 8 6 Conclusions 8 7 Summary 9 1 Generalized Linear Models
More informationChecking the Poisson assumption in the Poisson generalized linear model
Checking the Poisson assumption in the Poisson generalized linear model The Poisson regression model is a generalized linear model (glm) satisfying the following assumptions: The responses y i are independent
More informationExam Applied Statistical Regression. Good Luck!
Dr. M. Dettling Summer 2011 Exam Applied Statistical Regression Approved: Tables: Note: Any written material, calculator (without communication facility). Attached. All tests have to be done at the 5%-level.
More informationAge 55 (x = 1) Age < 55 (x = 0)
Logistic Regression with a Single Dichotomous Predictor EXAMPLE: Consider the data in the file CHDcsv Instead of examining the relationship between the continuous variable age and the presence or absence
More informationModeling Overdispersion
James H. Steiger Department of Psychology and Human Development Vanderbilt University Regression Modeling, 2009 1 Introduction 2 Introduction In this lecture we discuss the problem of overdispersion in
More informationStatistical Methods III Statistics 212. Problem Set 2 - Answer Key
Statistical Methods III Statistics 212 Problem Set 2 - Answer Key 1. (Analysis to be turned in and discussed on Tuesday, April 24th) The data for this problem are taken from long-term followup of 1423
More informationNon-Gaussian Response Variables
Non-Gaussian Response Variables What is the Generalized Model Doing? The fixed effects are like the factors in a traditional analysis of variance or linear model The random effects are different A generalized
More informationLogistic Regression - problem 6.14
Logistic Regression - problem 6.14 Let x 1, x 2,, x m be given values of an input variable x and let Y 1,, Y m be independent binomial random variables whose distributions depend on the corresponding values
More informationHurricane Forecasting Using Regression Modeling
Hurricane Forecasting Using Regression Modeling Yue Liu, Ashley Corkill, Roger Estep Group 10 Overview v Introduction v Choosing Predictors v Modeling The Hurricane Data v Conclusion and Results Images
More informationNonlinear Models. What do you do when you don t have a line? What do you do when you don t have a line? A Quadratic Adventure
What do you do when you don t have a line? Nonlinear Models Spores 0e+00 2e+06 4e+06 6e+06 8e+06 30 40 50 60 70 longevity What do you do when you don t have a line? A Quadratic Adventure 1. If nonlinear
More informationLinear Regression Models P8111
Linear Regression Models P8111 Lecture 25 Jeff Goldsmith April 26, 2016 1 of 37 Today s Lecture Logistic regression / GLMs Model framework Interpretation Estimation 2 of 37 Linear regression Course started
More informationGeneralized linear models for binary data. A better graphical exploratory data analysis. The simple linear logistic regression model
Stat 3302 (Spring 2017) Peter F. Craigmile Simple linear logistic regression (part 1) [Dobson and Barnett, 2008, Sections 7.1 7.3] Generalized linear models for binary data Beetles dose-response example
More informationR Output for Linear Models using functions lm(), gls() & glm()
LM 04 lm(), gls() &glm() 1 R Output for Linear Models using functions lm(), gls() & glm() Different kinds of output related to linear models can be obtained in R using function lm() {stats} in the base
More informationGeneralized Linear Models. Last time: Background & motivation for moving beyond linear
Generalized Linear Models Last time: Background & motivation for moving beyond linear regression - non-normal/non-linear cases, binary, categorical data Today s class: 1. Examples of count and ordered
More informationIntroduction to the Generalized Linear Model: Logistic regression and Poisson regression
Introduction to the Generalized Linear Model: Logistic regression and Poisson regression Statistical modelling: Theory and practice Gilles Guillot gigu@dtu.dk November 4, 2013 Gilles Guillot (gigu@dtu.dk)
More informationLab 3: Two levels Poisson models (taken from Multilevel and Longitudinal Modeling Using Stata, p )
Lab 3: Two levels Poisson models (taken from Multilevel and Longitudinal Modeling Using Stata, p. 376-390) BIO656 2009 Goal: To see if a major health-care reform which took place in 1997 in Germany was
More informationGeneralized Linear Models
Generalized Linear Models 1/37 The Kelp Data FRONDS 0 20 40 60 20 40 60 80 100 HLD_DIAM FRONDS are a count variable, cannot be < 0 2/37 Nonlinear Fits! FRONDS 0 20 40 60 log NLS 20 40 60 80 100 HLD_DIAM
More informationMixed models in R using the lme4 package Part 7: Generalized linear mixed models
Mixed models in R using the lme4 package Part 7: Generalized linear mixed models Douglas Bates University of Wisconsin - Madison and R Development Core Team University of
More informationCorrelation and Regression: Example
Correlation and Regression: Example 405: Psychometric Theory Department of Psychology Northwestern University Evanston, Illinois USA April, 2012 Outline 1 Preliminaries Getting the data and describing
More informationTopic 17 - Single Factor Analysis of Variance. Outline. One-way ANOVA. The Data / Notation. One way ANOVA Cell means model Factor effects model
Topic 17 - Single Factor Analysis of Variance - Fall 2013 One way ANOVA Cell means model Factor effects model Outline Topic 17 2 One-way ANOVA Response variable Y is continuous Explanatory variable is
More informationTento projekt je spolufinancován Evropským sociálním fondem a Státním rozpočtem ČR InoBio CZ.1.07/2.2.00/
Tento projekt je spolufinancován Evropským sociálním fondem a Státním rozpočtem ČR InoBio CZ.1.07/2.2.00/28.0018 Statistical Analysis in Ecology using R Linear Models/GLM Ing. Daniel Volařík, Ph.D. 13.
More informationWeek 7 Multiple factors. Ch , Some miscellaneous parts
Week 7 Multiple factors Ch. 18-19, Some miscellaneous parts Multiple Factors Most experiments will involve multiple factors, some of which will be nuisance variables Dealing with these factors requires
More informationBivariate data analysis
Bivariate data analysis Categorical data - creating data set Upload the following data set to R Commander sex female male male male male female female male female female eye black black blue green green
More informationThis module focuses on the logic of ANOVA with special attention given to variance components and the relationship between ANOVA and regression.
WISE ANOVA and Regression Lab Introduction to the WISE Correlation/Regression and ANOVA Applet This module focuses on the logic of ANOVA with special attention given to variance components and the relationship
More informationSTATS216v Introduction to Statistical Learning Stanford University, Summer Midterm Exam (Solutions) Duration: 1 hours
Instructions: STATS216v Introduction to Statistical Learning Stanford University, Summer 2017 Remember the university honor code. Midterm Exam (Solutions) Duration: 1 hours Write your name and SUNet ID
More informationIntroduction to Statistics and R
Introduction to Statistics and R Mayo-Illinois Computational Genomics Workshop (2018) Ruoqing Zhu, Ph.D. Department of Statistics, UIUC rqzhu@illinois.edu June 18, 2018 Abstract This document is a supplimentary
More informationMS&E 226: Small Data
MS&E 226: Small Data Lecture 6: Model complexity scores (v3) Ramesh Johari ramesh.johari@stanford.edu Fall 2015 1 / 34 Estimating prediction error 2 / 34 Estimating prediction error We saw how we can estimate
More informationChaper 5: Matrix Approach to Simple Linear Regression. Matrix: A m by n matrix B is a grid of numbers with m rows and n columns. B = b 11 b m1 ...
Chaper 5: Matrix Approach to Simple Linear Regression Matrix: A m by n matrix B is a grid of numbers with m rows and n columns B = b 11 b 1n b m1 b mn Element b ik is from the ith row and kth column A
More informationAdministration. Homework 1 on web page, due Feb 11 NSERC summer undergraduate award applications due Feb 5 Some helpful books
STA 44/04 Jan 6, 00 / 5 Administration Homework on web page, due Feb NSERC summer undergraduate award applications due Feb 5 Some helpful books STA 44/04 Jan 6, 00... administration / 5 STA 44/04 Jan 6,
More information9 Generalized Linear Models
9 Generalized Linear Models The Generalized Linear Model (GLM) is a model which has been built to include a wide range of different models you already know, e.g. ANOVA and multiple linear regression models
More informationStatistical Prediction
Statistical Prediction P.R. Hahn Fall 2017 1 Some terminology The goal is to use data to find a pattern that we can exploit. y: response/outcome/dependent/left-hand-side x: predictor/covariate/feature/independent
More informationExercise 5.4 Solution
Exercise 5.4 Solution Niels Richard Hansen University of Copenhagen May 7, 2010 1 5.4(a) > leukemia
More information7/28/15. Review Homework. Overview. Lecture 6: Logistic Regression Analysis
Lecture 6: Logistic Regression Analysis Christopher S. Hollenbeak, PhD Jane R. Schubart, PhD The Outcomes Research Toolbox Review Homework 2 Overview Logistic regression model conceptually Logistic regression
More informationLogistic Regression. James H. Steiger. Department of Psychology and Human Development Vanderbilt University
Logistic Regression James H. Steiger Department of Psychology and Human Development Vanderbilt University James H. Steiger (Vanderbilt University) Logistic Regression 1 / 38 Logistic Regression 1 Introduction
More informationClassification. Chapter Introduction. 6.2 The Bayes classifier
Chapter 6 Classification 6.1 Introduction Often encountered in applications is the situation where the response variable Y takes values in a finite set of labels. For example, the response Y could encode
More informationGeneralized Linear Models (GLZ)
Generalized Linear Models (GLZ) Generalized Linear Models (GLZ) are an extension of the linear modeling process that allows models to be fit to data that follow probability distributions other than the
More informationGeneralized Linear Models. stat 557 Heike Hofmann
Generalized Linear Models stat 557 Heike Hofmann Outline Intro to GLM Exponential Family Likelihood Equations GLM for Binomial Response Generalized Linear Models Three components: random, systematic, link
More informationLISA Short Course Series Generalized Linear Models (GLMs) & Categorical Data Analysis (CDA) in R. Liang (Sally) Shan Nov. 4, 2014
LISA Short Course Series Generalized Linear Models (GLMs) & Categorical Data Analysis (CDA) in R Liang (Sally) Shan Nov. 4, 2014 L Laboratory for Interdisciplinary Statistical Analysis LISA helps VT researchers
More informationMixed models in R using the lme4 package Part 5: Generalized linear mixed models
Mixed models in R using the lme4 package Part 5: Generalized linear mixed models Douglas Bates Madison January 11, 2011 Contents 1 Definition 1 2 Links 2 3 Example 7 4 Model building 9 5 Conclusions 14
More informationSample solutions. Stat 8051 Homework 8
Sample solutions Stat 8051 Homework 8 Problem 1: Faraway Exercise 3.1 A plot of the time series reveals kind of a fluctuating pattern: Trying to fit poisson regression models yields a quadratic model if
More informationSCHOOL OF MATHEMATICS AND STATISTICS. Linear and Generalised Linear Models
SCHOOL OF MATHEMATICS AND STATISTICS Linear and Generalised Linear Models Autumn Semester 2017 18 2 hours Attempt all the questions. The allocation of marks is shown in brackets. RESTRICTED OPEN BOOK EXAMINATION
More informationReview: what is a linear model. Y = β 0 + β 1 X 1 + β 2 X 2 + A model of the following form:
Outline for today What is a generalized linear model Linear predictors and link functions Example: fit a constant (the proportion) Analysis of deviance table Example: fit dose-response data using logistic
More informationRegression Methods for Survey Data
Regression Methods for Survey Data Professor Ron Fricker! Naval Postgraduate School! Monterey, California! 3/26/13 Reading:! Lohr chapter 11! 1 Goals for this Lecture! Linear regression! Review of linear
More informationOutline. Mixed models in R using the lme4 package Part 5: Generalized linear mixed models. Parts of LMMs carried over to GLMMs
Outline Mixed models in R using the lme4 package Part 5: Generalized linear mixed models Douglas Bates University of Wisconsin - Madison and R Development Core Team UseR!2009,
More informationRecap. HW due Thursday by 5 pm Next HW coming on Thursday Logistic regression: Pr(G = k X) linear on the logit scale Linear discriminant analysis:
1 / 23 Recap HW due Thursday by 5 pm Next HW coming on Thursday Logistic regression: Pr(G = k X) linear on the logit scale Linear discriminant analysis: Pr(G = k X) Pr(X G = k)pr(g = k) Theory: LDA more
More informationTopic 20: Single Factor Analysis of Variance
Topic 20: Single Factor Analysis of Variance Outline Single factor Analysis of Variance One set of treatments Cell means model Factor effects model Link to linear regression using indicator explanatory
More informationUNIVERSITY OF TORONTO Faculty of Arts and Science
UNIVERSITY OF TORONTO Faculty of Arts and Science December 2013 Final Examination STA442H1F/2101HF Methods of Applied Statistics Jerry Brunner Duration - 3 hours Aids: Calculator Model(s): Any calculator
More informationA Generalized Linear Model for Binomial Response Data. Copyright c 2017 Dan Nettleton (Iowa State University) Statistics / 46
A Generalized Linear Model for Binomial Response Data Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 1 / 46 Now suppose that instead of a Bernoulli response, we have a binomial response
More informationMultiple Regression Introduction to Statistics Using R (Psychology 9041B)
Multiple Regression Introduction to Statistics Using R (Psychology 9041B) Paul Gribble Winter, 2016 1 Correlation, Regression & Multiple Regression 1.1 Bivariate correlation The Pearson product-moment
More informationMixed models in R using the lme4 package Part 5: Generalized linear mixed models
Mixed models in R using the lme4 package Part 5: Generalized linear mixed models Douglas Bates 2011-03-16 Contents 1 Generalized Linear Mixed Models Generalized Linear Mixed Models When using linear mixed
More informationSTA 4504/5503 Sample Exam 1 Spring 2011 Categorical Data Analysis. 1. Indicate whether each of the following is true (T) or false (F).
STA 4504/5503 Sample Exam 1 Spring 2011 Categorical Data Analysis 1. Indicate whether each of the following is true (T) or false (F). (a) T In 2 2 tables, statistical independence is equivalent to a population
More informationPAPER 206 APPLIED STATISTICS
MATHEMATICAL TRIPOS Part III Thursday, 1 June, 2017 9:00 am to 12:00 pm PAPER 206 APPLIED STATISTICS Attempt no more than FOUR questions. There are SIX questions in total. The questions carry equal weight.
More informationUNIVERSITY OF TORONTO. Faculty of Arts and Science APRIL 2010 EXAMINATIONS STA 303 H1S / STA 1002 HS. Duration - 3 hours. Aids Allowed: Calculator
UNIVERSITY OF TORONTO Faculty of Arts and Science APRIL 2010 EXAMINATIONS STA 303 H1S / STA 1002 HS Duration - 3 hours Aids Allowed: Calculator LAST NAME: FIRST NAME: STUDENT NUMBER: There are 27 pages
More informationLogistic Regressions. Stat 430
Logistic Regressions Stat 430 Final Project Final Project is, again, team based You will decide on a project - only constraint is: you are supposed to use techniques for a solution that are related to
More informationUsing R in 200D Luke Sonnet
Using R in 200D Luke Sonnet Contents Working with data frames 1 Working with variables........................................... 1 Analyzing data............................................... 3 Random
More informationTwo Hours. Mathematical formula books and statistical tables are to be provided THE UNIVERSITY OF MANCHESTER. 26 May :00 16:00
Two Hours MATH38052 Mathematical formula books and statistical tables are to be provided THE UNIVERSITY OF MANCHESTER GENERALISED LINEAR MODELS 26 May 2016 14:00 16:00 Answer ALL TWO questions in Section
More informationStat 8053, Fall 2013: Poisson Regression (Faraway, 2.1 & 3)
Stat 8053, Fall 2013: Poisson Regression (Faraway, 2.1 & 3) The random component y x Po(λ(x)), so E(y x) = λ(x) = Var(y x). Linear predictor η(x) = x β Link function log(e(y x)) = log(λ(x)) = η(x), for
More informationR Hints for Chapter 10
R Hints for Chapter 10 The multiple logistic regression model assumes that the success probability p for a binomial random variable depends on independent variables or design variables x 1, x 2,, x k.
More informationPoisson Regression. James H. Steiger. Department of Psychology and Human Development Vanderbilt University
Poisson Regression James H. Steiger Department of Psychology and Human Development Vanderbilt University James H. Steiger (Vanderbilt University) Poisson Regression 1 / 49 Poisson Regression 1 Introduction
More informationStatistics 203: Introduction to Regression and Analysis of Variance Course review
Statistics 203: Introduction to Regression and Analysis of Variance Course review Jonathan Taylor - p. 1/?? Today Review / overview of what we learned. - p. 2/?? General themes in regression models Specifying
More informationy response variable x 1, x 2,, x k -- a set of explanatory variables
11. Multiple Regression and Correlation y response variable x 1, x 2,, x k -- a set of explanatory variables In this chapter, all variables are assumed to be quantitative. Chapters 12-14 show how to incorporate
More informationLogistic Regression 21/05
Logistic Regression 21/05 Recall that we are trying to solve a classification problem in which features x i can be continuous or discrete (coded as 0/1) and the response y is discrete (0/1). Logistic regression
More informationStat 401B Exam 3 Fall 2016 (Corrected Version)
Stat 401B Exam 3 Fall 2016 (Corrected Version) I have neither given nor received unauthorized assistance on this exam. Name Signed Date Name Printed ATTENTION! Incorrect numerical answers unaccompanied
More informationStructural Equation Modeling and Confirmatory Factor Analysis. Types of Variables
/4/04 Structural Equation Modeling and Confirmatory Factor Analysis Advanced Statistics for Researchers Session 3 Dr. Chris Rakes Website: http://csrakes.yolasite.com Email: Rakes@umbc.edu Twitter: @RakesChris
More informationWISE Regression/Correlation Interactive Lab. Introduction to the WISE Correlation/Regression Applet
WISE Regression/Correlation Interactive Lab Introduction to the WISE Correlation/Regression Applet This tutorial focuses on the logic of regression analysis with special attention given to variance components.
More informationStatistical analysis of trends in climate indicators by means of counts
U.U.D.M. Project Report 2016:43 Statistical analysis of trends in climate indicators by means of counts Erik Jansson Examensarbete i matematik, 15 hp Handledare: Jesper Rydén Examinator: Jörgen Östensson
More informationConsider fitting a model using ordinary least squares (OLS) regression:
Example 1: Mating Success of African Elephants In this study, 41 male African elephants were followed over a period of 8 years. The age of the elephant at the beginning of the study and the number of successful
More informationRegression Analysis Chapter 2 Simple Linear Regression
Regression Analysis Chapter 2 Simple Linear Regression Dr. Bisher Mamoun Iqelan biqelan@iugaza.edu.ps Department of Mathematics The Islamic University of Gaza 2010-2011, Semester 2 Dr. Bisher M. Iqelan
More informationHomework 10 - Solution
STAT 526 - Spring 2011 Homework 10 - Solution Olga Vitek Each part of the problems 5 points 1. Faraway Ch. 4 problem 1 (page 93) : The dataset parstum contains cross-classified data on marijuana usage
More informationMATH 644: Regression Analysis Methods
MATH 644: Regression Analysis Methods FINAL EXAM Fall, 2012 INSTRUCTIONS TO STUDENTS: 1. This test contains SIX questions. It comprises ELEVEN printed pages. 2. Answer ALL questions for a total of 100
More informationLinear Regression. In this lecture we will study a particular type of regression model: the linear regression model
1 Linear Regression 2 Linear Regression In this lecture we will study a particular type of regression model: the linear regression model We will first consider the case of the model with one predictor
More informationAnalysis of Covariance. The following example illustrates a case where the covariate is affected by the treatments.
Analysis of Covariance In some experiments, the experimental units (subjects) are nonhomogeneous or there is variation in the experimental conditions that are not due to the treatments. For example, a
More informationQuantitative Understanding in Biology Module II: Model Parameter Estimation Lecture I: Linear Correlation and Regression
Quantitative Understanding in Biology Module II: Model Parameter Estimation Lecture I: Linear Correlation and Regression Correlation Linear correlation and linear regression are often confused, mostly
More informationLecture 18: Simple Linear Regression
Lecture 18: Simple Linear Regression BIOS 553 Department of Biostatistics University of Michigan Fall 2004 The Correlation Coefficient: r The correlation coefficient (r) is a number that measures the strength
More informationExperimental Design and Statistical Methods. Workshop LOGISTIC REGRESSION. Jesús Piedrafita Arilla.
Experimental Design and Statistical Methods Workshop LOGISTIC REGRESSION Jesús Piedrafita Arilla jesus.piedrafita@uab.cat Departament de Ciència Animal i dels Aliments Items Logistic regression model Logit
More informationGeneralized Linear Models. Kurt Hornik
Generalized Linear Models Kurt Hornik Motivation Assuming normality, the linear model y = Xβ + e has y = β + ε, ε N(0, σ 2 ) such that y N(μ, σ 2 ), E(y ) = μ = β. Various generalizations, including general
More informationGeneralized Additive Models (GAMs)
Generalized Additive Models (GAMs) Israel Borokini Advanced Analysis Methods in Natural Resources and Environmental Science (NRES 746) October 3, 2016 Outline Quick refresher on linear regression Generalized
More informationR in Linguistic Analysis. Wassink 2012 University of Washington Week 6
R in Linguistic Analysis Wassink 2012 University of Washington Week 6 Overview R for phoneticians and lab phonologists Johnson 3 Reading Qs Equivalence of means (t-tests) Multiple Regression Principal
More informationVarious Issues in Fitting Contingency Tables
Various Issues in Fitting Contingency Tables Statistics 149 Spring 2006 Copyright 2006 by Mark E. Irwin Complete Tables with Zero Entries In contingency tables, it is possible to have zero entries in a
More informationLecture 19. Spatial GLM + Point Reference Spatial Data. Colin Rundel 04/03/2017
Lecture 19 Spatial GLM + Point Reference Spatial Data Colin Rundel 04/03/2017 1 Spatial GLM Models 2 Scottish Lip Cancer Data Observed Expected 60 N 59 N 58 N 57 N 56 N value 80 60 40 20 0 55 N 8 W 6 W
More informationStat 579: Generalized Linear Models and Extensions
Stat 579: Generalized Linear Models and Extensions Yan Lu Jan, 2018, week 3 1 / 67 Hypothesis tests Likelihood ratio tests Wald tests Score tests 2 / 67 Generalized Likelihood ratio tests Let Y = (Y 1,
More informationLinear model selection and regularization
Linear model selection and regularization Problems with linear regression with least square 1. Prediction Accuracy: linear regression has low bias but suffer from high variance, especially when n p. It
More informationChecking, Selecting & Predicting with GAMs. Simon Wood Mathematical Sciences, University of Bath, U.K.
Checking, Selecting & Predicting with GAMs Simon Wood Mathematical Sciences, University of Bath, U.K. Model checking Since a GAM is just a penalized GLM, residual plots should be checked, exactly as for
More informationLecture 9 STK3100/4100
Lecture 9 STK3100/4100 27. October 2014 Plan for lecture: 1. Linear mixed models cont. Models accounting for time dependencies (Ch. 6.1) 2. Generalized linear mixed models (GLMM, Ch. 13.1-13.3) Examples
More informationLOGISTIC REGRESSION Joseph M. Hilbe
LOGISTIC REGRESSION Joseph M. Hilbe Arizona State University Logistic regression is the most common method used to model binary response data. When the response is binary, it typically takes the form of
More information1 Introduction to Minitab
1 Introduction to Minitab Minitab is a statistical analysis software package. The software is freely available to all students and is downloadable through the Technology Tab at my.calpoly.edu. When you
More informationMultilevel Models in Matrix Form. Lecture 7 July 27, 2011 Advanced Multivariate Statistical Methods ICPSR Summer Session #2
Multilevel Models in Matrix Form Lecture 7 July 27, 2011 Advanced Multivariate Statistical Methods ICPSR Summer Session #2 Today s Lecture Linear models from a matrix perspective An example of how to do
More informationIntroduction and Background to Multilevel Analysis
Introduction and Background to Multilevel Analysis Dr. J. Kyle Roberts Southern Methodist University Simmons School of Education and Human Development Department of Teaching and Learning Background and
More informationPoisson Regression. Gelman & Hill Chapter 6. February 6, 2017
Poisson Regression Gelman & Hill Chapter 6 February 6, 2017 Military Coups Background: Sub-Sahara Africa has experienced a high proportion of regime changes due to military takeover of governments for
More information1 A Review of Correlation and Regression
1 A Review of Correlation and Regression SW, Chapter 12 Suppose we select n = 10 persons from the population of college seniors who plan to take the MCAT exam. Each takes the test, is coached, and then
More informationAnalysing categorical data using logit models
Analysing categorical data using logit models Graeme Hutcheson, University of Manchester The lecture notes, exercises and data sets associated with this course are available for download from: www.research-training.net/manchester
More informationPackage HGLMMM for Hierarchical Generalized Linear Models
Package HGLMMM for Hierarchical Generalized Linear Models Marek Molas Emmanuel Lesaffre Erasmus MC Erasmus Universiteit - Rotterdam The Netherlands ERASMUSMC - Biostatistics 20-04-2010 1 / 52 Outline General
More informationHow to deal with non-linear count data? Macro-invertebrates in wetlands
How to deal with non-linear count data? Macro-invertebrates in wetlands In this session we l recognize the advantages of making an effort to better identify the proper error distribution of data and choose
More informationrobmixglm: An R package for robust analysis using mixtures
robmixglm: An R package for robust analysis using mixtures 1 Introduction 1.1 Model Ken Beath Macquarie University Australia Package robmixglm implements the method of Beath (2017). This assumes that data
More informationSTA 4504/5503 Sample Exam 1 Spring 2011 Categorical Data Analysis. 1. Indicate whether each of the following is true (T) or false (F).
STA 4504/5503 Sample Exam 1 Spring 2011 Categorical Data Analysis 1. Indicate whether each of the following is true (T) or false (F). (a) (b) (c) (d) (e) In 2 2 tables, statistical independence is equivalent
More informationFinal Review. Yang Feng. Yang Feng (Columbia University) Final Review 1 / 58
Final Review Yang Feng http://www.stat.columbia.edu/~yangfeng Yang Feng (Columbia University) Final Review 1 / 58 Outline 1 Multiple Linear Regression (Estimation, Inference) 2 Special Topics for Multiple
More information