quantile regression in r for fin and fun
play

Quantile Regression in R: For Fin and Fun Roger Koenker University - PowerPoint PPT Presentation

Quantile Regression in R: For Fin and Fun Roger Koenker University of Illinois at Urbana-Champaign R in Finance: 25 April 2009 Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 1 / 28 What is Quantile Regression?


  1. Quantile Regression in R: For Fin and Fun Roger Koenker University of Illinois at Urbana-Champaign R in Finance: 25 April 2009 Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 1 / 28

  2. What is Quantile Regression? Quantiles Describe Marginal Distributions ◮ Proportion τ of portfolio managers perform better than the τ th quantile. (Except in Lake Woebegone.) Regression Quantiles Describe Conditional Distributions ◮ Given characteristics X , proportion τ of portfolio managers of type X perform better than τ th conditional quantile. Quantiles minimize asymmetric linear loss ◮ Sorting can be replaced by optimization. Regression Quantiles also minimize asymmetric linear loss ◮ Optimization generalizes nicely to the regression setting. Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 2 / 28

  3. Sample Quantiles via Optimization The τ th sample quantile can be defined as any solution to: n � ˆ α ( τ ) = argmin a ∈ ℜ ρ τ ( y i − a ) i = 1 where ρ τ ( u ) = ( τ − I ( u < 0 )) u as illustrated below. ρ τ ( u ) τ τ − 1 Biases the argmin toward making the lower cost error; like forecasting flood crest levels. Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 3 / 28

  4. The Least Squares Meta-Model The unconditional mean solves m E ( Y − m ) 2 µ = min Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 4 / 28

  5. The Least Squares Meta-Model The unconditional mean solves m E ( Y − m ) 2 µ = min The conditional mean µ ( x ) = E ( Y | X = x ) solves m E Y | X = x ( Y − m ( x )) 2 . µ ( x ) = min Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 4 / 28

  6. The Least Squares Meta-Model The unconditional mean solves m E ( Y − m ) 2 µ = min The conditional mean µ ( x ) = E ( Y | X = x ) solves m E Y | X = x ( Y − m ( x )) 2 . µ ( x ) = min Similarly, the unconditional τ th quantile solves α τ = min a Eρ τ ( Y − a ) Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 4 / 28

  7. The Least Squares Meta-Model The unconditional mean solves m E ( Y − m ) 2 µ = min The conditional mean µ ( x ) = E ( Y | X = x ) solves m E Y | X = x ( Y − m ( x )) 2 . µ ( x ) = min Similarly, the unconditional τ th quantile solves α τ = min a Eρ τ ( Y − a ) and the conditional τ th quantile solves α τ ( x ) = min q E Y | X = x ρ τ ( Y − q ( x )) Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 4 / 28

  8. Boxplot of CEO Pay by Firm Size 100 annual compensation in millions * 10 + * * + * + + * * + * + * * + + + * 1 + 0.1 ● ● ● ● ● 0.1 1 10 100 firm market value in billions Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 5 / 28

  9. Three Applications Engel’s Law: A Classical Economic Example Infant Birthweight: A Public Health Example Melbourne Daily Temperature: A Time Series Example Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 6 / 28

  10. Engel’s Food Expenditure Data 2000 1500 Food Expenditure 1000 500 1000 2000 3000 4000 5000 Household Income Engel Curves for Food: This figure plots data taken from Engel’s (1857) study of the de- pendence of households’ food expenditure on household income. Seven estimated quantile regression lines for τ ∈ { .05, .1, .25, .5, .75, .9, .95 } are superimposed on the scatterplot. The median τ = .5 fit is indicated by the darker solid line; the least squares estimate of the conditional mean function is indicated by the dashed line. Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 7 / 28

  11. Engel’s Food Expenditure Data 800 700 Food Expenditure 600 500 400 300 400 500 600 700 800 900 1000 Household Income Engel Curves for Food: This figure plots data taken from Engel’s (1857) study of the de- pendence of households’ food expenditure on household income. Seven estimated quantile regression lines for τ ∈ { .05, .1, .25, .5, .75, .9, .95 } are superimposed on the scatterplot. The median τ = .5 fit is indicated by the darker solid line; the least squares estimate of the conditional mean function is indicated by the dashed line. Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 8 / 28

  12. A Model of Infant Birthweight Reference: Abrevaya (2001), Koenker and Hallock (2001) Data: June, 1997, Detailed Natality Data of the US. Live, singleton births, with mothers recorded as either black or white, between 18-45, and residing in the U.S. Sample size: 198,377. Response: Infant Birthweight (in grams) Covariates: ◮ Mother’s Education ◮ Mother’s Prenatal Care ◮ Mother’s Smoking ◮ Mother’s Age ◮ Mother’s Weight Gain Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 9 / 28

  13. Quantile Regression Birthweight Model I Intercept Boy Married Black -150 140 • • • • • 4000 • • • • • • • • • • • • • • • 100 • • • • 120 • • • • -200 • • • • • • • 3500 • • 100 • • • 80 • • • • • -250 • • • • • 80 • 3000 • • • 60 • • • • • • • • -300 60 • • • • • • • • • • • • 2500 • • 40 40 -350 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 Mother’s Age Mother’s Age^2 High School Some College 60 -0.4 • 50 30 • • • • • • • • • • • • • • • 50 • -0.6 40 • • 20 • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 30 • • • • -0.8 40 • 10 • • • • • • • 20 • • • • • • • • • • • • • -1.0 • 0 30 10 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 10 / 28

  14. Quantile Regression Birthweight Model II College No Prenatal Prenatal Second Prenatal Third 100 0 60 • 150 -100 • 80 • • • • • • • • • • • • • • • 100 -200 40 60 • • • • • • • • • • • 40 • -300 50 • • • • • • 20 • • • • • • • 20 • • • • -400 • • • 0 • • • • • • • • • • • • • • 0 • • • • • • • -500 • • • 0 • • • -50 -20 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 Smoker Cigarette’s/Day Mother’s Weight Gain Mother’s Weight Gain^2 -140 -2 0.1 • 40 • • • • • • • • • • • • • • -3 0.0 • • -160 • • • • • 30 • • • • • • • • • • • • • • • • • • • • • • • • -0.1 • -4 • • 20 • -180 • • • • • -0.2 • • • • -5 10 • • • • • • -0.3 -200 • • • • • • • • -6 • • • 0 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 11 / 28

  15. AR(1) Model of Melbourne Daily Temperature 40 today's max temperature 30 20 10 10 15 20 25 30 35 40 yesterday's max temperature The plot illustrates 10 years of daily maximum temperature data for Melbourne, Australia as an AR(1) scatterplot. Superimposed are estimated conditional quantile functions for τ ∈ { .05, .10, ..., .95 } . parameterized via B-splines. Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 12 / 28

  16. Conditional Densities of Melbourne Daily Temperature Yesterday's Temp 11 Yesterday's Temp 16 Yesterday's Temp 21 0.14 0.10 0.15 0.10 density density density 0.06 0.10 0.06 0.05 0.02 0.02 10 12 14 16 12 16 20 24 15 20 25 30 today's max temperature today's max temperature today's max temperature Yesterday's Temp 25 Yesterday's Temp 30 Yesterday's Temp 35 0.05 0.05 0.05 density density density 0.03 0.03 0.03 0.01 0.01 0.01 15 20 25 30 35 20 25 30 35 40 20 25 30 35 40 today's max temperature today's max temperature today's max temperature Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 13 / 28

  17. Quantile Autoregression and Irrational Exuberance Simple linear QAR models Q Y t | Y t − 1 ( τ | y t − 1 ) = α ( τ ) + β ( τ ) y t − 1 can exhibit strong unit-root or even explosive episodic tendencies, but still be stationary, and mean reverting, provided that β ( τ ) is square integrable. Copulas offer a rich source of convenient nonlinear specifications of QAR models. Similar methods yield more flexible GARCH type models. Roger Koenker (UIUC) Quantile Regression in R: For Fin and Fun R in Finance 14 / 28

Recommend


More recommend