SlideShare a Scribd company logo
1 of 15
Download to read offline
gnm: a Package for Generalized Nonlinear
                          Models

                                 Heather Turner and David Firth

                                        Department of Statistics
                                       University of Warwick, UK




Heather Turner and David Firth                                     University of Warwick
gnm: a Package for Generalized Nonlinear Models
Generalized Nonlinear Models

         Same form as generalized linear models:

                                          g(E(Y )) = g(µ) = η(x; β)
                                           Var(Y ) = f (µ)

         except η(x; β) can be nonlinear in β.
         E.g. row-column association model (Goodman, 1979)

                                            log µrc = αr + βc + γr δc



Heather Turner and David Firth                                          University of Warwick
gnm: a Package for Generalized Nonlinear Models
Further Examples
         Diagonal reference (Sobel, 1981)

                                            e.g. µrc = w1 γr + w2 γc

         Stereotype (Anderson, 1984)

                                  e.g. log µic = β0c + γc (β1 x1i + β2 x2i )

         UNIDIFF (Erikson & Goldthorpe, 1992; Xie, 1992)

                                     e.g. log µijk = αik + βjk + γk δij

         GAMMI (van Eeuwijk, 1995)

                                 e.g. µij = αi + βj + σ1 γ1i δ1j + σ2 γ2i δ2j
Heather Turner and David Firth                                                  University of Warwick
gnm: a Package for Generalized Nonlinear Models
The gnm Package


         Provides framework for fitting generalized nonlinear models
         Model-fitting function gnm
                 in-built mechanism to fit multiplicative terms
                 works with “plug-in” functions to fit other nonlinear terms
         Designed to be glm-like
                 common arguments, gnm objects inherit from glm objects, etc
         Uses over-parameterized representations of models




Heather Turner and David Firth                                      University of Warwick
gnm: a Package for Generalized Nonlinear Models
Model Specification

         gnm introduces two functions to specify nonlinear terms
                 Mult for standard multiplicative interactions, e.g.
                 counts ∼ row + column +
                     Mult(-1 + row, -1 + column)
                 Nonlin for other terms that require a “plug-in” function, e.g.
                 counts ∼ row + column +
                     Nonlin(MultHomog(row, column))
         Also functions to create factors for structured linear interactions
                 Diag (diagonal), Symm (symmetric), Topo (topological)



Heather Turner and David Firth                                       University of Warwick
gnm: a Package for Generalized Nonlinear Models
Working with Over-Parameterized Models

         gnm imposes minimal identifiability constraints
                 the same model can be represented by an infinite number of
                 parameterisations, e.g.

                                          log µrc = αr + βc + γr δc
                                                  = αr + βc + (2γr )(0.5δc )
                                                  = αr + βc + γr δc

                 gnm will return one of these parameterisations, at random
         Rules for constraining nonlinear parameters not required


Heather Turner and David Firth                                                 University of Warwick
gnm: a Package for Generalized Nonlinear Models
Estimating Identifiable Parameter
                              Combinations


         Through gnm
                 using arguments constrain and constrainTo
         From gnm object
                 estimate simple contrasts using getContrasts
                 estimate linear combinations of parameters using se
         both getContrasts and se check estimability first




Heather Turner and David Firth                                     University of Warwick
gnm: a Package for Generalized Nonlinear Models
Example: Occupational Status Data
         Study of occupational status taken from Goodman (1979)
         Cross-classified by occupational status of father: orig[in] and
         son: dest[ination]
                         > status
                               dest
                         orig     1                2   3   4    5     6   7   8
                              1 50                19 26    8    7    11   6   2
                              2 16                40 34 18     11    20   8   3
                              3 12                35 65 66     35    88 23 21
                              4 11                20 58 110    40   183 64 32
                              5   2                8 12 23     25    46 28 12
                              6 12                28 102 162   90   554 230 177
                              7   0                6 19 40     21   158 143 71
                              8   0                3 14 32     15   126 91 106

Heather Turner and David Firth                                                    University of Warwick
gnm: a Package for Generalized Nonlinear Models
Row-Column Association Model

         Model diagonal effects separately and use standard multiplicative
         interaction

                                 log µrc = αr + βc + θr (r = c) + γr δc
         > RC <- gnm(Freq ~ orig + dest + Diag(orig, dest) +
         +           Mult(-1 + orig, -1 + dest),
         +           family = poisson, data = status)

         Print summary of model
         > summary(RC)



Heather Turner and David Firth                                            University of Warwick
gnm: a Package for Generalized Nonlinear Models
Row-Column Association Model Summary
        Call: ...

        Deviance Residuals: ...

        Coefficients:
                            Estimate Std. Error z value Pr(>|z|)
        (Intercept)          0.19649         NA      NA       NA
        orig2                0.46730         NA      NA       NA
        ...
        orig8                1.15890         NA      NA       NA
                                                                     orig main effects
        dest2                0.98771         NA      NA       NA
        ...
        dest8                1.67662         NA      NA       NA
                                                                     dest main effects
        Diag(orig, dest)1    1.47923    0.45401   3.258 0.00112 **
        ...                                                          diagonal effects
        Diag(orig, dest)8    0.40731    0.21930   1.857 0.06327 .
        Mult1.Factor1.orig1 1.80430          NA      NA       NA
        ...                                                          orig multiplier
        Mult1.Factor1.orig8 -1.48489         NA      NA       NA
        Mult1.Factor2.dest1 1.23943          NA      NA       NA
        ...                                                          dest multiplier
        Mult1.Factor2.dest8 -0.82438         NA      NA       NA

        ...
        Residual deviance: 29.149 on 28 degrees of freedom
        AIC: 423.49

        Number of iterations: 9
