Chapter 4 Model Selection and Estimation

Chapter Description

Chapters 2 and 3 have described how to fit parametric models to frequency and severity data, respectively. This chapter begins with the selection of models. To compare alternative parametric models, it is helpful to summarize data without reference to a specific parametric distribution. Section 4.1 describes nonparametric estimation, how we can use it for model comparisons and how it can be used to provide starting values for parametric procedures. The process of model selection is then summarized in Sections 4.2 and 4.3. Although our focus is on data from continuous distributions, the same process can be used for discrete versions or data that come from a hybrid combination of discrete and continuous distributions.

Model selection and estimation are fundamental aspects of statistical modeling. To provide a flavor as to how they can be adapted to alternative sampling schemes, Sections 4.4 and 4.5 describes estimation for grouped, censored and truncated data. To see how they can be adapted to alternative models, the chapter closes with Section 4.6 on Bayesian inference, an alternative procedure where the (typically unknown) parameters are treated as random variables.

4.1 Nonparametric Inference


In this section, you learn how to:

  • Estimate moments, quantiles, and distributions without reference to a parametric distribution.

Video: Nonparametric Estimation Tools

Overheads: Nonparametric Estimation Tools (Click Tab to View)




Hide
Hide
Hide
Hide
Hide
Hide
Hide
Hide
Hide
Hide
Hide
Hide
Hide

4.1.1 Exercise. Empirical Distribution Function and Quartiles, Percentiles and Quantiles

Assignment Text

In this tutorial, you will find empirical (cumulative) distribution and quantiles for the loss. The Wisconsin Property Fund data has already been read into a data frame called Insample. These data consist of claim experience for fund members over the years 2006-2010, inclusive. It includes the claim year Year and claim loss y.

Instructions

  • Use the function ecdf() to create the empirical (cumulative) distribution for loss amount y and plot it.
  • Use the function quantile() to produce sample quantiles corresponding to the given percentiles for each year. Which year has the largest 90th percentile?


eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6Ikluc2FtcGxlIDwtIHJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL09wZW5BY3RUZXh0cy9MREFDb3Vyc2UxL21haW4vRGF0YS9JbnNhbXBsZS5jc3ZcIiwgaGVhZGVyPVQsIG5hLnN0cmluZ3M9YyhcIi5cIiksIHN0cmluZ3NBc0Zh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SBgZW1waXJpY2FsYCFcIikgJT4lIGNoZWNrX2VxdWFsKGluY29ycmVjdF9tc2c9ZW1wbXNnKVxucGxvdDFtc2c8LVwiVXNlIGBwbG90YCBvbiB0aGUgYGVtcGlyaWNhbGAgb2JqZWN0XCJcbmV4KCkgJT4lIGNoZWNrX2Z1bmN0aW9uKFwicGxvdFwiLCBub3RfY2FsbGVkX21zZz1wbG90MW1zZykgJT4lIGNoZWNrX3Jlc3VsdCgpICU+JSBjaGVja19lcXVhbChpbmNvcnJlY3RfbXNnPXBsb3QxbXNnKVxuc3VjY2Vzc19tc2coXCJXZWxsIGRvbmUhIEFzIHlvdXIgYW5hbHlzaXMgc2hvd3MsIFllYXIgMjAwNyBoYXMgdGhlIGxhcmdlc3QgOTB0aCBwZXJjZW50aWxlcy5cIikiLCJoaW50IjoiZ3JvdXBfYnkoKSB0YWtlcyBhbiBleGlzdGluZyBkYXRhIGFuZCBjb252ZXJ0cyBpdCBpbnRvIGEgZ3JvdXBlZCBkYXRhIHdoZXJlIG9wZXJhdGlvbnMgYXJlIHBlcmZvcm1lZCBieSBncm91cC5cbnN1bW1hcmlzZSgpIG91dHB1dHMgYSBzaW5nbGUgcm93IHN1bW1hcmlzaW5nIGFsbCBvYnNlcnZhdGlvbnMgaW4gdGhlIGlucHV0LiBJdCB3aWxsIGNvbnRhaW4gb25lIGNvbHVtbiBmb3IgZWFjaCBncm91cGluZyB2YXJpYWJsZSBhbmQgb25lIGNvbHVtbiBmb3IgZWFjaCBvZiB0aGUgc3VtbWFyeSBzdGF0aXN0aWNzIHRoYXQgeW91IGhhdmUgc3BlY2lmaWVkLlxuV2hpY2ggPGNvZGU+dHlwZTwvY29kZT4gc2hvdWxkIHdlIHVzZSBmb3IgcXVhbnRpbGUoKT8ifQ==

4.1.2 Exercise. Density Estimators

Assignment Text

Nonparametric density estimators, such as the kernel estimator, are regularly used in practice. In this tutorial, We will use the Wisconsin Property Fund data, which already has been read into a data frame called Insample, to plot a histogram and overlay density curves with various density estimators.

Instructions

  • Plot a histogram of logarithmic loss amount y.
  • Use the function density() to compute kernel density estimates.
  • Overlay density curves on top of the histogram:
    • using a blue thick curve to represent a Gaussian kernel density where the bandwidth was selected automatically using an ad hoc rule based on the sample size and volatility of these data,
    • using a green thick curve to represent a Gaussian kernel density with a bandwidth equal to 1,
    • using a red thick curve to represent a triangular kernel density with a bandwidth of 0.1.


eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6Ikluc2FtcGxlIDwtIHJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL09wZW5BY3RUZXh0cy9MREFDb3Vyc2UxL21haW4vRGF0YS9JbnNhbXBsZS5jc3ZcIiwgaGVhZGVyPVQsIG5hLnN0cmluZ3M9YyhcIi5cIiksIHN0cmluZ3NBc0ZhY3RvcnM9RkFMU0UpIiwic2FtcGxlIjoiIyBQbG90IGhpc3RvZ3JhbVxuaGlzdCg/PywgZnJlcT1GQUxTRSlcbiMgR2F1c3NpYW4ga2VybmVsIGRlbnNpdHkgLSBibHVlIGN1cnZlXG5saW5lcyhkZW5zaXR5KD8/LCBjb2w9XCJibHVlXCIsIGx3ZD0yKVxuIyBHYXVzc2lhbiBrZXJuZWwgZGVuc2l0eSB3aXRoIGEgYmFuZHdpZHRoIGVxdWFsIHRvIDEgLSBncmVlbiBjdXJ2ZVxubGluZXMoZGVuc2l0eSg/PywgYnc9Pz8pLCBjb2w9XCJncmVlblwiLCBsd2Q9MilcbiMgVHJpYW5ndWxhciBrZXJuZWwgZGVuc2l0eSB3aXRoIGEgYmFuZHdpZHRoIGVxdWFsIHRvIDAuMSAtIHJlZCBjdXJ2ZVxubGluZXMoZGVuc2l0eSg/Pywga2VybmVsPT8/LCBidz0/PyksIGNvbD1cInJlZFwiLCBsd2Q9MikiLCJzb2x1dGlvbiI6IiMgUGxvdCBoaXN0b2dyYW1cbmhpc3QobG9nKEluc2FtcGxlJHkpLCBmcmV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GNoZWNrX3Jlc3VsdCgpICU+JSBjaGVja19lcXVhbChpbmNvcnJlY3RfbXNnPWRlbnNpdHkxbXNnKVxuc3VjY2Vzc19tc2coXCJFeGNlbGxlbnQhIFRoaXMgaXMgYSB2ZXJ5IGJlYXV0aWZ1bCBncmFwaGljIHdpdGggY29sb3JzISBXZSBvYnNlcnZlZCBkaWZmZXJlbnQgZGVuc2l0eSBjdXJ2ZXMuXCIpIiwiaGludCI6IlRoZSBzeW50YXggPGNvZGU+bG9nKGRhdGEkeCk8L2NvZGU+IHByb2R1Y2VzIHRoZSBsb2dhcml0aG0gb2YgdmFyaWFibGUgPGNvZGU+eDwvY29kZT4gaW4gdGhlIGRhdGEgZnJhbWUgPGNvZGU+ZGF0YTwvY29kZT4uIn0=

4.1.3 Exercise. Comparing Poisson and Negative Binomial Distributions

In this tutorial, you will model claim count data and decide whether a Poisson\((\lambda)\) or a negative binomial\((r=3,p)\) better fits the data. Because of the number of steps involved, we split this tutorial into several distinct stages.

Assignment Text

The raw data are the number of claims filed by \(n=100\) policyholders. Recall that claim count data are discrete and take values \(0, 1, 2, \dots\). So, we consider two discrete probability models. You will apply tools learned in Section 4.1 to make a decision on which model fits these data better.

We start with exploratory data analysis, making graphical and numeric summaries of data before fitting a model.

Instructions

  • Make a table of the claims counts.
  • Make a barplot to graphically display the claims counts.
  • Compute the mean and variance of the claims count distribution. Based on these, do you think a Poisson or a negative binomial model might be better?


eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6InNldC5zZWVkKDQpXG5jbGFpbXMgPSBybmJpbm9tKG4gPSAxMDAsIHNpemUgPSAzLCBwcm9iID0gMC41KSIsInNhbXBsZSI6InRhYmxlKGNsYWltcylcbmJhcnBsb3QoPz8sIHhsYWI9XCIjIENsYWltc1wiKVxuXG5tZWFuKGNsYWltcylcbj8/KGNsYWltcykiLCJzb2x1dGlvbiI6InRhYmxlKGNsYWltcylcbmJhcnBsb3QodGFibGUoY2xhaW1zKSwgeGxhYj1cIiMgQ2xhaW1zXCIpXG5tZWFuKGNsYWltcylcbnZhcihjbGFpbXMpIiwic2N0IjoiYmFycGxvdDFtc2c8LVwiVXNlIGBiYXJwbG90YCBvbiB0aGUgYHRhYmxlKGNsYWltcylgIG9iamVjdD9cIlxuZXgoKSAlPiUgY2hlY2tfZnVuY3Rpb24oXCJiYXJwbG90XCIsIG5vdF9jYWxsZWRfbXNnPWJhcnBsb3QxbXNnKSAlPiUgY2hlY2tfcmVzdWx0KCkgJT4lIGNoZWNrX2VxdWFsKGluY29ycmVjdF9tc2c9YmFycGxvdDFtc2cpXG52YXIxbXNnPC1cIlVzZSBgdmFyYCBvbiB0aGUgYGNsYWltc2Agb2JqZWN0P1wiXG5leCgpICU+JSBjaGVja19mdW5jdGlvbihcInZhclwiLCBub3RfY2FsbGVkX21zZz12YXIxbXNnKSAlPiUgY2hlY2tfcmVzdWx0KCkgJT4lIGNoZWNrX2VxdWFsKGluY29ycmVjdF9tc2c9dmFyMW1zZylcbnN1Y2Nlc3NfbXNnKFwiQW5kIHlvdSdyZSBvZmYhICBCeSB0aGUgd2F5IC0gZGlkIHlvdSBsYWJlbCB5b3VyIGF4ZXM/XCIpIiwiaGludCI6IlRoZSBvdXRwdXQgZnJvbSB0aGUgPGNvZGU+dGFibGUoKTwvY29kZT4gZnVuY3Rpb24gY2FuIGJlIHVzZWQgYXMgYW4gYXJndW1lbnQgaW4gdGhlIDxjb2RlPmJhcnBsb3QoKTwvY29kZT4gZnVuY3Rpb24ifQ==

