940 likes | 1.62k Views
Introduction to Generalized Linear Models. Prepared by Louise Francis Francis Analytics and Actuarial Data Mining, Inc. October 3, 2004. Objectives. Gentle introduction to Linear Models and Generalized Linear Models Illustrate some simple applications
E N D
Introduction to Generalized Linear Models Prepared by Louise Francis Francis Analytics and Actuarial Data Mining, Inc. October 3, 2004
Objectives • Gentle introduction to Linear Models and Generalized Linear Models • Illustrate some simple applications • Show examples in commonly available software • Which model(s) to use? • Practical issues
A Brief Introduction to Regression • One of most common statistical methods fits a line to data • Model: Y = a+bx + error • Error assumed to be Normal
A Brief Introduction to Regression • Fits line that minimizes squared deviation between actual and fitted values
Excel Does Regression • Install Data Analysis Tool Pak (Add In) that comes with Excel • Click Tools, Data Analysis, Regression
Goodness of Fit Statistics • R2: (SS Regression/SS Total) • percentage of variance explained • F statistic: (MS Regression/MS Resid) • significance of regression • T statistics: Uses SE of coefficient to determine if it is significant • significance of coefficients • It is customary to drop variable if coefficient not significant • Note SS = Sum squared of errors
Assumptions of Regression • Errors independent of value of X • Errors independent of value of Y • Errors independent of prior errors • Errors are from normal distribution • We can test these assumptions
Other Diagnostics: Residual Plot • Points should scatter randomly around zero • If not, a straight line probably is not be appropriate
Other Diagnostics: Normal Plot • Plot should be a straight line • Otherwise residuals not from normal distribution
Test for autocorrelated errors • Autocorrelation often present in time series data • Durban – Watson statistic: • If residuals uncorrelated, this is near 2
Durban Watson Statistic • Indicates autocorrelation present
Non-Linear Relationships • The model fit was of the form: • Severity = a + b*Year • A more common trend model is: • SeverityYear=SeverityYear0*(1+t)(Year-Year0) • T is the trend rate • This is an exponential trend model • Cannot fit it with a line
Transformation of Variables • SeverityYear=SeverityYear0*(1+t)(Year-Year0) • Log both sides • ln(SevYear)=ln(SevYear0)+(Year-Year0)*ln(1+t) • Y = a + x * b • A line can be fit to transformed variables where dependent variable is log(Y)
Exponential Trend – Cont. • R2 declines and Residuals indicate poor fit
A More Complex Model • Use more than one variable in model (Econometric Model) • In this case we use a medical cost index and the consumer price index to predict workers compensation severity
Regression Output cont. • Standardized residuals more evenly spread around the zero line – but pattern still present • R2 is .84 vs .52 of simple trend regression • We might want other variables in model (i.e, unemployment rate), but at some point overfitting becomes a problem
Multicollinearity • Predictor variables are assumed uncorrelated • Assess with correlation Matrix
Remedies for Multicollinearity • Drop one of the highly correlated variables • Use Factor analysis or Principle components to produce a new variable which is a weighted average of the correlated variables
Exponential Smoothing • A weighted average with more weight given to more recent values • Linear Exponential Smoothing: model level and trend
Tail Development Factors: Another Regression Application • Typically involve non-linear functions: • Inverse Power Curve: • Hoerel Curve: • Probability distribution such as Gamma, Lognormal
Example: Inverse Power Curve • Can use transformation of variables to fit simplified model: LDF=1+k/ta • ln(LDF-1) =a+b*ln(1/t) • Use nonlinear regression to solve for a and c • Uses numerical algorithms, such as gradient descent to solve for parameters. • Most statistics packages let you do this
Nonlinear Regression: Grid Search Method • Try out a number of different values for parameters and pick the ones which minimize a goodness of fit statistic • You can use the Data Table capability of Excel to do this • Use regression functions linest and intercept to get k and a • Try out different values for c until you find the best one
Fitting Non-linear functions • Another approach is to use a numerical method • Newton-Raphson (one dimension) • xn+1 = xn – f’(xn)/f’’(xn) • f(xn) is typically a function being maximized or minimized, such as squared errors • x’s are parameters being estimated • A multivariate version of Newton_Raphson or other algorithm is available to solve non-linear problems in most statistical software • In Excel the Solver add-in is used to do this
Claim Count Triangle Model • Chain ladder is common approach
Claim Count Development • Another approach: additive model • This model is the same as a one factor ANOVA
Regression With Dummy Variables • Let Devage24=1 if development age = 24 months, 0 otherwise • Let Devage36=1 if development age = 36 months, 0 otherwise • Need one less dummy variable than number of ages
Apply Logarithmic Transformation • It is reasonable to believe that variance is proportional to expected value • Claims can only have positive values • If we log the claim values, can’t get a negative • Regress log(Claims+.001) on dummy variables or do ANOVA on logged data
Poisson Regression • Log Regression assumption: errors on log scale are from normal distribution. • But these are claims – Poisson assumption might be reasonable • Poisson and Normal from more general class of distributions: exponential family of distributions
Specific Members of the Exponential Family • Normal (Gaussian) • Poisson • Negative Binomial • Gamma • Inverse Gaussian
Some Other Members of the Exponential Family • Natural Form • Binomial • Logarithmic • Compound Poisson/Gamma (Tweedie) • General Form [use ln(y) instead of y] • Lognormal • Single Parameter Pareto
Poisson Distribution • Poisson distribution: • Natural Form: • “Over-dispersed” Poisson allows 1. • Variance/Mean ratio =
Linear Model vs GLM • Regression: • GLM:
The Link Function • Like transformation of variables in linear regression • Y=AXB is transformed into a linear model • log(Y) = log(A) + B*log(X) • This is similar to having a log link function: • h(Y) = log(Y) • denote h(Y) as n • n = a+bx
Other Link Functions • Identity • h(Y)=Y • Inverse • h(Y) = 1/Y • Logistic • h(Y)=log(y/(1-y)) • Probit • h(Y) =
The Other Parameters: Poisson Example Link function