Heather Turner and David Firth                                                     University of Warwick
gnm: a Package for Generalized Nonlinear Models
Homogeneous Row-Column Association Model
         Compare to model with homogeneous multiplicative interaction

                                       log µij = αi + βj + θij + δi δj
         > RChomog <- update(RC, . ~ . - Mult(-1 + orig, -1 + dest)
         +                   + Nonlin(MultHomog(orig, dest)),
         +                   ofInterest = "Mult")
         >
         > anova(RChomog, RC, test = "Chisq")
         Analysis of Deviance Table

         Model 1:         Freq ~ orig + ... + Nonlin(MultHomog(orig, dest))
         Model 2:         Freq ~ orig + ... + Mult(orig, dest)
           Resid.         Df Resid. Dev Df Deviance P(>|Chi|)
         1                34     32.561
         2                28     29.149 6     3.412     0.756
Heather Turner and David Firth                                           University of Warwick
gnm: a Package for Generalized Nonlinear Models
Homogeneous Model Summary
        > summary(RChomog)
        Call:

        gnm(formula = Freq ~ orig + dest + Diag(orig, dest) + Nonlin(MultHomog(orig,
            dest)), ofInterest = "Mult", family = poisson, data = status)


        Deviance Residuals:
            Min       1Q   Median          3Q        Max
        -1.6588 -0.4297     0.0000     0.3862     1.7208

        Coefficients of interest:
                                Estimate Std. Error z value Pr(>|z|)
        MultHomog(orig, dest).1 -1.50270         NA      NA       NA
        MultHomog(orig, dest).2 -1.28440         NA      NA       NA
        MultHomog(orig, dest).3 -0.68624         NA      NA       NA
        MultHomog(orig, dest).4 -0.10236         NA      NA       NA
        MultHomog(orig, dest).5 -0.08519         NA      NA       NA        coefficients of interest
        MultHomog(orig, dest).6 0.42657          NA      NA       NA
        MultHomog(orig, dest).7 0.84271          NA      NA       NA
        MultHomog(orig, dest).8 1.08629          NA      NA       NA

        Std. Error is NA where coefficient has been constrained or is unidentified

        Residual deviance: 32.561 on 34 degrees of freedom
        AIC: 414.9

        Number of iterations: 7

Heather Turner and David Firth                                                         University of Warwick
gnm: a Package for Generalized Nonlinear Models
Using getContrasts
         > contr <- getContrasts(RChomog,         ofInterest(RChomog))
         > round(contr[[1]]$qvframe, 3)
                                 estimate            SE quasiSE quasiVar
         MultHomog(orig, dest).1    0.000         0.000   0.157    0.025
         MultHomog(orig, dest).2    0.218         0.235   0.119    0.014
         MultHomog(orig, dest).3    0.816         0.167   0.061    0.004
         MultHomog(orig, dest).4    1.400         0.160   0.052    0.003
         MultHomog(orig, dest).5    1.418         0.172   0.080    0.006
         MultHomog(orig, dest).6    1.929         0.157   0.036    0.001
         MultHomog(orig, dest).7    2.345         0.173   0.080    0.006
         MultHomog(orig, dest).8    2.589         0.189   0.110    0.012


         Quasi standard errors are independent of the parameterisation -
         for more detail see Firth and de Menezes (Biometrika, 2004)
Heather Turner and David Firth                                    University of Warwick
gnm: a Package for Generalized Nonlinear Models
More on gnm ...


         Package available on CRAN: http://cran.r-project.org
         demo(gnm) covers example from this talk
         vignette("gnmOverview", package = "gnm") covers more
         examples and details of further features
                 for Mult terms: Exp, multiplicity
                 other: Dref, eliminate, ...
         Vignette and slides from short course available from
         http://www.warwick.ac.uk/go/heatherturner/gnm



Heather Turner and David Firth                             University of Warwick
gnm: a Package for Generalized Nonlinear Models
Further Work

         Integrate models which currently need work-arounds
                 > 1 instance of homogeneous multiplicative interaction, e.g.

                                       log µij = αi + βj + θij + δi δj + θi θj

                 “sum-of-exponentials” models, e.g.

                                 y = α + exp(β1 + γ1 x) + exp(β2 + γ2 x) + e

         Handle exponentials and reciprocals as standard
                 add Exp and Inv terms
                 allow nested nonlinear terms?


Heather Turner and David Firth                                                   University of Warwick
gnm: a Package for Generalized Nonlinear Models

More Related Content

What's hot

Random Matrix Theory and Machine Learning - Part 2
Random Matrix Theory and Machine Learning - Part 2Random Matrix Theory and Machine Learning - Part 2
Random Matrix Theory and Machine Learning - Part 2Fabian Pedregosa
 