Observe that the distribution is heavily right-skewed, and the sample variance is much larger than the sample mean. You may recall that if \(X \sim\) Poisson\((\lambda)\), \[ \mathrm{E}(X) = \mathrm{Var}(X) = \lambda. \] We would expect the sample mean and sample variance to be roughly equal if the claims data came from the Poisson… our first clue this distribution may not be best!

Instructions

  • Fit the Poisson distribution by estimating \(\lambda\) using maximum likelihood estimation.
  • Make a \(qq\) plot comparing the observed data to the fitted Poisson.

Fitting the distribution involves estimating the parameter \(\lambda\). Do you recall the maximum likelihood estimator for a Poisson? If not, this is shown in the companion video for this tutorial.


eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6InNldC5zZWVkKDQpXG5jbGFpbXMgPSBybmJpbm9tKG4gPSAxMDAsIHNpemUgPSAzLCBwcm9iID0gMC41KVxuI0luc2FtcGxlIDwtIHJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL09wZW5BY3RUZXh0cy9MREFDb3Vyc2UxL21haW4vRGF0YS9JbnNhbXBsZS5jc3ZcIiwgaGVhZGVyPVQsXG4jICAgICAgICAgICAgICAgICAgICAgIG5hLnN0cmluZ3M9YyhcIi5cIiksIHN0cmluZ3NBc0ZhY3RvcnM9RkFMU0UpIiwic2FtcGxlIjoibGFtYmRhID0gPz9cbmxhbWJkYVxuXG4jIyBtYWtlIHRoZSBxdWFudGlsZXNcbnA9c2VxKDAuMDEsMC45OSwgYnk9MC4wMSlcbnFwID0gcXBvaXMocCwgbGFtYmRhPTMpXG5cbiMjIGNvbXB1dGUgdGhlIHF1YW50aWxlc1xucWNsYWltcyA9IHF1YW50aWxlKD8/LCBwKVxuXG4jIyBNYWtlIGEgcGxvdCAoYW5kIGxhYmVsIGF4ZXMhKVxucGxvdCg/PywgPz8sIHlsaW09YygwLDEyKSx4bGltPWMoMCwxMiksIHhsYWI9XCJNb2RlbCBRdWFudGlsZXNcIiwgeWxhYj1cIkVtcGlyaWNhbCBRdWFudGlsZXNcIilcbmFibGluZSgwLDEpIiwic29sdXRpb24iOiJsYW1iZGEgPSBtZWFuKGNsYWltcylcbmxhbWJkYVxuXG4jIyBtYWtlIHRoZSBxdWFudGlsZXNcbnByPXNlcSgwLjAxLDAuOTksIGJ5PTAuMDEpXG5xcCA9IHFwb2lzKHByLCBsYW1iZGE9MylcblxuIyMgY29tcHV0ZSB0aGUgcXVhbnRpbGVzXG5xY2xhaW1zID0gcXVhbnRpbGUoY2xhaW1z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TUxFIGZvciBhIFBvaXNzb24gaXMganVzdCB0aGUgc2FtcGxlIG1lYW4hPC9wPlxuXG48cD5TaG91bGQgeW91IGJydXNoIHVwIG9uIHRoZSAgPGEgaHJlZj1cImh0dHBzOi8vd3d3LnJkb2N1bWVudGF0aW9uLm9yZy9wYWNrYWdlcy9iYXNlL3ZlcnNpb25zLzMuNi4yL3RvcGljcy9xdWFudGlsZVwiPnF1YW50aWxlPC9hPiBmdW5jdGlvbj8ifQ==

Do you notice how the empirical quantiles do not match the model for some of the larger values in the right tail? This plot says the empirical quantiles are too large, that’s why they are above the diagonal line \(y=x\). Our claims data are too right-skewed, and that’s why the \(qq\) plot seems off for larger quantiles. Might the negative binomial might be more promising?

Instructions

  • Fit the negative binomial by using the method of moments estimator to estimate \(p\).
  • Make a \(qq\) plot comparing the observed data to the fitted negative binomial.

To fit the Negative Binomial(\(r=3, \beta\)), we need to estimate the parameter \(\beta\) using the method of moments. Recall that the probability mass function for a negative binomial (Sec 2.2.3.3 of Loss Data Analytics) is \[ \Pr(X = k) = \frac{(k+r-1)!}{k!(r-1)!}\left(\frac{1}{1+\beta}\right)^r \left(\frac{\beta}{1+\beta} \right)^k, \hspace{5mm} k=0, 1, ... \] with parameters \(r\) and \(\beta\). Also recall that in the method of moments we equate the \(t^{th}\) sample moment and \(t^{th}\) model moment, \[ \mathrm{E}(X^t) = \frac{1}{n}\sum_{i=1}^{n}x_{i}^t, \] where \(t=1, 2, ...\). If we use \(t=1\) to equate the first moments, we get the expression \[ \mathrm{E}(X) = r\beta = 3\beta = \overline{x} = 3 \] Solving the above for \(\beta\), we see \(\hat{\beta} = 1\). Therefore the Negative Binomial(\(r=3, \beta=1\)) is the fitted model.

Next, we use R to fit this and make a \(qq\) plot. It is important to understand that distributions are not uniquely parameterized, and there can be different conventions across fields, textbooks, and software. Indeed, in R the function defines the negative binomial as \[ \Pr(X = k) = \frac{(k+n-1)!}{(n-1)!k!}p^n(1-p)^k, \hspace{5mm} k=0, 1, ... \]

This matches the definition in the textbook by equating probability \(p = \frac{1}{1+\beta}\), and size \(r=n\). It is very important to carefully consider the parameterization of any distribution you use in R.

eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6InNldC5zZWVkKDQpXG5jbGFpbXMgPSBybmJpbm9tKG4gPSAxMDAsIHNpemUgPSAzLCBwcm9iID0gMC41KVxuI0luc2FtcGxlIDwtIHJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL09wZW5BY3RUZXh0cy9MREFDb3Vyc2UxL21haW4vRGF0YS9JbnNhbXBsZS5jc3ZcIiwgaGVhZGVyPVQsXG4jICAgICAgICAgICAgICAgICAgICAgIG5hLnN0cmluZ3M9YyhcIi5cIiksIHN0cmluZ3NBc0ZhY3RvcnM9RkFMU0UpIiwic2FtcGxlIjoicCA9ID8/XG5wcj1zZXEoMC4wMSwwLjk5LCBieT0wLjAxKVxucWIgPSBxbmJpbm9tKHByLCBzaXplPT8/LCBwcm9iID0gcClcblxuIyMgY29tcHV0ZSB0aGUgcXVhbnRpbGVzXG5xY2xhaW1zID0gcXVhbnRpbGUoY2xhaW1zLCBwcilcblxucGxvdCg/PywgPz8sIHlsaW09YygwLDEyKSwgeGxpbT1jKDAsMTIpLCB5bGFiPVwiRW1waXJpY2FsIFF1YW50aWxlc1wiLCB4bGFiPVwiTW9kZWwgUXVhbnRpbGVzXCIpXG5hYmxpbmUoMCwxKSIsInNvbHV0aW9uIjoicCA9IDAuNVxucHI9c2VxKDAuMDEsMC45OSwgYnk9MC4wMSlcbnFiID0gcW5iaW5vbShwciwgc2l6ZT0zLCBwcm9iID0gcClcblxuIyMgY29tcHV0ZSB0aGUgcXVhbnRpbGVzXG5xY2xhaW1zID0gcXVhbnRpbGUoY2xhaW1zLCBwcilcblxucGxvdChxYiwgcWNsYWltcywgeWxpbT1jKDAsMTIpLCB4bGltPWMoMCwxMiksIHlsYWI9XCJFbXBpcmljYWwgUXVh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jYW4gYmUgZWFzeSB0byBlbnRlciB0aGUgd3JvbmcgcGFyYW1ldGVycyBmb3IgYSBkaXN0cmlidXRpb24sIGVzcGVjaWFsbHkgaWYgdGhlIG5hbWVzIG9yIGRlZmluaXRpb25zIG9mIHRoZSBwYXJhbWV0ZXJzIGFyZSBub3QgdW5pdmVyc2FsbHkgYWdyZWVkIHVwb24uICBBbHdheXMgY2hlY2shIn0=

4.2 Tools for Model Selection


In this section, you learn how to:

  • Summarize the data graphically without reference to a parametric distribution.
  • Determine measures that summarize deviations of a parametric from a nonparametric fit.
  • Use nonparametric estimators to approximate parameters that can be used to start a parametric estimation procedure.

Video: Tools for Model Selection

Overheads: Tools for Model Selection (Click Tab to View)

Hide
Hide
Hide
Hide
Hide
Hide

4.2.1 Exercise. Probability-Probability (\(pp\)) plot

Assignment Text

Probability-probability (\(pp\)) plots can be used to corroborate the selection of parametric models. The Wisconsin Property Fund data has already been read into a data frame called Insample and we created subset data which contains the positive loss data called positive_loss.

In this tutorial, you will generate \(pp\) plots with Gaussian and gamma distribution. Based on the \(pp\) plots, which parametric fitted model is closer to the empirical distribution?

Instructions

  • Use the function glm(response~1,data=,family=Gamma(link=log)) to fit generalized linear model (glm) with gamma family.
    • Find the shape and rate parameters from the fitted gamma glm. (No action required on your part.)
  • Use the function glm(response~1,data=,family=gaussian(link=log)) to fit generalized linear model (glm) with Gaussian distribution.
    • Find the mean and standard deviation from the fitted Gaussian glm. (No action required on your part.)
  • Use the function ecdf() to create the empirical distribution for positive loss.
  • Use the function pgamma() to create distribution function for the gamma distribution. Generate a \(pp\) plot for the positive loss amount y using the gamma distribution.
  • Use the function pnorm() to create distribution function for the Gaussian distribution. Generate a \(pp\) plot for the positive loss amount y using Gaussian distribution.


eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6Ikluc2FtcGxlIDwtIHJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL09wZW5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mV0dGVyIHJlcHJlc2VudGF0aW9uIG9mIHRoZSBkYXRhLlwiKSIsImhpbnQiOiJXZSBzaG93IHRoZSBjb2RlIHRoYXQgdXNlcyA8ZW0+Z2xtPC9lbT4gdG8gZmluZCBwYXJhbWV0ZXJzLiJ9

Editorial Note. This exercise uses the glm() function to produce maximum likelihood estimates of certain classes of distributions including the gamma and Gaussian (normal). Section 3.5 of Loss Data Analytics employs a comparable function, vlgm(). These functions are even more useful when employed in regression modeling contexts. Although regression modeling is outside the scope of this course, the exercise provides an initial exposure to these functions that are very useful in actuarial practice.

4.2.2 Exercise. Quantile-Quantile (\(qq\)) plot

Assignment Text

