Lecture 7 Confidence intervals

Slides:



Advertisements
Similar presentations
Analysis of multivariate transformations. Transformation of the response in regression The normalized power transformation is: is the geometric mean of.
Advertisements

SADC Course in Statistics Estimating population characteristics with simple random sampling (Session 06)
Likelihood Ratio, Wald, and Lagrange Multiplier (Score) Tests
Lecture 23: Tues., Dec. 2 Today: Thursday:
Hui-Hua Lee 1, Kevin R. Piner 1, Mark N. Maunder 2 Evaluation of traditional versus conditional fitting of von Bertalanffy growth functions 1 NOAA Fisheries,
1 1 Slide © 2003 South-Western/Thomson Learning™ Slides Prepared by JOHN S. LOUCKS St. Edward’s University.
Sampling Distributions & Point Estimation. Questions What is a sampling distribution? What is the standard error? What is the principle of maximum likelihood?
AS 737 Categorical Data Analysis For Multivariate
Inference for regression - Simple linear regression
Chapter 8 Inferences Based on a Single Sample: Tests of Hypothesis.
One-Factor Experiments Andy Wang CIS 5930 Computer Systems Performance Analysis.
Prof. Dr. S. K. Bhattacharjee Department of Statistics University of Rajshahi.
Disciplined Software Engineering Lecture #4 Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Sponsored by the U.S. Department.
Physics 114: Exam 2 Review Lectures 11-16
Lecture 8 Simple Linear Regression (cont.). Section Objectives: Statistical model for linear regression Data for simple linear regression Estimation.
Inference for Regression Simple Linear Regression IPS Chapter 10.1 © 2009 W.H. Freeman and Company.
May 2004 Prof. Himayatullah 1 Basic Econometrics Chapter 5: TWO-VARIABLE REGRESSION: Interval Estimation and Hypothesis Testing.
Testing Hypothesis That Data Fit a Given Probability Distribution Problem: We have a sample of size n. Determine if the data fits a probability distribution.
Lecture 4: Statistics Review II Date: 9/5/02  Hypothesis tests: power  Estimation: likelihood, moment estimation, least square  Statistical properties.
Maximum Likelihood Estimation Psych DeShon.
Understanding Your Data Set Statistics are used to describe data sets Gives us a metric in place of a graph What are some types of statistics used to describe.
Lecture PowerPoint Slides Basic Practice of Statistics 7 th Edition.
Brief Review Probability and Statistics. Probability distributions Continuous distributions.
How Good is a Model? How much information does AIC give us? –Model 1: 3124 –Model 2: 2932 –Model 3: 2968 –Model 4: 3204 –Model 5: 5436.
Lecture 8 Resampling inference Trevor A. Branch FISH 553 Advanced R School of Aquatic and Fishery Sciences University of Washington.
Review. Common probability distributions Discrete: binomial, Poisson, negative binomial, multinomial Continuous: normal, lognormal, beta, gamma, (negative.
Lecture 5 More maximum likelihood estimation Trevor A. Branch FISH 553 Advanced R School of Aquatic and Fishery Sciences University of Washington.
Lecture 5 More loops Introduction to maximum likelihood estimation Trevor A. Branch FISH 553 Advanced R School of Aquatic and Fishery Sciences University.
Lecture 2 Functions Trevor A. Branch FISH 553 Advanced R School of Aquatic and Fishery Sciences University of Washington.
Chapter 7 Estimation. Chapter 7 ESTIMATION What if it is impossible or impractical to use a large sample? Apply the Student ’ s t distribution.
Physics 114: Lecture 16 Least Squares Fit to Arbitrary Functions
Virtual University of Pakistan
Physics 114: Lecture 13 Probability Tests & Linear Fitting
ESTIMATION.
Practice & Communication of Science From Distributions to Confidence
Parameter Estimation and Fitting to Data
Notes on Logistic Regression
Physics 114: Exam 2 Review Weeks 7-9
Inference and Tests of Hypotheses
DISCUSSION OF MINIMUM DISTANCE ESTIMATION OF LOSS DISTRIBUTIONS BY STUART A. KLUGMAN AND A. RAHULJI PARSA CLIVE L. KEATINGE.
Lecture 8 ARIMA Forecasting II
Lecture 7 Resampling inference
A Simple Artificial Neuron
Lecture 5 More maximum likelihood estimation
Sampling Distributions & Point Estimation
Statistics in Applied Science and Technology
Likelihood Ratio, Wald, and Lagrange Multiplier (Score) Tests
From Distributions to Confidence
Inferences Regarding Population Variances
Model Estimation and Comparison Gamma and Lognormal Distributions
Physics 114: Exam 2 Review Material from Weeks 7-11
Multiple logistic regression
Statistical Methods For Engineers
Introduction to Statistics
CONCEPTS OF ESTIMATION
Algorithm An algorithm is a finite set of steps required to solve a problem. An algorithm must have following properties: Input: An algorithm must have.
CHAPTER 14: Confidence Intervals The Basics
Modelling data and curve fitting
Lecture 5, Goodness of Fit Test
Logistic Regression.
6.2 Grid Search of Chi-Square Space
The total score of the quizzes:
Contingency tables and goodness of fit
5.2 Least-Squares Fit to a Straight Line
Mathematical Foundations of BME
Some statistics questions answered:
IE 355: Quality and Applied Statistics I Confidence Intervals
Chapter 9 – Modeling Breaking Strength with Dichotomous Data
One-Factor Experiments
Presentation transcript:

Lecture 7 Confidence intervals Trevor A. Branch FISH 553 Advanced R School of Aquatic and Fishery Sciences University of Washington

Questions to answer Estimate the parameters ( , K, ) for this equation separately for males and females [done] Calculate 95% confidence intervals for asymptotic length Can we conclude that asymptotic length differs for males and females?

Likelihood profiles Likelihood profiles are a way of estimating confidence intervals for a particular model parameter when the model is fitted using maximum likelihood Statistical theory supports this approach, just accept it can be done, is valid, and works The problem: we have a model based on a set of parameters  = {X1, X2, X3, ..., Xn}. We want the 95% confidence interval for one parameter, say X1. The negative log-likelihood function is –lnL(data|)

Steps in likelihood profile Fit the full model to find the maximum likelihood estimates (MLEs) for all parameters, with corresponding lowest negative log-likelihood –lnLbest Select a wide range of values for X1 from well below to well above its MLE value: A1, A2, ..., Am Fix parameter X1 to the first of these values, A1, and find the values for all other parameters X2, X3, ..., Xn that will minimize –lnL(data|X1=A1, X2, ..., Xn) Save the resulting negative log-likelihood –lnLX1=A1 Repeat steps 3 and 4 for X1=A2, ..., X1=Am Plot –lnLX1={A} – (–lnLbest) against the values of X1

Visual likelihood profile Negative log-likelihood, fixing the parameter to each value in turn (minimize on the rest of the parameters) –lnL –lnL –lnLbest         A1 A2 A3 A4 MLE A5 A6 Am=7 Parameter of interest (X1) Alternative values for the parameter

Application to Von Bertalanffy To compute a likelihood profile for L for males Extract the data for males, fit the model and find the MLE; saving the –lnL as –lnLbest Based on the fit, select a reasonable range for L, and choose a set {A1, ..., Am} of equally spaced values in this range Fit the model fixing L to A1, minimizing over K and , store the –lnLL=A1. Repeat for A2, A3, etc., until you have the –lnL for all values in the range Plot!

Model code returning –lnL VB.NLL <- function(Linfinity, K, sigma) { gender <- "Male" LA <- read.csv(file="Data//LengthAge.csv") ages <- LA[LA$Gender==gender,]$Ages lengths <- LA[LA$Gender==gender,]$Lengths model.predL <- Linfinity*(1-exp(-K*ages)) ndata <- length(ages) NLL <- -sum(dnorm(x=lengths, mean=model.predL,sd=sigma,log=TRUE)) return(NLL) }

Finding the best –lnL require(bbmle) MLE.res <- mle2(minuslogl=VB.NLL, start=list(Linfinity=50, K=0.2, sigma=10), method="L-BFGS-B", lower=list(Linfinity=20, K=0.02, sigma=0.1), upper=list(Linfinity=500, K=1, sigma=100)) bestNLL <- -1*logLik(MLE.res)[1] bestNLL coef(MLE.res) Store the results of fitting the model Returns the lnL (not the –lnL) Accesses the best estimates for each parameter

Within each profile step When using mle2(), the start=, lower=, and upper= arguments will contain values only for K and sigma, not Linfinity since we are fixing Linfinity The fixed= option will point to the particular value of Linfinity being profiled, e.g. fixed=list(Linfinity=100) fixed=list(Linfinity=105) fixed=list(Linfinity=110)

Algorithm for obtaining profile Find the best –lnL [done] Use this to create a vector Linf.values to profile over (loop through) Find the number of elements in this vector, nLinf Create an empty vector profNLL to store the NLL values for each value in Linf.values Loop through the Linf.values values, at each step use mle2 to minimize the function Store the –lnL in element i of the profNLL vector Plot Linf.values against profNLL. Done!

In-class exercise 1: profile Starting with "7 Code template.r", create code to profile over Linfinity from 80 to 130 cm for males. If you have time, profile over females too. –lnL Linfinity (cm)

Confidence intervals Confidence intervals can be computed directly from the likelihood profile For a single parameter, the 95% confidence interval is 1.92 log-likelihood units away from the lowest negative log-likelihood Obscure technicalities: chi-square distribution with 1 degree of freedom at the 5% level is 3.84. The 1.92 is half of this and is related to the likelihood ratio test.

Computing 95% CIs Subtract –lnLbest and find the points where the resulting likelihood profile is 1.92 units away from the lowest point 95% confidence intervals –lnL – (–lnLbest) Linfinity (cm)

Using uniroot to find 95% CI The function uniroot() finds x values that result in a function y being equal to zero (i.e. the “roots” of the function) Key recognition: the likelihood profile equals zero when: –lnL – (–lnLbest) – 1.92 = 0 –lnL – (–lnLbest) – 1.92 Linfinity (cm)

Create a new function VB.uni() The function will be zero when the –lnL is 1.92 units from –lnLbest. VB.uni <- function(Linfinity, bestNLL, targetNLL=1.92) { #at this point call mle2 and extract tempNLL return(tempNLL-bestNLL-targetNLL) } VB.uni(Linfinity=97, bestNLL=bestNLL) [1] 2.022249 #testing: you should get this VB.uni(Linfinity=101, bestNLL=bestNLL) [1] -1.734966 #more testing VB.uni(Linfinity=98.5788, bestNLL=bestNLL) [1] -9.332921e-05 #close to zero

Now call uniroot() The function uniroot() searches between lower and upper for values of x that result in func(x) = 0 func <- function(x, a, b) { return(x-a) } uniroot(f=func, lower=x.LME, upper=150, a=10, b=5) uniroot(f=func, lower=80, upper=x.LME, a=10,b=5) additional function parameters added at the end uniroot will vary the first parameter until func(x, a, b)==0

–lnL – (–lnLbest) – 1.92 Linfinity (cm) Lower 95% CI: uniroot could search between these upper and lower values to find where Linfinity = 0 Upper 95% CI: uniroot could search between these upper and lower values to find where Linfinity = 0 –lnL – (–lnLbest) – 1.92 Linfinity (cm)

In-class exercise 2 Use uniroot() to find the two values of Linfinity that are targetNLL=1.92 units above the bestNLL. You should get results similar to those below for the lower root uniroot( #figure out the function call ) $root [1] 98.57871 #value of Linfinity $f.root [1] 9.664733e-09 #should be close to zero $iter [1] 6 #how often VB.uni() was called $estim.prec [1] 6.103516e-05 #precision of root

Questions to answer Estimate the parameters ( , K, ) for this equation separately for males and females [done] Calculate 95% confidence intervals for asymptotic length [done] Can we conclude that asymptotic length differs for males and females? [test: does 95% CI overlap for males vs. females]

Better way of testing part 3 (beyond scope of FISH553) Q: Does asymptotic length differ for males and females? Find NLL1 when fitting VB equation to all data combined. Find NLL2 fitting VB equation, using Linf1 for males, and Linf2 for females, but the same K value for both Calculate AIC = 2×(number of params) + 2×NLL for steps 1 and 2 Lowest AIC is the best model, so if AIC is lower from 2 then Linf is different, otherwise Linf is similar This method is covered in FISH458.