| Line 1... |
Line 1... |
| 1 |
% File src/library/stats/man/SSasymp.Rd
|
1 |
% File src/library/stats/man/SSasymp.Rd
|
| 2 |
% Part of the R package, https://www.R-project.org
|
2 |
% Part of the R package, https://www.R-project.org
|
| 3 |
% Copyright 1995-2010 R Core Team
|
3 |
% Copyright 1995-2017 R Core Team
|
| 4 |
% Distributed under GPL 2 or later
|
4 |
% Distributed under GPL 2 or later
|
| 5 |
|
5 |
|
| 6 |
\name{SSasymp}
|
6 |
\name{SSasymp}
|
| 7 |
\encoding{UTF-8}
|
7 |
\encoding{UTF-8}
|
| 8 |
\title{Self-Starting Nls Asymptotic Regression Model}
|
8 |
\title{Self-Starting Nls Asymptotic Regression Model}
|
| Line 22... |
Line 22... |
| 22 |
\description{
|
22 |
\description{
|
| 23 |
This \code{selfStart} model evaluates the asymptotic regression
|
23 |
This \code{selfStart} model evaluates the asymptotic regression
|
| 24 |
function and its gradient. It has an \code{initial} attribute that
|
24 |
function and its gradient. It has an \code{initial} attribute that
|
| 25 |
will evaluate initial estimates of the parameters \code{Asym}, \code{R0},
|
25 |
will evaluate initial estimates of the parameters \code{Asym}, \code{R0},
|
| 26 |
and \code{lrc} for a given set of data.
|
26 |
and \code{lrc} for a given set of data.
|
| - |
|
27 |
|
| - |
|
28 |
Note that \code{\link{SSweibull}()} generalizes this asymptotic model
|
| - |
|
29 |
with an extra parameter.
|
| 27 |
}
|
30 |
}
|
| 28 |
\value{
|
31 |
\value{
|
| 29 |
a numeric vector of the same length as \code{input}. It is the value of
|
32 |
a numeric vector of the same length as \code{input}. It is the value of
|
| 30 |
the expression \code{Asym+(R0-Asym)*exp(-exp(lrc)*input)}. If all of
|
33 |
the expression \code{Asym+(R0-Asym)*exp(-exp(lrc)*input)}. If all of
|
| 31 |
the arguments \code{Asym}, \code{R0}, and \code{lrc} are
|
34 |
the arguments \code{Asym}, \code{R0}, and \code{lrc} are
|
| Line 37... |
Line 40... |
| 37 |
\code{\link{nls}}, \code{\link{selfStart}}
|
40 |
\code{\link{nls}}, \code{\link{selfStart}}
|
| 38 |
}
|
41 |
}
|
| 39 |
\examples{
|
42 |
\examples{
|
| 40 |
\dontshow{options(show.nls.convergence=FALSE)}
|
43 |
\dontshow{options(show.nls.convergence=FALSE)}
|
| 41 |
Lob.329 <- Loblolly[ Loblolly$Seed == "329", ]
|
44 |
Lob.329 <- Loblolly[ Loblolly$Seed == "329", ]
|
| 42 |
SSasymp( Lob.329$age, 100, -8.5, -3.2 ) # response only
|
45 |
SSasymp( Lob.329$age, 100, -8.5, -3.2 ) # response only
|
| 43 |
Asym <- 100
|
46 |
local({
|
| 44 |
resp0 <- -8.5
|
47 |
Asym <- 100 ; resp0 <- -8.5 ; lrc <- -3.2
|
| 45 |
lrc <- -3.2
|
- |
|
| 46 |
SSasymp( Lob.329$age, Asym, resp0, lrc ) # response and gradient
|
48 |
SSasymp( Lob.329$age, Asym, resp0, lrc) # response _and_ gradient
|
| - |
|
49 |
})
|
| 47 |
getInitial(height ~ SSasymp( age, Asym, resp0, lrc), data = Lob.329)
|
50 |
getInitial(height ~ SSasymp( age, Asym, resp0, lrc), data = Lob.329)
|
| 48 |
## Initial values are in fact the converged values
|
51 |
## Initial values are in fact the converged values
|
| 49 |
fm1 <- nls(height ~ SSasymp( age, Asym, resp0, lrc), data = Lob.329)
|
52 |
fm1 <- nls(height ~ SSasymp( age, Asym, resp0, lrc), data = Lob.329)
|
| 50 |
summary(fm1)
|
53 |
summary(fm1)
|
| 51 |
\dontshow{
|
- |
|
| 52 |
require(graphics)
|
- |
|
| 53 |
|
54 |
|
| - |
|
55 |
## Visualize the SSasymp() model parametrization :
|
| - |
|
56 |
|
| 54 |
xx <- seq(0, 5, len = 101)
|
57 |
xx <- seq(-.3, 5, len = 101)
|
| - |
|
58 |
## Asym + (R0-Asym) * exp(-exp(lrc)* x) :
|
| 55 |
yy <- 5 - 4 * exp(-xx/(2*log(2)))
|
59 |
yy <- 5 - 4 * exp(-xx / exp(3/4))
|
| - |
|
60 |
stopifnot( all.equal(yy, SSasymp(xx, Asym = 5, R0 = 1, lrc = -3/4)) )
|
| - |
|
61 |
require(graphics)
|
| 56 |
par(mar = c(0, 0, 4.1, 0))
|
62 |
op <- par(mar = c(0, .2, 4.1, 0))
|
| 57 |
plot(xx, yy, type = "l", axes = FALSE, ylim = c(0,6), xlim = c(-1, 5),
|
63 |
plot(xx, yy, type = "l", axes = FALSE, ylim = c(0,5.2), xlim = c(-.3, 5),
|
| 58 |
xlab = "", ylab = "", lwd = 2,
|
64 |
xlab = "", ylab = "", lwd = 2,
|
| 59 |
main = "Parameters in the SSasymp model")
|
65 |
main = quote("Parameters in the SSasymp model " ~
|
| - |
|
66 |
{f[phi](x) == phi[1] + (phi[2]-phi[1])*~e^{-e^{phi[3]}*~x}}))
|
| - |
|
67 |
mtext(quote(list(phi[1] == "Asym", phi[2] == "R0", phi[3] == "lrc")))
|
| 60 |
usr <- par("usr")
|
68 |
usr <- par("usr")
|
| 61 |
arrows(usr[1], 0, usr[2], 0, length = 0.1, angle = 25)
|
69 |
arrows(usr[1], 0, usr[2], 0, length = 0.1, angle = 25)
|
| 62 |
arrows(0, usr[3], 0, usr[4], length = 0.1, angle = 25)
|
70 |
arrows(0, usr[3], 0, usr[4], length = 0.1, angle = 25)
|
| 63 |
text(usr[2] - 0.2, 0.1, "x", adj = c(1, 0))
|
71 |
text(usr[2] - 0.2, 0.1, "x", adj = c(1, 0))
|
| 64 |
text(-0.1, usr[4], "y", adj = c(1, 1))
|
72 |
text( -0.1, usr[4], "y", adj = c(1, 1))
|
| 65 |
abline(h = 5, lty = 2, lwd = 0)
|
73 |
abline(h = 5, lty = 3)
|
| 66 |
arrows(-0.8, 2.1, -0.8, 0, length = 0.1, angle = 25)
|
74 |
arrows(c(0.35, 0.65), 1,
|
| 67 |
arrows(-0.8, 2.9, -0.8, 5, length = 0.1, angle = 25)
|
75 |
c(0 , 1 ), 1, length = 0.08, angle = 25); text(0.5, 1, quote(1))
|
| 68 |
text(-0.8, 2.5, expression(phi[1]), adj = c(0.5, 0.5))
|
76 |
y0 <- 1 + 4*exp(-3/4) ; t.5 <- log(2) / exp(-3/4) ; AR2 <- 3 # (Asym + R0)/2
|
| 69 |
segments(-0.4, 1, 0, 1, lty = 2, lwd = 0.75)
|
77 |
segments(c(1, 1), c( 1, y0),
|
| 70 |
arrows(-0.3, 0.25, -0.3, 0, length = 0.07, angle = 25)
|
78 |
c(1, 0), c(y0, 1), lty = 2, lwd = 0.75)
|
| 71 |
arrows(-0.3, 0.75, -0.3, 1, length = 0.07, angle = 25)
|
79 |
text(1.1, 1/2+y0/2, quote((phi[1]-phi[2])*e^phi[3]), adj = c(0,.5))
|
| 72 |
text(-0.3, 0.5, expression(phi[2]), adj = c(0.5, 0.5))
|
80 |
axis(2, at = c(1,AR2,5), labels= expression(phi[2], frac(phi[1]+phi[2],2), phi[1]),
|
| - |
|
81 |
pos=0, las=1)
|
| 73 |
segments(1, 3.025, 1, 4, lty = 2, lwd = 0.75)
|
82 |
arrows(c(.6,t.5-.6), AR2,
|
| 74 |
arrows(0.2, 3.5, 0, 3.5, length = 0.08, angle = 25)
|
83 |
c(0, t.5 ), AR2, length = 0.08, angle = 25)
|
| 75 |
arrows(0.8, 3.5, 1, 3.5, length = 0.08, angle = 25)
|
84 |
text( t.5/2, AR2, quote(t[0.5]))
|
| - |
|
85 |
text( t.5 +.4, AR2,
|
| - |
|
86 |
quote({f(t[0.5]) == frac(phi[1]+phi[2],2)}~{} \%=>\% {}~~
|
| 76 |
text(0.5, 3.5, expression(t[0.5]), adj = c(0.5, 0.5))
|
87 |
{t[0.5] == frac(log(2), e^{phi[3]})}), adj = c(0, 0.5))
|
| 77 |
}
|
88 |
par(op)
|
| 78 |
}
|
89 |
}
|
| 79 |
\keyword{models}
|
90 |
\keyword{models}
|