The \(pp\) plot shows cumulative distribution functions, discrepancies can sometimes be difficult to detect where a fitted parametric distribution is deficient. As an alternative, it is common to use a quantile-quantile (\(qq\)) plot. The Wisconsin Property Fund data has already been read into a data frame called Insample and we also created a subset data which includes only positive loss data called positive_loss. In this exercise, parameter estimates are determined by the method of moments, in contrast to the maximum likelihood approach (with the glm function) taken in Exercise 4.2.1. This is approach is simpler and demonstrates an alternative method. Recall that we used the method of moments for the gamma distribution in Exercise 3.2.2.

In this tutorial, you will generate \(qq\) plots with Gaussian and gamma distribution. Based on the \(qq\) plot, which parametric fitted model is closer to the empirical distribution?

Instructions

  • Find sample size, mean, variance, and standard deviation for the positive loss.
  • Determine the method of moments estimators for the gamma distribution.
  • Calculate p_value, a list of probabilities used for plotting quantiles.
  • Use the function qnorm() to create the quantiles for the Gaussian distribution. Generate a \(qq\) plot for the positive loss amount y using the Gaussian distribution.
  • Use the function qgamma() to create the quantiles for the gamma distribution. Generate a \(qq\) plot for the positive loss amount y using the gamma distribution.


eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6Ikluc2FtcGxlIDwtIHJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL09wZW5BY3RUZXh0cy9MREFDb3Vyc2UxL21haW4vRGF0YS9JbnNhbX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istic

Assignment Text

For reporting results, it can be effective to supplement the graphical displays with selected statistics that summarize model goodness of fit. For background, you can learn more about the Kolmogorov-Smirnov statistic and other goodness of fit statistics in Section 4.1.2 of Loss Data Analytics.

The Wisconsin Property Fund data has already been read into a data frame called Insample. Previously, we also created a subset, positive_loss, which included only positive losses. Perform Kolmogorov-Smirnov tests.

Instructions

  • Compare the empirical positive loss amount y distribution to gamma distribution by performing the Kolmogorov-Smirnov test.
  • Use the function ks.test to perform Kolmogorov-Smirnov test.


eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6ImxpYnJhcnkoTUFTUylcbmxpYnJhcnkoc3RhdHMpXG5cbkluc2FtcGxlIDwtIHJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL09wZW5BY3RUZXh0cy9MREFDb3Vyc2UxL21haW4vRGF0YS9JbnNhbXBsZS5jc3ZcIiwgaGVhZGVyPVQsIG5hLnN0cmluZ3M9YyhcIi5cIiksIHN0cmluZ3NBc0ZhY3RvcnM9RkFMU0UpXG5cbiMgU3Vic2V0IGZvciBwb3NpdGl2ZSBsb3NzXG5wb3NpdGl2ZV9sb3NzIDwtIHN1YnNldChJbnNhbXBsZSwgeT4wKVxuXG4jIEZpdCBnYW1tYVxuZml0X2dhbW1hIDwtIGdsbShwb3NpdGl2ZV9sb3NzJHl+MSwgXG4gICAgICAgICAgICAgICAgIGRhdGE9cG9zaXRpdmVfbG9zcywgXG4gICAgICAgICAgICAgICAgIGZhbWlseT1HYW1tYShsaW5rPWxvZykpXG50aGV0YSA8LSBleHAoY29lZihmaXRfZ2FtbWEpKSpnYW1tYS5kaXNwZXJzaW9uKGZpdF9nYW1tYSkgI211PXRoZXRhL2FscGhhXG5hbHBoYSA8LSAxL2dhbW1hLmRpc3BlcnNpb24oZml0X2dhbW1hKVxuXG5nYW1tYSA8LSBwZ2FtbWEocG9zaXRpdmVfbG9zcyR5LCBzaGFwZT1hbH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jdW1lbnRhdGlvbi4gPGNvZGU+dGhldGE8L2NvZGU+LCA8Y29kZT5hbHBoYTwvY29kZT4sIGFuZCA8Y29kZT5nYW1tYTwvY29kZT4gY2FuIGJlIGZvdW5kIGluIHRoZSBwcmV2aW91cyBxdWVzdGlvbi4ifQ==

4.3 Model Selection: Likelihood Ratio Tests and Goodness of Fit

Video: Likelihood Ratio Tests and Goodness of Fit

Overheads: Likelihood Ratio Tests and Goodness of Fit (Click Tab to View)

Hide
Hide
Hide
Hide

4.4 Estimation using Modified Data: Nonparametric Approach


In this section, you learn how to:

  • Describe grouped and censored truncated data.
  • Estimate distributions nonparametrically based on grouped and censored data.

Video: Nonparametric Estimation using Modified Data

Overheads: Nonparametric Estimation using Modified Data (Click Tab to View)

Hide
Hide
Hide

4.4.1 Exercise. Kaplan-Meier Estimation based on Censored Data

Assignment Text

This exercise is based on the Wisconsin Property Fund data. These data consist of claim experience for fund members over the years 2006-2010, inclusive. A subset which includes only positive loss data has been read into a data frame called positive_loss. In part because the units of observations are governmental units, there are no upper limits on these policies. So, simply to illustrate coding for censored data, in this exercise we impose an upper limit of 50,000 on the first 100 claims as well as 100,000 on the remainder. (As an analyst, this part of the exercise could be useful to you as you test the sensitivity of policy limits.)

After adding censoring information to the data, we use Kaplan-Meier technique to estimate the claims survival distribution (recall that the survival function is one minus the distribution function).

