Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 7. What to Optimize? In this session: 1.Can one do better by optimizing something else? 2.Likelihood, not LS? 3.Using a handful of likelihood functions.

Similar presentations


Presentation on theme: "1 7. What to Optimize? In this session: 1.Can one do better by optimizing something else? 2.Likelihood, not LS? 3.Using a handful of likelihood functions."— Presentation transcript:

1 1 7. What to Optimize? In this session: 1.Can one do better by optimizing something else? 2.Likelihood, not LS? 3.Using a handful of likelihood functions. CH1. What is what CH2. A simple SPF CH3. EDA CH4. Curve fitting CH5. A first SPF CH6: Which fit is fitter CH7: Choosing the objective function CH8: Theoretical stuff Ch9: Adding variables CH10. Choosing a model equation SPF workshop February 2014, UBCO

2 2 Perhaps the fit was bad because: The function is not good Important traits are missing The objective function is not appropriate later Now The two common methods:  Least Squares  Maximum Likelihood Carl Friedrich Gauss 1777-1855 Sir Ronald Fisher 1890-1962

3 SPF workshop February 2014, UBCO3 Introducing ‘Likelihood’ In statistics, maximum-likelihood estimation (MLE) is a method of estimating the parameters of a statistical model. When applied to a data set and given a statistical model, maximum-likelihood estimation provides estimates for the model's parameters.estimatingparametersstatistical model statistical modelestimates From Wikipedia Popular in SPF modeling

4 SPF workshop February 2014, UBCO4 Year1234 Crashes1740 What is the probability of 1, 7, 4, 0 if μ=2.0 crashes/year? Open #9. ‘Likelihood functions’ on ‘Poisson’ workpage Example 1: Get the ML estimate of a 

5 The likelihood of μ=4.0 The likelihood of μ=2.0 The ‘Likelihood Function’ ℒ(.) will be used to denote a likelihood function. The dot in the parenthesis is a placeholder for parameters. Thus, e.g., ℒ(μ) is the is the likelihood function of μ. 5

6 6 Computing likelihood at very many μ’s we would see a smooth curve - the ‘likelihood function’. Probability to observe 1, 7,4 and 0 accidents The  at which Observing 1 & 7 &4 & 0 is most probable SPF workshop February 2014, UBCO

7 7 The parameter value at which the likelihood function has its peak is the ‘Maximum Likelihood’ (ML) estimate of that parameter. It is not the most probable value of the parameter. It is the parameter value at which the observations are most probable. SPF workshop February 2014, UBCO

8 8 Return to #9 on the ‘Poisson ML’ workpage The ‘Target’ cell The ‘By Changing’ cell Use ‘Solver’ With the 1, 7, 4, 0 crash record, which μ is most likely? Show that ML estimate of  is 3.00.

9 Example 2: What distribution fits the data? Number of drivers out of 29531 who, during 1931-1936 had 1 accident. Continue now to the ‘Does the Poisson fit’ workpage. The Data If all drivers had the same  then one would expect n(k) to be consistent with the Poisson distribution. Is it? 9SPF workshop February 2014, UBCO

10 10 Here the Poisson predicts too few crashes If Poisson was a good fit Answer:.... SPF workshop February 2014, UBCO

11 What distribution does fit the data? Continue to the ‘NegBin ML Empty’ workpage in #9. NB applies to populations of units where each unit may have a different  and the  ’s are Gamma distributed Poisson applies to population of units that all have the same  11

12 12 1781-1840 1817-1951 Parameters to be estimated Will NB fit the data?

13 13 Question 1: What are the ML estimates of ‘a’ and ‘b’? (both must be positive) Question 2: With these ‘a’ and ‘b’ how good is the correspondence between the observed and fitted n(k) SPF workshop February 2014, UBCO

14 14 The likelihood function is the product of many small probabilities. To avoid computational difficulties we use the log-likelihood ‘product’ replaced by ‘sum’. Initial guesses Preparing the likelihood function for Solver SPF workshop February 2014, UBCO

15 15 The probability than n(k) units have k accidents is P(K=k) n(k) The log-likelihood is the sum over all k of n(k)ln[P(K=k)] Now we are ready to estimate ‘a’ and ‘b’ B*C SPF workshop February 2014, UBCO

16 16 ‘a’ and ‘b’ must be non-negative ML estimates Does this NB fit the data?

