Nonlinear Regression

Similar documents
Regression and the 2-Sample t

Dealing with Heteroskedasticity

Logistic Regression. James H. Steiger. Department of Psychology and Human Development Vanderbilt University

Diagnostics and Transformations Part 2

Activity #12: More regression topics: LOWESS; polynomial, nonlinear, robust, quantile; ANOVA as regression

22s:152 Applied Linear Regression. Take random samples from each of m populations.

22s:152 Applied Linear Regression. There are a couple commonly used models for a one-way ANOVA with m groups. Chapter 8: ANOVA

MS&E 226: Small Data

Introduction to Linear Regression

Modeling Overdispersion

Stat 5102 Final Exam May 14, 2015

Recall that a measure of fit is the sum of squared residuals: where. The F-test statistic may be written as:

Categorical Predictor Variables

Lab 3 A Quick Introduction to Multiple Linear Regression Psychology The Multiple Linear Regression Model

Example: Poisondata. 22s:152 Applied Linear Regression. Chapter 8: ANOVA

MODELS WITHOUT AN INTERCEPT

ST430 Exam 2 Solutions

22s:152 Applied Linear Regression. Chapter 8: 1-Way Analysis of Variance (ANOVA) 2-Way Analysis of Variance (ANOVA)

1 Multiple Regression

UNIVERSITY OF MASSACHUSETTS Department of Mathematics and Statistics Basic Exam - Applied Statistics January, 2018

Multiple Linear Regression. Chapter 12

Outline of GLMs. Definitions

Chapter 8 Conclusion

22s:152 Applied Linear Regression. 1-way ANOVA visual:

22s:152 Applied Linear Regression

Chapter 3: Multiple Regression. August 14, 2018

MA 575 Linear Models: Cedric E. Ginestet, Boston University Non-parametric Inference, Polynomial Regression Week 9, Lecture 2

STA 101 Final Review

Lecture 6 Multiple Linear Regression, cont.

36-707: Regression Analysis Homework Solutions. Homework 3

STAT 571A Advanced Statistical Regression Analysis. Chapter 8 NOTES Quantitative and Qualitative Predictors for MLR

Tests of Linear Restrictions

Lecture 5: Clustering, Linear Regression

General Linear Model (Chapter 4)

Regression, Part I. - In correlation, it would be irrelevant if we changed the axes on our graph.

Chapter 1 Statistical Inference

1-Way Fixed Effects ANOVA

MS&E 226: Small Data

Linear Modelling in Stata Session 6: Further Topics in Linear Modelling

Linear Regression. In this lecture we will study a particular type of regression model: the linear regression model

First Year Examination Department of Statistics, University of Florida

Statistics - Lecture Three. Linear Models. Charlotte Wickham 1.

Applied Regression Modeling: A Business Approach Chapter 3: Multiple Linear Regression Sections

Lecture 5: Clustering, Linear Regression

Multiple Regression Part I STAT315, 19-20/3/2014

Lecture 10: F -Tests, ANOVA and R 2

Inference. ME104: Linear Regression Analysis Kenneth Benoit. August 15, August 15, 2012 Lecture 3 Multiple linear regression 1 1 / 58

Lecture 5: Clustering, Linear Regression

Poisson Regression. James H. Steiger. Department of Psychology and Human Development Vanderbilt University

STAT 510 Final Exam Spring 2015

Psychology 282 Lecture #4 Outline Inferences in SLR

Multiple Regression: Example

Myths about the Analysis of Change

Multiple Linear Regression

Lecture 18: Simple Linear Regression

Simple Linear Regression

Dr. Junchao Xia Center of Biophysics and Computational Biology. Fall /1/2016 1/46

Chapter 7: Variances. October 14, In this chapter we consider a variety of extensions to the linear model that allow for more gen-

BIOSTATS 640 Spring 2018 Unit 2. Regression and Correlation (Part 1 of 2) R Users

CAS MA575 Linear Models

Key Algebraic Results in Linear Regression

GMM - Generalized method of moments

Explanatory Variables Must be Linear Independent...

Econometrics. 4) Statistical inference

Statistics Univariate Linear Models Gary W. Oehlert School of Statistics 313B Ford Hall

