cohplot1 <- function(x, ci = 0.95) { alfa <- 1 - (1 - ci)/2 p <- qnorm(alfa) plot(x$freq, x$coh, type = "l", ylim = c(0, 1), xlab = "", ylab = "", main = "Coherence", sub = paste("Coherence spectra with ", ci, "% pointwise confidence interval"), sep = "") gg <- 2/x$df se <- sqrt(gg/2) lines(x$freq, sign((tanh(atanh(x$coh) + p * se)))*(tanh(atanh(x$coh) + p * se))^2, lty = 3) lines(x$freq, sign((tanh(atanh(x$coh) - p * se)))*(tanh(atanh(x$coh) - p * se))^2, lty = 3) }