Presentation is loading. Please wait.

Presentation is loading. Please wait.

Nonlinear function minimization (review). Newton’s minimization method Ecological detective p. 267 Isaac Newton We want to find the minimum value of f(x)

Similar presentations


Presentation on theme: "Nonlinear function minimization (review). Newton’s minimization method Ecological detective p. 267 Isaac Newton We want to find the minimum value of f(x)"— Presentation transcript:

1 Nonlinear function minimization (review)

2 Newton’s minimization method Ecological detective p. 267 Isaac Newton We want to find the minimum value of f(x)

3 Golden section search L = 0U = 1x1x1 x2x2 L = x 1 x2x2 x3x3 U = 1L = x 2 x3x3 x4x4 Step 1 Step 2 Step 3

4 Simplex approach This is a very sophisticated form of hill climbing, and is derivative-free. Algorithm called “amoeba”. Source: http://optics.nuigalway.ie/people/larry/

5 Simulated annealing Randomly jump to a new spot, if it is better then stay there, if it is worse, go back to initial jump Source: http://www.stanford.edu/~hwang41/

6 Complications with model fitting Parameter confounding (correlations) Problems with numerical derivatives Non-continuous problems Integer parameters Multiple minima Constrained parameters

7 Transform bounded parameters to unbounded using Then let Solver search over x, but use y in the model equations 6 atan_demo.xlsx

8 Arctan transformation 6 atan_demo.xlsx

9 Hints for minimization Constrain population sizes to not go negative Bound parameters in code using ABS or ATAN Particularly problematic are multiple proportions that must add to 1 –Fix each p to be 1-sum of the previous ones In Solver set convergence criteria smaller Keep away from extremely small or extremely large values

10 Conclusions Non-linear minimization is as much art as science You cannot just plug numbers into a program and hope for the best, you must make checks to assure convergence Takes time and experience, but is well rewarded

11 Probability distributions and likelihood

12 Readings Ecological detective: –Chapter 3 Probability distributions Wikipedia (seriously!) –e.g. Beta distribution, lognormal distribution, etc.

13 Overview Probability vs. likelihood Probability distributions: binomial, poisson, normal, lognormal, negative binomial, beta, gamma, multinomial Likelihood profile The concept of support Model selection, likelihood ratio, AIC Robustness Contradictory data

14 Probability If I flip a fair coin 10 times, what is the probability of it landing heads up every time? Given the fixed parameter (p = 0.5), what is the probability of different outcomes? Probabilities add up to 1. I flipped a coin 10 times and obtained 10 heads. What is the likelihood that the coin is fair? Given the fixed outcomes (data), what is the likelihood of different parameter values? Likelihoods do not add up to 1. Hypotheses (parameter values) are compared using likelihood values (higher = better). Likelihood

15 Probability What is the probability that 5 ≤ x ≤ 10 given a normal distribution with µ = 13 and σ = 4? Answer: 0.204 What is the probability that –1000 ≤ x ≤ 1000 given a normal distribution with µ = 13 and σ = 4? Answer: 1.000 What is the likelihood that µ = 13 and σ = 4 if you observed a value of (a)x = 10 (answer: the likelihood is 0.075) (b)x = 14 (answer: the likelihood is 0.097) Conclusion: if the observed value was 14, it is more likely that the parameters are µ = 13 and σ = 4, because 0.097 is higher than 0.075. Likelihood Area under curve between 5 and 10 Height of curve at x = 14 Height of curve at x = 10

16 We use the same (normal) probability distribution function for both probability and likelihood!

17 Common probability distributions Discrete: binomial, Poisson, negative binomial, multinomial Continuous: normal, lognormal, beta, gamma, (negative binomial)

18 7 distributions.xlsx Examples of all distributions defined here, including excel functions and functions defined directly in the spreadsheet

19 Binomial probability distribution Number of trials Number of successes Probability of success [0,1] The “factorial term” How many ways are there of selecting k objects from among N objects Example: probability of getting k = 5 heads when flipping a coin N = 10 times, if the coin is fair (p = 0.5). Note: known number of trials.

20 SD and CV (all distributions)

21 Poisson probability distribution Number of events Expected number of events Example: On average there are λ = 9.4 fatal traffic accidents in Washington State every week. What is the probability that there would be k = 0 in a week? (Note: rare event out of large number of possible events.)

22 Limitations of Poisson Has only one parameter, which is both the mean and the variance We often have discrete count data, but in real-life data the variance is often larger than predicted by the Poisson

23 Thus we often use the negative binomial Closely related to the Poisson and binomial One extra parameter related to the variance VERY useful Looks scary, but don’t be scared!

24 Standard negative binomial Number of successes Number of failures Probability of a success Example: a factory makes widgets successfully with probability p. How many successful widgets have been made when r = 3 failed widgets have been made. The distribution predicts the probability of k = 0, 1, 2, … successful widgets being made. Squint a lot and this looks kind of like a binomial

25 Ecological usefulness? Almost no ecological problems can be thought of as successes or failures in this way Great for factory production problems But we want a function with parameters for –Mean –Overdispersion (increased variance = increased chance of extreme events) Integer events are rare in nature, we want to deal with real numbers

26 Practitioner’s negative binomial Predicted mean As θ increases, variance increases, hence “overdispersion” As θ → ∞, var(Z) → ∞ As θ → 0, var(Z) = λ, just like a Poisson! Example: our data contain observations k, with mean λ and variance greater than λ. Find the value of overdispersion θ that best accounts for this increased variance. Overdispersion parameter Gamma function (factorial that accepts non-integers, see later)

27 Weird facts about the practitioner’s negative binomial When θ → 0 this doesn’t just smell like a Poisson, and act like a Poisson, it is the Poisson (advanced stats) By replacing the factorials with gamma functions, the r and k can be real numbers not just integers What on earth is a gamma function???

28 Gamma function Γ() A generalized factorial function that accepts real numbers not just integers Excel: does not have a gamma function but has a ln of gamma function (GAMMALN)

29 Multinomial probability distribution Example: fitting a model to proportions at age (or proportions at length) data. Model produces predicted proportions p i and data gives observed numbers x i in each category. Total numbers sampled = n = x 1 + x 2 + … + x k Predicted proportion in category k Observed number in category k Total number observed

30

31 Unrealism of multinomial (and other distributions too!) Assumes every sampling event is completely independent But there is much correlation in reality –Same trawl, area, time of day, day of year, gender, etc. Real data never ever fit a multinomial this well Later lectures will introduce the concept of “effective sample size” n eff, which will be smaller than reported sample size n.

32 Normal distribution

33 Lognormal distribution

34 Lognormal: key notes 0 < x < ∞ Mean(x) is not µ If we want the mean to be µ, then replace the model parameter with: Used widely for abundance and biomass

35 Beta distribution 0.5,0.5 1,1 1.3,1.3 4,4 50,50 2,60.5,2

36 Beta: key notes Values confined to be 0 < x < 1 Can mimic almost any shape within those bounds Although bounded, can change the bounds by multiplying / dividing x values E.g. survival parameters

37 Gamma distribution 4, 1 4, 2 1.1, 0.5 0.9, 0.0001 60, 5

38 Gamma: key notes 0 ≤ x < ∞ Somewhat like an exponential, lognormal, or normal Flexibility without being bounded like the beta distribution E.g. salmon arrival numbers plotted over time Excel function beta.dist() assumes parameters α* = α and β* =1/β


Download ppt "Nonlinear function minimization (review). Newton’s minimization method Ecological detective p. 267 Isaac Newton We want to find the minimum value of f(x)"

Similar presentations


Ads by Google