trendlines | R Documentation |
Extract 'overall' trendlines
trendlines(x)
x |
An object of class |
A data.frame containing the information on all trendline segments and their uncertainty. The data.frame has the following columns:
segment
segment ID, starting at 1
year
year for which value, lo and hi are given
value
the y coordinate of the trendline segment
lo
lower value of the uncertainty band
hi
upper value of the uncertainty interval
Other analyses:
coef.trim()
,
confint.trim()
,
gof()
,
index()
,
now_what()
,
overall()
,
overdispersion()
,
plot.trim.index()
,
plot.trim.overall()
,
plot.trim.smooth()
,
results()
,
serial_correlation()
,
summary.trim()
,
totals()
,
trim()
,
vcov.trim()
,
wald()
data(skylark2)
z <- trim(count ~ site+year, data=skylark2, model=3)
tt <- totals(z, long=TRUE) # collect time-totals
tl <- trendlines(overall(z)) # collect overall trend line
# define plot limits
xr <- range(tt$year)
yr <- range(tl$lo, tl$hi, tt$value)
plot(xr, yr, type='n', xlab="Year", ylab="Total counts")
# Plot uncertainty band
ubx <- c(tl$year, rev(tl$year))
uby <- c(tl$lo, rev(tl$hi))
polygon(ubx, uby, col=gray(0.9), border=NA)
# Plot trend line
lines(tl$year, tl$value, col="black", lwd=2)
# Plot time-totals
lines(tt$year, tt$value, col="red", lwd=2)
points(tt$year, tt$value, col="red", pch=16, cex=1.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.