# [R] zigzag confidence interval in a plot

Ozgul Inceoglu Ozgul.Inceoglu at ulb.ac.be
Fri May 17 15:03:51 CEST 2013

```Dear All,

When I plot the values and linear regression line for one data set, it is fine. But for another one I see zigzags, when I plot the confidence interval

>cd
Depth	CHAOsep12RNA
9,94	804
25,06	1476,833333
40,04	1540,561404
50,11	1575,166667
52,46	349,222222
54,92	1941,5
57,29	1053,507042
60,11	1535,1
70,04	2244,963303
79,97	1954,507042
100,31	2679,140625

> plot(cd\$CHAOsep12RNA,cd\$Depth, ylim = rev(range(0:100)), xlab="CHAO", ylab="Depth", pch=15, las=2, main="Sep12-RNA", cex.main=1)
> lmR <- lm(cd\$Depth~cd\$CHAOsep12RNA)
> abline(lmR)
pconfR <- predict(lmR,interval="confidence")
matlines(cd\$CHAOsep12RNA,pconfR[,c("lwr","upr")], col=1, lty=2)

I also tried

> newx <- seq(min(cd\$CHAOsep12RNA), max(cd\$CHAOsep12RNA), length.out=11)
> a <- predict(lmR, newdata=data.frame(CHAO=newx), interval=c("confidence"))
> plot(cd\$CHAOsep12RNA,cd\$Depth, ylim = rev(range(0:100)), xlab="CHAO", ylab="Depth", pch=15, las=2, main="Sep12-RNA", cex.main=1)
> abline(lmR)
> lines(cd\$CHAOsep12RNA, a[,2], lty=2)

But I see both cases kind of zigzags. What can it be the reason? thank you!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zigzaging.pdf
Type: application/pdf
Size: 2111 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130517/50fd982f/attachment.pdf>
```