Instructions

  • Introduce policy limits as part of the positive_loss data.
  • Create a new variable, AmountPaid, that is the smaller of the policy limit and the claim amount. In the following sample code, we show how to use the dplyr data wrangling package.
  • Also create a binary variable, UnCensored, that is one if the claim is less than or equal to the policy limit, and zero otherwise.
  • To determine the Kaplan-Meier product limit estimator, use survfit() to estimate the survival function for the right-censored empirical distribution for the positive loss amount y. Plot the result.


eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6Ikluc2FtcGxlIDwtIHJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL09wZW5BY3RU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mVtb3ZlIGBwb3NpdGl2ZV9sb3NzYCFcIikgJT4lIGNoZWNrX2VxdWFsKGluY29ycmVjdF9tc2c9cG9zaXRpdmVfbG9zc21zZylcblxuS00wbXNnIDwtIFwiRGlkIHlvdSBjb3JyZWN0bHkgc3BlY2lmeSB0aGUgb2JqZWN0IGBLTTBgP1wiXG5leCgpICU+JSBjaGVja19vYmplY3QoXCJLTTBcIiwgdW5kZWZpbmVkX21zZyA9IFwiTWFrZSBzdXJlIHRvIG5vdCByZW1vdmUgYEtNMGAhXCIpICU+JSBjaGVja19lcXVhbChpbmNvcnJlY3RfbXNnPUtNMG1zZylcblxucGxvdDRtc2c8LVwiVXNlIGBwbG90YCBvbiB0aGUgYEtNMGAgb2JqZWN0XCJcbmV4KCkgJT4lIGNoZWNrX2Z1bmN0aW9uKFwicGxvdFwiLCBub3RfY2FsbGVkX21zZz1wbG90NG1zZykgJT4lIGNoZWNrX3Jlc3VsdCgpICU+JSBjaGVja19lcXVhbChpbmNvcnJlY3RfbXNnPXBsb3Q0bXNnKVxuXG5zdWNjZXNzX21zZyhcIkV4Y2VsbGVudCEgSGFuZGxpbmcgZGF0YSBpcyBhbiBpbXBvcnRhbnQgYXNwZWN0IG9mIHRoZSBhY3R1YXJpYWwgZnVuY3Rpb24uIFRoZXJlIGFyZSBtYW55IHdheXMgdG8gZG8gZGF0YSBtYW5pcHVsYXRpb24uIFlvdSB3aWxsIGZpbmQgdGhlIGZsZXhpYmlsaXR5IGFmZm9yZGVkIGJ5IGRwbHlyIHBhY2thZ2UgdG8gYmUgdGVycmlmaWMgYXMgeW91IGJlY29tZSBmYW1pbGlhciB3aXRoIGl0LlwiKSIsImhpbnQiOiJXZSB3aWxsIHVzZSA8Y29kZT5kcGx5cjwvY29kZT4gYW5kIHRyYWRpdGlvbmFsIG1ldGhvZHMgdG8gcGVyZm9ybSBkYXRhIHdyYW5nbGluZy4ifQ==

4.4.2 Exercise. Nonparametric Estimation using Truncated and Censored Information

As described in Section 4.3.2.2 of Loss Data Analytics, it is very common to have data subject to both deductibles and upper limits. As emphasized in the previous exercise, upper limits typically means that the data are censored from the right. Typically, in the presence of deductibles, the data are truncated from the left (that is, we usually don’t see a claim less than the deductible). We make that assumption for this exercise, using the data from Exercise 4.4.1 where the deductible variable is called Deduct.

With these modified data, we again estimate the survival distribution. The following code guides you through the estimation using both the Kaplan-Meier Product Limit and the Nelson-Äalen estimators. These methods are described in more detail in Section 4.3.2.2 of Loss Data Analytics.

Instructions

  • Calculate and plot the KM estimate of the survival function without deductible information, that is, as in the prior exercise.
  • Calculate and plot the KM estimate with deductible information.
  • Calculate and plot the Nelson-Äalen estimate of the survival function without deductible information.
  • Calculate and plot the Nelson-Äalen estimate with deductible information.


eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6ImxpYnJhcnkoTUFTUylcbmxpYnJhcnkoZHBseXIpXG5saWJyYXJ5KHN1cnZpdmFsKSBcblxuSW5zYW1wbGUgPC0gcmVhZC5jc3YoXCJodHRwczovL3Jhdy5naXRodWJ1c2VyY29udGVudC5jb20vT3BlbkFjdFRleHRzL0xEQUNvdXJzZTEvbWFpbi9EYXRhL0luc2FtcGxlLmNzdlwiLCBoZWFkZXI9VCwgbmEuc3RyaW5ncz1jKFwiLlwiKSwgc3RyaW5nc0FzRmFjdG9ycz1GQUxTRSlcblxuIyBTdWJzZXQgZm9yIHBvc2l0aXZlIGxvc3NcbnBvc2l0aXZlX2xvc3MgPC0gc3Vic2V0KEluc2FtcGxlLCB5PjApXG5wb3NpdGl2ZV9sb3NzIDwtIHN1YnNldChwb3NpdGl2ZV9sb3NzLCBEZWR1Y3QgPD0geSlcblxuIyBBZGQgcG9saWN5IGxpbWl0IGZvciBwb3NpdGl2ZSBsb3NzIGRhdGFcbnBvc2l0aXZlX2xvc3MkUG9saWN5TGltaXQgPC0gMTAwMDAwXG5wb3NpdGl2ZV9sb3NzJFBvbGljeUxpbWl0WzE6MTAwXSA8LSA1MDAwMFxuXG4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FN1cnYoKSB0byBjcmVhdGUgdGhlIGVtcGlyaWNhbCBkaXN0cmlidXRpb24uIn0=

