Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How is the interval for the fitted value computed (in the presence of outliers)? #46

Open
stweb75 opened this issue Feb 12, 2025 · 0 comments

Comments

@stweb75
Copy link

stweb75 commented Feb 12, 2025

When hasOutlier=TRUE Rbeast will plot a wide gray band around the fitted Y values.
How is that interval computed? What does it mean?
I have made three attempts in the example below but can't reproduce the wide interval in the Rbeast plot.

library(Rbeast)
data(Nile)
out <- beast(Nile, season="none", dump.ci=TRUE, hasOutlier=TRUE)
plot(out)
# trend component
plot(out[[7]][13]$Y, type="l", ylim=c(700,1200))
  lines(out[[7]][15]$CI[,1], lty=3)
  lines(out[[7]][15]$CI[,2], lty=3)
# outlier component
plot(out[[9]][11]$Y, type="l", ylim=c(-200,200))
  lines(out[[9]][13]$CI[,1], lty=3)
  lines(out[[9]][13]$CI[,2], lty=3)
# no issues here
which(out[[9]][13]$CI[,2] > out[[9]][11]$slp)  
which(out[[9]][13]$CI[,1] < out[[9]][11]$slp)
# attempt 1: interval too narrow; ignores outlier uncertainty
plot(as.numeric(Nile), col="gray", ylim=c(400,1400))
  lines(out[[7]][13]$Y+out[[9]][11]$Y)
  lines(out[[7]][15]$CI[,1]+out[[9]][11]$Y, lty=3)
  lines(out[[7]][15]$CI[,2]+out[[9]][11]$Y, lty=3)
# attempt 2: interval too narrow and it's wrong to add CI limits together
plot(as.numeric(Nile), col="gray", ylim=c(400,1400))
  lines(out[[7]][13]$Y+out[[9]][11]$Y)
  lines(out[[7]][15]$CI[,1]+out[[9]][13]$CI[,1], lty=3)
  lines(out[[7]][15]$CI[,2]+out[[9]][13]$CI[,2], lty=3)
# attempt 3: interval too narrow; I'm not sure if outlierSigFactor is relevant
plot(as.numeric(Nile), col="gray", ylim=c(400,1400))
  lines(out[[7]][13]$Y+out[[9]][11]$Y)
  lines(out[[7]][13]$Y+out[[9]][11]$Y+out[[7]][14]$SD*2.5, lty=3)
  lines(out[[7]][13]$Y+out[[9]][11]$Y-out[[7]][14]$SD*2.5, lty=3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant