Variance & Regression, May 2008 - kustaff.pubhealth.ku.dk/~pd/V+R/slides/nonlin.pdfWhat do we...

Preview:

Citation preview

Nonlinear regression analysis

Peter Dalgaard (orig. Lene Theil Skovgaard)

Department of BiostatisticsUniversity of Copenhagen

Variance & Regression, May 2008

Nonlinear regression

I Simple kinetic modelI Compartment modelsI Michaelis Menten reactionI Dose-response relationships

How can we model non-linear effects?

I Polynomials tend to be very wiggly(use ’i=rq’ or ’i=rc’ in the symbol-statement)

I Splinespiecewise interpolations, often linear or cubic

Polynomial regression

Yi = β0 + β1xi + β2x2i + · · ·+ βpxp

i

With the new covariates

Z1 = X , Z2 = X 2, · · · , Zp = X p

this is just a linear multiple regression

Yi = β0 + β1z1i + β2z2i + · · ·+ βpzpi

The model is linear in the parameters!

How can this work?

The covariates Z1, · · · , Zp are of coursecorrelated, but they are not linearly dependent.

What do we use polynomial regression for?

I as model checking for the linear modelI as a smoothing methodI rarely as a ‘final model’ for publications

Linear splines

I Subdivide age into groups, using appropriate thresholdsI Fit linear effect of age in each age groupI Make the linear pieces ’meet’ at the thresholds

The result is a bent line:

Example

Oxygen consumption (from earlier exercise)

days1 105 97 104 1062 136 161 151 1533 173 179 174 1745 195 182 201 1727 207 194 206 213

10 218 193 235 229

We want to give a description of the oxygen consumption(boc) over time (days)

The above plot shows that boc as a function of days iscertainly not linear.

The biologists claim that the relation between boc and dayscan be described by a relation of the form

boc = γ exp(−β/days)

This relation is obviously nonlinear, but may be transformed tolinearity using the (natural) logarithm:

log(boc) = log(γ)− β/days

With

y = logboc = log(boc)

x = invdays = 1/days andα = log(γ)

we may write this equation as

y = α− βx

i.e., a linear relation, just with a minus sign on the slope.

A scatter plot of these new variables

This plot seems reasonably linear. We get

logboc = 5.431− 0.808× invdays

The linear regression model gives us the estimates:

intercept: α = log(γ) = 5.431(0.019)

slope: β = −0.808(0.039)

Noting that boc(∞) = γ = exp(α), we find the estimate ofboc(∞) to be

exp(5.431) = 228.38

with the 95% confidence interval

(exp(5.392), exp(5.471)) = (219.6, 237.7)

Residual plot and fitted curve

Why use non-linear regression?

I Transformation is necessary to obtain variancehomogeneity, but transformation destroys linearity.

I Linearity does not fit, and the transformation seems todestroy other parts of the model assumptions, e.g. theassumption of variance homogeneity.

I Theoretical knowledge (e.g. from kinetics or physiology)indicates that the proper relation is intrinsically non-linear.

I Interest is in functions of the parameters that do not enterlinearly in the model (e.g. kinetic rate constants or ED50 indose-response studies)

Untransformed:Linearity, but with increasingvariance

After a logarithmic trans-formation: Non-linearity, butwith constant variance

Example

Quantification of the Reticuloendothelial cell system(RES) of the liver:

Concentration measurements yi over the liver,following a bolus injection of radioactive tracer

First order kinetics implies

c(t) = β(1− e−γt)

No transformation to linearity possible!

yi = β(1− e−γti ) + εi , εi ∼ N(0, σ2)

Least squares method

Minimize the sums of squares

SS(β, γ) =∑

(yi − β(1− e−γti ))2 =∑

ε2i

This requires an iterative procedure

Example: RES in the liver

Starting values:I c(∞) = β ≈ 2000I dc

dt (0) = βγ ≈ 100

Residual sum of squares, SS, as a function of only oneparameter (hypothetical)

We have to determine the minimum

In case of linear regression:

Residual sum of squares, SS, as a function of two parameters(hypothetical)

There may be problems with convergence of the iterationprocedure and the solution may be a local minimum

SAS program

data reticulo;infile ’kw_res.txt’;input tid conc;run;

