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-boun...@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-boun...@r-project.org
> 
> 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@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.

______________________________________________
R-help@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.

Reply via email to