tensor-decomposition
tensor-decompositiontensor-decomposition
tensor-decompositionKenta Oono
 
Random Matrix Theory and Machine Learning - Part 3
Random Matrix Theory and Machine Learning - Part 3Random Matrix Theory and Machine Learning - Part 3
Random Matrix Theory and Machine Learning - Part 3Fabian Pedregosa
 
Tensor Decomposition and its Applications
Tensor Decomposition and its ApplicationsTensor Decomposition and its Applications
Tensor Decomposition and its ApplicationsKeisuke OTAKI
 
Digital Signal Processing[ECEG-3171]-Ch1_L02
Digital Signal Processing[ECEG-3171]-Ch1_L02Digital Signal Processing[ECEG-3171]-Ch1_L02
Digital Signal Processing[ECEG-3171]-Ch1_L02Rediet Moges
 
Chapter 9 computation of the dft
Chapter 9 computation of the dftChapter 9 computation of the dft
Chapter 9 computation of the dftmikeproud
 
Decimation in time and frequency
Decimation in time and frequencyDecimation in time and frequency
Decimation in time and frequencySARITHA REDDY
 
Signal Processing Introduction using Fourier Transforms
Signal Processing Introduction using Fourier TransformsSignal Processing Introduction using Fourier Transforms
Signal Processing Introduction using Fourier TransformsArvind Devaraj
 
Fast Fourier Transform
Fast Fourier TransformFast Fourier Transform
Fast Fourier Transformop205
 
Image transforms 2
Image transforms 2Image transforms 2
Image transforms 2Ali Baig
 
Rabbit challenge 3 DNN Day1
Rabbit challenge 3 DNN Day1Rabbit challenge 3 DNN Day1
Rabbit challenge 3 DNN Day1TOMMYLINK1
 
Fft presentation
Fft presentationFft presentation
Fft presentationilker Şin
 
Internal workshop jub talk jan 2013
Internal workshop jub talk jan 2013Internal workshop jub talk jan 2013
Internal workshop jub talk jan 2013Jurgen Riedel
 
Dsp U Lec10 DFT And FFT
Dsp U   Lec10  DFT And  FFTDsp U   Lec10  DFT And  FFT
Dsp U Lec10 DFT And FFTtaha25
 
On the stability and accuracy of finite difference method for options pricing
On the stability and accuracy of finite difference method for options pricingOn the stability and accuracy of finite difference method for options pricing
On the stability and accuracy of finite difference method for options pricingAlexander Decker
 
