Nonlinear Regression: What Is Nonlinear Model?
Nonlinear Regression: What Is Nonlinear Model?
Nonlinear regression
1
07/01/16
2
07/01/16
3
07/01/16
4
07/01/16
yˆ = β 0 + β1 xʹ
5
07/01/16
yˆ ʹ = β 0ʹ + β1ʹxʹ
6
07/01/16
to get: 0 0
yˆ = β 0ʹ + β1ʹxʹ
Nonlinear models in R
To estimate nonlinear models (that can be transformed to
linear models) we use lm function, but we have to define
formula. Some examples will be presented:
yˆ = β 0 + β1 x1 + β 2 x2 (1)
yˆ = β1 x1 + β 2 x2 ( 2)
yˆ = β 0 + β1 ln x1 + β 2 ln x2 (3)
log yˆ = β 0 + β1 x1 + β 2 x2 (4)
x2
yˆ = β 0 + β1 + β 3 x3 + β 4 x42 (5)
x1
yˆ = β 0 β1x1 β 2x2 (6) we have to use logarithms
yˆ = β 0 x1β1 x2β 2 (7) for equations 6 and 7
yˆ t = β 0 + β1 x1t −1 + β 2 x2t − 2 (8)
7
07/01/16
Nonlinear models in R
How to apply these functions in formula:
Function no. Formula
1 y~x1+x2
2 y~-1+x1+x2 or y~0+x1+x2
3 y~log(x1)+log(x2)
4 log10(y)~x1+x2
5 y~I(x2/x1)+sqrt(x3)+I(x4^2)
6 log(y)~x1+x2
7 log(y)~log(x1)+log(x2)
8 z.y~v1+v2
8
07/01/16
9
07/01/16
2
S (θ ) = ∑ w[ y − m(θ, x )]
From now on we will use for the minimizer of the residual
sum of squares θˆ
10
07/01/16
11
07/01/16
12
07/01/16
13
07/01/16
By setting trace=TRUE, we can see that S evaluated at the starting values is 3061. The first
iteration reduces this to 558.5, the next iteration to 458, and the remaining iterations result in
only very small changes.
We get convergence in 6 iterations.
14
07/01/16
The estimated year in which the population is half the asymptote is:
− θˆ3 θˆ2 =and
1976so
,6 the standard error is about 7.6 years
15
07/01/16
σˆ = S (θˆ ) (n − k )
16
07/01/16
17
07/01/16
θ1
m( x , θ ) =
1 + exp[− (θ 2 + θ 3 x )]
Fitting a nonlinear model with the self-starting logistic growth
function in R is quite easy:
pop.ss <- nls(population ~ SSlogis(year, phi1, phi2,
phi3), data=USPop)
summary(pop.ss)
18
07/01/16
19