proc nlin data=reticulo;parms beta=2000

gamma=0.05;model conc=beta*(1-exp(-gamma*tid));

run;

OutputDependent Variable conc

Iterative PhaseSum of

Iter beta gamma Squares

0 2000.0 0.0500 43709901 1958.6 0.0824 3829952 2169.2 0.0769 26355.03 2174.2 0.0772 25286.74 2174.0 0.0773 25286.75 2174.0 0.0773 25286.7

NOTE: Convergence criterion met.Sum of Mean Approx

Source DF Squares Square F Value Pr > F

Regression 2 63048136 31524068 29920.0 <.0001Residual 24 25286.7 1053.6Uncorrected Total 26 63073423

Corrected Total 25 3455129

ApproxParameter Estimate Std Error Approximate 95% Confidence Limits

beta 2174.0 28.3459 2115.5 2232.5gamma 0.0773 0.00226 0.0726 0.0819

Example

The fit becomes:

Estimates:I β = 2174.0(28.3), CI=(2115.5, 2232.5)I γ = 0.0773(0.0023), CI=(0.0726, 0.0819)

Residuals

Residual pattern shows systematic behaviour:

so the model does not fit particularly well

Asymptotic normality of parameter estimates

I The distribution of the estimates is in general unknown,we only have approximate normality

I The approximations may be very poor for small samples

Confidence regions:

I Asymptotically (i.e. for large sample sizes), the estimatesare normally distributed

I The confidence areas will therefore be approximatelyelliptic

I For small sample sizes, this can become extremelymisleading!

Alternative procedure

Determine confidence regions directly from the sum of squaresSS, i.e. as those values of the parameter, which makes SSsufficiently small.

Determining the cutoff

What is “sufficently small” SS to obtain a 95% confidenceregion?Or: How do we determine the coverage probability for a givenconfidence region?

This is rather technical. . .

Good approximation to a (1-α)-sized region:

{θ|SS(θ) ≤ SS(θ)(1 +p

n − pFα(p, n − p))}

For linear regression, the situation is:

and confidence intervals become symmetric/elliptic

Example: RES in the liver

Residual sum ofsquares, SS:

Confidence regionbased upon SS:

Same model as before: c(t) = β(1− e−γt)

Simulated data, (β = 1, γ = 1, σ = 0.05):

The design is not adequate, we only see the linear part of theconcentration curve!

Confidence regions based on SS(β, γ):

If we spread out the x’s:

Enlarged picture, with superimposed normal approximation:

’Optimal’ design (in terms of a normal confidence region):

Effect of parametrization:

yi = β(1− e−γti ) + εi

Reparametrization:α = βγ

yi = αγ (1− e−γti ) + εi

Parameters β and γ:

ApproxParameter Estimate Std Error Approx. 95% Confidence Limits

beta 1.0559 0.2407 0.3875 1.7244gamma 1.0376 0.5202 -0.4067 2.4818

Approximate Correlation Matrixbeta gamma

beta 1.0000000 -0.9592479gamma -0.9592479 1.0000000

Parameters α and γ:

ApproxParameter Estimate Std Error Approx. 95% Confidence Limits

alfa 1.0956 0.3176 0.2138 1.9774gamma 1.0376 0.5202 -0.4067 2.4818

Approximate Correlation Matrixalfa gamma

alfa 1.0000000 0.9749950gamma 0.9749950 1.0000000

Compartment models

Differential equations ⇒multi-exponential curves

Often only measurementsfrom a single compartment!

Identification problems

There may be problems with the identification of parameters,even with good quality data.

This will give rise to very unprecise and extremely correlatedestimates.

Compartment models yield solutions as a sum of exponentialcurves:

f (t) = α1 exp(−λ1t) + α2 exp(−λ2t)

α1 λ1 α2 λ2

1 7 12 11 1

7

2 11.78 13.1 6.06 1

9.4

Rule of thumb:There must be a ratio of at least 5 in λ1

λ2

Example: Dose-effect

Effect of isoprenalinon heart rate

I E: Increase in heart rateI D: Dose of isoprenalin

Michaelis-Menten relation: E = Emax Dkd+D

Linearization (Lineweaver-Burk)

1E

=kd + DEmaxD

=1

Emax+

