| makePeakMatrix | R Documentation |
Make peak lower- and upper-bounds matrix from peak discharge qualification codes for left- and right-bounds (limits) based on the less than and greater than censoring.
makePeakMatrix(x, lo=0, hi=NA, eps=sqrt(.Machine$double.eps), wypad=FALSE)
x |
A |
lo |
The lower (left) bounds for |
hi |
The upper (right) bounds for |
eps |
A small number subtracted from the lower (left) or added to the upper (right) bounds when computed internally when |
wypad |
A logical to left append two columns of |
A two- or four-column matrix is returned depending on argument wypad with row names set as the water year.
W.H. Asquith
splitPeakCodes
## Not run:
# Example of a streamflow site with several less and greater than annual peaks.
site <- "08136220"; # another good test is "02370750"
r <- 1E3; par(ljoin=1); myblu <- rgb(0, 0.3, 0.7, 0.2)
pk <- splitPeakCodes(dataRetrieval::readNWISpeak(site, convert=FALSE))
pk <- pk[pk$appearsSystematic,]
plotPeaks(pk, xlab="Water Year", ylab="Streamflow, cfs")
mtext(site, line=0, font=2)
zmat <- makePeakMatrix(pk, wypad=TRUE); Y <- pk$water_yr; Q <- pk$peak_va
S1 <- copBasic::wolfCOPtest(Y,Q, zmat=zmat, rndphi=r)
d1 <- S1$table # plot sigmas and p-values based on z-matrix (using codes 4 and 8)
S2 <- copBasic::wolfCOPtest(Y,Q, zmat=NULL, rndphi=r, ties.method="average")
d2 <- S2$table # plot sigmas and p-values of a potentially naive ties averaging.
S3 <- copBasic::wolfCOPtest(Y,Q, zmat=NULL, rndphi=r, ties.method="random" )
d3 <- S3$table # plot sigmas and p-values by randomization of the ties
plot( d1$sigmas, d1$sigmas_pvl, pch=16, col=myblu, xlab="Sigma", ylab="p-value",
xlim=c(0,1), ylim=c(0,1))
points(d2$sigmas, d2$sigmas_pvl, pch=25, col="green4", cex=2.1, bg="white", lwd=2)
points(d3$sigmas, d3$sigmas_pvl, pch=24, col="red", cex=1.4, bg="white", lwd=2)
lines( d1$sigmas, d1$sigmas_pvl, col="blue")
mtext(site, line=1, font=2) #
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.