4.5 Estimation using Modified Data: Parametric Approach


In this section, you learn how to:

  • Describe grouped and censored truncated data.
  • Estimate parametric distributions based on grouped, censored,and truncated data.

Video: Parametric Estimation using Modified Data

Overheads: Parametric Estimation using Modified Data (Click Tab to View)

Hide
Hide
Hide
Hide
Hide
Hide

4.6 Bayesian Inference


In this section, you learn how to:

  • Describe the Bayesian model as an alternative to the frequentist approach and summarize the five components of this modeling approach.
  • Summarize posterior distributions of parameters and use these posterior distributions to predict new outcomes.
  • Use conjugate distributions to determine posterior distributions of parameters.

Video: Bayesian Inference

Overheads: Bayesian Inference (Click Tab to View)

Hide
Hide
Hide
Hide
Hide
Hide

4.6.1 Visualizing Bayesian Methods

Assignment Text

In this tutorial, we will visually explore the prior and posterior distributions from Example 4.4.1 of Loss Data Analytics, and explore what would happen if we observed one more observation as well. Recall that for this problem, the prior distribution was \[ \pi(q) = q^3/0.07, \hspace{5mm} 0.6 \leq q \leq 0.8. \]

two observations from a Bernoulli(q) were \(X_1 = 1, X_2 = 0\), and the posterior was found (Example 4.4.1) to be \[ \pi(q \mid 1,0) = \frac{q^4 - q^5}{0.014069}. \]

Instructions

  • Make a plot() of the prior distribution.
  • Think about how you expect the observed data to reshape it to the posterior.
  • Add the posterior and a legend to your plot, to confirm the influence of the observed data. This requires advanced commands such as lines() and legend().


eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJxID0gc2VxKDAuNiwgMC44LCBieSA9IC4wMSlcbnByaW9yID0gPz9cbnBsb3QoPz8gLCA/PywgY29sPVwicmVkXCIsIHR5cGU9XCJsXCIsIHlsYWI9XCJcIikiLCJzb2x1dGlvbiI6InEgPSBzZXEoMC42LCAwLjgsIGJ5ID0gLjAxKVxucHJpb3IgPSBxXjMvMC4wN1xucGxvdChxLCBwcmlvciwgY29sPVwicmVkXCIsIHR5cGU9XCJsXCIsIHlsYWI9XCJcIikiLCJzY3QiOiJwcmlvcm1zZyA8LSBcIkRpZCB5b3UgY29ycmVjdGx5IHNwZWNpZnkgdGhlIG9iamVjdCBgcHJpb3JgP1wiXG5leCgpICU+JSBjaGVja19vYmplY3QoXCJwcmlvclwiLCB1bmRlZmluZWRfbXNnID0gXCJNYWtlIHN1cmUgdG8gbm90IHJlbW92ZSBgcHJpb3JgIVwiKSAlPiUgY2hlY2tfZXF1YWwoaW5jb3JyZWN0X21zZz1wcmlvcm1zZylcblxucGxvdDVtc2c8LVwiVXNlIGBwbG90YCBvbiB0aGUgYHEgYW5kIGBwcmlvcmAgb2JqZWN0c1wiXG5leCgpICU+JSBjaGVja19mdW5jdGlvbihcInBsb3RcIiwgbm90X2NhbGxlZF9tc2c9cGxvdDVtc2cpICU+JSBjaGVja19yZXN1bHQoKSAlPiUgY2hlY2tfZXF1YWwoaW5jb3JyZWN0X21zZz1wbG90NW1zZylcblxuc3VjY2Vzc19tc2coXCJFeGNlbGxlbnQhXCIpIiwiaGludCI6IlJlY2FsbCB0aGUgbWF0aGVtYXRpY2FsIGRlZmluaXRpb24gb2YgdGhlIHByaW9yIGRlbnNpdHkgZnVuY3Rpb24uICBQbG90IHRoaXMgYWdhaW5zdCB0aGUgc2VxdWVuY2Ugb2YgcGFyYW1ldGVyIHZhbHVlcy4ifQ==

Notice that the prior distribution sets the support for \(q\), which is bounded between 0.6 and 0.8. The posterior will necessarily have this same support. Notice also that the prior distribution places more mass for larger values of \(q\). This is saying that prior to observing data, we think larger parameters values near 0.8 are more likely than smaller values near 0.6

