Skip to content

Commit

Permalink
Merge branch 'dev-docs' of github.com:EarthSystemDiagnostics/paleospe…
Browse files Browse the repository at this point in the history
…c into dev-docs

# Conflicts:
#	README.Rmd
  • Loading branch information
andrewdolman committed Feb 15, 2024
2 parents 143150d + 861d449 commit b4b70d2
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 17 deletions.
5 changes: 4 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ Suggests:
covr,
testthat,
ggplot2,
tibble
tibble,
knitr,
rmarkdown
URL: https://earthsystemdiagnostics.github.io/paleospec/
VignetteBuilder: knitr
8 changes: 5 additions & 3 deletions R/AddConfInterval.R
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -16,7 +16,7 @@
#' respectively.
#' @author Thomas Laepple
#' @examples
#'
#'
#' N.R <- 1000
#' N.T <- 100
#' save.spec <- matrix(NA, N.T / 2, N.R)
Expand All @@ -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) {

Expand All @@ -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)

}
4 changes: 1 addition & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ remotes::install_github("EarthSystemDiagnostics/paleospec")
```

Please refer to function references here:

<https://earthsystemdiagnostics.github.io/paleospec/reference/index.html>

## Usage
Expand All @@ -46,15 +45,15 @@ sunspot <- datasets::sunspot.month
plot(sunspot)
```

<img src="man/figures/README-unnamed-chunk-2-1.png" width="100%" />
<img src="man/figures/README-unnamed-chunk-3-1.png" width="100%" />

``` r
library(PaleoSpec)
sp_sun <- SpecMTM(sunspot)
LPlot(sp_sun)
```

<img src="man/figures/README-unnamed-chunk-3-1.png" width="100%" />
<img src="man/figures/README-unnamed-chunk-4-1.png" width="100%" />

Alternatively we can use the gg_spec() function to get a ggplot2

Expand All @@ -64,7 +63,7 @@ gg_spec(sp_sun)
#> Adding another scale for colour, which will replace the existing scale.
```

<img src="man/figures/README-unnamed-chunk-4-1.png" width="100%" />
<img src="man/figures/README-unnamed-chunk-5-1.png" width="100%" />

Appproximate confidence intervals can be added with the function
AddConfInterval()
Expand All @@ -76,7 +75,7 @@ gg_spec(sp_sun)
#> Adding another scale for colour, which will replace the existing scale.
```

<img src="man/figures/README-unnamed-chunk-5-1.png" width="100%" />
<img src="man/figures/README-unnamed-chunk-6-1.png" width="100%" />

### Simulating timeseries with given spectral properties

Expand All @@ -99,7 +98,7 @@ ts1 <- SimPLS(N = N, b = beta, a = alpha)
plot(ts1, type = "l")
```

<img src="man/figures/README-unnamed-chunk-6-1.png" width="100%" />
<img src="man/figures/README-unnamed-chunk-7-1.png" width="100%" />

`SpecMTM` can again be used to estimate the power spectrum using the
multitaper method. If we convert the vector from SimPLS to a timeseries
Expand All @@ -113,7 +112,7 @@ LPlot(sp1)
abline(log10(alpha), -beta, col = "red")
```

<img src="man/figures/README-unnamed-chunk-7-1.png" width="100%" />
<img src="man/figures/README-unnamed-chunk-8-1.png" width="100%" />

You can add confidence intervals to the spectral estimates with
`AddConfInterval`
Expand All @@ -124,7 +123,7 @@ LPlot(sp1)
abline(log10(alpha), -beta, col = "red")
```

<img src="man/figures/README-unnamed-chunk-8-1.png" width="100%" />
<img src="man/figures/README-unnamed-chunk-9-1.png" width="100%" />

The `LogSmooth` function can be used to smooth power spectra with
equally spaced filter in log-space.
Expand All @@ -135,4 +134,4 @@ LPlot(sp1)
LLines(sp1_f, col = "green")
```

<img src="man/figures/README-unnamed-chunk-9-1.png" width="100%" />
<img src="man/figures/README-unnamed-chunk-10-1.png" width="100%" />
2 changes: 1 addition & 1 deletion man/AddConfInterval.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added man/figures/README-unnamed-chunk-10-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed man/figures/README-unnamed-chunk-2-1.png
Binary file not shown.
Binary file modified man/figures/README-unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-4-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-5-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-6-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed man/figures/README-unnamed-chunk-6-2.png
Binary file not shown.
Binary file removed man/figures/README-unnamed-chunk-6-3.png
Binary file not shown.
Binary file modified man/figures/README-unnamed-chunk-7-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-8-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-9-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b4b70d2

Please sign in to comment.