kd

Emax

1D

Linear relation between the inverses:

1E

= α + β1D

with the reparametrisation:

α = 1/Emax β = kd/EmaxEmax = 1/α kd = β/α

Ex. Isoprenalin:α: 0.0165 (0.0004), β: 0.0202 (0.0004)Emax : 1/0.0165 = 60.6(57.8, 63.7)kd : 0.0202/0.0165 = 1.22

Lineweaver-Burk plot

The model fits nicely ???

Model fit using Lineweaver-Burk linearisation:

Model fit using direct non-linear regression:

Estimates, isoprenalin

Emax kd

1/E linear 60.6 1.22E, non-linear 62.67 (2.12) 1.33 (0.14)

log(E), non-linear 61.59 (1.82) 1.26 (0.08)

Isoprenalin following metropolol:

Emax kd

1/E linear -228.2 -45.62E, non-linear 56.97 (3.47) 5.46 (0.85)

log(E), non-linear 80.73 (30.93) 11.71 (6.09)

Isoprenalin followingmetropolol:

Lineweaver-Burk plot:

Model fit using Lineweaver-Burk linearisation:

Model fit using direct non-linear regression:

What is the difference between the two fits?

I It is not just a reparametrisation!I We change the outcome from E to 1

EI If we have constant variance on the E scale,

the variance on the 1E scale will be proportional to 1

E4

I The assumption of constant variance on the 1E scale

corresponds to an assumption that the variance on the Escale is proportional to E4, i.e. an SD proportional to E2

– which more or less corresponds todisregarding the observations with large outcomes!

If the smallest concentration is omitted:Emax kd

1/E linear 65.19 7.14E, non-linear 56.31 (3.04) 5.25 (0.74)

log(E), non-linear 59.49 (5.36) 6.06 (1.011)

If we omit the lowest concentration:Model fit using Lineweaver-Burk linearisation:

Model fit using direct non-linear regression:

Why non-linear regression?

I Transformation is necessary to obtain variancehomogeneity, but transformation destroys linearity.

I Linearity does not fit, and the transformation seems todestroy other parts of the model assumptions, e.g. theassumption of variance homogeneity.

I Theoretical knowledge (e.g. from kinetics or physiology)indicates that the proper relation is intrinsically non-linear.

I Interest is focused on functions of the parameters, that donot enter linearly in the model (e.g. kinetic rate constantsor ED50 in dose-response studies)

Example of a typical dose-response relation,for moderate doses

We almost have linearity in this dose range:

For extreme doses we see a clear deviation from linearity

and: smaller variation in the ends

Y axis: Probit- or logit- transformed outcomeX axis: Logarithmic transformed dose

We get a reasonable linearity on these scales

Theoretical dose response relation:

Example from anaesthesia:

47 patients to be operatedwith two different anesthetics

I HalothaneI Neurolept

Y: Twitch response at the ulnar nerve(at the thumb), in %

X: Dose of muscle relaxantia

group=halothane

patient dose response

1 22.2 582 22.8 273 22.2 67. . .. . .. . .13 34.9 9414 35.9 9615 35.4 37

group=neurolept

patient dose response

1 22.9 272 25.0 483 24.6 12. . .. . .. . .

30 37.1 9331 37.7 8532 37.1 70

Halothane, probit- and logit-transformed

Transformation to linearityUsing two different transformations:

y : logit_twitch = log(

twitch100− twitch

)or

y : probit_twitch = probit(

twitch100

)= Φ−1

(twitch100

)

x : logdose = log(dose)

Linear relation:logit_twitch = α + βlogdose

produces estimates of α and β, with corresponding standarderrors (s.e.)

We get estimates of α and β from the equationlogit_twitch = α + β logdose

But: What about the parameters of interest, i.e. ED50 andED90?

ED50 = exp(− α

β

)

How do we calculate s.e.(ED50) ?

Reparameterization:

γ1= log(ED50)

γ2= log(ED90)

The model may then be written as:

y= logit_twitch = logit(0.9) × x−γ1γ2−γ1

= 2.197× x−γ1γ2−γ1

or, using the probit-transformation:

probit_twitch = Probit(0.9) × x−γ1γ2−γ1

= 1.282× x−γ1γ2−γ1