Statistics 3858 : Maximum Likelihood Estimators

NC Births, ANOVA & F-tests

1 The Classic Bivariate Least Squares Model

Week 7 Multiple factors. Ch , Some miscellaneous parts

Linear Regression Measurement & Evaluation of HCC Systems

Proportional hazards regression

Stat 401B Final Exam Fall 2015

Simple Linear Regression

Lecture 20: Multiple linear regression

Data Set 1A: Algal Photosynthesis vs. Salinity and Temperature

Applied Regression Analysis. Section 4: Diagnostics and Transformations

Part II { Oneway Anova, Simple Linear Regression and ANCOVA with R

1 Use of indicator random variables. (Chapter 8)

The Matrix Algebra of Sample Statistics

POLI 8501 Introduction to Maximum Likelihood Estimation

Extensions of One-Way ANOVA.

Regression. Bret Hanlon and Bret Larget. December 8 15, Department of Statistics University of Wisconsin Madison.

Nature vs. nurture? Lecture 18 - Regression: Inference, Outliers, and Intervals. Regression Output. Conditions for inference.

Linear models and their mathematical foundations: Simple linear regression

R 2 and F -Tests and ANOVA

Multiple Linear Regression

Diagnostics can identify two possible areas of failure of assumptions when fitting linear models.

Statistics. Lecture 2 August 7, 2000 Frank Porter Caltech. The Fundamentals; Point Estimation. Maximum Likelihood, Least Squares and All That

MORE ON SIMPLE REGRESSION: OVERVIEW

Final Exam. Name: Solution:

Semiparametric Regression

Statistical Estimation

Ch 2: Simple Linear Regression

Example: 1982 State SAT Scores (First year state by state data available)

Density Temp vs Ratio. temp

Lecture 17: Numerical Optimization October 2014

Scatter plot of data from the study. Linear Regression

Multiple Regression Introduction to Statistics Using R (Psychology 9041B)

Topic 1. Definitions

Extensions of One-Way ANOVA.

Transcription:

Nonlinear Regression James H. Steiger Department of Psychology and Human Development Vanderbilt University James H. Steiger (Vanderbilt University) Nonlinear Regression 1 / 36

Nonlinear Regression 1 Introduction 2 Estimation for Nonlinear Mean Functions Iterative Estimation Technique 3 Large Sample Inference 4 An Artificial Example Three Sources of Methionine 5 Bootstrap Inference The Temperature Example James H. Steiger (Vanderbilt University) Nonlinear Regression 2 / 36

Introduction Introduction A mean function may not necessarily be a linear combination of terms. Some examples: E(Y X = x) = θ 1 + θ 2 (1 exp( θ 3 x)) (1) E(Y X = x) = β 0 + β 1 ψ S (x, λ) (2) where ψ S (x, λ) is the scaled power transformation, defined as { (X λ 1)/λ if λ 0 ψ S (X, λ) = log(x ) if λ = 0 (3) Once λ has been chosen, the function becomes, in the sense we have been describing, linear in its terms, just as a quadratic in X can be viewed as linear in X and X 2. James H. Steiger (Vanderbilt University) Nonlinear Regression 3 / 36

Introduction Introduction Nonlinear mean functions often arise in practice when we have special information about the processes we are modeling. For example, consider again the function E(Y X = x) = θ 1 + θ 2 (1 exp( θ 3 x)). As X increases, assuming θ 3 > 0, the function approaches θ 1 + θ 2. When X = 0, the function value is θ 1, representing the average growth with no supplementation. θ 3 is a rate parameter. James H. Steiger (Vanderbilt University) Nonlinear Regression 4 / 36

Estimation for Nonlinear Mean Functions Estimation for Nonlinear Mean Functions Our general notational setup is straightforward. We say that E(Y X = x) = m(x, θ) (4) where m is a kernel mean function The variance function is Var(Y X = x i ) = σ 2 /w i (5) where the w i are known positive weights, and σ 2 is an unknown positive number. James H. Steiger (Vanderbilt University) Nonlinear Regression 5 / 36

Estimation for Nonlinear Mean Functions Iterative Estimation Technique Estimation for Nonlinear Mean Functions Iterative Estimation Technique Nonlinear regression is a complex topic. For example, the classic book by Seber and Wild (1989) is over 700 pages. We will discuss the Gauss-Newton algorithm without going into the mathematics in detail. On the next slide, I discuss how the algorithm works, as described by Weisberg. His account is somewhat abbreviated. James H. Steiger (Vanderbilt University) Nonlinear Regression 6 / 36

Estimation for Nonlinear Mean Functions Iterative Estimation Technique Estimation for Nonlinear Mean Functions Iterative Estimation Technique We need to minimize RSS(θ) = n w i (y i m(x i, θ)) 2 (6) This is done using Gauss-Newton iteration, with the following algorithm. 1 Choose starting values θ (0) for θ, and compute RSS(θ (0) ). 2 Set the iteration counter at j = 0. 3 Compute U(θ (j) ) and ê (j) with ith element equal to y i m(x i, θ (j) ). 4 Compute the new estimate as i=1 θ (j+1) = θ (j) + [U(θ (j) ) WU(θ (j) )] 1 U(θ (j) ) Wê (j) (7) 5 Compute RSS(θ (j+1) ). 6 If RSS(θ (j) ) RSS(θ (j+1) ) > tol 1, and j itmax and RSS(θ (j+1) ) > tol 2, go to step 3, else stop. U(θ) is a matrix of derivatives known as the score matrix. If θ has k elements, then the n k matrix U has element u ij = m(x i, θ)/ θ j evaluated at the current estimate of θ. James H. Steiger (Vanderbilt University) Nonlinear Regression 7 / 36

Estimation for Nonlinear Mean Functions Iterative Estimation Technique Estimation for Nonlinear Mean Functions Iterative Estimation Technique Generally, the Gauss-Newton algorithm will converge to a solution as long as you start reasonably close to the solution, and certain other problems do not occur. However, problems do occur, and Weisberg s account does not deal with them. In particular, in some cases, the step will be too long, and the function will not decrease because you have stepped over the point where the minimum occurs. You can tell this has happened, because the vector of derivatives of the function with respect to the values of θ will not be near zero, even though the function has increased. You have moved in the right direction, but too far. A solution to this is called backtracking. You simply multiply the step by a constant less than one, and try again with the reduced step that is going in the same direction, but not as far. Many unsophisticated algorithms use what is called step-halving. Each time you backtrack, the initial step is multiplied by 1/2 and the iteration is retried. This keeps going on until the function is reduced, or a maximum number of step-halves has occurred. James H. Steiger (Vanderbilt University) Nonlinear Regression 8 / 36

Large Sample Inference Large Sample Inference Under certain regularity conditions, the final estimate ˆθ will be approximately normally distributed, ˆθ N(θ, σ 2 [U(θ ) WU(θ )] 1 ) (8) We can obtain a consistent estimate of the covariance matrix of the estimates by substituting the estimates ˆθ in place of the true minimizing values (that we would obtain if we had the population at hand instead of the sample) in the above formula. Thus, Var( ˆθ) = ˆσ 2 [U( ˆθ) WU( ˆθ)] 1 (9) where ˆσ 2 = RSS( ˆθ) n k and k is the number of parameters estimated in the mean function. (10) James H. Steiger (Vanderbilt University) Nonlinear Regression 9 / 36

Large Sample Inference Large Sample Inference Weisberg is careful to stress that, in small samples, large-sample inferences may be inaccurate. He then goes on to investigate some examples of nonlinear regression in practice, using data on turkey growth. Let s start with a little artificial example of our own. Suppose Y and X fit the model E(Y X = x) = X 2 1 (11) with Var(Y X = x) = σ 2 We can easily create some artificial data satisfying that model prescription. James H. Steiger (Vanderbilt University) Nonlinear Regression 10 / 36

An Artificial Example An Artificial Example The following R code generates data fitting the model > x <- 1:100/10 > y <- x^2-1 + rnorm(100,0,.25) Now, suppose we suspect that the model is of the form E(Y X = x) = x θ1 θ 2, but we don t know the values for the θs. We can use nls as follows > m1 <- nls(y~x^theta1 - theta2,start=list(theta1=.5,theta2=.5)) > summary(m1) Formula: y ~ x^theta1 - theta2 Parameters: Estimate Std. Error t value Pr(> t ) theta1 2.0002158 0.0004066 4919.15 <2e-16 *** theta2 0.9531194 0.0389960 24.44 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.2797 on 98 degrees of freedom Number of iterations to convergence: 5 Achieved convergence tolerance: 1.409e-06 nls did quite well at estimating the correct structure. James H. Steiger (Vanderbilt University) Nonlinear Regression 11 / 36

An Artificial Example An Artificial Example Note that the Gauss-Newton algorithm requires derivatives, and if these derivatives do not exist or do not have real values, the method will fail. Try repeating the previous example, but with values of X extended into the negative values. > x <- -1:100/10 > y <- x^2-1 + rnorm(102,0,.25) > m2 <- nls(y~x^theta1 - theta2, + start=list(theta1=.5,theta2=.5)) The rather cryptic error message results from an inability to calculate the derivative, i.e. X θ 1 + θ 2 θ 1 = X θ 1 log(x ) (12) The derivative is when X = 0, and takes on imaginary values for negative values of X. James H. Steiger (Vanderbilt University) Nonlinear Regression 12 / 36

An Artificial Example An Artificial Example An experiment was conducted to study the effects on turkey growth of different amounts A of methionine, ranging from a control with no supplementation to 0.44% of the total diet. The experimental unit was a pen of young turkeys, and treatments were assigned to pens at random so that 10 pens get the control (no supplementation) and 5 pens received each of the other five amounts used in the experiment, for a total of 35 pens. Pen weights, the average weight of the turkeys in the pen, were obtained at the beginning and the end of the experiment three weeks later. The response variable is Gain, the average weight gain in grams per turkey in a pen. The weight gains are in the turk0 data set. The primary goal of this experiment is to understand how expected weight gain E(Gain A) changes as A is varied. James H. Steiger (Vanderbilt University) Nonlinear Regression 13 / 36

An Artificial Example An Artificial Example Here is what a plot reveals. > data(turk0) > attach(turk0) > plot(a,gain) Gain 600 650 700 750 800 0.0 0.1 0.2 0.3 0.4 A James H. Steiger (Vanderbilt University) Nonlinear Regression 14 / 36

An Artificial Example An Artificial Example We can see what appears to be an exponential function with an asymptote at around 810. A versatile asymptotic function is the two-parameter exponential augmented with an intercept, i.e. E(Gain A) = θ 1 + θ 2 (1 exp( θ 3 A)) (13) It helps to have starting values for the parameters, so let s examine the behavior of this function. The function takes on a value of θ 1 at A = 0, so θ 1 is clearly the intercept, which, we can see from the plot, is roughly 620. When A =, the function has an asymptote at θ 1 + θ 2, so θ 2 is the difference between the asymptote and θ 1. A reasonable estimate is 800 620 = 180. James H. Steiger (Vanderbilt University) Nonlinear Regression 15 / 36

An Artificial Example An Artificial Example Getting an estimate for θ 3 is more involved. One approach is to solve equations for a subset of the data. Looking at the plot, when A =.16, Gain is approximately 750, so plugging in these values along with our prior estimates for θ 1 and θ 2 gives This evaluates to 8.005837 in R. 750 = 620 + 180(1 exp( θ 3 (.16))) (14) 130 = 180(1 exp( θ 3 (.16))) (15) 130/180 1 = exp( θ 3 (.16)) (16) log(50/180) = θ 3 (.16) (17) log(50/180)/.16 = θ 3 (18) James H. Steiger (Vanderbilt University) Nonlinear Regression 16 / 36

An Artificial Example An Artificial Example We can check out how this approximation looks by adding our curve to the plot of the data. > plot(a,gain) > curve(620+180*(1-exp(-8*x)),add=t,col="red") Gain 600 650 700 750 800 0.0 0.1 0.2 0.3 0.4 A James H. Steiger (Vanderbilt University) Nonlinear Regression 17 / 36

An Artificial Example An Artificial Example The fit looks good with the starting values, so we should be able to get convergence with nls > m1 <- nls(gain ~ theta1 + theta2 * + (1 - exp(-theta3 * A)), + start=list(theta1=620,theta2=180,theta3=8)) > summary(m1) Formula: Gain ~ theta1 + theta2 * (1 - exp(-theta3 * A)) Parameters: Estimate Std. Error t value Pr(> t ) theta1 622.958 5.901 105.57 < 2e-16 *** theta2 178.252 11.636 15.32 2.74e-16 *** theta3 7.122 1.205 5.91 1.41e-06 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 19.66 on 32 degrees of freedom Number of iterations to convergence: 4 Achieved convergence tolerance: 6.736e-06 James H. Steiger (Vanderbilt University) Nonlinear Regression 18 / 36

An Artificial Example An Artificial Example Plotting the final fitted function shows only minor change from our starting values. > plot(a,gain) > curve(620+180*(1-exp(-8*x)),add=t,col="red") > curve(622.958+178.252*(1-exp(-7.122*x)),col="blue",add=t) Gain 600 650 700 750 800 0.0 0.1 0.2 0.3 0.4 A James H. Steiger (Vanderbilt University) Nonlinear Regression 19 / 36

An Artificial Example An Artificial Example Using the repeated observations at each level of A, we can perform a lack-of-fit test for the mean function. The idea, as you recall from Weisberg section 5.3, is to compare the nonlinear fit to the one-way analysis of variance, using the levels of the predictor as a grouping variable. The residual variance in ANOVA is computed and pooled strictly within-group, and consequently is a measure of error variance that does not depend on the model we fit. That estimate of variance is compared to the estimate obtained from fitting our exponential model. As the logic goes, failure to reject supports the idea that the model is reasonable. James H. Steiger (Vanderbilt University) Nonlinear Regression 20 / 36

An Artificial Example An Artificial Example > p1 <- lm(gain~as.factor(a),turk0) > xtablenew(anova(m1,p1)) Res.Df Res.Sum Sq Df Sum Sq F value Pr(>F) 1 32 12367.42 2 29 9823.60 3 2543.82 2.50 0.0789 which F = 2.50 with (3, 29) df, for a significance level of 0.08, so we cannot reject the notion that the fit appears adequate. James H. Steiger (Vanderbilt University) Nonlinear Regression 21 / 36

An Artificial Example Three Sources of Methionine An Artificial Example Three Sources of Methionine The complete turkey experiment, with data in the file turkey, actually investigated 3 sources of methionine, which we might call S 1, S 2, S 3. We wish to fit response curves separately for the 3 sources, and test whether they are different, and how well they fit. We quickly realize that, for A = 0, it doesn t matter what the source was, so the expected response is the same at A = 0 for all 3 sources. Treating the S i as dummy variables, we may write E(Gain A = a, S 1, S 2, S 3 ) = θ 1 + S 1 [θ 21 (1 exp( θ 31 a))] + S 2 [θ 22 (1 exp( θ 32 a))] + S 3 [θ 23 (1 exp( θ 33 a))] James H. Steiger (Vanderbilt University) Nonlinear Regression 22 / 36

An Artificial Example Three Sources of Methionine An Artificial Example Three Sources of Methionine Another reasonable function has common intercepts and asymptotes, but separate rate parameters: E(Gain A = a, S 1, S 2, S 3 ) = θ 1 + θ 2 {S 1 [1 exp( θ 31 a)] + S 2 [1 exp( θ 32 a)] + S 3 [1 exp( θ 33 a)]} Even more restricted is the model that specifies a common exponential function for all 3 sources: E(Gain A = a, S 1, S 2, S 3 ) = θ 1 + θ 2 (1 exp( θ 3 A)) (19) James H. Steiger (Vanderbilt University) Nonlinear Regression 23 / 36

An Artificial Example Three Sources of Methionine An Artificial Example Three Sources of Methionine We use weighted least squares nonlinear regression. > data(turkey) > tdata <- turkey > tdata <- turkey > # create the indicators for the categories of S > tdata$s1 <- tdata$s2 <- tdata$s3 <- rep(0,dim(tdata)[1]) > tdata$s1[tdata$s==1] <- 1 > tdata$s2[tdata$s==2] <- 1 > tdata$s3[tdata$s==3] <- 1 > m4a <- nls( Gain ~ th1 + th2*(1-exp(-th3*a)),weights=m, + data=tdata,start=list(th1=620,th2=200,th3=10)) > m3a <- nls( Gain ~ th1 + th2 *( + S1*(1-exp(-th31*A))+ + S2*(1-exp(-th32*A))+ + S3*(1-exp(-th33*A))),weights=m, + data=tdata,start= list(th1=620, th2=200, th31=10,th32=10,th33=10)) > m2a <- nls(gain ~ th1 + + S1*(th21*(1-exp(-th31*A)))+ + S2*(th22*(1-exp(-th32*A)))+ + S3*(th23*(1-exp(-th33*A))),weights=m, + data=tdata,start= list(th1=620, + th21=200,th22=200,th23=200, + th31=10,th32=10,th33=10)) > m1a <- nls( Gain ~ S1*(th11 + th21*(1-exp(-th31*a)))+ + S2*(th12 + th22*(1-exp(-th32*a)))+ + S3*(th13 + th23*(1-exp(-th33*a))),weights=m, + data=tdata,start= list(th11=620,th12=620,th13=620, + th21=200,th22=200,th23=200, + th31=10,th32=10,th33=10)) James H. Steiger (Vanderbilt University) Nonlinear Regression 24 / 36

An Artificial Example Three Sources of Methionine An Artificial Example Three Sources of Methionine Reproducing the ANOVA table, we see that the relaxed models don t appear to improve significantly on the most restricted model. > xtablenew(anova(m4a,m3a,m2a,m1a)) Res.Df Res.Sum Sq Df Sum Sq F value Pr(>F) 1 10 4326.08 2 8 2568.39 2 1757.69 2.74 0.1242 3 6 2040.01 2 528.38 0.78 0.5011 4 4 1151.15 2 888.85 1.54 0.3184 Note that the ANOVA method reports F values (shown in the above table) that disagree slightly with the calculations (even with the errata) in chapter 11. This is because these ANOVAs use as an estimate of error variance the model-derived estimate from the model with the smaller residual sum of squares. James H. Steiger (Vanderbilt University) Nonlinear Regression 25 / 36

An Artificial Example Three Sources of Methionine An Artificial Example Three Sources of Methionine The calculation shown in the book uses ˆσ 2 pe, the model free estimate obtained by pooling within-group variances. > sspe <- sum(tdata$sd^2*(tdata$m-1)) > dfpe <- sum(tdata$m-1) > s2pe <- sspe/dfpe > sspe; dfpe; s2pe [1] 19916 [1] 57 [1] 349.4035 James H. Steiger (Vanderbilt University) Nonlinear Regression 26 / 36

An Artificial Example Three Sources of Methionine An Artificial Example Three Sources of Methionine A test of model fit is not rejected, even for the most restricted model. The corrected calculations are shown below. > F = (4326.1/10)/s2pe > F [1] 1.238139 > 1-pf(F,10,57) [1] 0.2874172 James H. Steiger (Vanderbilt University) Nonlinear Regression 27 / 36

Bootstrap Inference Bootstrap Inference Inference methods based on large samples depends on the rate of convergence to the asumptotic result. Large sample inference depends for its accuracy on a host of factors, including the way the mean function was parameterized. Weisberg suggests bootstrapping as a way to alert oneself to situations where the large sample theory may not be working well. James H. Steiger (Vanderbilt University) Nonlinear Regression 28 / 36

Bootstrap Inference The Temperature Example Bootstrap Inference The Temperature Example The data set segreg contains data on electricity consumption in KWH and mean temperature in degrees F for one building on the University of Minnesota s Twin Cities campus for 39 months in 1988 1992. As usual, higher temperature should lead to higher consumption. (Steam heating simplifies things by essentially eliminating the use of electricity for heating.) The mean function plotted to the data is { θ 0 Temp γ E(C Temp) = θ 0 + θ 1 (Temp γ) Temp > γ The interpretation of this is pretty straightforward. What do the parameters mean? (C.P.) James H. Steiger (Vanderbilt University) Nonlinear Regression 29 / 36

Bootstrap Inference The Temperature Example Bootstrap Inference The Temperature Example The mean function can be rewritten as E(C Temp) = θ 0 + θ 1 (max(0, Temp γ)) (20) Plotting C vs. Temp (see next slide) suggests starting values of about 73,0.5, and 40 for θ 0, θ 1, and γ, respectively. James H. Steiger (Vanderbilt University) Nonlinear Regression 30 / 36

Bootstrap Inference The Temperature Example Bootstrap Inference The Temperature Example > data(segreg) > attach(segreg) > plot(temp,c) C 60 70 80 90 10 20 30 40 50 60 70 80 Temp James H. Steiger (Vanderbilt University) Nonlinear Regression 31 / 36

Bootstrap Inference The Temperature Example Bootstrap Inference The Temperature Example This can be fit easily with nls > m1 <- nls(c ~ th0 + th1*(pmax(0,temp-gamma)), + data=segreg,start=list(th0=70,th1=.5,gamma=40)) > summary(m1) Formula: C ~ th0 + th1 * (pmax(0, Temp - gamma)) Parameters: Estimate Std. Error t value Pr(> t ) th0 74.6953 1.3433 55.607 < 2e-16 *** th1 0.5674 0.1006 5.641 2.10e-06 *** gamma 41.9512 4.6583 9.006 9.43e-11 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.373 on 36 degrees of freedom Number of iterations to convergence: 2 Achieved convergence tolerance: 1.673e-08 From the plot, one might get the impression that information about the knot is asymmetric: γ could be larger than 42 but is very unlikely to be muchless than 42. We might expect that, in this case, asymptotic normal theory might be a bad approximation. James H. Steiger (Vanderbilt University) Nonlinear Regression 32 / 36

Bootstrap Inference The Temperature Example Bootstrap Inference The Temperature Example We perform B=999 bootstrap replications, and display the scatterplot matrix of parameter estimates. We use the very valuable boot.case function. > pdf("alr_fig1105.pdf", onefile=t) > set.seed(10131985) > s1.boot <- boot.case(m1,b=999) > library(car) > scatterplotmatrix(s1.boot,diagonal="histogram", + col=palette(),#[-1], + lwd=0.7,pch=".", + var.labels=c(expression(theta[1]), + expression(theta[2]),expression(gamma)), + ellipse=false,smooth=true,level=c(.90)) James H. Steiger (Vanderbilt University) Nonlinear Regression 33 / 36

Bootstrap Inference The Temperature Example Bootstrap Inference The Temperature Example 0.4 0.6 0.8 1.0 1.2 1.4 θ 1 70 72 74 76 78 0.4 0.6 0.8 1.0 1.2 1.4 Frequency θ 2 x Frequency γ 30 40 50 60 70 72 74 76 78 30 40 50 60 x James H. Steiger (Vanderbilt University) Nonlinear Regression 34 / 36

Bootstrap Inference The Temperature Example Bootstrap Inference The Temperature Example The plot displays both the substantial nonnormality of the estimates of θ 2 and γ, but also the correlation between the various parameter estimates. ALR Table 11.5 compares the estimates and confidence intervals generated by the asymptotic normal theory and the bootstrap. There are some non-negligible differences. Weisberg also provides a scatterplot matrix for bootstrapped parameter estimates from the turkey data, demonstrating that the asymptotic normal theory is much more appropriate for those data than for the temperature data. James H. Steiger (Vanderbilt University) Nonlinear Regression 35 / 36

Bootstrap Inference The Temperature Example inference is adequate here. Table 11.5 compares the estimates and confidence intervals produced by largesample theory, and by the bootstrap. The bootstrap standard errors are the standard Bootstrap Inference The Temperature Example TABLE 11.5 Comparison of Large-Sample and Bootstrap Inference for the Segmented Regression Data Large Sample Bootstrap θ 0 θ 1 γ θ 0 θ 1 γ Estimate 74.70 0.57 41.95 Mean 74.92 0.62 43.60 SE 1.34 0.10 4.66 SD 1.47 0.13 4.81 2.5% 72.06 0.37 32.82 2.5% 71.96 0.47 37.16 97.5% 77.33 0.76 51.08 97.5% 77.60 0.99 55.59 James H. Steiger (Vanderbilt University) Nonlinear Regression 36 / 36