Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Areas of Bivarate Density Distributions

License

NotificationsYou must be signed in to change notification settings

JoFrhwld/densityarea

Repository files navigation

R-CMD-checkCRAN statuspkgdownDOI

The package{ggdensity}1 allows for plotting interpretablebivariate densities by using highest density ranges (HDRs). For example:

library(tibble)library(ggplot2)library(ggdensity)set.seed(10)df<- tibble(x= c(rnorm(100), rnorm(100,mean=3)),y= c(rnorm(100), rnorm(100,mean=3)))ggplot(df, aes(x,y))+  stat_hdr()

{densityarea} gives direct access to these HDRs, either as data framesor assimple features, for furtheranalysis.

Installation

You can install{densityarea} from CRAN with:

install.packages("densityarea")

Or you can install the development version fromGitHub with:

# install.packages("devtools")devtools::install_github("JoFrhwld/densityarea")

Example

The use case the package was initially developed for was for estimatingvowel space areas.

library(densityarea)library(dplyr)library(tidyr)library(sf)data(s01)# initial data processings01|>   mutate(lF1=-log(F1),lF2=-log(F2))->s01

To get this speaker’s vowel space area we can pass the data throughdplyr::reframe()

s01|>   reframe(    density_area(lF2,lF1,probs=0.8)  )#> # A tibble: 1 × 3#>   level_id  prob  area#>      <int> <dbl> <dbl>#> 1        1   0.8 0.406

Or, we could get the spatial polygon associated with the 80% probabilitylevel

s01|>   reframe(    density_polygons(lF2,lF1,probs=0.8,as_sf=T)  )#> # A tibble: 1 × 3#>   level_id  prob                                                        geometry#>      <int> <dbl>                                                       <POLYGON>#> 1        1   0.8 ((-7.777586 -6.009484, -7.801131 -6.010429, -7.824676 -6.01700…

For more

For more details on using{densityarea}, see , and for furtherinformation on using spatial polygons, seevignette("sf-operations").

Footnotes

  1. Otto J, Kahle D (2023).ggdensity: Interpretable BivariateDensity Visualization with ‘ggplot2’.https://jamesotto852.github.io/ggdensity/https://github.com/jamesotto852/ggdensity/

About

Areas of Bivarate Density Distributions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp