Skip to content

Commit c066757

Browse files
committed
Merge branch 'SSmodel-examples'
2 parents 3e77fea + cbaba93 commit c066757

File tree

2 files changed

+57
-14
lines changed

2 files changed

+57
-14
lines changed

man/SSarrhenius.Rd

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ SSlomolino(area, Asym, xmid, slope)
3232
}
3333
}
3434
\details{
35+
These functions are intended to be used as self-starting models in
36+
non-linear regression (\code{\link{nls}}). There are several functions
37+
that can be used to further handle \code{nls} result, including
38+
\code{summary}, \code{confint} and many more (see \code{\link{nls}}).
39+
3540
All these functions are assumed to be used for species richness
3641
(number of species) as the independent variable, and area or sample
3742
size as the independent variable. Basically, these define least
@@ -73,7 +78,10 @@ SSlomolino(area, Asym, xmid, slope)
7378
Numeric vector of the same length as \code{area}. It is the value of
7479
the expression of each model. If all arguments are names of objects
7580
the gradient matrix with respect to these names is attached as an
76-
attribute named \code{gradient}.
81+
attribute named \code{gradient}. This result object will be used in
82+
non-linear regression in function \code{\link{nls}} which returns its
83+
own result object with many support functions documented with
84+
\code{\link{nls}}.
7785
}
7886
\references{
7987
Dengler, J. (2009) Which function describes the species-area
@@ -105,6 +113,7 @@ plot(S ~ area, sipoo.map, xlab = "Island Area (ha)",
105113
## The Arrhenius model
106114
marr <- nls(S ~ SSarrhenius(area, k, z), data=sipoo.map)
107115
marr
116+
summary(marr)
108117
## confidence limits from profile likelihood
109118
confint(marr)
110119
## draw a line
@@ -113,7 +122,7 @@ lines(xtmp, predict(marr, newdata=data.frame(area = xtmp)), lwd=2)
113122
## The normal way is to use linear regression on log-log data,
114123
## but this will be different from the previous:
115124
mloglog <- lm(log(S) ~ log(area), data=sipoo.map)
116-
mloglog
125+
summary(mloglog) # (Intercept) is log(k) of SSarrhenius result
117126
lines(xtmp, exp(predict(mloglog, newdata=data.frame(area=xtmp))),
118127
lty=2)
119128
## Gleason: log-linear
@@ -126,7 +135,7 @@ lines(xtmp, predict(mgit, newdata=data.frame(area=xtmp)),
126135
lwd=2, col = 3)
127136
## Lomolino: using original names of the parameters (Lomolino 2000):
128137
mlom <- nls(S ~ SSlomolino(area, Smax, A50, Hill), sipoo.map)
129-
mlom
138+
summary(mlom)
130139
lines(xtmp, predict(mlom, newdata=data.frame(area=xtmp)),
131140
lwd=2, col = 4)
132141
## One canned model of standard R:

tests/Examples/vegan-Ex.Rout.save

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,22 @@ Nonlinear regression model
411411

412412
Number of iterations to convergence: 5
413413
Achieved convergence tolerance: 1.056e-06
414+
> summary(marr)
415+
416+
Formula: S ~ SSarrhenius(area, k, z)
417+
418+
Parameters:
419+
Estimate Std. Error t value Pr(>|t|)
420+
k 3.40619 0.40790 8.351 3.16e-07 ***
421+
z 0.43644 0.02743 15.910 3.15e-11 ***
422+
---
423+
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
424+
425+
Residual standard error: 2.209 on 16 degrees of freedom
426+
427+
Number of iterations to convergence: 5
428+
Achieved convergence tolerance: 1.056e-06
429+
414430
> ## confidence limits from profile likelihood
415431
> confint(marr)
416432
Waiting for profiling to be done...
@@ -423,14 +439,25 @@ z 0.3813576 0.4944693
423439
> ## The normal way is to use linear regression on log-log data,
424440
> ## but this will be different from the previous:
425441
> mloglog <- lm(log(S) ~ log(area), data=sipoo.map)
426-
> mloglog
442+
> summary(mloglog) # (Intercept) is log(k) of SSarrhenius result
427443

428444
Call:
429445
lm(formula = log(S) ~ log(area), data = sipoo.map)
430446

447+
Residuals:
448+
Min 1Q Median 3Q Max
449+
-0.87519 -0.11897 0.05503 0.19842 0.40087
450+
431451
Coefficients:
432-
(Intercept) log(area)
433-
1.0111 0.4925
452+
Estimate Std. Error t value Pr(>|t|)
453+
(Intercept) 1.01109 0.14897 6.787 4.36e-06 ***
454+
log(area) 0.49252 0.05565 8.850 1.46e-07 ***
455+
---
456+
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
457+
458+
Residual standard error: 0.3163 on 16 degrees of freedom
459+
Multiple R-squared: 0.8304, Adjusted R-squared: 0.8198
460+
F-statistic: 78.32 on 1 and 16 DF, p-value: 1.462e-07
434461

435462
> lines(xtmp, exp(predict(mloglog, newdata=data.frame(area=xtmp))),
436463
+ lty=2)
@@ -444,16 +471,23 @@ Coefficients:
444471
+ lwd=2, col = 3)
445472
> ## Lomolino: using original names of the parameters (Lomolino 2000):
446473
> mlom <- nls(S ~ SSlomolino(area, Smax, A50, Hill), sipoo.map)
447-
> mlom
448-
Nonlinear regression model
449-
model: S ~ SSlomolino(area, Smax, A50, Hill)
450-
data: sipoo.map
451-
Smax A50 Hill
452-
53.493 94.697 2.018
453-
residual sum-of-squares: 55.37
474+
> summary(mlom)
475+
476+
Formula: S ~ SSlomolino(area, Smax, A50, Hill)
477+
478+
Parameters:
479+
Estimate Std. Error t value Pr(>|t|)
480+
Smax 53.493 13.849 3.863 0.00153 **
481+
A50 94.697 74.964 1.263 0.22578
482+
Hill 2.018 0.235 8.587 3.56e-07 ***
483+
---
484+
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
485+
486+
Residual standard error: 1.921 on 15 degrees of freedom
454487

455488
Number of iterations to convergence: 6
456489
Achieved convergence tolerance: 9.715e-07
490+
457491
> lines(xtmp, predict(mlom, newdata=data.frame(area=xtmp)),
458492
+ lwd=2, col = 4)
459493
> ## One canned model of standard R:
@@ -9177,7 +9211,7 @@ Procrustes sum of squares:
91779211
> cleanEx()
91789212
> options(digits = 7L)
91799213
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
9180-
Time elapsed: 8.784 0.398 9.198 0 0
9214+
Time elapsed: 8.8 0.411 9.234 0 0
91819215
> grDevices::dev.off()
91829216
null device
91839217
1

0 commit comments

Comments
 (0)