The observed data has a claim in year 1 (\(X_1 = 1\)) and no claim in year 2 (\(X_2 = 0\)). So, we have two independent samples drawn from a Bernoulli(q), and \(\overline{X} = 0.5\). If we were only using the likelihood and a method such as maximum likelihood estimation, we would estimate \(\widehat{q} = \overline{X} = 0.5\). So these data are telling us that values near \(q=0.5\) are consistent. But, Bayesian methods blend information from the data with information from the prior to produce a posterior. So, expect that our posterior distribution will place more mass towards smaller values of \(q\), and less towards larger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ZWNpZnkgdGhlIG9iamVjdCBgcG9zdGVyaW9yYD9cIlxuZXgoKSAlPiUgY2hlY2tfb2JqZWN0KFwicG9zdGVyaW9yXCIsIHVuZGVmaW5lZF9tc2cgPSBcIk1ha2Ugc3VyZSB0byBub3QgcmVtb3ZlIGBwb3N0ZXJpb3JgIVwiKSAlPiUgY2hlY2tfZXF1YWwoaW5jb3JyZWN0X21zZz1wb3N0ZXJpb3Jtc2cpXG5cbnBsb3Q2bXNnPC1cIlVzZSBgcGxvdGAgb24gdGhlIGBxIGFuZCBgcHJpb3JgIG9iamVjdHNcIlxuZXgoKSAlPiUgY2hlY2tfZnVuY3Rpb24oXCJwbG90XCIsIG5vdF9jYWxsZWRfbXNnPXBsb3Q2bXNnKSAlPiUgY2hlY2tfcmVzdWx0KCkgJT4lIGNoZWNrX2VxdWFsKGluY29ycmVjdF9tc2c9cGxvdDZtc2cpXG5cbnN1Y2Nlc3NfbXNnKFwiRXhjZWxsZW50ISAgTm93IHdlIGNhbiBzZWUgaG93IHRoZSBvYnNlcnZlZCBkYXRhIHNoaWZ0ZWQgb3VyIHVuZGVyc3RhbmRpbmcgb2YgdGhpcyB1bmtub3duIHBhcmFtZXRlci5cIikiLCJoaW50IjoiTWFrZSBzdXJlIHlvdSB1bmRlcnN0YW5kIHdoaWNoIGlzIHRoZSBwcmlvciBkZW5zaXR5IGFuZCB3aGljaCBpcyB0aGUgcG9zdGVyaW9yLiAgQWxzbywgbWFrZSBzdXJlIHlvdSBhcmUgaW4gdGhlIGhhYml0IG9mIGtlZXBpbmcgY29sb3JzIGFuZCBsaW5lIHR5cGVzIGNvbnNpc3RlbnQgaW4geW91ciB3b3JrLiJ9

Indeed, the posterior has shifted the mass towards lower values, balancing what the data tell us and what the prior tells us. Since this is only two data points, the shift is not especially dramatic.

Assignment Extension

Let’s continue with the prior example, but now imagine we next observe the third year, and there was again no claim, \(X_3 = 0\). We will compute the new posterior distribution, and compare it to the posterior in the previous problem.

Instructions

  • Make a plot showing the original prior, posterior from example 4.1.1, and posterior for the new case.


The posterior distribution after observing three data points is:

\[ \pi(q \mid 1,0,0) \propto f(1\mid q)f(0\mid q)f(0\mid q)\pi(q) = q(1-q)(1-q)q^3 = q^4 - 2q^5 + q^6 \]

Recall the posterior is proportional to \(q^4 - 2q^5 + q^6\), so that means \[ \pi(q \mid 1,0,0) = c \left(q^4 - 2q^5 + q^6 \right). \]

In order to find the normalizing constant \(c\), we would need to integrate this and make sure the integral is 1:

\[ \begin{array}{ll} 1 &= \int_{q=0.6}^{0.8} c \left(q^4 - 2q^5 + q^6\right)dq\\ &= c \left(\frac{1}{5}q^5 - \frac{2}{6} q^6 +\frac{1}{7} q^7 \right) \rvert_{q=0.6}^{q=0.8}\\ &= c \left( 0.0081 - 0.00400 \right)\\ &= c \left(0.0041 \right)\\ \end{array} \]

Thus, we see the normalizing constant is \(c = \frac{1}{.0041}\). We can now revisit the code and add the new posterior line:

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJxID0gc2VxKDAuNiwgMC44LCBieSA9IC4wMSlcbnByaW9yID0gcV4zLzAuMDdcbnBvc3Rlcmlvcl9vbGQgPSAocV40IC0gcV41KS8wLjAxNDA2OVxucG9zdGVyaW9yX25ldyA9ID8/XG5cbnBsb3QocSwgcHJpb3IsIGNvbD1cInJlZFwiLCB0eXBlPVwibFwiLCB5bGFiPVwiXCIpXG5saW5lcyhxLCBwb3N0ZXJpb3Jfb2xkLCBjb2w9XCJibHVlXCIsIHR5cGU9XCJsXCIsIGx0eT0yKVxubGluZXMocSwgcG9zdGVyaW9yX25ldywgY29sPVwiZ3JlZW5cIiwgdHlwZT1cImxcIiwgbHR5PTMpXG5sZWdlbmQoXCJ0b3BsZWZ0XCIsbGVnZW5kPWMoXCJQcmlvclwiLFwiT2xkIFBvc3RlcmlvclwiLFwiTmV3IFBvc3RlcmlvclwiKSwgY29sPWMoXCJyZWRcIixcImJsdWVcIiw/PyksIGx0eT1jKDEsMiwzKSkiLCJzb2x1dGlv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9yX25ld2AhXCIpICU+JSBjaGVja19lcXVhbChpbmNvcnJlY3RfbXNnPXBvc3Rlcmlvcm5ld21zZylcblxucGxvdDdtc2c8LVwiVXNlIGBwbG90YCBvbiB0aGUgYHEgYW5kIGBwcmlvcmAgb2JqZWN0c1wiXG5leCgpICU+JSBjaGVja19mdW5jdGlvbihcInBsb3RcIiwgbm90X2NhbGxlZF9tc2c9cGxvdDdtc2cpICU+JSBjaGVja19yZXN1bHQoKSAlPiUgY2hlY2tfZXF1YWwoaW5jb3JyZWN0X21zZz1wbG90N21zZylcblxuc3VjY2Vzc19tc2coXCJOaWNlIVwiKSJ9

As expected, the new posterior has shifted even more mass towards lower parameter values in the posterior, since \(\overline{X} = \frac{1}{3}\) and the data are more consistent with low parameter values for \(q\).

Contributors

  • Authors. Rob Erhardt, Wake Forest University, Brian Hartman, Brigham Young University, and Zhiyu (Frank) Quan, University of Illinois at Urbana-Champaign, are the principal authors of the initial version of this chapter.
  • Chapter Maintainers. Please contact Frank at and/or Jed at for chapter comments and suggested improvements.