I am trying to understand my population abundance data and am looking into analyses of change point to try and determine, at approximately what point do populations begin to change (either decline or increasing). Can anyone offer suggestions on ways to go about this? I have looked into bcp and strucchange packages but am not completely convinced that these are appropriate for my data. Here is an example of what type of data I have Year of survey (continuous variable) 1960 - 2009 (there are gaps in the surveys (e.g., there were no surveys from 2002-2004) Relative abundance of salamanders during the survey periods Thanks for your help, Nick -- Nicholas M Caruso Graduate Student CLFS-Biology 4219 Biology-Psychology Building University of Maryland, College Park, MD 20742-5815 ------------------------------------------------------------------ I learned something of myself in the woods today, and walked out pleased for having made the acquaintance. [[alternative HTML version deleted]]
Hi Nick, I've used MCMC to fit change point regressions to a variety of ecological data and prefer this approach to strucchange and similar because I feel I have more control over the model, ie. I find it easier to tailor the form of the model to biological / demographic processes. I also find the imputing of missing response data more straightforward with MCMC - at least when they are some distance from potential changepoint(s). Most recently I've used JAGS via the rjags package to do such models. As an example, here is a toy model that looks for a single change-point after which there is a change in slope (time trend) in the data model { # y[i] is population data # N is number of (regular) observations for (i in 1:N) { y[i] ~ dnorm(mu[i], tau) mu[i] <- b0 + i*(b1 + b1cp*step(cp - i)) } # intercept b0 ~ dnorm(0, 1.0e-6) # pre-change slope b1 ~ dnorm(0, 1.0e-6) # post-change slope b1cp ~ dnorm(0, 1.0e-6) # change point location (time) cp ~ dunif(2, N-1) # variance (assumed equal either side of change) sd ~ dunif(0.01, 100) tau <- pow(sd, -2) } The step() function returns 1 when its argument is positive, and 0 otherwise. As a result, the slope is b1 before the change (time = cp) and b1 + b1cp after the change. You can easily modify this model to, for instance... - assume 0 slope but different intercepts either side of the change - allow for change in variance; or variance proportional to mean etc. - impute missing response data Michael On 17 November 2010 09:30, Nicholas M. Caruso <carusonm at gmail.com> wrote:> I am trying to understand my population abundance data and am looking into > analyses of change point to try and determine, at approximately what point > do populations begin to change (either decline or increasing). > > Can anyone offer suggestions on ways to go about this? > > I have looked into bcp and strucchange packages but am not completely > convinced that these are appropriate for my data. > > Here is an example of what type of data I have > Year of survey (continuous variable) 1960 - 2009 (there are gaps in the > surveys (e.g., there were no surveys from 2002-2004) > Relative abundance of salamanders during the survey periods > > > Thanks for your help, Nick > > -- > Nicholas M Caruso > Graduate Student > CLFS-Biology > 4219 Biology-Psychology Building > University of Maryland, College Park, MD 20742-5815 > > > > > ------------------------------------------------------------------ > I learned something of myself in the woods today, > and walked out pleased for having made the acquaintance. > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
dear Nick, I do not know your data, however it seems to me that the pattern of relative abundance of salamanders should not exhibit a sudden change, but rather a gradual change. If this is the case, have a look to the segmented package and references therin. In particular have a look to the relevant Rnews paper Segmented: an R package to fit regression models with broken-line relationships. R News, 8, 1: 20-25 at http://cran.r-project.org/doc/Rnews/Rnews_2008-1.pdf Hope this helps you, best, vito On Tue, 16 Nov 2010 17:30:49 -0500, Nicholas M. Caruso wrote> I am trying to understand my population abundance data and am looking into > analyses of change point to try and determine, at approximately what point > do populations begin to change (either decline or increasing). > > Can anyone offer suggestions on ways to go about this? > > I have looked into bcp and strucchange packages but am not completely > convinced that these are appropriate for my data. > > Here is an example of what type of data I have > Year of survey (continuous variable) 1960 - 2009 (there are gaps in the > surveys (e.g., there were no surveys from 2002-2004) > Relative abundance of salamanders during the survey periods > > Thanks for your help, Nick > > -- > Nicholas M Caruso > Graduate Student > CLFS-Biology > 4219 Biology-Psychology Building > University of Maryland, College Park, MD 20742-5815 > > ------------------------------------------------------------------ > I learned something of myself in the woods today, > and walked out pleased for having made the acquaintance. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Open WebMail Project (http://openwebmail.org)
There are really no set ways to determine a changepoint, since a changepoint depends completely on what you decide. Recursive partitioning will fit a best changepoint, but it will pretty much always fit one. This function can be found in the package rpart:> fit <- rpart(count ~ year, control = list(maxdepth = 1)) > summary(fit)However this measure offers no level of confidence. This is where packages like strucchange and party come into use, as they provide measures of confidence. Alternatively, you could look into regression-based methods where the changepoint is some parameter. Piecewise regression, for instance, is as simple as fitting a spline of degree 1 and changepoint X:> library(splines) > fit <- lm(count ~ bs(year, knots = X, degree = 1)) > plot(year, count) > lines(year, fitted(fit))Then you can fit a regression at each year and compare. Alternatively, since count data is often noisy, you could easily substitute quantile regression for linear regression to much of the same effect (assuming whatever tau you decide, I used 0.8 but this is arbitrary):> library(splines) > library(quantreg) > fit <- rq(count ~ bs(year, knots = X, degree = 1), tau = 0.8) > plot(year, count) > lines(year, fitted(fit))-------------------------------------- Jonathan P. Daily Technician - USGS Leetown Science Center 11649 Leetown Road Kearneysville WV, 25430 (304) 724-4480 "Is the room still a room when its empty? Does the room, the thing itself have purpose? Or do we, what's the word... imbue it." - Jubal Early, Firefly r-help-bounces at r-project.org wrote on 11/16/2010 05:30:49 PM:> [image removed] > > [R] Population abundance, change point > > Nicholas M. Caruso > > to: > > r-help > > 11/16/2010 05:32 PM > > Sent by: > > r-help-bounces at r-project.org > > I am trying to understand my population abundance data and am lookinginto> analyses of change point to try and determine, at approximately whatpoint> do populations begin to change (either decline or increasing). > > Can anyone offer suggestions on ways to go about this? > > I have looked into bcp and strucchange packages but am not completely > convinced that these are appropriate for my data. > > Here is an example of what type of data I have > Year of survey (continuous variable) 1960 - 2009 (there are gaps in the > surveys (e.g., there were no surveys from 2002-2004) > Relative abundance of salamanders during the survey periods > > > Thanks for your help, Nick > > -- > Nicholas M Caruso > Graduate Student > CLFS-Biology > 4219 Biology-Psychology Building > University of Maryland, College Park, MD 20742-5815 > > > > > ------------------------------------------------------------------ > I learned something of myself in the woods today, > and walked out pleased for having made the acquaintance. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.