These functions are nonlinear in γ1 and γ2!

Direct estimation of γ1 and γ2 usingnon-linear regression

Estimation

data twitch2;set twitch;

logdose=log(dose);logit_twitch=log(response/(100-response));probit_twitch=probit(response/100);run;

proc nlin data=twitch2; by group;parms loged50=3.2

loged90=3.6;model logit_twitch=probit(0.9)*(logdose-loged50)

/(loged90-loged50);run;

Halothane, output from logit analysis:

group=halotan

The NLIN ProcedureDependent Variable logit_twitch

Sum of Mean ApproxSource DF Squares Square F Value Pr > F

Model 1 27.6468 27.6468 15.80 0.0016Error 13 22.7511 1.7501Corrected Total 14 50.3980

ApproxParameter Estimate Std Error Approx. 95% Confidence Limits

loged50 3.2450 0.0551 3.1259 3.3641loged90 3.5755 0.0814 3.3996 3.7513

Halothane, output from probit analysis:

group=halotan

The NLIN ProcedureDependent Variable probit_twitch

Sum of Mean ApproxSource DF Squares Square F Value Pr > F

Model 1 8.3329 8.3329 14.49 0.0022Error 13 7.4776 0.5752Corrected Total 14 15.8105

ApproxParameter Estimate Std Error Approx. 95% Confidence Limits

loged50 3.2473 0.0574 3.1234 3.3712loged90 3.5984 0.0897 3.4045 3.7923

Halothane – results

from probit analysis:

Estimate of log(ED50): 3.247 (0.0574)

with confidence interval:

3.247 ± 2.16× 0.0574 =

3.247 ± 0.124 = (3.123, 3.371)

Transformed back to the original scale:Estimate of ED50: exp(3.247) = 25.7with confidence interval:

(exp(3.125), exp(3.371)) = (22.7, 29.1)

The confidence interval for ED50 is not symmetric around25.7!!

Similarly for ED90:log(ED90): 3.598 (0.090) ED90: exp(3.598) = 36.5with confidence interval (30.5,43.7)

A more complicated nonlinear model

Ethanol elimination: Infusion until time t0:

Theoretical compartment modelI Blood compartment: VB, cBI Peripheral compartment: VE , cEI 1st order kinetics for interchange between compartments kI 0th order elimination from blood: vmax

Letting T =V 2

Ek(VB+VE )2 and λ = k( 1

VB+ 1

VE), we find that

until t0:

cB = (I0 − vmax)(T (1− exp(−λt)) +t

VB + VE)

After t0:

cB = (I0 − vmax)(T (1− exp(−λt)) +t

VB + VE)

−I0(T (1− exp(−λ(t − t0))) +(t − t0)

VB + VE)

proc nlin; by patient;parms ve=18

vb=6.2k=0.6vmax=2;

v=ve+vb;t=ve**2/(k*v**2);lam=k*(1/vb+1/ve);b1=i0-vmax;if del=1 then do;

model etanol=b1*(t*(1-exp(-lam*tid))+tid/v);end;if del=2 then do;

model etanol=b1*(t*(1-exp(-lam*tid))+tid/v)-i0*(t*(1-exp(-lam*(tid-t0)))+(tid-t0)/v);

end;output out=ny p=yhat r=resid;

run;

patient=9

The NLIN ProcedureDependent Variable etanolMethod: Gauss-Newton

Iterative PhaseSum of

Iter ve vb k vmax Squares

0 18.0000 6.2000 0.6000 2.0000 1563.71 21.6636 8.5737 0.8629 2.1047 86.12512 22.4079 9.7563 1.0459 2.1391 3.83593 22.4565 9.8477 1.1087 2.1416 2.67084 22.4854 9.8174 1.1161 2.1417 2.66765 22.4879 9.8142 1.1164 2.1418 2.66766 22.4881 9.8140 1.1165 2.1418 2.6676

NOTE: Convergence criterion met.

ApproxParameter Estimate Std Error Approximate 95% Confidence Limits

ve 22.4881 0.5138 21.4402 23.5360vb 9.8140 0.5867 8.6175 11.0106k 1.1165 0.0654 0.9830 1.2499vmax 2.1418 0.0163 2.1085 2.1750

Recommended