17 SPF workshop February 2014, UBCO17 Was the NB assumption for populations reasonable? Numbers expected if NB and parameters both were true. (By method of moments in 1.4 we got 3.55 and 0.85)

18 SPF workshop February 2014, UBCO18 Now the ground is ready: The Poisson Likelihood function for SPF curve-fitting Chapter 8 Replace by and you have a function of. Now you can find values of which make the log-likelihood largest. Does not matter

19 19 The C-F spreadsheet for Poisson likelihood function. Go to: #10.Poisson fit (Full).xlsx on ‘Poisson’ workpage Our model equation (for now) Sum of log-likelihoods Formula:=-E8+D8*LN(E8), copy down

20 Very similar to OLS, No point in CURE SOLVER solution Click

21 21 The Poisson L-F solves the ‘equal variances’ problem. However, it has a problem of its own – no overdispersion. The Negative Binomial Likelihood Function To illustrate, 91 of 5323 segments are 0.01 miles long. For these, Sample Variance of accident counts =0.114, Sample Mean of accident counts =0.098. If Poisson, Variance=Mean If Variance>Mean, Overdispersion, not Poisson SPF workshop February 2014, UBCO

22 22 (Sample variance)/(Sample Mean) Segment Length [miles] 50 segment length bins If Poisson

23 23 The NB Likelihood Function continued PoissonNegative Binomial Crash Counts for each unit are Poisson distributed Units with the same traits in the model equation have the same μ Units with the same traits in the model equation have μ’s that comes from a Gamma distribution Assumptions: Common and Different SPF workshop February 2014, UBCO

24 24 The Gamma pdf can take on a variety of shapes. Limitations. E{μ}=b/a, VAR{μ}=(E{μ}) 2 /b For many populations NB fits. Ergo: Gamma is often OK.

25 SPF workshop February 2014, UBCO25 Go to #11 NB fit.xlsx Our model equation (for now) Implementing the NB on a C-F spreadsheet. Log-likelihood for segment 1 Sum of log-likelihoods

26 26 Details in text Modifying the Poisson C-F spreadsheet to NB =IF(OR(B8<=0,C8<=0,E8<=0),0,GAMMALN(D8+$G$2*B8)- GAMMALN($G$2*B8)+$G$2*B8*LN($G$2*B8)+D8*LN(E8)- ($G$2*B8+D8)*LN($G$2*B8+E8)) Add cell for new parameter

27 Very similar to OLS, and Poisson SOLVER solution 27

28 SPF workshop February 2014, UBCO28 Example of use: What are the estimates of E{μ} and VAR{μ} for a 0.7 mile long segment (Colorado, two-lane,...)? Answer: Estimate of E{μ}=1.636 × 0.7 0.871 =1.20 I&F crashes in 5 years; V{μ i }=(E{μ i }) 2 /b i and b i = ×L i Estimate of VAR{μ}=1.20 2 /(0.531*0.7)=3.87 (I&F...) 2 1.20±1.97, must reduce uncertainty!

29 SPF workshop February 2014, UBCO29 In this session we asked: What to Optimize? Traditionally: 1.Minimize (weighted) SSD 2.Maximize Likelihood Both are motivated by focus on parameters When the focus is on ‘How to predict well’, other criteria emerge: 1.Minimize absolute deviations 2.Minimize Total Absolute Bias 3.Minimize, etc. In lecture notes.

30 SPF workshop February 2014, UBCO30 Summary for Chapter 7. 1.Instead of minimizing SSD (which gave poor fits), we asked whether fit is improved by maximizing likelihood; 2.Likelihood was explained and illustrated; 3.To write a likelihood function one must make assumptions. The assumptions behind the Poisson and NB likelihoods were discussed; 4.We used the Poisson likelihood function. The fit was not improved. 5. One of the assumptions behind the Poisson likelihood is not realistic. The NB likelihood function removes the blemish.

31 SPF workshop February 2014, UBCO31 6.The estimate of the shape parameter ‘b’ is needed for tasks such as blackspot identification and EB safety estimation; 7.The fit is still not very good. Can it be improved by using a better model equation?


Download ppt "1 7. What to Optimize? In this session: 1.Can one do better by optimizing something else? 2.Likelihood, not LS? 3.Using a handful of likelihood functions."

Similar presentations


Ads by Google