Tensor representations in signal processing and machine learning (tutorial ta...
Tensor representations in signal processing and machine learning (tutorial ta...Tensor representations in signal processing and machine learning (tutorial ta...
Tensor representations in signal processing and machine learning (tutorial ta...Tatsuya Yokota
 
Lesson 27: Integration by Substitution (Section 041 slides)
Lesson 27: Integration by Substitution (Section 041 slides)Lesson 27: Integration by Substitution (Section 041 slides)
Lesson 27: Integration by Substitution (Section 041 slides)Matthew Leingang
 
Rao-Blackwellisation schemes for accelerating Metropolis-Hastings algorithms
Rao-Blackwellisation schemes for accelerating Metropolis-Hastings algorithmsRao-Blackwellisation schemes for accelerating Metropolis-Hastings algorithms
Rao-Blackwellisation schemes for accelerating Metropolis-Hastings algorithmsChristian Robert
 

What's hot (20)

Random Matrix Theory and Machine Learning - Part 2
Random Matrix Theory and Machine Learning - Part 2Random Matrix Theory and Machine Learning - Part 2
Random Matrix Theory and Machine Learning - Part 2
 
tensor-decomposition
tensor-decompositiontensor-decomposition
tensor-decomposition
 
Random Matrix Theory and Machine Learning - Part 3
Random Matrix Theory and Machine Learning - Part 3Random Matrix Theory and Machine Learning - Part 3
Random Matrix Theory and Machine Learning - Part 3
 
Tensor Decomposition and its Applications
Tensor Decomposition and its ApplicationsTensor Decomposition and its Applications
Tensor Decomposition and its Applications
 
Digital Signal Processing[ECEG-3171]-Ch1_L02
Digital Signal Processing[ECEG-3171]-Ch1_L02Digital Signal Processing[ECEG-3171]-Ch1_L02
Digital Signal Processing[ECEG-3171]-Ch1_L02
 
Chapter 9 computation of the dft
Chapter 9 computation of the dftChapter 9 computation of the dft
Chapter 9 computation of the dft
 
Decimation in time and frequency
Decimation in time and frequencyDecimation in time and frequency
Decimation in time and frequency
 
Signal Processing Introduction using Fourier Transforms
Signal Processing Introduction using Fourier TransformsSignal Processing Introduction using Fourier Transforms
Signal Processing Introduction using Fourier Transforms
 
Fast Fourier Transform
Fast Fourier TransformFast Fourier Transform
Fast Fourier Transform
 
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...
 
Image transforms 2
Image transforms 2Image transforms 2
Image transforms 2
 
Rabbit challenge 3 DNN Day1
Rabbit challenge 3 DNN Day1Rabbit challenge 3 DNN Day1
Rabbit challenge 3 DNN Day1
 
Fft presentation
Fft presentationFft presentation
Fft presentation
 
Internal workshop jub talk jan 2013
Internal workshop jub talk jan 2013Internal workshop jub talk jan 2013
Internal workshop jub talk jan 2013
 
Dsp U Lec10 DFT And FFT
Dsp U   Lec10  DFT And  FFTDsp U   Lec10  DFT And  FFT
Dsp U Lec10 DFT And FFT
 
On the stability and accuracy of finite difference method for options pricing
On the stability and accuracy of finite difference method for options pricingOn the stability and accuracy of finite difference method for options pricing
On the stability and accuracy of finite difference method for options pricing
 
Tensor representations in signal processing and machine learning (tutorial ta...
Tensor representations in signal processing and machine learning (tutorial ta...Tensor representations in signal processing and machine learning (tutorial ta...
Tensor representations in signal processing and machine learning (tutorial ta...
 
QMC Opening Workshop, High Accuracy Algorithms for Interpolating and Integrat...
QMC Opening Workshop, High Accuracy Algorithms for Interpolating and Integrat...QMC Opening Workshop, High Accuracy Algorithms for Interpolating and Integrat...
QMC Opening Workshop, High Accuracy Algorithms for Interpolating and Integrat...
 
Lesson 27: Integration by Substitution (Section 041 slides)
Lesson 27: Integration by Substitution (Section 041 slides)Lesson 27: Integration by Substitution (Section 041 slides)
Lesson 27: Integration by Substitution (Section 041 slides)
 
Rao-Blackwellisation schemes for accelerating Metropolis-Hastings algorithms
Rao-Blackwellisation schemes for accelerating Metropolis-Hastings algorithmsRao-Blackwellisation schemes for accelerating Metropolis-Hastings algorithms
Rao-Blackwellisation schemes for accelerating Metropolis-Hastings algorithms
 

Viewers also liked

Nonlinear Discrete-time Hazard Models for Entry into Marriage
Nonlinear Discrete-time Hazard Models for Entry into MarriageNonlinear Discrete-time Hazard Models for Entry into Marriage
Nonlinear Discrete-time Hazard Models for Entry into Marriagehtstatistics
 
Clustering Microarray Data
Clustering Microarray DataClustering Microarray Data
Clustering Microarray Datahtstatistics
 
Custom Functions for Specifying Nonlinear Terms to gnm
Custom Functions for Specifying Nonlinear Terms to gnmCustom Functions for Specifying Nonlinear Terms to gnm
Custom Functions for Specifying Nonlinear Terms to gnmhtstatistics
 
Modelling the Diluting Effect of Social Mobility on Health Inequality
Modelling the Diluting Effect of Social Mobility on Health InequalityModelling the Diluting Effect of Social Mobility on Health Inequality
Modelling the Diluting Effect of Social Mobility on Health Inequalityhtstatistics
 
Detecting Drug Effects in the Brain
Detecting Drug Effects in the BrainDetecting Drug Effects in the Brain
Detecting Drug Effects in the Brainhtstatistics
 
Generalized Bradley-Terry Modelling of Football Results
Generalized Bradley-Terry Modelling of Football ResultsGeneralized Bradley-Terry Modelling of Football Results
Generalized Bradley-Terry Modelling of Football Resultshtstatistics
 
BradleyTerry2: Flexible Models for Paired Comparisons
BradleyTerry2: Flexible Models for Paired ComparisonsBradleyTerry2: Flexible Models for Paired Comparisons
BradleyTerry2: Flexible Models for Paired Comparisonshtstatistics
 
Sample slides from "Programming with R" course
Sample slides from "Programming with R" courseSample slides from "Programming with R" course
Sample slides from "Programming with R" coursehtstatistics
 
Sample slides from "Getting Started with R" course
Sample slides from "Getting Started with R" courseSample slides from "Getting Started with R" course
Sample slides from "Getting Started with R" coursehtstatistics
 
SAEM Novela of the Marvelous Millennials
SAEM Novela of the Marvelous MillennialsSAEM Novela of the Marvelous Millennials
SAEM Novela of the Marvelous MillennialsNMSU
 
VideoWerkt videomarketing whitepaper
VideoWerkt videomarketing whitepaperVideoWerkt videomarketing whitepaper
VideoWerkt videomarketing whitepaperVideoWerkt BV
 
Pareto Law - Sales Recruitment
Pareto Law - Sales RecruitmentPareto Law - Sales Recruitment
Pareto Law - Sales Recruitmentkylepareto
 
Flagship Enterprise Center Annual Report
Flagship Enterprise Center Annual ReportFlagship Enterprise Center Annual Report
Flagship Enterprise Center Annual Reportflagshipcenter
 
Асимметрия управления проектом
Асимметрия управления проектомАсимметрия управления проектом
Асимметрия управления проектомЕвгений Пикулев
 
QuestBack Overview
QuestBack OverviewQuestBack Overview
QuestBack OverviewStewart Nash
 
Alaska Dispatch Study Final Report
Alaska Dispatch Study Final ReportAlaska Dispatch Study Final Report
Alaska Dispatch Study Final ReportJeff Granger
 
Microsoft office power point presentation
Microsoft office power point presentationMicrosoft office power point presentation
Microsoft office power point presentationHovolo
 
Eric Niehoff's Sample Design Portfolio
Eric Niehoff's Sample Design PortfolioEric Niehoff's Sample Design Portfolio
Eric Niehoff's Sample Design PortfolioEric Niehoff
 

Viewers also liked (20)

Nonlinear Discrete-time Hazard Models for Entry into Marriage
Nonlinear Discrete-time Hazard Models for Entry into MarriageNonlinear Discrete-time Hazard Models for Entry into Marriage
Nonlinear Discrete-time Hazard Models for Entry into Marriage
 
Clustering Microarray Data
Clustering Microarray DataClustering Microarray Data
Clustering Microarray Data
 
Custom Functions for Specifying Nonlinear Terms to gnm
Custom Functions for Specifying Nonlinear Terms to gnmCustom Functions for Specifying Nonlinear Terms to gnm
Custom Functions for Specifying Nonlinear Terms to gnm
 
Modelling the Diluting Effect of Social Mobility on Health Inequality
Modelling the Diluting Effect of Social Mobility on Health InequalityModelling the Diluting Effect of Social Mobility on Health Inequality
Modelling the Diluting Effect of Social Mobility on Health Inequality
 
Detecting Drug Effects in the Brain
Detecting Drug Effects in the BrainDetecting Drug Effects in the Brain
Detecting Drug Effects in the Brain
 
Generalized Bradley-Terry Modelling of Football Results
Generalized Bradley-Terry Modelling of Football ResultsGeneralized Bradley-Terry Modelling of Football Results
Generalized Bradley-Terry Modelling of Football Results
 
BradleyTerry2: Flexible Models for Paired Comparisons
BradleyTerry2: Flexible Models for Paired ComparisonsBradleyTerry2: Flexible Models for Paired Comparisons
BradleyTerry2: Flexible Models for Paired Comparisons
 
Sample slides from "Programming with R" course
Sample slides from "Programming with R" courseSample slides from "Programming with R" course
Sample slides from "Programming with R" course
 
Sample slides from "Getting Started with R" course
Sample slides from "Getting Started with R" courseSample slides from "Getting Started with R" course
Sample slides from "Getting Started with R" course
 
SAEM Novela of the Marvelous Millennials
SAEM Novela of the Marvelous MillennialsSAEM Novela of the Marvelous Millennials
SAEM Novela of the Marvelous Millennials
 
VideoWerkt videomarketing whitepaper
VideoWerkt videomarketing whitepaperVideoWerkt videomarketing whitepaper
VideoWerkt videomarketing whitepaper
 
Pareto Law - Sales Recruitment
Pareto Law - Sales RecruitmentPareto Law - Sales Recruitment
Pareto Law - Sales Recruitment
 
Flagship Enterprise Center Annual Report
Flagship Enterprise Center Annual ReportFlagship Enterprise Center Annual Report
Flagship Enterprise Center Annual Report
 
Асимметрия управления проектом
Асимметрия управления проектомАсимметрия управления проектом
Асимметрия управления проектом
 
QuestBack Overview
QuestBack OverviewQuestBack Overview
QuestBack Overview
 
Alaska Dispatch Study Final Report
Alaska Dispatch Study Final ReportAlaska Dispatch Study Final Report
Alaska Dispatch Study Final Report
 
Presentation: Can your consumer find you
Presentation: Can your consumer find youPresentation: Can your consumer find you
Presentation: Can your consumer find you
 
Microsoft office power point presentation
Microsoft office power point presentationMicrosoft office power point presentation
Microsoft office power point presentation
 
iMetaphors
iMetaphorsiMetaphors
iMetaphors
 
Eric Niehoff's Sample Design Portfolio
Eric Niehoff's Sample Design PortfolioEric Niehoff's Sample Design Portfolio
Eric Niehoff's Sample Design Portfolio
 

Similar to Generalized Nonlinear Models Package

Container and algorithms(C++)
Container and algorithms(C++)Container and algorithms(C++)
Container and algorithms(C++)JerryHe
 
Skiena algorithm 2007 lecture02 asymptotic notation
Skiena algorithm 2007 lecture02 asymptotic notationSkiena algorithm 2007 lecture02 asymptotic notation
Skiena algorithm 2007 lecture02 asymptotic notationzukun
 
A Fast Implicit Gaussian Curvature Filter
A Fast Implicit Gaussian Curvature FilterA Fast Implicit Gaussian Curvature Filter
A Fast Implicit Gaussian Curvature FilterYuanhao Gong
 
An introduction to isogeometric analysis
An introduction to isogeometric analysisAn introduction to isogeometric analysis
An introduction to isogeometric analysisNguyen Vinh Phu
 
Day_1_-_Rules_for_Differentiation (1).ppt
Day_1_-_Rules_for_Differentiation (1).pptDay_1_-_Rules_for_Differentiation (1).ppt
Day_1_-_Rules_for_Differentiation (1).pptVenuAravind10A
 
Stochastic Alternating Direction Method of Multipliers
Stochastic Alternating Direction Method of MultipliersStochastic Alternating Direction Method of Multipliers
Stochastic Alternating Direction Method of MultipliersTaiji Suzuki
 
Index Determination in DAEs using the Library indexdet and the ADOL-C Package...
Index Determination in DAEs using the Library indexdet and the ADOL-C Package...Index Determination in DAEs using the Library indexdet and the ADOL-C Package...
Index Determination in DAEs using the Library indexdet and the ADOL-C Package...Dagmar Monett
 
[系列活動] Data exploration with modern R
[系列活動] Data exploration with modern R[系列活動] Data exploration with modern R
[系列活動] Data exploration with modern R台灣資料科學年會
 
Rules_for_Differentiation.ppt
Rules_for_Differentiation.pptRules_for_Differentiation.ppt
Rules_for_Differentiation.pptjimj87313
 
Research in Composites for Aero Engine Applications
Research in Composites for Aero Engine ApplicationsResearch in Composites for Aero Engine Applications
Research in Composites for Aero Engine Applicationssicchiuricciu
 
Spectral-, source-, connectivity- and network analysis of EEG and MEG data
Spectral-, source-, connectivity- and network analysis of EEG and MEG dataSpectral-, source-, connectivity- and network analysis of EEG and MEG data
Spectral-, source-, connectivity- and network analysis of EEG and MEG dataRobert Oostenveld
 
Friedlander et al. Evolution of Bow-Tie Architectures in Biology (2015)
Friedlander et al. Evolution of Bow-Tie Architectures in Biology (2015)Friedlander et al. Evolution of Bow-Tie Architectures in Biology (2015)
Friedlander et al. Evolution of Bow-Tie Architectures in Biology (2015)Thoma Itoh
 
Spectral methods for linear systems with random inputs
Spectral methods for linear systems with random inputsSpectral methods for linear systems with random inputs
Spectral methods for linear systems with random inputsDavid Gleich
 
FUNCTION OF RIVAL SIMILARITY IN A COGNITIVE DATA ANALYSIS

FUNCTION OF RIVAL SIMILARITY IN A COGNITIVE DATA ANALYSIS
FUNCTION OF RIVAL SIMILARITY IN A COGNITIVE DATA ANALYSIS

FUNCTION OF RIVAL SIMILARITY IN A COGNITIVE DATA ANALYSIS
Maxim Kazantsev
 
Hierarchical Deterministic Quadrature Methods for Option Pricing under the Ro...
Hierarchical Deterministic Quadrature Methods for Option Pricing under the Ro...Hierarchical Deterministic Quadrature Methods for Option Pricing under the Ro...
Hierarchical Deterministic Quadrature Methods for Option Pricing under the Ro...Chiheb Ben Hammouda
 

Similar to Generalized Nonlinear Models Package (20)

Container and algorithms(C++)
Container and algorithms(C++)Container and algorithms(C++)
Container and algorithms(C++)
 
Skiena algorithm 2007 lecture02 asymptotic notation
Skiena algorithm 2007 lecture02 asymptotic notationSkiena algorithm 2007 lecture02 asymptotic notation
Skiena algorithm 2007 lecture02 asymptotic notation
 
A Fast Implicit Gaussian Curvature Filter
A Fast Implicit Gaussian Curvature FilterA Fast Implicit Gaussian Curvature Filter
A Fast Implicit Gaussian Curvature Filter
 
An introduction to isogeometric analysis
An introduction to isogeometric analysisAn introduction to isogeometric analysis
An introduction to isogeometric analysis
 
Day_1_-_Rules_for_Differentiation (1).ppt
Day_1_-_Rules_for_Differentiation (1).pptDay_1_-_Rules_for_Differentiation (1).ppt
Day_1_-_Rules_for_Differentiation (1).ppt
 
Stochastic Alternating Direction Method of Multipliers
Stochastic Alternating Direction Method of MultipliersStochastic Alternating Direction Method of Multipliers
Stochastic Alternating Direction Method of Multipliers
 
MUMS: Bayesian, Fiducial, and Frequentist Conference - Model Selection in the...
MUMS: Bayesian, Fiducial, and Frequentist Conference - Model Selection in the...MUMS: Bayesian, Fiducial, and Frequentist Conference - Model Selection in the...
MUMS: Bayesian, Fiducial, and Frequentist Conference - Model Selection in the...
 
Index Determination in DAEs using the Library indexdet and the ADOL-C Package...
Index Determination in DAEs using the Library indexdet and the ADOL-C Package...Index Determination in DAEs using the Library indexdet and the ADOL-C Package...
Index Determination in DAEs using the Library indexdet and the ADOL-C Package...
 
[系列活動] Data exploration with modern R
[系列活動] Data exploration with modern R[系列活動] Data exploration with modern R
[系列活動] Data exploration with modern R
 
Rules_for_Differentiation.ppt
Rules_for_Differentiation.pptRules_for_Differentiation.ppt
Rules_for_Differentiation.ppt
 
Research in Composites for Aero Engine Applications
Research in Composites for Aero Engine ApplicationsResearch in Composites for Aero Engine Applications
Research in Composites for Aero Engine Applications
 
Spectral-, source-, connectivity- and network analysis of EEG and MEG data
Spectral-, source-, connectivity- and network analysis of EEG and MEG dataSpectral-, source-, connectivity- and network analysis of EEG and MEG data
Spectral-, source-, connectivity- and network analysis of EEG and MEG data
 
Friedlander et al. Evolution of Bow-Tie Architectures in Biology (2015)
Friedlander et al. Evolution of Bow-Tie Architectures in Biology (2015)Friedlander et al. Evolution of Bow-Tie Architectures in Biology (2015)
Friedlander et al. Evolution of Bow-Tie Architectures in Biology (2015)
 
CMU_13
CMU_13CMU_13
CMU_13
 
Spectral methods for linear systems with random inputs
Spectral methods for linear systems with random inputsSpectral methods for linear systems with random inputs
Spectral methods for linear systems with random inputs
 
FUNCTION OF RIVAL SIMILARITY IN A COGNITIVE DATA ANALYSIS

FUNCTION OF RIVAL SIMILARITY IN A COGNITIVE DATA ANALYSIS
FUNCTION OF RIVAL SIMILARITY IN A COGNITIVE DATA ANALYSIS

FUNCTION OF RIVAL SIMILARITY IN A COGNITIVE DATA ANALYSIS

 
Presentation.pdf
Presentation.pdfPresentation.pdf
Presentation.pdf
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
 
DP_M4_L2.pdf
DP_M4_L2.pdfDP_M4_L2.pdf
DP_M4_L2.pdf
 
Hierarchical Deterministic Quadrature Methods for Option Pricing under the Ro...
Hierarchical Deterministic Quadrature Methods for Option Pricing under the Ro...Hierarchical Deterministic Quadrature Methods for Option Pricing under the Ro...
Hierarchical Deterministic Quadrature Methods for Option Pricing under the Ro...
 

Generalized Nonlinear Models Package

  • 1. gnm: a Package for Generalized Nonlinear Models Heather Turner and David Firth Department of Statistics University of Warwick, UK Heather Turner and David Firth University of Warwick gnm: a Package for Generalized Nonlinear Models
  • 2. Generalized Nonlinear Models Same form as generalized linear models: g(E(Y )) = g(µ) = η(x; β) Var(Y ) = f (µ) except η(x; β) can be nonlinear in β. E.g. row-column association model (Goodman, 1979) log µrc = αr + βc + γr δc Heather Turner and David Firth University of Warwick gnm: a Package for Generalized Nonlinear Models
  • 3. Further Examples Diagonal reference (Sobel, 1981) e.g. µrc = w1 γr + w2 γc Stereotype (Anderson, 1984) e.g. log µic = β0c + γc (β1 x1i + β2 x2i ) UNIDIFF (Erikson & Goldthorpe, 1992; Xie, 1992) e.g. log µijk = αik + βjk + γk δij GAMMI (van Eeuwijk, 1995) e.g. µij = αi + βj + σ1 γ1i δ1j + σ2 γ2i δ2j Heather Turner and David Firth University of Warwick gnm: a Package for Generalized Nonlinear Models
  • 4. The gnm Package Provides framework for fitting generalized nonlinear models Model-fitting function gnm in-built mechanism to fit multiplicative terms works with “plug-in” functions to fit other nonlinear terms Designed to be glm-like common arguments, gnm objects inherit from glm objects, etc Uses over-parameterized representations of models Heather Turner and David Firth University of Warwick gnm: a Package for Generalized Nonlinear Models
  • 5. Model Specification gnm introduces two functions to specify nonlinear terms Mult for standard multiplicative interactions, e.g. counts ∼ row + column + Mult(-1 + row, -1 + column) Nonlin for other terms that require a “plug-in” function, e.g. counts ∼ row + column + Nonlin(MultHomog(row, column)) Also functions to create factors for structured linear interactions Diag (diagonal), Symm (symmetric), Topo (topological) Heather Turner and David Firth University of Warwick gnm: a Package for Generalized Nonlinear Models
  • 6. Working with Over-Parameterized Models gnm imposes minimal identifiability constraints the same model can be represented by an infinite number of parameterisations, e.g. log µrc = αr + βc + γr δc = αr + βc + (2γr )(0.5δc ) = αr + βc + γr δc gnm will return one of these parameterisations, at random Rules for constraining nonlinear parameters not required Heather Turner and David Firth University of Warwick gnm: a Package for Generalized Nonlinear Models
  • 7. Estimating Identifiable Parameter Combinations Through gnm using arguments constrain and constrainTo From gnm object estimate simple contrasts using getContrasts estimate linear combinations of parameters using se both getContrasts and se check estimability first Heather Turner and David Firth University of Warwick gnm: a Package for Generalized Nonlinear Models
  • 8. Example: Occupational Status Data Study of occupational status taken from Goodman (1979) Cross-classified by occupational status of father: orig[in] and son: dest[ination] > status dest orig 1 2 3 4 5 6 7 8 1 50 19 26 8 7 11 6 2 2 16 40 34 18 11 20 8 3 3 12 35 65 66 35 88 23 21 4 11 20 58 110 40 183 64 32 5 2 8 12 23 25 46 28 12 6 12 28 102 162 90 554 230 177 7 0 6 19 40 21 158 143 71 8 0 3 14 32 15 126 91 106 Heather Turner and David Firth University of Warwick gnm: a Package for Generalized Nonlinear Models
  • 9. Row-Column Association Model Model diagonal effects separately and use standard multiplicative interaction log µrc = αr + βc + θr (r = c) + γr δc > RC <- gnm(Freq ~ orig + dest + Diag(orig, dest) + + Mult(-1 + orig, -1 + dest), + family = poisson, data = status) Print summary of model > summary(RC) Heather Turner and David Firth University of Warwick gnm: a Package for Generalized Nonlinear Models
  • 10. Row-Column Association Model Summary Call: ... Deviance Residuals: ... Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) 0.19649 NA NA NA orig2 0.46730 NA NA NA ... orig8 1.15890 NA NA NA orig main effects dest2 0.98771 NA NA NA ... dest8 1.67662 NA NA NA dest main effects Diag(orig, dest)1 1.47923 0.45401 3.258 0.00112 ** ... diagonal effects Diag(orig, dest)8 0.40731 0.21930 1.857 0.06327 . Mult1.Factor1.orig1 1.80430 NA NA NA ... orig multiplier Mult1.Factor1.orig8 -1.48489 NA NA NA Mult1.Factor2.dest1 1.23943 NA NA NA ... dest multiplier Mult1.Factor2.dest8 -0.82438 NA NA NA ... Residual deviance: 29.149 on 28 degrees of freedom AIC: 423.49 Number of iterations: 9 Heather Turner and David Firth University of Warwick gnm: a Package for Generalized Nonlinear Models
  • 11. Homogeneous Row-Column Association Model Compare to model with homogeneous multiplicative interaction log µij = αi + βj + θij + δi δj > RChomog <- update(RC, . ~ . - Mult(-1 + orig, -1 + dest) + + Nonlin(MultHomog(orig, dest)), + ofInterest = "Mult") > > anova(RChomog, RC, test = "Chisq") Analysis of Deviance Table Model 1: Freq ~ orig + ... + Nonlin(MultHomog(orig, dest)) Model 2: Freq ~ orig + ... + Mult(orig, dest) Resid. Df Resid. Dev Df Deviance P(>|Chi|) 1 34 32.561 2 28 29.149 6 3.412 0.756 Heather Turner and David Firth University of Warwick gnm: a Package for Generalized Nonlinear Models
  • 12. Homogeneous Model Summary > summary(RChomog) Call: gnm(formula = Freq ~ orig + dest + Diag(orig, dest) + Nonlin(MultHomog(orig, dest)), ofInterest = "Mult", family = poisson, data = status) Deviance Residuals: Min 1Q Median 3Q Max -1.6588 -0.4297 0.0000 0.3862 1.7208 Coefficients of interest: Estimate Std. Error z value Pr(>|z|) MultHomog(orig, dest).1 -1.50270 NA NA NA MultHomog(orig, dest).2 -1.28440 NA NA NA MultHomog(orig, dest).3 -0.68624 NA NA NA MultHomog(orig, dest).4 -0.10236 NA NA NA MultHomog(orig, dest).5 -0.08519 NA NA NA coefficients of interest MultHomog(orig, dest).6 0.42657 NA NA NA MultHomog(orig, dest).7 0.84271 NA NA NA MultHomog(orig, dest).8 1.08629 NA NA NA Std. Error is NA where coefficient has been constrained or is unidentified Residual deviance: 32.561 on 34 degrees of freedom AIC: 414.9 Number of iterations: 7 Heather Turner and David Firth University of Warwick gnm: a Package for Generalized Nonlinear Models
  • 13. Using getContrasts > contr <- getContrasts(RChomog, ofInterest(RChomog)) > round(contr[[1]]$qvframe, 3) estimate SE quasiSE quasiVar MultHomog(orig, dest).1 0.000 0.000 0.157 0.025 MultHomog(orig, dest).2 0.218 0.235 0.119 0.014 MultHomog(orig, dest).3 0.816 0.167 0.061 0.004 MultHomog(orig, dest).4 1.400 0.160 0.052 0.003 MultHomog(orig, dest).5 1.418 0.172 0.080 0.006 MultHomog(orig, dest).6 1.929 0.157 0.036 0.001 MultHomog(orig, dest).7 2.345 0.173 0.080 0.006 MultHomog(orig, dest).8 2.589 0.189 0.110 0.012 Quasi standard errors are independent of the parameterisation - for more detail see Firth and de Menezes (Biometrika, 2004) Heather Turner and David Firth University of Warwick gnm: a Package for Generalized Nonlinear Models
  • 14. More on gnm ... Package available on CRAN: http://cran.r-project.org demo(gnm) covers example from this talk vignette("gnmOverview", package = "gnm") covers more examples and details of further features for Mult terms: Exp, multiplicity other: Dref, eliminate, ... Vignette and slides from short course available from http://www.warwick.ac.uk/go/heatherturner/gnm Heather Turner and David Firth University of Warwick gnm: a Package for Generalized Nonlinear Models
  • 15. Further Work Integrate models which currently need work-arounds > 1 instance of homogeneous multiplicative interaction, e.g. log µij = αi + βj + θij + δi δj + θi θj “sum-of-exponentials” models, e.g. y = α + exp(β1 + γ1 x) + exp(β2 + γ2 x) + e Handle exponentials and reciprocals as standard add Exp and Inv terms allow nested nonlinear terms? Heather Turner and David Firth University of Warwick gnm: a Package for Generalized Nonlinear Models