Description Usage Arguments Details Value Method requirements Data frame dat Options for variable type Author(s) References See Also Examples
View source: R/TrendNPS_Binary.R
TrendNPS_Binary
fits trend models of binary outcomes for
four approaches:
the unreplicated generalized linear mixed model with variance components as specified by Piepho and Ogutu (2002) that does not incorporate design weights ("PO");
simple linear regression of annual design-based estimates ("SLRDB");
weighted linear regression of annual design-based estimates ("WLRDB");
and probability-weighted iterative generalized least squares ("PWIGLS")
Fixed effects structure includes a year term for trend estimation and an optional two-level stratification factor. The function assumes random site and year intercepts, and an optional random site-level slope effect may be included.
1 2 3 |
alpha |
The probability of a Type I error. |
dat |
Data frame containing columns at least for |
method |
Method for trend estimation entered as a string. Valid values
include |
slope |
Logical value indicating inclusion of a random site-level slope
effect in the variance components structure used for the |
type |
Scaling type when |
stratum |
Text string identifying an optional two-level stratification
factor in |
Y |
Text string indicating the binary outcome variable in |
lat |
Site latitudes using an equal-area projection, e.g., UTM or Albers. |
long |
Site longitudes using an equal-area projection, e.g., UTM or Albers. |
stage1wt |
Design weights from the original sample draw without accounting for temporal revisit designs. |
stage2wt |
Panel inclusion weights for each site each year. |
str1prop |
Proportion of the first stratum in the population in a two-level stratification variable. |
nbhd |
Logical indictor for the neighborhood variance estimator
when |
For long-term monitoring, TrendNPS_Binary
assumes a single annual sampling
occasion per unique record of WYear
and Site
in data frame dat
.
Sampling (stage1wt
) and temporal-revisit (stage2wt
) design
weights must be adjusted for any missing data or frame error prior to trend
analysis. See Oh and Scheuren (1983), Little and Rubin (2002), and
Starcevich et al. (2016).
For background on the variance structure, see Piepho & Ogutu (2002). For information on the probability-weighted generalized least squares approach, see Pfeffermann et al. (1998), Asparouhov (2006), and Starcevich et al. (2017).
A list containing three or four elements, depending on the specified trend method. The first element of the list, ModelEstimates, contains a data frame with the trend model output:
mu | Estimated intercept from the trend model. |
trend | Estimated trend of the outcome Y on the link function scale from the trend model. |
SEtrend | Estimated standard error of the trend estimate. |
sig2a | Estimated site-to-site variation. |
sig2b | Estimated year-to-year variation. |
sig2t | Estimated variation among site-level slopes. |
sig2e | Estimated residual variation. |
eta | Degrees of freedom used to test for trend and calculate confidence intervals. |
The contents of the second list element, TrendTest, include the trend coefficient on the link scale, the trend standard error, the t-statistic, degrees of freedom, and p-value for a two-sided test of no trend.
The contents of the third list element, TrendCI, include the back-transformed trend on the original scale
and the lower and upper (1-alpha
)*100%-confidence interval bounds.
A fourth list element, DBests, contains the annual design-based estimates and is returned only when the SLRDB and WLRDB trend approaches are used. The design-based estimates may be used to assess the assumption of independence for the linear regression models. The output of the DBests list element include:
Year | Year of survey. |
Est.Mean | Design-based estimate of the mean of the outcome of interest. |
SE | Estimated standard error of design-based mean estimate if nbhd=TRUE . |
WYear | WYear variable. |
Resid | Residuals from the linear model fit. |
Spatially balanced samples utilizing method="SLRDB"
or
method="WLRDB"
require specification of lat
and long
on setting the neighborhood variance estimator nbhd=TRUE
. If
spatial balance cannot be assumed, set option nbhd=FALSE
for
non-spatially balanced designs so that the "SLRDB"
and
"WLRDB"
methods assume independent random sampling for standard
errors.
The stratification variable stratum
is required for all methods when
design strata are used. Note that method="PWIGLS"
further requires
a value for type
. See section "Options for variable type
"
below.
Specify stage1wt
and stage2wt
for all
methods except unweighted method="PO"
.
dat
Data frame dat
requires at least variables Site
,
WYear
, Year
, and Y
. Variable Site
defines the
sampling unit.
Underlying statistical functions called by TrendNPS_Cont
require two
separate temporal variables: Year
is a factor and WYear
is a
scalar-year value. WYear
is shifted so that the year for which Y
is least variable is centered on 0. See Piepho & Ogutu (2002) for more
information.
Ultimately, WYear
represents time in the fixed-effects portion of the
trend model. The regression coefficient associated with WYear
provides
the basis for trend estimation and testing.
Variable Year
enters the model as a random effect and provides
the basis for estimation of random year-to-year variation among survey
occasions.
Variable Y
must contain only binary values coded as 0 or 1.
type
Selection of method="PWIGLS"
requires further specification of
argument type
. Valid options include
"Aonly" | Probability weighting but no scaling at either stage |
"A" | Panel-weights scaling with mean site-level design weight |
"AI" | Panel-weights scaling with mean site-level design weight, but no site-level scaling |
"B" | Panel-weights scaling with effective mean site-level design weight |
"BI" | Panel-weights scaling with effective mean site-level design weight, but no site-level scaling |
"C" | Year-level scaling only with inverse of the average year-level weight |
Leigh Ann Starcevich and Jason Mitchell of Western EcoSystems Technology, Inc.
Asparouhov, T. (2006). General multi-level modeling with sampling weights. Communications in Statistics - Theory and Methods 35: 439-460.
Little, J. A. R., and D. B. Rubin. (2002). Statistical analysis with missing data, 2nd edition. John Wiley and Sons, Inc., New Jersey.
Oh, H. L., and F. J. Scheuren. (1983). Weighting adjustment for unit nonresponse. Pages 143-184 in W.G. Madow, I. Olkin, and D.B. Rubin, editors. Incomplete data and in sample surveys. (Vol. 2). Academic Press, New York.
Pfeffermann, D., C. J. Skinner, D. J. Holmes, H. Goldstein, and J. Rasbash (1998). Weighting for unequal selection probabilities in multilevel models. Journal of the Royal Statistical Society, Series B 60(1): 23-40.
Piepho, H. P., & Ogutu, J. O. (2002). A simple mixed model for trend analysis in wildlife populations. Journal of Agricultural, Biological, and Environmental Statistics, 7(3), 350-360.
Starcevich, L. A., G. DiDonato, T. McDonald, and J. Mitchell. (2016). A GRTS user's manual for the SDrawNPS package: A graphical user interface for generalized random tessellation stratified (GRTS) sampling and estimation. Natural Resource Report NPS/PWRO/NRR-2016/1233. National Park Service, Fort Collins, Colorado.
Starcevich, L. A., T. McDonald, A. Chung-MacCoubrey, A. Heard, and J. Nesmith. (2017). Trend Estimation for Complex Survey Designs. Natural Resource Report NPS/xxxx/NRR-2017/xxxx. National Park Service, Fort Collins, Colorado.
R. Wolfinger. (1993). Laplace's approximation for nonlinear mixed models. Biometrika 80(4): 791-795.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | # ---- Read example data set.
data(Cover_Acro)
# ---- Load dependent packages.
pkgList <- c("lme4","lmerTest","spsurvey")
inst <- pkgList %in% installed.packages()
if (length(pkgList[!inst]) > 0) install.packages(pkgList[!inst])
lapply(pkgList, library, character.only = TRUE)
###########################
# Example 1: Trend analysis of a binary indicator of Acrosophonia presence
# with the PO approach: stratification and full random effects model.
TrendAcro_PO_StRS = TrendNPS_Binary(alpha=0.1,
dat=Cover_Acro,method="PO",slope=TRUE,type=NA,stratum="Park",Y="Y",
stage1wt="wgt",stage2wt="PanelWt",str1prop=0.13227)
# $ModelEstimates
# mu trend SEtrend sig2a sig2t sigat sig2b
# -0.2992415 0.221928 0.09341594 0.2867116 0.01394005 -0.04732509 0.2411157
# $TrendTest
# trend SEtrend z-stat pvalue
# 0.221928 0.09341594 2.375698 0.0175158
# $TrendCIofOddsRatio
# Annual Pct Change CI low CI high
# 0.2484815 0.07065702 0.4558408
# Example 2: Trend analysis of a binary indicator of Acrosophonia presence
# with the SLRDB approach for stratification.
TrendAcro_SLRDB_StRS = TrendNPS_Binary(alpha=0.1,
dat=Cover_Acro,method="SLRDB",slope=TRUE,type=NA,stratum="Park",Y="Y",
lat="Lat",long="Long",stage1wt="wgt",stage2wt="PanelWt",
str1prop=0.13227)
TrendAcro_SLRDB_StRS
# $ModelEstimates
# mu trend SEtrend sig2a sig2t sigat sig2b
# -0.9909923 0.211127 0.08966504 0 0 0 0
#
# $TrendTest
# trend SEtrend z-stat pvalue
# 0.211127 0.08966504 2.354619 0.01854169
#
# $TrendCIofOddsRatio
# Annual Pct Change CI low CI high
# 0.2350692 0.06570992 0.4313426
#
# $DBests
# Year Est.Mean SE WYear Resid
# 2008 0.1604049 0.06934590 0 -0.6642261
# 2009 0.2652986 0.05963881 1 -0.2387430
# 2010 0.4121248 0.10439841 2 0.2135496
# 2011 0.6416667 0.07341420 3 0.9402165
# 2012 0.5439923 0.11698602 4 0.3229097
# 2013 0.5875758 0.03719284 5 0.2893100
# 2014 0.4954618 0.06389670 6 -0.2939231
# 2015 0.4794624 0.04936033 7 -0.5690937
num <- TrendAcro_SLRDB_StRS$DBests$Est.Mean
denom <- 1-TrendAcro_SLRDB_StRS$DBests$Est.Mean
TrendAcro_SLRDB_StRS$DBests$LogOdds = num / denom
plot(TrendAcro_SLRDB_StRS$DBests$Year,
TrendAcro_SLRDB_StRS$DBests$LogOdds,
xlab="Year", ylab="Odds ratio of cover proportion")
lines(2008:2015, exp(-0.9909923 + 0.211127*(0:7)), col=2)
# Plot trend on proportional cover scale
plot(TrendAcro_SLRDB_StRS$DBests$Year,
TrendAcro_SLRDB_StRS$DBests$Est.Mean,
xlab="Year", ylab="Cover proportion")
lines(2008:2015, TrendNPS::expit(-0.9909923 + 0.211127*(0:7)), col=2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.