diff --git a/DESCRIPTION b/DESCRIPTION index a631408..1e92777 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,5 +23,8 @@ Suggests: covr, testthat, ggplot2, - tibble + tibble, + knitr, + rmarkdown URL: https://earthsystemdiagnostics.github.io/paleospec/ +VignetteBuilder: knitr diff --git a/R/AddConfInterval.R b/R/AddConfInterval.R index 32506e3..9f17c7d 100644 --- a/R/AddConfInterval.R +++ b/R/AddConfInterval.R @@ -1,7 +1,7 @@ #' Add confidence interval #' #' Add a confidence interval to a spectral estimate assuming the uncertainty of -#' the spectral estimates follows a chi-squared distribution with the degress of +#' the spectral estimates follows a chi-squared distribution with the degrees of #' the freedom from the spectral estimates. #' #' @param spec a spectral object of class \code{"spec"} or a list with the @@ -16,7 +16,7 @@ #' respectively. #' @author Thomas Laepple #' @examples -#' +#' #' N.R <- 1000 #' N.T <- 100 #' save.spec <- matrix(NA, N.T / 2, N.R) @@ -33,7 +33,7 @@ #' legend("bottomleft", lwd = 2, col = c("black", "red"), #' legend = c("one realization with chisq conf intervals", #' "MC confidence intervals")) -#' +#' #' @export AddConfInterval <- function(spec, pval = 0.05, MINVALUE = 1e-10) { @@ -44,6 +44,8 @@ AddConfInterval <- function(spec, pval = 0.05, MINVALUE = 1e-10) { spec$lim.1[spec$lim.1 < MINVALUE] <- MINVALUE spec$lim.2[spec$lim.2 < MINVALUE] <- MINVALUE + spec$pval <- pval + return(spec) } diff --git a/README.Rmd b/README.Rmd index 152090d..9b30e35 100644 --- a/README.Rmd +++ b/README.Rmd @@ -29,18 +29,16 @@ PaleoSpec is an R package to assist in the spectral analysis of timeseries, in p You can install the development version of PaleoSpec from [GitHub](https://github.com/) with: -``` r +```{r, eval=FALSE} # install.packages("remotes") remotes::install_github("EarthSystemDiagnostics/paleospec") ``` Please refer to function references here: - https://earthsystemdiagnostics.github.io/paleospec/reference/index.html - ## Usage ### Estimating power spectra diff --git a/README.md b/README.md index 4515e53..69775bd 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,6 @@ remotes::install_github("EarthSystemDiagnostics/paleospec") ``` Please refer to function references here: - ## Usage @@ -46,7 +45,7 @@ sunspot <- datasets::sunspot.month plot(sunspot) ``` - + ``` r library(PaleoSpec) @@ -54,7 +53,7 @@ sp_sun <- SpecMTM(sunspot) LPlot(sp_sun) ``` - + Alternatively we can use the gg_spec() function to get a ggplot2 @@ -64,7 +63,7 @@ gg_spec(sp_sun) #> Adding another scale for colour, which will replace the existing scale. ``` - + Appproximate confidence intervals can be added with the function AddConfInterval() @@ -76,7 +75,7 @@ gg_spec(sp_sun) #> Adding another scale for colour, which will replace the existing scale. ``` - + ### Simulating timeseries with given spectral properties @@ -99,7 +98,7 @@ ts1 <- SimPLS(N = N, b = beta, a = alpha) plot(ts1, type = "l") ``` - + `SpecMTM` can again be used to estimate the power spectrum using the multitaper method. If we convert the vector from SimPLS to a timeseries @@ -113,7 +112,7 @@ LPlot(sp1) abline(log10(alpha), -beta, col = "red") ``` - + You can add confidence intervals to the spectral estimates with `AddConfInterval` @@ -124,7 +123,7 @@ LPlot(sp1) abline(log10(alpha), -beta, col = "red") ``` - + The `LogSmooth` function can be used to smooth power spectra with equally spaced filter in log-space. @@ -135,4 +134,4 @@ LPlot(sp1) LLines(sp1_f, col = "green") ``` - + diff --git a/man/AddConfInterval.Rd b/man/AddConfInterval.Rd index 75c95f1..09efe07 100644 --- a/man/AddConfInterval.Rd +++ b/man/AddConfInterval.Rd @@ -24,7 +24,7 @@ the input object including the new list elements \code{lim.1} and } \description{ Add a confidence interval to a spectral estimate assuming the uncertainty of -the spectral estimates follows a chi-squared distribution with the degress of +the spectral estimates follows a chi-squared distribution with the degrees of the freedom from the spectral estimates. } \examples{ diff --git a/man/figures/README-unnamed-chunk-10-1.png b/man/figures/README-unnamed-chunk-10-1.png new file mode 100644 index 0000000..75cd0a9 Binary files /dev/null and b/man/figures/README-unnamed-chunk-10-1.png differ diff --git a/man/figures/README-unnamed-chunk-2-1.png b/man/figures/README-unnamed-chunk-2-1.png deleted file mode 100644 index f53dcf5..0000000 Binary files a/man/figures/README-unnamed-chunk-2-1.png and /dev/null differ diff --git a/man/figures/README-unnamed-chunk-3-1.png b/man/figures/README-unnamed-chunk-3-1.png index 46c9e7a..f53dcf5 100644 Binary files a/man/figures/README-unnamed-chunk-3-1.png and b/man/figures/README-unnamed-chunk-3-1.png differ diff --git a/man/figures/README-unnamed-chunk-4-1.png b/man/figures/README-unnamed-chunk-4-1.png index 050c59d..46c9e7a 100644 Binary files a/man/figures/README-unnamed-chunk-4-1.png and b/man/figures/README-unnamed-chunk-4-1.png differ diff --git a/man/figures/README-unnamed-chunk-5-1.png b/man/figures/README-unnamed-chunk-5-1.png index 5eaca85..050c59d 100644 Binary files a/man/figures/README-unnamed-chunk-5-1.png and b/man/figures/README-unnamed-chunk-5-1.png differ diff --git a/man/figures/README-unnamed-chunk-6-1.png b/man/figures/README-unnamed-chunk-6-1.png index 0cec6ea..5eaca85 100644 Binary files a/man/figures/README-unnamed-chunk-6-1.png and b/man/figures/README-unnamed-chunk-6-1.png differ diff --git a/man/figures/README-unnamed-chunk-6-2.png b/man/figures/README-unnamed-chunk-6-2.png deleted file mode 100644 index ad35cfa..0000000 Binary files a/man/figures/README-unnamed-chunk-6-2.png and /dev/null differ diff --git a/man/figures/README-unnamed-chunk-6-3.png b/man/figures/README-unnamed-chunk-6-3.png deleted file mode 100644 index d459fd5..0000000 Binary files a/man/figures/README-unnamed-chunk-6-3.png and /dev/null differ diff --git a/man/figures/README-unnamed-chunk-7-1.png b/man/figures/README-unnamed-chunk-7-1.png index c3d603f..0cec6ea 100644 Binary files a/man/figures/README-unnamed-chunk-7-1.png and b/man/figures/README-unnamed-chunk-7-1.png differ diff --git a/man/figures/README-unnamed-chunk-8-1.png b/man/figures/README-unnamed-chunk-8-1.png index 1540779..c3d603f 100644 Binary files a/man/figures/README-unnamed-chunk-8-1.png and b/man/figures/README-unnamed-chunk-8-1.png differ diff --git a/man/figures/README-unnamed-chunk-9-1.png b/man/figures/README-unnamed-chunk-9-1.png index 75cd0a9..1540779 100644 Binary files a/man/figures/README-unnamed-chunk-9-1.png and b/man/figures/README-unnamed-chunk-9-1.png differ