How to define limits of breakpoint (max and min possible values) in a linear model (R segmented package)? I'm trying to estimate where the breakpoint of my lm is, but it only makes sense in my system to have a breakpoint value between 5 and 20. How can I specify psi location limits in segmented()?
psi=c(5,20) does not work. psi=seq(5,20,1) also does not work.
  ## segmented regression on linear trend
  y <- birdpred$mean
  z <- birdpred$year
  lin.mod <- lm(y~z)

  lm.seg <- segmented(lin.mod,seg.Z=~z,psi=c(5,20))
  lm.seg$psi     ## breakpoint 


Thank you!
 A: You have prior knowledge that the breakpoint can only occur at values between 5 and 20. Therefore, Bayesian modeling is well suited to this task. One further advantage of going Bayesian is that you can quantify the uncertainty of the change point. Using the mcp package, you could do:
library(mcp)
model = list(
    mean ~ year,  # y ~ z (with implicit intercept)
    ~ year  # also y ~ z (with implicit intercept)
)
prior = list(cp_1 = "dunif(5, 20)")
fit = mcp(model, data = birdpred, prior = prior)

If you know more about likely values in the interval, you could also do something like prior = list(cp_1 = "dnorm(15, 5) T(5, 20)") to truncate another distribution to the interval. Read more about using priors in mcp. If you want the segments to be joined, the second segment should be ~ 0 + year.
Among others, you can inspect the fit using plot(fit), plot_pars(fit), and summary(fit).
A: There are two parts to your question. One is statistical and the other is about R code. The latter is off-topic here, but the former is on-topic.
I am always very leery when I hear anything like 

it only makes sense in my system to have a breakpoint value between 5
  and 20

My favorite professor in grad school often said "if you're not surprised, you haven't learned anything".  If you manage to make a function that does what you want, you are taking away your ability to be surprised.
You haven't told us what your variables are, but "birdpred" sounds like some sort of  count of birds and year is almost certainly year. So, what happens if the program gives a break point somewhere outside of 5 and 20?  You are surprised. Maybe 


*

*Your data is wrong and you can correct it.

*Your model is wrong and you can correct it.

*You've discovered something really new and can make a new theory.


In addition, I would surely look carefully at a graph of birdpred and year to see where the breakpoint might be.
