R Language on R Views
https://rviews.rstudio.com/tags/r-language/
Recent content in R Language on R ViewsHugo -- gohugo.ioen-usTue, 21 Dec 2021 00:00:00 +0000November 2021: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2021/12/21/november-2021-top-40-new-cran-packages/
Tue, 21 Dec 2021 00:00:00 +0000https://rviews.rstudio.com/2021/12/21/november-2021-top-40-new-cran-packages/
<p>Two hundred eleven new packages made it to CRAN in November. Here are my “Top 40” picks in thirteen categories: Computational Methods, Data, Ecology, Finance, Genomics, Humanities, Machine Learning, Medicine, Networks, Statistics, Time Series, Utilities, and Visualization. It was gratifying to see multiple packages developed for applications in the Computational Humanities. R is helping to extend the reach of data literacy.</p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=bigQF">bigQF</a> v1.6: Implements a computationally efficient leading-eigenvalue approximation to tail probabilities and quantiles of large quadratic forms (e.g. in the sequence kernel association test) and also provides stochastic singular value decomposition for dense or sparse matrices. See <a href="https://onlinelibrary.wiley.com/doi/10.1002/gepi.22136">Lumley et al. (2018)</a> for background and the vignettes: <a href="https://cran.r-project.org/web/packages/bigQF/vignettes/check-vs-SKAT-2.html">Checking pQF vs SKAT</a>, <a href="https://cran.r-project.org/web/packages/bigQF/vignettes/matrix-free.html">Matrix-free computations</a>, <a href="https://cran.r-project.org/web/packages/bigQF/vignettes/skat-proj.html">SKAT, weights, and projections</a>.</p>
<p><a href="https://cran.r-project.org/package=LMMsolver">LMMsolver</a> v1.0.0: Implements an efficient system to solve sparse, mixed model equations. See the <a href="https://cran.r-project.org/web/packages/LMMsolver/vignettes/Solving_Linear_Mixed_Models.html">vignette</a>.</p>
<p><img src="LMMsolver.png" height = "300" width="500" alt="Heat map of precipitation anomalies"></p>
<p><a href="https://cran.r-project.org/package=nimbleAPT">nimbleAPT</a> v1.0.4: Provides functions for <a href="https://www.tandfonline.com/doi/abs/10.1080/10618600.2013.778779">adaptive parallel tempering</a> with <code>nimble</code> models. See <a href="https://link.springer.com/article/10.1007%2Fs11222-015-9579-0">Lacki & Miasojedow (2016)</a> and the <a href="https://cran.r-project.org/web/packages/nimbleAPT/vignettes/nimbleAPT-vignette.html">vignette</a> to get started.</p>
<p><img src="nimbleAPT.png" height = "300" width="400" alt="Plot of jumps and samples"></p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=binancer">binancer</a> v1.2.0: Implements an R client to the <a href="https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md">Binance Public Rest API</a> for data collection on cryptocurrencies, portfolio management and trading. See <a href="https://cran.r-project.org/web/packages/binancer/readme/README.html">README</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=japanstat">japanstat</a> v0.1.0: Provides tools for using the API of <a href="https://www.e-stat.go.jp/">e-Stat</a>, a portal site for Japanese government statistics which include functions for automatic query generation, data collection and formatting. See <a href="https://cran.r-project.org/web/packages/japanstat/readme/README.html">README</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=openeo">openeo</a> v1.1.0: Provides to access data and processing for <a href="https://github.com/Open-EO/openeo-r-client">openEO</a> compliant back-ends. See the <a href="https://cran.r-project.org/web/packages/openeo/vignettes/getting_started.html">vignette</a> to get started.</p>
<h3 id="ecology">Ecology</h3>
<p><a href="https://cran.r-project.org/package=mFD">mFD</a> v1.0.1: Provides functions to compute functional traits-based distances between pairs of species for species gathered in assemblages. <a href="https://esajournals.onlinelibrary.wiley.com/doi/10.1002/ecm.1343">Chao et al. (2018)</a> and <a href="https://onlinelibrary.wiley.com/doi/10.1111/geb.12299">Mouillot et al. (2013)</a> along with the other references listed for background. There are five vignettes including <a href="https://cran.r-project.org/web/packages/mFD/vignettes/mFD_general_workflow.html">General Workflow</a> and <a href="https://cran.r-project.org/web/packages/mFD/vignettes/Compute_and_interpret_quality_of_functional_spaces.html">Compute and Interpret Quality of Functional Spaces</a></p>
<p><img src="mFD.png" height = "300" width="500" alt="Plots of trait differences"></p>
<p><a href="https://cran.r-project.org/package=popbayes">popbayes</a> v1.0: Implements a Bayesian framework to infer the trends of animal populations over time from series of counts by accounting for count precision, smoothing the population rate of increase over time, and accounting for the maximum demographic potential of species. There is a <a href="https://cran.r-project.org/web/packages/popbayes/vignettes/popbayes.html">Get started</a> vignette and another on <a href="https://cran.r-project.org/web/packages/popbayes/vignettes/generate_data.html">Getting species information</a>.</p>
<p><img src="popbayes.png" height = "300" width="500" alt="Plot of population size over time"></p>
<h3 id="finance">Finance</h3>
<p><a href="https://onlinelibrary.wiley.com/doi/10.1111/jofi.12131">MultiATSM</a> v0.0.1: Provides functions to model the affine term structure of interest rates based on the single-country unspanned macroeconomic risk framework of <a href="https://www.sciencedirect.com/science/article/abs/pii/S0304405X14001883?via%3Dihub">Joslin et al. (2014)</a> and the multi country extensions of <a href="https://doi.org/10.1016%2Fj.jfineco.2014.09.004">Jotikasthira et al.(2015)</a>, and <a href="https://dial.uclouvain.be/pr/boreal/object/boreal:249985">Candelon and Moura (2021)</a>. See the <a href="https://cran.r-project.org/web/packages/MultiATSM/vignettes/my-vignette.html">vignette</a> for an example.</p>
<p><img src="MultiATSM.png" height = "300" width="400" alt="Plot of level, slope and curvature by maturity years"></p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=gwasrapidd">gwasrapidd</a> v0.99.12: Provides easy access to the NHGRI-EBI <a href="https://www.ebi.ac.uk/gwas/">GWAS Catalog</a> via the <a href="https://www.ebi.ac.uk/gwas/rest/docs/api/">REST API</a>. There is a <a href="https://cran.r-project.org/web/packages/gwasrapidd/vignettes/gwasrapidd.html">Getting Started Guide</a>, a vignette on <a href="https://cran.r-project.org/web/packages/gwasrapidd/vignettes/bmi_variants.html">Variants associated with BMI</a>, and an <a href="https://cran.r-project.org/web/packages/gwasrapidd/vignettes/faq.html">FAQ</a>.</p>
<p><img src="gwasrapidd.png" height = "300" width="500" alt="Examples of search criteria"></p>
<p><a href="https://cran.r-project.org/package=phylosamp">phylosamp</a> v0.1.6: Implements tools to estimate the probability of true transmission between two cases given phylogenetic linkage and the expected number of true transmission links in a sample. The methods are described in <a href="https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1009182">Wohl et al. (2021)</a>. There are vignettes on estimating <a href="https://cran.r-project.org/web/packages/phylosamp/vignettes/V1_FalseDicoveryRate.html">FDR from sample size</a>, <a href="https://cran.r-project.org/web/packages/phylosamp/vignettes/V2_SampleSize.html">Sample size from FDR</a>, <a href="https://cran.r-project.org/web/packages/phylosamp/vignettes/V3_SensitivitySpecificity.html">Sensitivity and specificity</a>, and <a href="https://cran.r-project.org/web/packages/phylosamp/vignettes/V4_FullExamples.html">Examples</a>.</p>
<p><img src="phylosamp.png" height = "300" width="500" alt="Histogram of Genetic Distance"></p>
<p><a href="https://cran.r-project.org/package=Rtropical">Rtropical</a> v1.2.1: Provides functions to process phylogenetic trees with tropical support vector machines and principal component analysis defined with tropical geometry. See <a href="https://arxiv.org/abs/2003.00677">Tang et al. (2020)</a> for details about tropical SVMs, <a href="https://academic.oup.com/bioinformatics/article/36/17/4590/5855129">Page et al. (2020)</a> and <a href="https://link.springer.com/article/10.1007%2Fs11538-018-0493-4">Yoshida et al. (2019)</a> for tropical PCA, and <a href="https://arxiv.org/pdf/0706.2920.pdf">Ardila & Develin (2007)</a> for some background on tropical mathematics. The <a href="https://cran.r-project.org/web/packages/Rtropical/vignettes/usage.html">vignette</a> will get you started.</p>
<h3 id="humanities">Humanities</h3>
<p><a href="https://cran.r-project.org/package=litRiddle">litRiddle</a> v0.4.1: Provides a dataset, functions to explore the quality of literary novels, the data of a reader survey about fiction in Dutch, a description of the novels the readers rated, and the results of stylistic measurements of the novels. There is a <a href="https://cran.r-project.org/web/packages/litRiddle/vignettes/litRiddle.html">vignette</a>.</p>
<p><img src="litRiddle.png" height = "400" width="400" alt="Histograms of Literariness by Gender"></p>
<p><a href="https://cran.r-project.org/package=kairos">kairos</a> v1.0.0: Provides a toolkit for absolute dating and analysis of chronological patterns, including functions for chronological modeling and dating of archaeological assemblages from count data. There is a <a href="https://cran.r-project.org/web/packages/kairos/vignettes/kairos.html">Manual</a>, and a <a href="https://cran.r-project.org/web/packages/kairos/vignettes/bibliography.html">Bibliography</a>.</p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=cuda.ml">cuda.ml</a> v0.3.1: Implements an R interface for <a href="https://github.com/rapidsai/cuml">RAPIDS cuML</a>, a suite of GPU-accelerated machine learning libraries powered by <a href="https://en.wikipedia.org/wiki/CUDA">CUDA</a>. Look <a href="https://mlverse.github.io/cuda.ml/">here</a> for an example.</p>
<p><img src="cuda.png" height = "300" width="500" alt="Projection map of manifold embedding"></p>
<p><a href="https://cran.r-project.org/package=innsight">innsight</a> v0.1.1: Implements methods to analyze the behavior and individual predictions of modern neural networks including Connection Weights as described by <a href="https://www.sciencedirect.com/science/article/abs/pii/S0304380004001565?via%3Dihub">Olden et al. (2004)</a>, Layer-wise Relevance Propagation as described by <a href="https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0130140">Bach et al. (2015)</a>, Deep Learning Important Features as described by <a href="https://arxiv.org/abs/1704.02685">Shrikumar et al. (2017)</a>, and gradient-based methods like SmoothGrad described by <a href="https://arxiv.org/abs/1706.03825">Smilkov et al. (2017)</a>, and Gradient x Input described by <a href="https://arxiv.org/abs/0912.1128">Baehrens et al. (2009)</a>. There is an <a href="https://cran.r-project.org/web/packages/innsight/vignettes/innsight.html">Introduction</a> and a vignette on <a href="https://cran.r-project.org/web/packages/innsight/vignettes/Custom_Model_Definition.html">Custom Model Definition</a>.</p>
<p><img src="innsight.png" height = "300" width="500" alt="Heatmap showing feature relevance"></p>
<p><a href="https://cran.r-project.org/package=topicmodels.etm">topicmodels.etm</a> v0.1.0: Provides functions to find topics in texts which are semantically embedded using techniques like <a href="https://en.wikipedia.org/wiki/Word2vec">word2vec</a> or <a href="https://nlp.stanford.edu/projects/glove/">GloVe</a>. See <a href="https://arxiv.org/abs/1907.04907">Dieng et al. (2019)</a> for the details, and look <a href="https://cran.r-project.org/web/packages/topicmodels.etm/readme/README.html">here</a> for an example.</p>
<p><img src="topic.png" height = "300" width="500" alt="Plot of ETM clusters"></p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=clustra">clustra</a> v0.1.5: Provides functions to cluster medical trajectories of unequally spaced and unequal length time series aligned by an intervention time. See the <a href="https://cran.r-project.org/web/packages/clustra/vignettes/clustra_vignette.html">vignette</a> for examples.</p>
<p><img src="clustra.png" height = "500" width="400" alt="Plot of trajectories clustered by group"></p>
<p><a href="https://cran.r-project.org/package=eSIR">eSIR</a> v0.4.2: Implements the extended state-space SIR models developed by <a href="http://websites.umich.edu/~songlab/">Song Lab</a> at UM school of Public Health which include capabilities to model time-varying transmission, time-dependent quarantine, and time-dependent antibody-immunization. See <a href="https://jds-online.org/journal/JDS/article/28/info">Wang et al. (2020)</a> for background, and <a href="https://cran.r-project.org/web/packages/eSIR/readme/README.html">README</a> for examples.</p>
<p><img src="eSIR.png" height = "300" width="500" alt="Plot of Probability of infection over time"></p>
<p><a href="https://cran.r-project.org/package=QHScrnomo">QHScrnomo</a> v2.2.0: Provides functions for fitting and predicting competing risk models, creating nomograms, k-fold cross validation, calculating the discrimination metric, and drawing calibration curves. See the <a href="https://cran.r-project.org/web/packages/QHScrnomo/vignettes/introduction.html">vignette</a> for a short tutorial.</p>
<p><img src="QHS.png" height = "300" width="500" alt="Example of a nomogram"></p>
<p><a href="https://cran.r-project.org/package=rnmamod">rnmamod</a> v0.1.0: Implements a comprehensive suite of functions to perform and visualize pairwise and network meta-analyses. The package covers core Bayesian one-stage models implemented in a systematic review with multiple interventions, including fixed-effect and random-effects network meta-analysis. There are vignettes on <a href="https://cran.r-project.org/web/packages/rnmamod/vignettes/perform_network_metaanalysis.html">Performing a network meta-analysis</a> and <a href="https://cran.r-project.org/web/packages/rnmamod/vignettes/network_description.html">Describing the network</a>.</p>
<p><img src="rnmamod.png" height = "300" width="500" alt="Map of network of interventions evaluated"></p>
<p><a href="https://cran.r-project.org/package=whomds">whomds</a> v1.0.1: Provides functions for calculating and presenting the results from the <a href="https://www.who.int/home/cms-decommissioning">WHO</a> Model Disability Survey (<a href="https://www.who.int/publications/i/item/9789241512862">MDA</a>). See <a href="https://www.who.int/publications/i/item/9789241512862">Andrich (2014)</a> for background on Rasch measurement. There are English and Spanish versions of six vignettes including <a href="https://cran.r-project.org/web/packages/whomds/vignettes/c1_background_EN.html">Background on disability measurement</a> and <a href="https://cran.r-project.org/web/packages/whomds/vignettes/c5_best_practices_EN.html">Best practices with Rasch Analysis</a>.</p>
<p><img src="whomds.png" height = "300" width="600" alt="Illustration of disability scores"></p>
<h3 id="networks">Networks</h3>
<p><a href="https://CRAN.R-project.org/package=diffudist">diffudist</a> v1.0.0: Enables the evaluation of diffusion distances for complex single-layer networks by providing functions to evaluate the Laplacians, stochastic matrices, and the corresponding diffusion distance matrices. See <a href="https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.118.168301">De Domenico (2017)</a> and <a href="https://journals.aps.org/pre/abstract/10.1103/PhysRevE.103.042301">Bertagnolli & De Domenico (2021)</a> for the details and the <a href="https://cran.r-project.org/web/packages/diffudist/vignettes/diffusion-distances.html">vignette</a> for some theory and examples.</p>
<p><img src="diffudist.png" height = "300" width="500" alt="Hierarchical cluster plots of distances"></p>
<p><a href="https://cran.r-project.org/package=NetFACS">NetFACS</a> V0.3.0: Provides functions to analyze and visualize facial communication data, based on network theory and resampling methods and primarily targeted at datasets of facial expressions coded with the <a href="https://www.paulekman.com/facial-action-coding-system/">Facial Action Coding System</a>. See <a href="https://besjournals.onlinelibrary.wiley.com/doi/10.1111/2041-210X.12772">Farine (2017)</a> and <a href="https://methods.sagepub.com/book/monte-carlo-simulation-and-resampling-methods-for-social-science">Carsey & Harden (2014)</a> for background, and the <a href="https://cran.r-project.org/web/packages/NetFACS/vignettes/tutorial.html">vignette</a> for an introduction.</p>
<p><img src="NetFACS.png" height = "300" width="500" alt="Network of facial expressions"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=adass">adass</a> v1.0.0: Implements the adaptive smoothing spline estimator for the function-on-function linear regression model described in <a href="https://arxiv.org/abs/2011.12036">Centofanti et al. (2020)</a>. Look <a href="https://github.com/unina-sfere/adass">here</a> for an example.</p>
<p><img src="adass.png" height = "300" width="500" alt="Heatmap of adaptive spline estimator"></p>
<p><a href="https://cran.r-project.org/package=OneSampleMR">OneSampleMR</a> v0.1.0: Provides functions for one sample Mendelian randomization and instrumental variable analyses including implementations of the <a href="https://www.sciencedirect.com/science/article/pii/S0304407615001736?via%3Dihub">Sanderson & Windmeijer (2016)</a> conditional F-statistic, the multiplicative structural mean model <a href="https://journals.lww.com/epidem/Fulltext/2006/07000/Instruments_for_Causal_Inference__An.4.aspx">Hernán and Robins (2006)</a>, and two-stage predictor substitution and two-stage residual inclusion estimators explained by <a href="https://www.sciencedirect.com/science/article/abs/pii/S0167629607001063?via%3Dihub">Terza et al. (2008)</a>. There are short vignettes on the <a href="https://cran.r-project.org/web/packages/OneSampleMR/vignettes/compare-smm-fits.html">Multiplicative structural mean model</a> and the <a href="https://cran.r-project.org/web/packages/OneSampleMR/vignettes/f-statistic-comparison.html">Coditional F-Statistic</a>.</p>
<p><a href="https://cran.r-project.org/package=PhaseTypeR">PhaseTypeR</a> v1.0.1: Implements functions to model continuous and discrete <a href="https://en.wikipedia.org/wiki/Phase-type_distribution">phase-type distributions</a>, both univariate and multivariate. See <a href="https://orbit.dtu.dk/en/publications/order-statistics-and-multivariate-discrete-phase-type-distributio">Navarro (2019)</a> for background. There is an <a href="https://cran.r-project.org/web/packages/PhaseTypeR/vignettes/PhaseTypeR.html">Introduction</a> and vignettes on <a href="https://cran.r-project.org/web/packages/PhaseTypeR/vignettes/a2_pop_gen_iker.html">Population Genetics</a> and <a href="https://cran.r-project.org/web/packages/PhaseTypeR/vignettes/a3_phasetypeR_SFS.html">The Site Frequency Spectrum</a>.</p>
<p><img src="PhaseTypeR.png" height = "300" width="500" alt="Histogram of Phase Type Distribution"></p>
<p><a href="https://cran.r-project.org/package=stan4bart">stan4bart</a> v0.0-2: Fits semiparametric linear and multilevel models with non-parametric additive Bayesian additive regression trees <a href="https://projecteuclid.org/journals/annals-of-applied-statistics/volume-4/issue-1/BART-Bayesian-additive-regression-trees/10.1214/09-AOAS285.full">BART</a> and <code>Stan</code>. Multilevel models can be expressed using <a href="https://www.jstatsoft.org/article/view/v067i01"><code>lme4</code> syntax</a>. Look <a href="https://github.com/vdorie/stan4bart">here</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=zoid">zoid</a> v1.0.0: Fits Dirichlet regression and zero-and-one inflated Dirichlet regression (also called trinomial mixture models) with Bayesian methods implemented in <code>Stan</code>. There are vignettes on <a href="https://cran.r-project.org/web/packages/zoid/vignettes/a01_fitting.html">Fitting Models</a>, <a href="https://cran.r-project.org/web/packages/zoid/vignettes/a02_simulating.html">Simulating data</a>, <a href="https://cran.r-project.org/web/packages/zoid/vignettes/a03_beta_priors.html">Priors</a>, and <a href="https://cran.r-project.org/web/packages/zoid/vignettes/a04_priors.html">Prior sensitivity for overdispersion</a>.</p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=surveil">surveil</a> v0.1.0: Fits time series models for routine disease surveillance tasks and returns probability distributions for a variety of quantities of interest, including measures of health inequality, period and cumulative percent change, and age-standardized rates. See the <a href="https://cran.r-project.org/web/packages/surveil/vignettes/demonstration.html">vignette</a> for an introduction.</p>
<p><img src="surveil.png" height = "300" width="400" alt="Plot time series by race"></p>
<p><a href="https://cran.r-project.org/package=VisitorCounts">VisitorCounts</a> v1.0.0: Provides functions for modeling and forecasting of park visitor counts using social media data and (partial) on-site visitor counts. See <a href="https://www.nature.com/articles/srep02976">Wood et al. (2013)</a> for background and the <a href="https://cran.r-project.org/web/packages/VisitorCounts/vignettes/VisitorCounts.html">vignette</a> for examples.</p>
<p><img src="VisitorCounts.png" height = "300" width="500" alt="Plot of model fits and differences"></p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=dateutils">dateutils</a> v0.1.5: Provides utilities for mixed frequency data, in particular, to aggregate and normalize tabular mixed frequency data, index dates to end of period, and seasonally adjust tabular data. There is an <a href="https://cran.r-project.org/web/packages/dateutils/vignettes/intro.html">Introduction</a>.</p>
<p><a href="https://cran.r-project.org/package=datefixR">datefixR</a> v0.1.2: Provides functions to fix messy dates such as those entered via text boxes. Standardizes “/” or “-”, whitespace separation, month abbreviations, and more. See the <a href="https://cran.r-project.org/web/packages/datefixR/vignettes/datefixR.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=lambdr">lambdar</a> v1.1.0: Provides functions for serving containers that can execute R code on the <a href="https://aws.amazon.com/lambda/">AWS Lambda</a> serverless compute service. There are five vignettes including <a href="https://cran.r-project.org/web/packages/lambdr/vignettes/api-gateway-invocations.html">api-gateway-invocations</a> and <a href="https://cran.r-project.org/web/packages/lambdr/vignettes/lambda-runtime-in-container.html">lambda-runtime-in-container</a>.</p>
<p><img src="lambdar.svg" height = "300" width="500" alt="Diagram of package structure"></p>
<p><a href="https://cran.r-project.org/package=mtb">mtb</a> v0.1.1: Provides functions to summarize time related data, generate axis transformation from data, and assist Markdown and Shiny file editing. There are vignettes on working with <a href="https://cran.r-project.org/web/packages/mtb/vignettes/vignette_mtb_axis.html">axes</a>, <a href="https://cran.r-project.org/web/packages/mtb/vignettes/vignette_mtb_color.html">color</a>, <a href="https://cran.r-project.org/web/packages/mtb/vignettes/vignette_mtb_md.html">Markdown</a>, and <a href="https://cran.r-project.org/web/packages/mtb/vignettes/vignette_mtb_timerelated.html">time related data</a>.</p>
<p><img src="mtb.png" height = "300" width="500" alt="Diagram showing arrows associated with times"></p>
<p><a href="https://cran.r-project.org/package=rocker">rocker</a> v0.2.1: Provides an <code>R6</code> class interface for handling database connections using the <code>DBI</code> package as backend which allows handling of connections to <code>PostgreSQL</code>, <code>MariaDB</code>, <code>SQLite</code> and other databases. There are seven short vignettes including <a href="https://cran.r-project.org/web/packages/rocker/vignettes/DBI_objects_and_functions.html">DBI package objects and functions in R6 rocker class</a> and <a href="https://cran.r-project.org/web/packages/rocker/vignettes/Transactions.html">Database transactions with R6 rocker class</a>.</p>
<p><a href="https://cran.r-project.org/package=shinySelect">shinySelect</a> v1.0.0: Provides a customizable, select control widget for <code>Shiny</code> to enable using HTML in the items and <a href="https://katex.org/">KaTeX</a> to type mathematics. Look <a href="https://github.com/stla/shinySelect">here</a> for examples.</p>
<p><img src="katex.gif" height = "300" width="500" alt="Mathematics in Shiny select bar"></p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=gggrid">gggrid</a> v0.1-1: Extends<code>ggplot2</code> to make it easy to add raw <code>grid</code> output, such as customised annotations, to a plot. See the <a href="https://cran.r-project.org/web/packages/gggrid/vignettes/gggrid.html">vignette</a> for examples.</p>
<p><img src="gggrid.png" height = "300" width="500" alt="latitude vs. longitude plot"></p>
<p><a href="https://cran.r-project.org/package=NHSRplotthedots">NHSRplotthedots</a> v0.1.0: Provides tools for drawing statistical process control charts with functions to draw <a href="https://www.pqsystems.com/qualityadvisor/DataAnalysisTools/x_mr.php">XmR</a> charts, use change points and apply rules with summary indicators for when rules are breached. There is an <a href="https://cran.r-project.org/web/packages/NHSRplotthedots/vignettes/intro.html">Introduction</a> and vignettes <a href="https://cran.r-project.org/web/packages/NHSRplotthedots/vignettes/deviations.html">Deviations from Excel defaults</a> and <a href="https://cran.r-project.org/web/packages/NHSRplotthedots/vignettes/number-of-points-required.html">Number of points required</a>.</p>
<p><img src="NHSR.png" height = "300" width="500" alt="SPC Charts"></p>
<p><a href="https://cran.r-project.org/package=shinymodels">shinymodels</a> v0.1.0: Allows users to launch a <code>shiny</code> application for <code>tidymodels</code> results. For classification or regression models, the app can be used to determine if there is lack of fit or poorly predicted points. Look <a href="https://github.com/tidymodels/shinymodels">here</a> to get started.</p>
<p><img src="shinymodels.png" height = "300" width="500" alt="Shiny generated scatter plots"></p>
<script>window.location.href='https://rviews.rstudio.com/2021/12/21/november-2021-top-40-new-cran-packages/';</script>
The COVID19 package, an interface to the COVID-19 Data Hub
https://rviews.rstudio.com/2021/12/08/the-r-package-covid19/
Wed, 08 Dec 2021 00:00:00 +0000https://rviews.rstudio.com/2021/12/08/the-r-package-covid19/
<script src="/2021/12/08/the-r-package-covid19/index_files/header-attrs/header-attrs.js"></script>
<script src="/2021/12/08/the-r-package-covid19/index_files/htmlwidgets/htmlwidgets.js"></script>
<script src="/2021/12/08/the-r-package-covid19/index_files/jquery/jquery.min.js"></script>
<link href="/2021/12/08/the-r-package-covid19/index_files/dygraphs/dygraph.css" rel="stylesheet" />
<script src="/2021/12/08/the-r-package-covid19/index_files/dygraphs/dygraph-combined.js"></script>
<script src="/2021/12/08/the-r-package-covid19/index_files/dygraphs/shapes.js"></script>
<script src="/2021/12/08/the-r-package-covid19/index_files/moment/moment.js"></script>
<script src="/2021/12/08/the-r-package-covid19/index_files/moment-timezone/moment-timezone-with-data.js"></script>
<script src="/2021/12/08/the-r-package-covid19/index_files/moment-fquarter/moment-fquarter.min.js"></script>
<script src="/2021/12/08/the-r-package-covid19/index_files/dygraphs-binding/dygraphs.js"></script>
<p><img src="logo.png" style="float:right" height="128" width = "128" /></p>
<p><a href="https://cran.r-project.org/package=COVID19"><img src="https://www.r-pkg.org/badges/version/COVID19" style="display:inline-block"/></a>
<a href="https://cran.r-project.org/package=COVID19"><img src="https://cranlogs.r-pkg.org/badges/last-month/COVID19" style="display:inline-block"/></a>
<a href="https://doi.org/10.21105/joss.02376"><img src="https://joss.theoj.org/papers/10.21105/joss.02376/status.svg" style="display:inline-block"/></a></p>
<p>The <a href="https://covid19datahub.io">COVID-19 Data Hub</a> provides a daily summary of COVID-19 cases, deaths, recovered, tests, vaccinations, and hospitalizations for 230+ countries, 760+ regions, and 12000+ administrative divisions of lower level. It includes policy measures, mobility, and geospatial data. This post presents version 3.0.0 of the <code>COVID19</code> package to seamlessly import the data in R.</p>
<div id="why-another-package-for-covid-19-data" class="section level2">
<h2>Why another package for COVID-19 data</h2>
<p>Many packages now exist to retrieve COVID-19 related data from within R. As an example, <a href="https://cran.r-project.org/package=covid19br">covid19br</a> retrieves case data for Brazil, <a href="https://cran.r-project.org/package=covid19sf">covid19sf</a> for San Francisco, <a href="https://cran.r-project.org/package=covid19us">covid19us</a> for United States, <a href="https://cran.r-project.org/package=covid19india">covid19india</a> for India, <a href="https://cran.r-project.org/package=covid19italy">covid19italy</a> for Italy, <a href="https://cran.r-project.org/package=covid19swiss">covid19swiss</a> for Switzerland, <a href="https://cran.r-project.org/package=covid19france">covid19france</a> for France, and so on. There also other packages, such as <a href="https://cran.r-project.org/package=coronavirus">coronavirus</a>, that retrieve national-level statistics worldwide from the Center for Systems Science and Engineering at Johns Hopkins University (JHU CCSE). However, national counts only represent a small portion of the available governmental data, and having the information scattered across many packages and different interfaces makes international comparisons of large, detailed outbreak data difficult, and prevents
inferences from such data to be effective.</p>
<p><code>COVID19</code> is the official package created around <a href="https://covid19datahub.io">COVID-19 Data Hub</a>: a unified database harmonizing open governmental data around the globe at fine-grained spatial resolution. Moreover, as epidemiological data alone are typically of limited use, the database includes a set of identifiers to match the epidemiological data with exogenous indicators and geospatial information. By unifying the access to the data, this database makes it possible to study the pandemic in its global scale with high resolution, taking into account within-country variations, non pharmaceutical interventions, and environmental and exogenous variables.</p>
<p>In particular, this package allows you to download a large set of <a href="https://covid19datahub.io/articles/docs.html#epidemiological-variables">epidemiological variables</a>, exogenous indicators from <a href="https://data.worldbank.org/">World Bank</a>, mobility data from <a href="https://www.google.com/covid19/mobility/">Google</a> and <a href="https://www.apple.com/covid19/mobility">Apple</a> mobility reports, and geospatial information from <a href="https://ec.europa.eu/eurostat/web/nuts/nuts-maps">Eurostat</a> for Europe or <a href="https://gadm.org/">GADM</a> worldwide, in, literally, one line of code.</p>
</div>
<div id="whats-new-in-version-3.0.0" class="section level2">
<h2>What’s new in version 3.0.0</h2>
<p>Version 3 is a major update of COVID-19 Data Hub, which includes a great improvement in the spatial coverage, new data on vaccines, and a new set of identifiers to enable geospatial analyses. The full changelog is available <a href="https://covid19datahub.io/news/index.html">here</a>.</p>
<p>The large amount of data that is now available (~2GB) has led to some breaking changes in the way the data are provided. Version 3 of the <code>COVID19</code> package is designed to be compatible with the latest version of COVID-19 Data Hub, and process large amount of data at speed with low memory requirements. The documentation and a quick start guide is available <a href="https://covid19datahub.io/articles/r.html">here</a>.</p>
</div>
<div id="data-coverage" class="section level2">
<h2>Data coverage</h2>
<p>The figure shows the granularity and the spatial coverage of the data as of November 27, 2021.</p>
<p><img src="main.png" /></p>
<p>What’s included?</p>
<pre class="r"><code>library(COVID19) # load the package
x <- covid19() # download the data</code></pre>
<p>Refer to the <a href="https://covid19datahub.io/articles/docs.html">documentation</a> for the description of each variable.</p>
<pre class="r"><code>colnames(x)</code></pre>
<pre><code>## [1] "id" "date"
## [3] "confirmed" "deaths"
## [5] "recovered" "tests"
## [7] "vaccines" "people_vaccinated"
## [9] "people_fully_vaccinated" "hosp"
## [11] "icu" "vent"
## [13] "school_closing" "workplace_closing"
## [15] "cancel_events" "gatherings_restrictions"
## [17] "transport_closing" "stay_home_restrictions"
## [19] "internal_movement_restrictions" "international_movement_restrictions"
## [21] "information_campaigns" "testing_policy"
## [23] "contact_tracing" "facial_coverings"
## [25] "vaccination_policy" "elderly_people_protection"
## [27] "government_response_index" "stringency_index"
## [29] "containment_health_index" "economic_support_index"
## [31] "administrative_area_level" "administrative_area_level_1"
## [33] "administrative_area_level_2" "administrative_area_level_3"
## [35] "latitude" "longitude"
## [37] "population" "iso_alpha_3"
## [39] "iso_alpha_2" "iso_numeric"
## [41] "iso_currency" "key_local"
## [43] "key_google_mobility" "key_apple_mobility"
## [45] "key_jhu_csse" "key_nuts"
## [47] "key_gadm"</code></pre>
</div>
<div id="data-transparency" class="section level2">
<h2>Data transparency</h2>
<p>This package applies no pre-processing to the original data, that are provided as-is. The data acquisition pipeline is open source and all the original data providers are listed <a href="https://covid19datahub.io/reference/index.html">here</a>.</p>
<p>As an example, the following code snippet plots the fraction of confirmed cases on a given day per number of tests performed on that day in U.S. Notice that around June 2021, the fraction becomes negative. This is a known issue due to decreasing cumulative counts in the original data provider. This package applies no cleaning procedure for this kind of issues, which are typically due to changes in the data collection methodology. If the provider corrects the data retroactively, the changes are reflected in this package.</p>
<pre class="r"><code>library(xts)
library(dygraphs)
x <- covid19("USA", verbose = FALSE) # download the data
ts <- xts(x[,c("confirmed", "tests")], order.by = x$date) # convert to an xts object
ts$ratio <- diff(ts$confirmed) / diff(ts$tests) # compute daily ratio
dygraph(ts$ratio, main = "Daily fraction confirmed/tests in U.S.") # plot</code></pre>
<div id="htmlwidget-1" style="width:672px;height:480px;" class="dygraphs html-widget"></div>
<script type="application/json" data-for="htmlwidget-1">{"x":{"attrs":{"title":"Daily fraction confirmed/tests in U.S.","labels":["day","ratio"],"legend":"auto","retainDateWindow":false,"axes":{"x":{"pixelsPerLabel":60}}},"scale":"daily","annotations":[],"shadings":[],"events":[],"format":"date","data":[["2020-01-21T00:00:00.000Z","2020-01-22T00:00:00.000Z","2020-01-23T00:00:00.000Z","2020-01-24T00:00:00.000Z","2020-01-25T00:00:00.000Z","2020-01-26T00:00:00.000Z","2020-01-27T00:00:00.000Z","2020-01-28T00:00:00.000Z","2020-01-29T00:00:00.000Z","2020-01-30T00:00:00.000Z","2020-01-31T00:00:00.000Z","2020-02-01T00:00:00.000Z","2020-02-02T00:00:00.000Z","2020-02-03T00:00:00.000Z","2020-02-04T00:00:00.000Z","2020-02-05T00:00:00.000Z","2020-02-06T00:00:00.000Z","2020-02-07T00:00:00.000Z","2020-02-08T00:00:00.000Z","2020-02-09T00:00:00.000Z","2020-02-10T00:00:00.000Z","2020-02-11T00:00:00.000Z","2020-02-12T00:00:00.000Z","2020-02-13T00:00:00.000Z","2020-02-14T00:00:00.000Z","2020-02-15T00:00:00.000Z","2020-02-16T00:00:00.000Z","2020-02-17T00:00:00.000Z","2020-02-18T00:00:00.000Z","2020-02-19T00:00:00.000Z","2020-02-20T00:00:00.000Z","2020-02-21T00:00:00.000Z","2020-02-22T00:00:00.000Z","2020-02-23T00:00:00.000Z","2020-02-24T00:00:00.000Z","2020-02-25T00:00:00.000Z","2020-02-26T00:00:00.000Z","2020-02-27T00:00:00.000Z","2020-02-28T00:00:00.000Z","2020-02-29T00:00:00.000Z","2020-03-01T00:00:00.000Z","2020-03-02T00:00:00.000Z","2020-03-03T00:00:00.000Z","2020-03-04T00:00:00.000Z","2020-03-05T00:00:00.000Z","2020-03-06T00:00:00.000Z","2020-03-07T00:00:00.000Z","2020-03-08T00:00:00.000Z","2020-03-09T00:00:00.000Z","2020-03-10T00:00:00.000Z","2020-03-11T00:00:00.000Z","2020-03-12T00:00:00.000Z","2020-03-13T00:00:00.000Z","2020-03-14T00:00:00.000Z","2020-03-15T00:00:00.000Z","2020-03-16T00:00:00.000Z","2020-03-17T00:00:00.000Z","2020-03-18T00:00:00.000Z","2020-03-19T00:00:00.000Z","2020-03-20T00:00:00.000Z","2020-03-21T00:00:00.000Z","2020-03-22T00:00:00.000Z","2020-03-23T00:00:00.000Z","2020-03-24T00:00:00.000Z","2020-03-25T00:00:00.000Z","2020-03-26T00:00:00.000Z","2020-03-27T00:00:00.000Z","2020-03-28T00:00:00.000Z","2020-03-29T00:00:00.000Z","2020-03-30T00:00:00.000Z","2020-03-31T00:00:00.000Z","2020-04-01T00:00:00.000Z","2020-04-02T00:00:00.000Z","2020-04-03T00:00:00.000Z","2020-04-04T00:00:00.000Z","2020-04-05T00:00:00.000Z","2020-04-06T00:00:00.000Z","2020-04-07T00:00:00.000Z","2020-04-08T00:00:00.000Z","2020-04-09T00:00:00.000Z","2020-04-10T00:00:00.000Z","2020-04-11T00:00:00.000Z","2020-04-12T00:00:00.000Z","2020-04-13T00:00:00.000Z","2020-04-14T00:00:00.000Z","2020-04-15T00:00:00.000Z","2020-04-16T00:00:00.000Z","2020-04-17T00:00:00.000Z","2020-04-18T00:00:00.000Z","2020-04-19T00:00:00.000Z","2020-04-20T00:00:00.000Z","2020-04-21T00:00:00.000Z","2020-04-22T00:00:00.000Z","2020-04-23T00:00:00.000Z","2020-04-24T00:00:00.000Z","2020-04-25T00:00:00.000Z","2020-04-26T00:00:00.000Z","2020-04-27T00:00:00.000Z","2020-04-28T00:00:00.000Z","2020-04-29T00:00:00.000Z","2020-04-30T00:00:00.000Z","2020-05-01T00:00:00.000Z","2020-05-02T00:00:00.000Z","2020-05-03T00:00:00.000Z","2020-05-04T00:00:00.000Z","2020-05-05T00:00:00.000Z","2020-05-06T00:00:00.000Z","2020-05-07T00:00:00.000Z","2020-05-08T00:00:00.000Z","2020-05-09T00:00:00.000Z","2020-05-10T00:00:00.000Z","2020-05-11T00:00:00.000Z","2020-05-12T00:00:00.000Z","2020-05-13T00:00:00.000Z","2020-05-14T00:00:00.000Z","2020-05-15T00:00:00.000Z","2020-05-16T00:00:00.000Z","2020-05-17T00:00:00.000Z","2020-05-18T00:00:00.000Z","2020-05-19T00:00:00.000Z","2020-05-20T00:00:00.000Z","2020-05-21T00:00:00.000Z","2020-05-22T00:00:00.000Z","2020-05-23T00:00:00.000Z","2020-05-24T00:00:00.000Z","2020-05-25T00:00:00.000Z","2020-05-26T00:00:00.000Z","2020-05-27T00:00:00.000Z","2020-05-28T00:00:00.000Z","2020-05-29T00:00:00.000Z","2020-05-30T00:00:00.000Z","2020-05-31T00:00:00.000Z","2020-06-01T00:00:00.000Z","2020-06-02T00:00:00.000Z","2020-06-03T00:00:00.000Z","2020-06-04T00:00:00.000Z","2020-06-05T00:00:00.000Z","2020-06-06T00:00:00.000Z","2020-06-07T00:00:00.000Z","2020-06-08T00:00:00.000Z","2020-06-09T00:00:00.000Z","2020-06-10T00:00:00.000Z","2020-06-11T00:00:00.000Z","2020-06-12T00:00:00.000Z","2020-06-13T00:00:00.000Z","2020-06-14T00:00:00.000Z","2020-06-15T00:00:00.000Z","2020-06-16T00:00:00.000Z","2020-06-17T00:00:00.000Z","2020-06-18T00:00:00.000Z","2020-06-19T00:00:00.000Z","2020-06-20T00:00:00.000Z","2020-06-21T00:00:00.000Z","2020-06-22T00:00:00.000Z","2020-06-23T00:00:00.000Z","2020-06-24T00:00:00.000Z","2020-06-25T00:00:00.000Z","2020-06-26T00:00:00.000Z","2020-06-27T00:00:00.000Z","2020-06-28T00:00:00.000Z","2020-06-29T00:00:00.000Z","2020-06-30T00:00:00.000Z","2020-07-01T00:00:00.000Z","2020-07-02T00:00:00.000Z","2020-07-03T00:00:00.000Z","2020-07-04T00:00:00.000Z","2020-07-05T00:00:00.000Z","2020-07-06T00:00:00.000Z","2020-07-07T00:00:00.000Z","2020-07-08T00:00:00.000Z","2020-07-09T00:00:00.000Z","2020-07-10T00:00:00.000Z","2020-07-11T00:00:00.000Z","2020-07-12T00:00:00.000Z","2020-07-13T00:00:00.000Z","2020-07-14T00:00:00.000Z","2020-07-15T00:00:00.000Z","2020-07-16T00:00:00.000Z","2020-07-17T00:00:00.000Z","2020-07-18T00:00:00.000Z","2020-07-19T00:00:00.000Z","2020-07-20T00:00:00.000Z","2020-07-21T00:00:00.000Z","2020-07-22T00:00:00.000Z","2020-07-23T00:00:00.000Z","2020-07-24T00:00:00.000Z","2020-07-25T00:00:00.000Z","2020-07-26T00:00:00.000Z","2020-07-27T00:00:00.000Z","2020-07-28T00:00:00.000Z","2020-07-29T00:00:00.000Z","2020-07-30T00:00:00.000Z","2020-07-31T00:00:00.000Z","2020-08-01T00:00:00.000Z","2020-08-02T00:00:00.000Z","2020-08-03T00:00:00.000Z","2020-08-04T00:00:00.000Z","2020-08-05T00:00:00.000Z","2020-08-06T00:00:00.000Z","2020-08-07T00:00:00.000Z","2020-08-08T00:00:00.000Z","2020-08-09T00:00:00.000Z","2020-08-10T00:00:00.000Z","2020-08-11T00:00:00.000Z","2020-08-12T00:00:00.000Z","2020-08-13T00:00:00.000Z","2020-08-14T00:00:00.000Z","2020-08-15T00:00:00.000Z","2020-08-16T00:00:00.000Z","2020-08-17T00:00:00.000Z","2020-08-18T00:00:00.000Z","2020-08-19T00:00:00.000Z","2020-08-20T00:00:00.000Z","2020-08-21T00:00:00.000Z","2020-08-22T00:00:00.000Z","2020-08-23T00:00:00.000Z","2020-08-24T00:00:00.000Z","2020-08-25T00:00:00.000Z","2020-08-26T00:00:00.000Z","2020-08-27T00:00:00.000Z","2020-08-28T00:00:00.000Z","2020-08-29T00:00:00.000Z","2020-08-30T00:00:00.000Z","2020-08-31T00:00:00.000Z","2020-09-01T00:00:00.000Z","2020-09-02T00:00:00.000Z","2020-09-03T00:00:00.000Z","2020-09-04T00:00:00.000Z","2020-09-05T00:00:00.000Z","2020-09-06T00:00:00.000Z","2020-09-07T00:00:00.000Z","2020-09-08T00:00:00.000Z","2020-09-09T00:00:00.000Z","2020-09-10T00:00:00.000Z","2020-09-11T00:00:00.000Z","2020-09-12T00:00:00.000Z","2020-09-13T00:00:00.000Z","2020-09-14T00:00:00.000Z","2020-09-15T00:00:00.000Z","2020-09-16T00:00:00.000Z","2020-09-17T00:00:00.000Z","2020-09-18T00:00:00.000Z","2020-09-19T00:00:00.000Z","2020-09-20T00:00:00.000Z","2020-09-21T00:00:00.000Z","2020-09-22T00:00:00.000Z","2020-09-23T00:00:00.000Z","2020-09-24T00:00:00.000Z","2020-09-25T00:00:00.000Z","2020-09-26T00:00:00.000Z","2020-09-27T00:00:00.000Z","2020-09-28T00:00:00.000Z","2020-09-29T00:00:00.000Z","2020-09-30T00:00:00.000Z","2020-10-01T00:00:00.000Z","2020-10-02T00:00:00.000Z","2020-10-03T00:00:00.000Z","2020-10-04T00:00:00.000Z","2020-10-05T00:00:00.000Z","2020-10-06T00:00:00.000Z","2020-10-07T00:00:00.000Z","2020-10-08T00:00:00.000Z","2020-10-09T00:00:00.000Z","2020-10-10T00:00:00.000Z","2020-10-11T00:00:00.000Z","2020-10-12T00:00:00.000Z","2020-10-13T00:00:00.000Z","2020-10-14T00:00:00.000Z","2020-10-15T00:00:00.000Z","2020-10-16T00:00:00.000Z","2020-10-17T00:00:00.000Z","2020-10-18T00:00:00.000Z","2020-10-19T00:00:00.000Z","2020-10-20T00:00:00.000Z","2020-10-21T00:00:00.000Z","2020-10-22T00:00:00.000Z","2020-10-23T00:00:00.000Z","2020-10-24T00:00:00.000Z","2020-10-25T00:00:00.000Z","2020-10-26T00:00:00.000Z","2020-10-27T00:00:00.000Z","2020-10-28T00:00:00.000Z","2020-10-29T00:00:00.000Z","2020-10-30T00:00:00.000Z","2020-10-31T00:00:00.000Z","2020-11-01T00:00:00.000Z","2020-11-02T00:00:00.000Z","2020-11-03T00:00:00.000Z","2020-11-04T00:00:00.000Z","2020-11-05T00:00:00.000Z","2020-11-06T00:00:00.000Z","2020-11-07T00:00:00.000Z","2020-11-08T00:00:00.000Z","2020-11-09T00:00:00.000Z","2020-11-10T00:00:00.000Z","2020-11-11T00:00:00.000Z","2020-11-12T00:00:00.000Z","2020-11-13T00:00:00.000Z","2020-11-14T00:00:00.000Z","2020-11-15T00:00:00.000Z","2020-11-16T00:00:00.000Z","2020-11-17T00:00:00.000Z","2020-11-18T00:00:00.000Z","2020-11-19T00:00:00.000Z","2020-11-20T00:00:00.000Z","2020-11-21T00:00:00.000Z","2020-11-22T00:00:00.000Z","2020-11-23T00:00:00.000Z","2020-11-24T00:00:00.000Z","2020-11-25T00:00:00.000Z","2020-11-26T00:00:00.000Z","2020-11-27T00:00:00.000Z","2020-11-28T00:00:00.000Z","2020-11-29T00:00:00.000Z","2020-11-30T00:00:00.000Z","2020-12-01T00:00:00.000Z","2020-12-02T00:00:00.000Z","2020-12-03T00:00:00.000Z","2020-12-04T00:00:00.000Z","2020-12-05T00:00:00.000Z","2020-12-06T00:00:00.000Z","2020-12-07T00:00:00.000Z","2020-12-08T00:00:00.000Z","2020-12-09T00:00:00.000Z","2020-12-10T00:00:00.000Z","2020-12-11T00:00:00.000Z","2020-12-12T00:00:00.000Z","2020-12-13T00:00:00.000Z","2020-12-14T00:00:00.000Z","2020-12-15T00:00:00.000Z","2020-12-16T00:00:00.000Z","2020-12-17T00:00:00.000Z","2020-12-18T00:00:00.000Z","2020-12-19T00:00:00.000Z","2020-12-20T00:00:00.000Z","2020-12-21T00:00:00.000Z","2020-12-22T00:00:00.000Z","2020-12-23T00:00:00.000Z","2020-12-24T00:00:00.000Z","2020-12-25T00:00:00.000Z","2020-12-26T00:00:00.000Z","2020-12-27T00:00:00.000Z","2020-12-28T00:00:00.000Z","2020-12-29T00:00:00.000Z","2020-12-30T00:00:00.000Z","2020-12-31T00:00:00.000Z","2021-01-01T00:00:00.000Z","2021-01-02T00:00:00.000Z","2021-01-03T00:00:00.000Z","2021-01-04T00:00:00.000Z","2021-01-05T00:00:00.000Z","2021-01-06T00:00:00.000Z","2021-01-07T00:00:00.000Z","2021-01-08T00:00:00.000Z","2021-01-09T00:00:00.000Z","2021-01-10T00:00:00.000Z","2021-01-11T00:00:00.000Z","2021-01-12T00:00:00.000Z","2021-01-13T00:00:00.000Z","2021-01-14T00:00:00.000Z","2021-01-15T00:00:00.000Z","2021-01-16T00:00:00.000Z","2021-01-17T00:00:00.000Z","2021-01-18T00:00:00.000Z","2021-01-19T00:00:00.000Z","2021-01-20T00:00:00.000Z","2021-01-21T00:00:00.000Z","2021-01-22T00:00:00.000Z","2021-01-23T00:00:00.000Z","2021-01-24T00:00:00.000Z","2021-01-25T00:00:00.000Z","2021-01-26T00:00:00.000Z","2021-01-27T00:00:00.000Z","2021-01-28T00:00:00.000Z","2021-01-29T00:00:00.000Z","2021-01-30T00:00:00.000Z","2021-01-31T00:00:00.000Z","2021-02-01T00:00:00.000Z","2021-02-02T00:00:00.000Z","2021-02-03T00:00:00.000Z","2021-02-04T00:00:00.000Z","2021-02-05T00:00:00.000Z","2021-02-06T00:00:00.000Z","2021-02-07T00:00:00.000Z","2021-02-08T00:00:00.000Z","2021-02-09T00:00:00.000Z","2021-02-10T00:00:00.000Z","2021-02-11T00:00:00.000Z","2021-02-12T00:00:00.000Z","2021-02-13T00:00:00.000Z","2021-02-14T00:00:00.000Z","2021-02-15T00:00:00.000Z","2021-02-16T00:00:00.000Z","2021-02-17T00:00:00.000Z","2021-02-18T00:00:00.000Z","2021-02-19T00:00:00.000Z","2021-02-20T00:00:00.000Z","2021-02-21T00:00:00.000Z","2021-02-22T00:00:00.000Z","2021-02-23T00:00:00.000Z","2021-02-24T00:00:00.000Z","2021-02-25T00:00:00.000Z","2021-02-26T00:00:00.000Z","2021-02-27T00:00:00.000Z","2021-02-28T00:00:00.000Z","2021-03-01T00:00:00.000Z","2021-03-02T00:00:00.000Z","2021-03-03T00:00:00.000Z","2021-03-04T00:00:00.000Z","2021-03-05T00:00:00.000Z","2021-03-06T00:00:00.000Z","2021-03-07T00:00:00.000Z","2021-03-08T00:00:00.000Z","2021-03-09T00:00:00.000Z","2021-03-10T00:00:00.000Z","2021-03-11T00:00:00.000Z","2021-03-12T00:00:00.000Z","2021-03-13T00:00:00.000Z","2021-03-14T00:00:00.000Z","2021-03-15T00:00:00.000Z","2021-03-16T00:00:00.000Z","2021-03-17T00:00:00.000Z","2021-03-18T00:00:00.000Z","2021-03-19T00:00:00.000Z","2021-03-20T00:00:00.000Z","2021-03-21T00:00:00.000Z","2021-03-22T00:00:00.000Z","2021-03-23T00:00:00.000Z","2021-03-24T00:00:00.000Z","2021-03-25T00:00:00.000Z","2021-03-26T00:00:00.000Z","2021-03-27T00:00:00.000Z","2021-03-28T00:00:00.000Z","2021-03-29T00:00:00.000Z","2021-03-30T00:00:00.000Z","2021-03-31T00:00:00.000Z","2021-04-01T00:00:00.000Z","2021-04-02T00:00:00.000Z","2021-04-03T00:00:00.000Z","2021-04-04T00:00:00.000Z","2021-04-05T00:00:00.000Z","2021-04-06T00:00:00.000Z","2021-04-07T00:00:00.000Z","2021-04-08T00:00:00.000Z","2021-04-09T00:00:00.000Z","2021-04-10T00:00:00.000Z","2021-04-11T00:00:00.000Z","2021-04-12T00:00:00.000Z","2021-04-13T00:00:00.000Z","2021-04-14T00:00:00.000Z","2021-04-15T00:00:00.000Z","2021-04-16T00:00:00.000Z","2021-04-17T00:00:00.000Z","2021-04-18T00:00:00.000Z","2021-04-19T00:00:00.000Z","2021-04-20T00:00:00.000Z","2021-04-21T00:00:00.000Z","2021-04-22T00:00:00.000Z","2021-04-23T00:00:00.000Z","2021-04-24T00:00:00.000Z","2021-04-25T00:00:00.000Z","2021-04-26T00:00:00.000Z","2021-04-27T00:00:00.000Z","2021-04-28T00:00:00.000Z","2021-04-29T00:00:00.000Z","2021-04-30T00:00:00.000Z","2021-05-01T00:00:00.000Z","2021-05-02T00:00:00.000Z","2021-05-03T00:00:00.000Z","2021-05-04T00:00:00.000Z","2021-05-05T00:00:00.000Z","2021-05-06T00:00:00.000Z","2021-05-07T00:00:00.000Z","2021-05-08T00:00:00.000Z","2021-05-09T00:00:00.000Z","2021-05-10T00:00:00.000Z","2021-05-11T00:00:00.000Z","2021-05-12T00:00:00.000Z","2021-05-13T00:00:00.000Z","2021-05-14T00:00:00.000Z","2021-05-15T00:00:00.000Z","2021-05-16T00:00:00.000Z","2021-05-17T00:00:00.000Z","2021-05-18T00:00:00.000Z","2021-05-19T00:00:00.000Z","2021-05-20T00:00:00.000Z","2021-05-21T00:00:00.000Z","2021-05-22T00:00:00.000Z","2021-05-23T00:00:00.000Z","2021-05-24T00:00:00.000Z","2021-05-25T00:00:00.000Z","2021-05-26T00:00:00.000Z","2021-05-27T00:00:00.000Z","2021-05-28T00:00:00.000Z","2021-05-29T00:00:00.000Z","2021-05-30T00:00:00.000Z","2021-05-31T00:00:00.000Z","2021-06-01T00:00:00.000Z","2021-06-02T00:00:00.000Z","2021-06-03T00:00:00.000Z","2021-06-04T00:00:00.000Z","2021-06-05T00:00:00.000Z","2021-06-06T00:00:00.000Z","2021-06-07T00:00:00.000Z","2021-06-08T00:00:00.000Z","2021-06-09T00:00:00.000Z","2021-06-10T00:00:00.000Z","2021-06-11T00:00:00.000Z","2021-06-12T00:00:00.000Z","2021-06-13T00:00:00.000Z","2021-06-14T00:00:00.000Z","2021-06-15T00:00:00.000Z","2021-06-16T00:00:00.000Z","2021-06-17T00:00:00.000Z","2021-06-18T00:00:00.000Z","2021-06-19T00:00:00.000Z","2021-06-20T00:00:00.000Z","2021-06-21T00:00:00.000Z","2021-06-22T00:00:00.000Z","2021-06-23T00:00:00.000Z","2021-06-24T00:00:00.000Z","2021-06-25T00:00:00.000Z","2021-06-26T00:00:00.000Z","2021-06-27T00:00:00.000Z","2021-06-28T00:00:00.000Z","2021-06-29T00:00:00.000Z","2021-06-30T00:00:00.000Z","2021-07-01T00:00:00.000Z","2021-07-02T00:00:00.000Z","2021-07-03T00:00:00.000Z","2021-07-04T00:00:00.000Z","2021-07-05T00:00:00.000Z","2021-07-06T00:00:00.000Z","2021-07-07T00:00:00.000Z","2021-07-08T00:00:00.000Z","2021-07-09T00:00:00.000Z","2021-07-10T00:00:00.000Z","2021-07-11T00:00:00.000Z","2021-07-12T00:00:00.000Z","2021-07-13T00:00:00.000Z","2021-07-14T00:00:00.000Z","2021-07-15T00:00:00.000Z","2021-07-16T00:00:00.000Z","2021-07-17T00:00:00.000Z","2021-07-18T00:00:00.000Z","2021-07-19T00:00:00.000Z","2021-07-20T00:00:00.000Z","2021-07-21T00:00:00.000Z","2021-07-22T00:00:00.000Z","2021-07-23T00:00:00.000Z","2021-07-24T00:00:00.000Z","2021-07-25T00:00:00.000Z","2021-07-26T00:00:00.000Z","2021-07-27T00:00:00.000Z","2021-07-28T00:00:00.000Z","2021-07-29T00:00:00.000Z","2021-07-30T00:00:00.000Z","2021-07-31T00:00:00.000Z","2021-08-01T00:00:00.000Z","2021-08-02T00:00:00.000Z","2021-08-03T00:00:00.000Z","2021-08-04T00:00:00.000Z","2021-08-05T00:00:00.000Z","2021-08-06T00:00:00.000Z","2021-08-07T00:00:00.000Z","2021-08-08T00:00:00.000Z","2021-08-09T00:00:00.000Z","2021-08-10T00:00:00.000Z","2021-08-11T00:00:00.000Z","2021-08-12T00:00:00.000Z","2021-08-13T00:00:00.000Z","2021-08-14T00:00:00.000Z","2021-08-15T00:00:00.000Z","2021-08-16T00:00:00.000Z","2021-08-17T00:00:00.000Z","2021-08-18T00:00:00.000Z","2021-08-19T00:00:00.000Z","2021-08-20T00:00:00.000Z","2021-08-21T00:00:00.000Z","2021-08-22T00:00:00.000Z","2021-08-23T00:00:00.000Z","2021-08-24T00:00:00.000Z","2021-08-25T00:00:00.000Z","2021-08-26T00:00:00.000Z","2021-08-27T00:00:00.000Z","2021-08-28T00:00:00.000Z","2021-08-29T00:00:00.000Z","2021-08-30T00:00:00.000Z","2021-08-31T00:00:00.000Z","2021-09-01T00:00:00.000Z","2021-09-02T00:00:00.000Z","2021-09-03T00:00:00.000Z","2021-09-04T00:00:00.000Z","2021-09-05T00:00:00.000Z","2021-09-06T00:00:00.000Z","2021-09-07T00:00:00.000Z","2021-09-08T00:00:00.000Z","2021-09-09T00:00:00.000Z","2021-09-10T00:00:00.000Z","2021-09-11T00:00:00.000Z","2021-09-12T00:00:00.000Z","2021-09-13T00:00:00.000Z","2021-09-14T00:00:00.000Z","2021-09-15T00:00:00.000Z","2021-09-16T00:00:00.000Z","2021-09-17T00:00:00.000Z","2021-09-18T00:00:00.000Z","2021-09-19T00:00:00.000Z","2021-09-20T00:00:00.000Z","2021-09-21T00:00:00.000Z","2021-09-22T00:00:00.000Z","2021-09-23T00:00:00.000Z","2021-09-24T00:00:00.000Z","2021-09-25T00:00:00.000Z","2021-09-26T00:00:00.000Z","2021-09-27T00:00:00.000Z","2021-09-28T00:00:00.000Z","2021-09-29T00:00:00.000Z","2021-09-30T00:00:00.000Z","2021-10-01T00:00:00.000Z","2021-10-02T00:00:00.000Z","2021-10-03T00:00:00.000Z","2021-10-04T00:00:00.000Z","2021-10-05T00:00:00.000Z","2021-10-06T00:00:00.000Z","2021-10-07T00:00:00.000Z","2021-10-08T00:00:00.000Z","2021-10-09T00:00:00.000Z","2021-10-10T00:00:00.000Z","2021-10-11T00:00:00.000Z","2021-10-12T00:00:00.000Z","2021-10-13T00:00:00.000Z","2021-10-14T00:00:00.000Z","2021-10-15T00:00:00.000Z","2021-10-16T00:00:00.000Z","2021-10-17T00:00:00.000Z","2021-10-18T00:00:00.000Z","2021-10-19T00:00:00.000Z","2021-10-20T00:00:00.000Z","2021-10-21T00:00:00.000Z","2021-10-22T00:00:00.000Z","2021-10-23T00:00:00.000Z","2021-10-24T00:00:00.000Z","2021-10-25T00:00:00.000Z","2021-10-26T00:00:00.000Z","2021-10-27T00:00:00.000Z","2021-10-28T00:00:00.000Z","2021-10-29T00:00:00.000Z","2021-10-30T00:00:00.000Z","2021-10-31T00:00:00.000Z","2021-11-01T00:00:00.000Z","2021-11-02T00:00:00.000Z","2021-11-03T00:00:00.000Z","2021-11-04T00:00:00.000Z","2021-11-05T00:00:00.000Z","2021-11-06T00:00:00.000Z","2021-11-07T00:00:00.000Z","2021-11-08T00:00:00.000Z","2021-11-09T00:00:00.000Z","2021-11-10T00:00:00.000Z","2021-11-11T00:00:00.000Z","2021-11-12T00:00:00.000Z","2021-11-13T00:00:00.000Z","2021-11-14T00:00:00.000Z","2021-11-15T00:00:00.000Z","2021-11-16T00:00:00.000Z","2021-11-17T00:00:00.000Z","2021-11-18T00:00:00.000Z","2021-11-19T00:00:00.000Z","2021-11-20T00:00:00.000Z","2021-11-21T00:00:00.000Z","2021-11-22T00:00:00.000Z","2021-11-23T00:00:00.000Z","2021-11-24T00:00:00.000Z","2021-11-25T00:00:00.000Z","2021-11-26T00:00:00.000Z","2021-11-27T00:00:00.000Z","2021-11-28T00:00:00.000Z","2021-11-29T00:00:00.000Z","2021-11-30T00:00:00.000Z","2021-12-01T00:00:00.000Z","2021-12-02T00:00:00.000Z","2021-12-03T00:00:00.000Z","2021-12-04T00:00:00.000Z","2021-12-05T00:00:00.000Z","2021-12-06T00:00:00.000Z","2021-12-07T00:00:00.000Z"],[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,0.0311890838206628,0.0339805825242718,0.0406779661016949,0.0557868442964196,0.0545335085413929,0.0660643704121965,0.0725609756097561,0.0838548185231539,0.0778995960761685,0.0507772020725389,0.0456698240866035,0.0474686246051396,0.0517983399938518,0.0486385366867595,0.0332392714479422,0.0351560536764336,0.048508425460969,0.0667591354171827,0.0736976024342899,0.0859868829095132,0.115585434476788,0.130889198378941,0.0998058029521778,0.127595016173893,0.131530890181998,0.127615078166997,0.173070761343751,0.168018434852031,0.173897195807481,0.172270532080167,0.175890063811583,0.183710435212661,0.190922356193841,0.237587236260501,0.184786293958521,0.216099088519823,0.168608205595634,0.189098602263003,0.19941610202123,0.194559562905054,0.150721772929001,0.243356405106871,0.225703324808184,0.164230073466977,0.174309477239882,0.171603671676953,0.158724321710308,0.169795752415574,0.18859384654324,0.170800289291236,0.115347752179102,0.122264205352637,0.144815315025618,0.141620925714638,0.156718423341972,0.155831060129165,0.102724772714189,0.0913920690473366,0.0900884091109558,0.094114765635415,0.100895196117451,0.109836627612319,0.121267228621664,0.0875384639913267,0.0742054114959077,0.0681371417767484,0.0785357351659625,0.0685026201360241,0.0741063020752625,0.081627159501808,0.0550838715324451,0.0528590086684034,0.0469562282234801,0.0598904015868891,0.058894039214806,0.0646816630943528,0.0624642737468709,0.0618382917480005,0.0483519269776876,0.0498363630472117,0.0559870676901119,0.0483596647193294,0.0570940688113265,0.0578075218174262,0.0580346019920149,0.040952021811026,0.0338723930238484,0.0419781494334106,0.0448933535964243,0.0515587503553382,0.0552676196674943,0.049877680438437,0.0398413321963418,0.034329832275573,0.0349561350313321,0.0501071642999763,0.04848834630103,0.0459012836381748,0.0405261927815432,0.0335530952529641,0.0363374427357712,0.0377320442662807,0.0413411173274953,0.047648603305723,0.046307951508579,0.0397173566250217,0.0369763906822764,0.0363403799627176,0.0399711103703514,0.0437807385195534,0.0548234351568438,0.0626056124095768,0.0555913399691626,0.050043820458873,0.0482239822691568,0.0533658750290011,0.0562033829676394,0.0609863880354277,0.0697697006514641,0.0593944461320525,0.0565167930407808,0.0564847550500027,0.0646987309224975,0.0713403940610002,0.0805743942741038,0.084952027447587,0.0652031915333416,0.0598570973225669,0.0606149890453611,0.0591795554888003,0.067147404037879,0.0722722782294059,0.0828314439940217,0.0709325836871302,0.0653481876392093,0.0660136969099848,0.0735527921820458,0.0677237956187652,0.0684509293065029,0.0867060875957735,0.0659918501916241,0.0629840043380683,0.0628398165418683,0.0645821340536392,0.0684105582543468,0.0757197950294994,0.0800100940487909,0.074184430056847,0.0651840284878041,0.0641789036672561,0.0664055953754553,0.0697412664427694,0.0716902488747149,0.0813599610451185,0.0611089805131795,0.0605820967793028,0.0556354116397032,0.0580621648988097,0.0602156487628897,0.0677327670135049,0.0773751193026025,0.0600973573877339,0.0586804944571529,0.0527831803329703,0.0551557872205405,0.0618602914486418,0.0660993281037102,0.0735820819938078,0.0554395731848759,0.0482849586540566,0.0428032640063688,0.046191408994023,0.0507836776294529,0.0566881747505587,0.0575548660767529,0.0605961531251172,0.0432530706997785,0.0445232799408963,0.0446902195319343,0.0471655016424461,0.0558751654936502,0.0543782909772932,0.0551427193988662,0.0485247266910783,0.0315808634218183,0.0449230304479716,0.0521238823843667,0.0517479776856518,0.0530213584270696,0.0606805890111374,0.0435813766486822,0.0347511682072476,0.0349826332241725,0.0432218236271185,0.0451670432127,0.053104011747449,0.0520624122283932,0.0405321884508533,0.0344578254047926,0.0391270632164156,0.0397637292516819,0.0445489328649468,0.0582455522000689,0.0732419896571947,0.036308145857933,0.0344824152048288,0.0375936222907127,0.0483132282700676,0.045468583599574,0.0624265653505615,0.0559360986966709,0.0443802336977773,0.0350207836501952,0.0379091105838924,0.0449539637180066,0.0489449168646324,0.0546918504260639,0.0773039903588313,0.0349157938125518,0.0375312630742123,0.0393910050847387,0.042087996333843,0.0467832867143002,0.0598831300813008,0.0593224422323998,0.0510660470356288,0.0486704722872756,0.0501068795465976,0.0529826023011461,0.0472465694052919,0.0621291448516579,0.0747300684606908,0.0474198243884115,0.0434058126232755,0.0490166335561362,0.0581941706902563,0.06660569402016,0.0752368989017164,0.0781759298827749,0.0555034083854639,0.0544472719510971,0.0610188449160721,0.0665051563005691,0.0690117793806339,0.0824796705037491,0.092465706265037,0.0677251158785702,0.066212052801536,0.0715497382384174,0.0791877742847655,0.086512640170592,0.102284393996641,0.106582511183283,0.0908266689197313,0.0797701105787322,0.0882929116304766,0.0953104642693412,0.0995118672999898,0.11293507899591,0.111632461298629,0.0848437541829764,0.0820871520837453,0.0903224687666186,0.0924958277594929,0.0926267824808977,0.0990048463812468,0.107367350159237,0.0902222914365979,0.0811836749739937,0.0683948325025865,0.136182839449814,0.112330307845939,0.118227756189669,0.114466307956684,0.0999672795288686,0.0959049283973877,0.101420241102358,0.109269962472809,0.121639952646823,0.133019767928588,0.132803607176692,0.114764801992403,0.103454088469641,0.103237691692764,0.136419828736612,0.120528641320256,0.147530874578856,0.134470988847245,0.104462109069892,0.117900958706469,0.115826166951958,0.1242542961446,0.113330648691646,0.140981165785752,0.131846231955363,0.101473817916102,0.0999640106212557,0.102308552455927,0.0936702446557539,0.218590487940586,0.16082093339988,0.146433109175989,0.107771006313045,0.104630879200277,0.120098751466638,0.117313846886819,0.260892982076301,0.192087641771494,0.1789046909644,0.119179190194502,0.109544286592224,0.124059488227063,0.139866679377155,0.146587344397254,0.178159803685935,0.147964020414061,0.112944320738946,0.108318348488219,0.114661871894959,0.11707650659984,0.126641955389422,0.15801119958977,0.108956676880414,0.102949930969842,0.0865993435765275,0.0921894820494231,0.0989136614087239,0.108050734303825,0.12865703627272,0.126139436861402,0.0840118300756752,0.0750408757675347,0.0866391868246914,0.088890796860918,0.0932356101497205,0.120228041834435,0.136757591591742,0.070326119255906,0.0640426770002046,0.0648376941735047,0.0704673773931516,0.0785050182560242,0.105045951059354,0.0886316062393478,0.0566964314599022,0.0576891304506282,0.0742152565603997,0.0702540094224866,0.0766326949991219,0.0958211578765503,0.0689545904230567,0.0514490471881988,0.047556913616565,0.0506057235340475,0.0574371509665259,0.0657233003805579,0.0805260607900252,0.0569880457928359,0.0435619345998539,0.043799817466324,0.0481644496750426,0.0528352445446487,0.0581520392740134,0.080160936011401,0.056803699814849,0.0356598690376401,0.0382105976873559,0.0431724936250598,0.0457579436472762,0.0529418589202611,0.0655100806121948,0.0963437234326675,0.0361876092445135,0.0359203339520145,0.0414920566724018,0.0457510934030754,0.0482407980655788,0.0654493017293956,0.0599956129441238,0.0362646680344086,0.0363410213670233,0.0409006945745536,0.0450046360944264,0.0549213794272636,0.0556010862318487,0.0559295024138738,0.0369844621721675,0.0480868298789148,0.0476512214089914,0.0541142254043912,0.060694476802611,0.0713241962308651,0.0699736284519921,0.0405350570209462,0.0428993699849648,0.053395929367104,0.0509347959756543,0.0660253823410721,0.0651968760457297,0.0805864120245187,0.0398727612910199,0.0438137176679761,0.0530089556132846,0.056182545410471,0.0640244083293622,0.0743651903266507,0.0681269078176602,0.0479415829570249,0.0452377354974986,0.0496574904012409,0.0538508431848656,0.0534410208490807,0.067562517237834,0.0689265470213254,0.0388741876260525,0.0377904884917244,0.0442688597599199,0.0452288601311824,0.0507518551257181,0.0569174983479336,0.0474182664759317,0.0329607142494078,0.0347124247405655,0.0405638446257238,0.0445054071670156,0.0494960162336406,0.0567083801405844,0.0557110396962352,0.0287965496171827,0.029230435368049,0.0364225640587019,0.0403521948881952,0.0394853510356313,0.0460576256642133,0.0425415296890001,0.0254822699813605,0.0263966618633962,0.0321837367429111,0.0377771570847956,0.036882144725282,0.0368145195936523,0.0366209474276816,0.0229491129796783,0.0244147920028286,0.0293770494404891,0.0294771816274379,0.0258120522949136,0.0346224803887505,0.0359996403969119,0.0212704923376679,0.022287706403832,0.0299258728784037,0.0262925729211808,0.0199609414795616,0.0206729113192662,0.017404257607049,0.0318779007194773,0.015195313591504,0.0197005308853452,-0.0276130196210185,0.0169507749366049,0.016690854344966,0.0302113959025445,0.0160230705105469,0.0238457641572685,0.0201462352209085,0.022041284674057,0.0148614736176981,0.0196527540495619,0.0253463135606717,0.0143002719846205,0.0182783983602586,0.0168877815438595,0.0184055570289663,0.0153240283999935,0.0122497218713161,0.0279681765786821,0.0163887897133728,0.0184405141947668,0.0212918247796561,0.0223550574152815,0.0138475121989017,0.0121384742410112,0.0283816370005422,0.0226799515515054,0.023705169824982,0.101263316736453,0.0341297954316577,0.00895442058642148,0.0112444297357828,0.0149854421537779,0.0458816332824422,0.0388939442106984,0.0681640711532497,0.0532175254114249,0.0159626345136931,0.0162354684795248,0.0603361691315773,0.0582835229923088,0.0502004456105775,0.0469639301682424,0.0721820473694686,0.0236815765136609,0.0227907352517913,0.0900402261427328,0.0690950595213595,0.0645864816781186,0.0716190609483676,0.0944790356227208,0.033070890264077,0.0281886169584089,0.118846745075609,0.103396406128399,0.0770836660037453,0.0889668087386488,0.117266938722447,0.0388735086031428,0.0403887509901366,0.141154738433024,0.119043131167535,0.0851896338356264,0.092386677668199,0.126550107456076,0.0421336230613931,0.0505040180015431,0.158147763649671,0.113366918661539,0.101929811343006,0.0909906115851675,0.123103928063244,0.0442179859633613,0.055265467974331,0.203336214333905,0.0900006736157197,0.0969913479600182,0.0969688434963705,0.12959795973754,0.0676403782156252,0.0484457780542643,0.201958675973893,0.0831239972483304,0.0879335241159243,0.0963520752584932,0.104393721808217,0.0596978243577822,0.0432878118903378,0.195893955716144,0.0821723234384695,0.10379428763702,0.0896587480761458,0.102755825647554,0.0487903604063426,0.044827213833793,0.0935206435254425,0.215333284708904,0.0905979130739317,0.0827186573439596,0.0858515968506084,0.0484848087360016,0.0404052578518964,0.19297484323138,0.0814406465074008,0.0804836538193264,0.0776860946690656,0.0877502929162367,0.049080302227546,0.0418510139098374,0.151556694883726,0.0681230686015942,0.0719774033907602,0.0643629420786879,0.0734253210401033,0.0382987947371078,0.0392298639702891,0.160231938134476,0.0608274660642955,0.0642891732133781,0.0604295260133642,0.0692264803836473,0.0336438131886608,0.0325177570940283,0.136950246625747,0.0538078367942094,0.0640487798924816,0.0557947933964357,0.0635949870079844,0.0303061543394526,0.0320721543428055,0.108153391030299,0.0679838217319618,0.0579503720707889,0.0479731041325166,0.0578992262087991,0.0281546731670629,0.03205960377039,0.101066543431954,0.0491456781190941,0.0463151140875005,0.0448795640965678,0.0544153910981566,0.0271657498772604,0.0272422878296967,0.0922656975189188,0.0524653423753226,0.0530471355534309,0.0515316903303266,0.0577234365362945,0.0282231984692242,0.0312395050780946,0.119595428165458,0.0474016657086901,0.0451855481232159,0.0477863575346893,0.0581901006824186,0.0288912347545118,0.0267459336129233,0.104160283337452,0.0452263251124131,0.0553477434209534,0.0379640757271683,0.0887568848667079,0.0558611083057881,0.0307823293340252,0.120858558957824,0.0498944598594563,0.0594268865387503,0.0595361629023184,0.0733167354297021,0.0365770559674206,0.041885292083557,0.140785270964112,0.0582892048324792,0.0742041399884261,0.0417293334776022,0.0701918099337929,0.0284144813801616,0.0351848859245765,0.200136007216709,0.0773178227011364,0.127478665433566,0.239510960398912,null,null,null,null,null]]},"evals":[],"jsHooks":[]}</script>
</div>
<div id="world-bank-data" class="section level2">
<h2>World Bank data</h2>
<p>Country-level covariates by <a href="https://data.worldbank.org/">World Bank Open Data</a> can be easily added. Refer to the table at the bottom of <a href="https://datatopics.worldbank.org/universal-health-coverage/coronavirus/">this page</a> for relevant indicators. The following code snippet shows e.g., how to download the number of hospital beds for each country. Refer to the <a href="https://covid19datahub.io/articles/r.html">quickstart guide</a> for more details.</p>
<pre class="r"><code>x <- covid19(wb = c("hosp_beds" = "SH.MED.BEDS.ZS"), verbose = FALSE)</code></pre>
</div>
<div id="mobility-data" class="section level2">
<h2>Mobility data</h2>
<p>Mobility data are obtained from <a href="https://www.google.com/covid19/mobility/">Google</a> and <a href="https://www.apple.com/covid19/mobility">Apple</a> mobility reports. The following example shows how to download the data by Google. Refer to the <a href="https://covid19datahub.io/articles/r.html">quickstart guide</a> for Apple’s reports and for more details.</p>
<pre class="r"><code>x <- covid19(gmr = TRUE, verbose = FALSE)
colnames(x[,48:53])</code></pre>
<pre><code>## [1] "retail_and_recreation_percent_change_from_baseline"
## [2] "grocery_and_pharmacy_percent_change_from_baseline"
## [3] "parks_percent_change_from_baseline"
## [4] "transit_stations_percent_change_from_baseline"
## [5] "workplaces_percent_change_from_baseline"
## [6] "residential_percent_change_from_baseline"</code></pre>
</div>
<div id="spatial-data" class="section level2">
<h2>Spatial data</h2>
<p>The dataset contains NUTS codes to match the <a href="https://ec.europa.eu/eurostat/web/nuts/nuts-maps">Eurostat</a> database for Europe, and GID codes to match the <a href="https://gadm.org/">GADM</a> worldwide database. The following example shows how to access spatial data using GADM for U.S. counties. Similar maps are available worldwide for most other countries at the various granularity levels.</p>
<p>First, download level 3 data for U.S.</p>
<pre class="r"><code>x <- covid19("USA", level = 3, verbose = FALSE)</code></pre>
<p>GADM data by country can be found <a href="https://gadm.org/download_country.html">here</a>. Download the geopackage for U.S. using GADM version 3.6:</p>
<pre class="r"><code>url <- "https://biogeo.ucdavis.edu/data/gadm3.6/gpkg/gadm36_USA_gpkg.zip"
zip <- tempfile()
download.file(url, destfile = zip)</code></pre>
<p>Unzip the geopackage:</p>
<pre class="r"><code>exdir <- tempfile()
unzip(zip, exdir = exdir)</code></pre>
<p>Load the <code>sf</code> package and list the layers:</p>
<pre class="r"><code>library(sf)
file <- paste0(exdir, "/gadm36_USA.gpkg")
st_layers(file)</code></pre>
<pre><code>## Driver: GPKG
## Available layers:
## layer_name geometry_type features fields
## 1 gadm36_USA_2 Multi Polygon 3148 13
## 2 gadm36_USA_1 Multi Polygon 51 10
## 3 gadm36_USA_0 Multi Polygon 1 2</code></pre>
<p>Read layer 2 that corresponds to U.S. counties. Note: in general, there is not a perfect correspondence between GADM layers and the granularity <code>level</code> from this package. It is recommended to read all the layers, and match on the corresponding GID. Read more about how <code>key_gadm</code> from this package is mapped to the corresponding GID <a href="https://covid19datahub.io/articles/docs.html#external-keys">here</a>.</p>
<pre class="r"><code>g <- st_read(file, layer = "gadm36_USA_2")</code></pre>
<pre><code>## Reading layer `gadm36_USA_2' from data source
## `/private/var/folders/w0/skxpg0h51jg72m5b01y_8n_c0000gn/T/RtmpmUy7P6/file56232c611dfd/gadm36_USA.gpkg'
## using driver `GPKG'
## Simple feature collection with 3148 features and 13 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -179.2 ymin: 18.91 xmax: 179.8 ymax: 72.69
## Geodetic CRS: WGS 84</code></pre>
<p>Subset the data to extract only the counts as of, e.g., 15 November 2021. Select only the administrative divisions inside the following bounding box for better visualization.</p>
<pre class="r"><code>x <- x[
x$date == "2021-11-15" &
x$latitude > 24.9493 & x$latitude < 49.5904 &
x$longitude > -125.0011 & x$longitude < -66.9326,]</code></pre>
<p>Merge COVID-19 data with the spatial data:</p>
<pre class="r"><code>library(dplyr)
gx <- right_join(g, x, by = c("GID_2" = "key_gadm"))</code></pre>
<p>Plot e.g., the total number of confirmed cases:</p>
<pre class="r"><code>plot(gx["confirmed"], logz = TRUE)</code></pre>
<p><img src="map2.png" /></p>
</div>
<div id="academic-publications" class="section level2">
<h2>Academic publications</h2>
<p>See the <a href="https://scholar.google.com/scholar?oi=bibs&hl=en&cites=1585537563493742217">publications</a> that use COVID-19 Data Hub.</p>
</div>
<div id="cite-as" class="section level2">
<h2>Cite as</h2>
<p><em>Guidotti, E., Ardia, D., (2020), “COVID-19 Data Hub”, Journal of Open Source Software 5(51):2376, doi: 10.21105/joss.02376.</em></p>
<p>A BibTeX entry for LaTeX users is</p>
<pre class="latex"><code>@Article{,
title = {COVID-19 Data Hub},
year = {2020},
doi = {10.21105/joss.02376},
author = {Emanuele Guidotti and David Ardia},
journal = {Journal of Open Source Software},
volume = {5},
number = {51},
pages = {2376}
}</code></pre>
</div>
<script>window.location.href='https://rviews.rstudio.com/2021/12/08/the-r-package-covid19/';</script>
October 2021: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2021/11/29/october-2021-top-40-new-cran-packages/
Mon, 29 Nov 2021 00:00:00 +0000https://rviews.rstudio.com/2021/11/29/october-2021-top-40-new-cran-packages/
<p>One hundred forty-one new packages made it to CRAN in October. Here are my “Top 40” picks in twelve categories: Computational Methods, Data, Genomics, Machine Learning, Medicine, Networks, Science, Social Science, Statistics, Time Series, Utilities, and Visualization.</p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=gslnls">gslnls</a> v1.0.2: Implements an R interface to nonlinear least-squares optimization with the GNU Scientific Library (GSL). See <a href="https://www.amazon.com/GNU-Scientific-Library-Reference-Manual/dp/0954612078">M. Galassi et al. (2009)</a>.</p>
<p><a href="https://cran.r-project.org/package=rsvddpd">rsvddpd</a> v1.0.0: Implements a robust method for computing the singular value decomposition using power density divergence. See <a href="https://arxiv.org/abs/2109.10680">Roy et. al (2021)</a> for background and the <a href="https://cran.r-project.org/web/packages/rsvddpd/vignettes/rSVDdpd-intro.html">vignette</a> for an example.</p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=blsR">blsR</a> v0.2.1: Implements v2 of the <a href="https://www.bls.gov/developers/api_signature_v2.htm">Bureau of Labor Statistics API</a> for requests of survey information and time series data. See <a href="https://cran.r-project.org/web/packages/blsR/readme/README.html">README</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=insiderTrades">insiderTrades</a> v0.0.1: Provides functions to download insider trading transactions and insider holdings from a public <a href="https://www.sec.gov/Archives/edgar/full-index/">NoSQL SEC database</a> using keyword criteria and generate a relational dataframe. See the vignettes <a href="https://cran.r-project.org/web/packages/insiderTrades/vignettes/insiderTrades.html">insiderTrades</a> and <a href="https://cran.r-project.org/web/packages/insiderTrades/vignettes/pullAndScrape.html">pullAndScrape</a>.</p>
<p><a href="https://cran.r-project.org/package=KingCountyHouses">KingCountyHouses</a> v0.1.0: Contains data on houses in and around Seattle WA are included. Basic characteristics are given along with sale prices. See <a href="https://cran.r-project.org/web/packages/KingCountyHouses/readme/README.html">README</a>.</p>
<p><a href="https://cran.r-project.org/package=meteospain">meteospain</a> v0.0.3: Provides access to different Spanish meteorological stations data services and APIs including AEMET, SMC, MG, and Meteoclimatic. There are seven short vignettes including <a href="https://cran.r-project.org/web/packages/meteospain/vignettes/api_limits.html">API limits and loops</a> and <a href="https://cran.r-project.org/web/packages/meteospain/vignettes/compatibility.html">Compatibility between services</a>.</p>
<p><a href="https://cran.r-project.org/package=owidR">owidR</a> v1.1.0: Provides function to import, search, download, and visualize data from the <a href="https://ourworldindata.org/">Our World in Data</a> website. See the <a href="https://cran.r-project.org/web/packages/owidR/vignettes/example-analysis.html">vignette</a>.</p>
<p><img src="owidR.png" height = "400" width="500" alt="Choropleth Showing Share of Population Using the Internet by Country"></p>
<p><a href="https://cran.r-project.org/package=QBMS">QBMS</a> v0.6: Enables users to query the <a href="https://bmspro.io/">Breeding Management System</a> database. There is a short <a href="https://cran.r-project.org/package=QBMS">Tutorial</a>.</p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=digitalDLSorteR">digitalDLSorteR</a> v0.1.1: Implements tools for the deconvolution of bulk RNA-Seq data using context-specific deconvolution models based on Deep Neural Networks using scRNA-Seq data as input. See <a href="https://www.frontiersin.org/articles/10.3389/fgene.2019.00978/full">Torroja & Sanchez-Cabo (2019)</a> for details. There are five vignettes including <a href="https://cran.r-project.org/web/packages/digitalDLSorteR/vignettes/kerasIssues.html">Keras/TensorFlow installation and configuration</a> and <a href="https://cran.r-project.org/web/packages/digitalDLSorteR/vignettes/newModels.html">Building new deconvolution models</a>.</p>
<p><img src="DLRSorteR.png" height = "400" width="600" alt="Process Flow Diagram"></p>
<p><a href="https://cran.r-project.org/package=Platypus">Platypus</a> v3.2.3: Implements an open-source software platform for investigating B-cell receptor and T-cell receptor repertoires from scSeq experiments which also incorporates transcriptional information involving unsupervised clustering, gene expression and gene ontology. See <a href="https://academic.oup.com/nargab/article/3/2/lqab023/6225857">Yermanos et al. (2021)</a> and the <a href="https://cran.r-project.org/web/packages/Platypus/vignettes/PlatypusV3_agedCNS.html">vignette</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=quincunx">quincunx</a> v0.1.4: Provides programmatic access to the <a href="https://www.pgscatalog.org/">PGS Catalog</a> through the <a href="https://www.pgscatalog.org/rest/">REST API</a>. See <a href="https://cran.r-project.org/web/packages/quincunx/readme/README.html">README</a> for the cheatsheet.</p>
<p><img src="quincunx.png" height = "300" width="500" alt="Cheatsheet for API Commands"></p>
<p><a href="https://cran.r-project.org/package=SNPfiltR">SNPfilter</a> v0.1.0: Provides functions to interactively and reproducibly visualize and filter SNP (single-nucleotide polymorphism) datasets, including functions for visualizing various quality and missing data metrics for a SNP dataset, and then filtering the dataset based on user specified cutoffs. See the <a href="https://cran.r-project.org/web/packages/SNPfiltR/vignettes/reproducible-vignette.html">vignette</a>.</p>
<p><img src="SNPfilter.png" height = "400" width="400" alt="Plot of Completeness vs. Missing Data"></p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=conText">conText</a> v1.0.0: Implements a framework to estimate context-specific word and short document embeddings using the <em>a la carte</em> embeddings approach developed by <a href="https://arxiv.org/abs/1805.05388">Khodak et al. (2018)</a> and evaluate hypotheses about covariate effects on embeddings using the regression framework developed by <a href="https://github.com/prodriguezsosa/EmbeddingRegression">Rodriguez et al. (2021)</a>. There is a <a href="https://cran.r-project.org/web/packages/conText/vignettes/quickstart.html">Quick Start Guide</a>.</p>
<p><a href="https://cran.r-project.org/package=pixelclasser">pixelclassifier</a> v1.0.0: Implements a Support Vector Machine to classify the pixels of an image file by its color. See the <a href="https://cran.r-project.org/web/packages/pixelclasser/vignettes/pixelclasser.html">vignette</a>.</p>
<p><img src="pixel.png" height = "300" width="300" alt="Plot Showing Boundaries Separating Pixels"></p>
<p><a href="https://cran.r-project.org/package=predtools">predtools</a> v0.0.2: Provides functions for evaluating predictive models, including plotting calibration curves and model-based Receiver Operating Characteristic (mROC) curves based on <a href="https://arxiv.org/abs/2003.00316">Sadatsafavi et al. (2021)</a>. There are three vignettes: <a href="https://cran.r-project.org/web/packages/predtools/vignettes/calibPlot.html">Calibration Plot</a>, <a href="https://cran.r-project.org/web/packages/predtools/vignettes/interceptAdj.html">Intercept Adjustment</a>, and <a href="https://cran.r-project.org/web/packages/predtools/vignettes/mROC.html">Model-based ROC</a>.</p>
<p><img src="predtools.png" height = "300" width="300" alt="Calibration Plot"></p>
<p><a href="https://cran.r-project.org/package=text2sdg">text2sdg</a> v0.1.1: Provides functions to identify <em>Sustainable Development Goals</em> in text using scientifically developed query systems, opening up the opportunity to monitor any type of text-based data, such as scientific output or corporate publications. There is a <a href="https://cran.r-project.org/web/packages/text2sdg/vignettes/text2sdg.html">vignette</a>.</p>
<p><img src="text2sdg.png" height = "300" width="500" alt="Histogram of SDGs by Query System"></p>
<p><a href="https://cran.r-project.org/package=Twitmo">Twitmo</a> v0.1.1: Provides functions to collect, pre-process and analyze the contents of tweets using LDA and STM models including functions to generate tweet and hashtag maps and built-in support for <code>LDAvis</code>. See <a href="https://cran.r-project.org/web/packages/Twitmo/readme/README.html">README</a> for examples.</p>
<p><img src="Twitmo.png" height = "300" width="500" alt="Plot of Geo-Tagged Tweets"></p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=ctrialsgov">ctrialsgov</a> v0.2.5: Provides tools to access and query the U.S. National Library of Medicine’s <a href="https://clinicaltrials.gov/">Clinical Trials database</a> including functions for searching the data using range queries, categorical filtering, and by searching for full-text keywords. There is an <a href="https://cran.r-project.org/web/packages/ctrialsgov/vignettes/introduction.html">Introduction</a> and a vignette on <a href="https://cran.r-project.org/web/packages/ctrialsgov/vignettes/text_analysis.html">Text Analysis</a>.</p>
<p><a href="https://cran.r-project.org/package=epidemia">epidemia</a> v1.0.0: Implements functions to specify and fit Bayesian statistical models for epidemics. Infections are propagated over time using self-exciting point processes. Multiple regions can be modeled simultaneously with multilevel models. See <a href="https://arxiv.org/abs/2012.00394">Bhatt et al. (2021)</a> for background on the models and the <a href="https://imperialcollegelondon.github.io/epidemia/index.html">package website</a> for examples and extensive documentation.</p>
<p><img src="epidemia.png" height = "300" width="300" alt="Distribution Plots for Posterior Prediction Checks"></p>
<h3 id="networks">Networks</h3>
<p><a href="https://cran.r-project.org/package=dissCqN">dissCqN</a> v0.1.0: Provides functions to calculate multiple or pairwise dissimilarity for orders q = 0-N for a set of species assemblages or interaction networks. See <a href="https://onlinelibrary.wiley.com/doi/10.1111/j.1541-0420.2008.01010.x">Chao et al. 2008</a> for background and the <a href="https://cran.r-project.org/web/packages/dissCqN/vignettes/dissCqN.html">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=modnets">modnets</a> v0.9.0: Implements methods for modeling moderator variables in cross-sectional, temporal, and multi-level networks including model selection techniques and a variety of plotting functions. See <a href="https://www.proquest.com/openview/d151ab6b93ad47e3f0d5e59d7b6fd3d3">Swanson (2020)</a> for details and the <a href="https://cran.r-project.org/web/packages/modnets/readme/README.html">README</a> for an example.</p>
<p><img src="modnets.png" height = "300" width="500" alt="Network Plot"></p>
<h3 id="science">Science</h3>
<p><a href="https://cran.r-project.org/package=cmpsR">cmpsR</a> v0.1.0: Implements the Congruent Matching Profile Segments (CMPS) method <a href="https://www.sciencedirect.com/science/article/abs/pii/S0379073819303767?via%3Dihub">Chen et al. (2019)</a> to provide an objective comparison of striated tool marks for fired bullet correlation. See the <a href="https://cran.r-project.org/web/packages/cmpsR/vignettes/cmpsR-vignette.html">vignette</a>.</p>
<p><img src="cmpsR.png" height = "300" width="500" alt="Series of Correlation Plots"></p>
<p><a href="https://cran.r-project.org/package=pvcurveanalysis">pvcurveanalysis</a> v1.0.0: Provides functions to analyze and display pressure volume curves which enable the derivation of the turgor loss point, osmotic potential and apoplastic fraction. See <a href="https://onlinelibrary.wiley.com/doi/10.1111/j.1461-0248.2012.01751.x">Bartlett et al. (2012)</a> for background and the <a href="https://cran.r-project.org/web/packages/pvcurveanalysis/vignettes/pvcurveanalysis.html">vignette</a> for examples.</p>
<p><img src="pvcurve.png" height = "300" width="300" alt="Plot Showing Turgor Loss Point"></p>
<h3 id="social-science">Social Science</h3>
<p><a href="https://cran.r-project.org/package=rcbayes">rcbayes</a> v0.1.0: Provides functions to estimate <em>Rogers-Castro</em> migration age schedules using <code>Stan</code>. See <a href="https://journals.sagepub.com/doi/10.1068/a100475">Rogers and Castro (1978)</a> for background and the vignettes on <a href="https://cran.r-project.org/web/packages/rcbayes/vignettes/convergence_issues.html">Model Convergence</a> and <a href="https://cran.r-project.org/web/packages/rcbayes/vignettes/intro_to_rcbayes.html">Rogers Castro Migration Models</a>.</p>
<p><img src="rcbayes.png" height = "300" width="500" alt="Migration Rate Plot"></p>
<p><a href="https://cran.r-project.org/package=QCAcluster">QCAcluster</a> v0.1.0: Provides functions to allow <a href="https://www.google.com/books/edition/Qualitative_Comparative_Analysis_with_R/-Y_Mzk00CioC?hl=en&gbpv=1&dq=qualitative+comparative+analysis&pg=PP3&printsec=frontcover">Qualitative Comparative Analysis</a> researchers to supplement the analysis of pooled data with a disaggregated perspective focusing on selected partitions of the data. The pooled data can be partitioned along the dimensions of the clustered data (individual cross sections or time series) to perform partition-specific truth table minimizations. There are vignettes that discuss the <a href="https://cran.r-project.org/web/packages/QCAcluster/vignettes/Aggregation-over-partitions.html">Aggregation</a>, <a href="https://cran.r-project.org/web/packages/QCAcluster/vignettes/Diversity-of-partitions.html">Diversity</a>, <a href="https://cran.r-project.org/web/packages/QCAcluster/vignettes/Minimization-of-partitions.html">Miimization</a>, and <a href="https://cran.r-project.org/web/packages/QCAcluster/vignettes/Weight-of-partitions.html">Weight</a> of partitions.</p>
<p><img src="QCAcluster.png" height = "300" width="500" alt="UpSet plot that displays how often a single condition occurs over multiple partition-specific models"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=bayesPO">bayesPO</a> v0.3.1: Provides functions to create Bayesian point process models of presence only data. See <a href="http://www.pg.im.ufrj.br/teses/Estatistica/Doutorado/043.pdf">Moreira (2020)</a> for background, and the <a href="https://cran.r-project.org/web/packages/bayesPO/vignettes/bayesPO.html">vignette</a> for examples.</p>
<p><img src="bayesPO.png" height = "300" width="500" alt="Scatter Plot of Data on Heat Map of Covariates."></p>
<p><a href="https://cran.r-project.org/package=hierbase">hierbase</a> v0.1.2: Implements the algorithms for hierarchical testing of variable importance described in <a href="https://academic.oup.com/biomet/article-abstract/95/2/265/230264">Meinshausen (2008)</a> which control for family-wise error rate. See the <a href="https://cran.r-project.org/web/packages/hierbase/vignettes/vignette-hierbase.pdf">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=pedmod">pedmod</a> v0.1.0: Provides functions to estimate mixed probit models, commonly called liability threshold models, for pedigree data such as that studied in <a href="https://onlinelibrary.wiley.com/doi/10.1002/sim.1603">Pawitan et al. (2004)</a>. See <a href="https://www.tandfonline.com/doi/abs/10.1198/106186002394">Genz & Bretz (2012)</a> for background. There is an <a href="https://cran.r-project.org/web/packages/pedmod/vignettes/pedmod.html">introduction</a> to pedigree models and a vignette on <a href="https://cran.r-project.org/web/packages/pedmod/vignettes/pedigree_partitioning.html">positioning families</a>.</p>
<p><img src="pedmod.png" height = "300" width="500" alt="Plot of Relationship Network"></p>
<p><a href="https://cran.r-project.org/package=slasso">slasso</a> v1.0.0: Implements the smooth LASSO estimator for the function-on-function linear regression model described in <a href="https://arxiv.org/abs/2007.00529">Centofanti et al. (2020)</a>. See <a href="https://cran.r-project.org/web/packages/slasso/readme/README.html">README</a> for examples.</p>
<p><img src="slasso.png" height = "300" width="600" alt="Contour Plot and 3D Plot of Functional Lasso"></p>
<p><a href="https://cran.r-project.org/package=StanMoMo">StanMoMo</a> v1.0.0: Implements Bayesian mortality models including those developed in <a href="https://www.tandfonline.com/doi/abs/10.1080/01621459.1992.10475265">Lee & Carter (1992)</a> and <a href="https://onlinelibrary.wiley.com/doi/10.1111/j.1539-6975.2006.00195.x">Cairns, Blake & Dowd (2006)</a>. There is a <a href="https://cran.r-project.org/web/packages/StanMoMo/vignettes/StanMoMo.html">vignette</a> introducing the <em>Lee & Carter</em> model and another on <a href="https://cran.r-project.org/web/packages/StanMoMo/vignettes/bma.html">Bayesian Model Averaging</a>.</p>
<p><img src="StanMoMo.png" height = "300" width="500" alt="Forecast Plot"></p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=esemifar">esemifar</a> v1.0.1: Implements algorithms that provide non-parametric estimates of trend and its derivatives in equidistant time series with long-memory errors. See <a href="https://ideas.repec.org/p/pdn/ciepap/145.html">Letmathe et al. (2021)</a> for a description of the smoothing methods employed, and <a href="https://cran.r-project.org/web/packages/esemifar/readme/README.html">README</a> for an example.</p>
<p><img src="esemifar.png" height = "300" width="500" alt="Plot of London Air Quality Index with Trend"></p>
<p><a href="https://cran.r-project.org/package=GDPuc">GDPuc</a> v0.5.1: Provides a function to convert GDP time series from one unit to another. All common GDP units are included, i.e. current and constant local currency units, US$ via market exchange rates and international dollars via purchasing power parities. See <a href="https://cran.r-project.org/web/packages/GDPuc/index.html">README</a> for examples.</p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=framecleaner">framecleaner</a> v0.2.0: Provides a friendly interface for modifying data frames with a sequence of piped commands built upon the <code>tidyverse</code>. See the <a href="https://cran.r-project.org/web/packages/framecleaner/vignettes/cleanYourFrame.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=presenter">presentr</a> v0.1.1: Implements wrapper functions using packages <code>openxlsx</code>, <code>flextable</code>, and <code>officer</code> to create highly formatted MS office friendly output of data frames. Vignettes include: <a href="https://cran.r-project.org/web/packages/presenter/vignettes/exportToExcel.html">exportToExcel</a>, <a href="https://cran.r-project.org/web/packages/presenter/vignettes/flextableAndPowerpoint.html">flextableAndPowerpoint</a>, and <a href="https://cran.r-project.org/web/packages/presenter/vignettes/formattedFlextable.html">formattedFlextable</a>.</p>
<p><a href="https://cran.r-project.org/package=shinyGovstyle">shinyGovstyle</a> v0.0.7: Implements a collection of <code>shiny</code> application styling tools that are the based on the <a href="https://design-system.service.gov.uk/components/">GOV.UK Design System</a>. See <a href="https://cran.r-project.org/web/packages/shinyGovstyle/readme/README.html">README</a> for an introduction and examples.</p>
<p><a href="https://cran.r-project.org/package=validata">validata</a> v0.1.0: Provides functions for validating the structure and properties of data frames helping users to answer essential questions about a data set such as: <em>What are the unique or missing values?</em> and <em>What columns form a primary key?</em>. See the <a href="https://cran.r-project.org/web/packages/validata/vignettes/PackageIntroduction.html">vignette</a> for an introduction.</p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=easylabel">easylabel</a> v0.2.4: Implements interactive labeling of scatter plots, volcano plots and Manhattan plots using a <code>shiny</code> or <code>plotly</code> interface. Users can hover over points to see where specific points are located and click points on/off to easily label them. See the <a href="https://cran.r-project.org/web/packages/easylabel/vignettes/easylabel.html">vignette</a> for examples.</p>
<p><img src="easylabel.png" height = "300" width="500" alt="Bubble Plot with Labels"></p>
<p><a href="https://cran.r-project.org/package=ggokabeito">ggokabeito</a> v0.1.0: Provides discrete scales for the colorblind-friendly <code>Okabe-Ito</code> palette, including color, fill, and edge_colour. See <a href="https://cran.r-project.org/web/packages/ggokabeito/readme/README.html">README</a> for examples.</p>
<p><img src="ggokabeito.png" height = "300" width="500" alt="Color Coded Density Plots "></p>
<p><a href="https://cran.r-project.org/package=metaconfoundr">metaconfoundr</a> v0.1.0: Implements an approach for evaluating bias in meta-analysis studies based on the causal inference framework. See the <a href="https://cran.r-project.org/web/packages/metaconfoundr/vignettes/intro-to-metaconfoundr.html">vignette</a> for examples.</p>
<p><img src="metaconfoundr.png" height = "400" width="600" alt="Heat Map of Confounders"></p>
<p><a href="https://cran.r-project.org/package=scatterPlotMatrix">scatterPlotMatrix</a> v0.1.0: Provides functions which make use of the packages <code>htmlwidgets</code> package and <code>d3.js</code> to create scatter plot matrices. See the <a href="https://cran.r-project.org/web/packages/scatterPlotMatrix/vignettes/introduction-to-scatterplotmatrix.html">vignette</a>.
<img src="SPM.png" height = "300" width="500" alt="Multiple Scatter PLots of Several Variables Arranged in a Matrix"></p>
<script>window.location.href='https://rviews.rstudio.com/2021/11/29/october-2021-top-40-new-cran-packages/';</script>
How to Scrape and Store Strava Data Using R
https://rviews.rstudio.com/2021/11/22/strava-data/
Mon, 22 Nov 2021 00:00:00 +0000https://rviews.rstudio.com/2021/11/22/strava-data/
<script src="/2021/11/22/strava-data/index_files/header-attrs/header-attrs.js"></script>
<p><em>This post by Julian During is the third place winner in the <a href="https://rviews.rstudio.com/2021/08/04/r-views-blog-contest/">Call for Documentation</a> contest. Julian is a data scientist from Germany working in the manufacturing industry. Julian loves working with R (especially the tidyverse ecosystem), sports, black coffee and cycling.</em></p>
<p>I am an avid runner and cyclist. For the past couple of years, I have recorded almost all my activities on some kind of GPS device.</p>
<p>I record my runs with a Garmin device and my bike rides with a Wahoo device, and I synchronize both accounts on Strava. I figured that it would be nice to directly access my data from my Strava account.</p>
<p>In the following text, I will describe the progress to get Strava data into R, process the data, and then create a visualization of activity routes. You can find the original analysis in this <a href="https://github.com/duju211/pin_strava">Github repository</a>.</p>
<p>You will need the following packages:</p>
<pre class="r"><code>library(tarchetypes)
library(conflicted)
library(tidyverse)
library(lubridate)
library(jsonlite)
library(targets)
library(httpuv)
library(httr)
library(pins)
library(httr)
library(fs)
library(readr)
conflict_prefer("filter", "dplyr")</code></pre>
<div id="set-up-targets" class="section level2">
<h2>Set Up Targets</h2>
<p>The whole data pipeline is implemented with the help of the <code>targets</code> package. You can learn more about the package and its functionalities <a href="https://docs.ropensci.org/targets/">here</a>.</p>
<p>In order to reproduce the analysis, perform the following steps:</p>
<ul>
<li>Clone the repository: <a href="https://github.com/duju211/pin_strava" class="uri">https://github.com/duju211/pin_strava</a></li>
<li>Install the packages listed in the ‘libraries.R’ file</li>
<li>Run the target pipeline by executing <code>targets::tar_make()</code> command</li>
<li>Follow the instructions printed in the console</li>
</ul>
<div id="target-plan" class="section level3">
<h3>Target Plan</h3>
<p>The manifest of the target plan looks like this:</p>
<table>
<colgroup>
<col width="4%" />
<col width="88%" />
<col width="4%" />
<col width="2%" />
</colgroup>
<thead>
<tr class="header">
<th align="left">name</th>
<th align="left">command</th>
<th align="left">pattern</th>
<th align="left">cue_mode</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">my_app</td>
<td align="left">define_strava_app()</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
<tr class="even">
<td align="left">my_endpoint</td>
<td align="left">define_strava_endpoint()</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
<tr class="odd">
<td align="left">act_col_types</td>
<td align="left">list(moving = col_logical(), velocity_smooth = col_number(), grade_smooth = col_number(), distance = col_number(), altitude = col_number(), time = col_integer(), lat = col_number(), lng = col_number(), cadence = col_integer(), watts = col_integer())</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
<tr class="even">
<td align="left">my_sig</td>
<td align="left">define_strava_sig(my_endpoint, my_app)</td>
<td align="left">NA</td>
<td align="left">always</td>
</tr>
<tr class="odd">
<td align="left">df_act_raw</td>
<td align="left">read_all_activities(my_sig)</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
<tr class="even">
<td align="left">df_act</td>
<td align="left">pre_process_act(df_act_raw, athlete_id)</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
<tr class="odd">
<td align="left">act_ids</td>
<td align="left">pull(distinct(df_act, id))</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
<tr class="even">
<td align="left">df_meas</td>
<td align="left">read_activity_stream(act_ids, my_sig)</td>
<td align="left">map(act_ids)</td>
<td align="left">never</td>
</tr>
<tr class="odd">
<td align="left">df_meas_all</td>
<td align="left">bind_rows(df_meas)</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
<tr class="even">
<td align="left">df_meas_wide</td>
<td align="left">meas_wide(df_meas_all)</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
<tr class="odd">
<td align="left">df_meas_pro</td>
<td align="left">meas_pro(df_meas_wide)</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
<tr class="even">
<td align="left">gg_meas</td>
<td align="left">vis_meas(df_meas_pro)</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
<tr class="odd">
<td align="left">df_meas_norm</td>
<td align="left">meas_norm(df_meas_pro)</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
<tr class="even">
<td align="left">gg_meas_save</td>
<td align="left">save_gg_meas(gg_meas)</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
</tbody>
</table>
<p><br>
We will go through the most important targets in detail.</p>
</div>
</div>
<div id="oauth-dance-from-r" class="section level2">
<h2>OAuth Dance from R</h2>
<p>The Strava API requires an ‘OAuth dance’, described below.
<br>
<br>
<font size="4"><strong>1. Create an OAuth Strava app</strong></font>
<br>
To get access to your Strava data from R, you must first create a Strava API. The steps are documented on the <a href="https://developers.strava.com/docs/getting-started/">Strava Developer site</a>. While creating the app, you’ll have to give it a name. In my case, I named it <code>r_api</code>.</p>
<p>After you have created your personal API, you can find your Client ID and Client Secret variables in the <a href="https://www.strava.com/settings/api">Strava API settings</a>. Save the Client ID as <code>STRAVA_KEY</code> and the Client Secret as <code>STRAVA_SECRET</code> in your R environment.<a href="#fn1" class="footnote-ref" id="fnref1"><sup>1</sup></a></p>
<pre><code>STRAVA_KEY=<Client ID>
STRAVA_SECRET=<Client Secret>
</code></pre>
<p>Then, you can run the function <code>define_strava_app</code> shown below.</p>
<table>
<thead>
<tr class="header">
<th align="left">name</th>
<th align="left">command</th>
<th align="left">pattern</th>
<th align="left">cue_mode</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">my_app</td>
<td align="left">define_strava_app()</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
</tbody>
</table>
<pre class="r"><code>define_strava_app <- function() {
oauth_app(
appname = "r_api",
key = Sys.getenv("STRAVA_KEY"),
secret = Sys.getenv("STRAVA_SECRET")
)
}</code></pre>
<p><br>
<font size="4"><strong>2. Define an endpoint</strong></font></p>
<p>Define an endpoint called <code>my_endpoint</code> using the function <code>define_strava_endpoint</code>.</p>
<p>The <code>authorize</code> parameter describes the authorization url and the <code>access</code> argument exchanges the authenticated token.</p>
<table>
<thead>
<tr class="header">
<th align="left">name</th>
<th align="left">command</th>
<th align="left">pattern</th>
<th align="left">cue_mode</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">my_endpoint</td>
<td align="left">define_strava_endpoint()</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
</tbody>
</table>
<pre class="r"><code>define_strava_endpoint <- function() {
oauth_endpoint(request = NULL,
authorize = "https://www.strava.com/oauth/authorize",
access = "https://www.strava.com/oauth/token")
}</code></pre>
<p><br>
<font size="4"><strong>3. The final authentication step</strong></font>
</br>
Before you can execute the following steps, you have to authenticate the API in the web browser.</p>
<table>
<thead>
<tr class="header">
<th align="left">name</th>
<th align="left">command</th>
<th align="left">pattern</th>
<th align="left">cue_mode</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">my_sig</td>
<td align="left">define_strava_sig(my_endpoint, my_app)</td>
<td align="left">NA</td>
<td align="left">always</td>
</tr>
</tbody>
</table>
<pre class="r"><code>define_strava_sig <- function(endpoint, app) {
oauth2.0_token(
endpoint,
app,
scope = "activity:read_all,activity:read,profile:read_all",
type = NULL,
use_oob = FALSE,
as_header = FALSE,
use_basic_auth = FALSE,
cache = FALSE
)
}</code></pre>
<p>The information in <code>my_sig</code> can now be used to access Strava data. Set the <code>cue_mode</code> of the target to ‘always’ so that the following API calls are always executed with an up-to-date authorization token.</p>
</div>
<div id="access-activities" class="section level2">
<h2>Access Activities</h2>
<p>You are now authenticated and can directly access your Strava data.
<br>
<br>
<font size="4"><strong>1. Load all activities</strong></font>
<br>
Load a table that gives an overview of all the activities from the data. Because the total number of activities is unknown, use a while loop. It will break the execution of the loop if there are no more activities to read.</p>
<table>
<thead>
<tr class="header">
<th align="left">name</th>
<th align="left">command</th>
<th align="left">pattern</th>
<th align="left">cue_mode</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">df_act_raw</td>
<td align="left">read_all_activities(my_sig)</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
</tbody>
</table>
<pre class="r"><code>read_all_activities <- function(sig) {
activities_url <- parse_url("https://www.strava.com/api/v3/athlete/activities")
act_vec <- vector(mode = "list")
df_act <- tibble::tibble(init = "init")
i <- 1L
while (nrow(df_act) != 0) {
r <- activities_url %>%
modify_url(query = list(
access_token = sig$credentials$access_token[[1]],
page = i
)) %>%
GET()
df_act <- content(r, as = "text") %>%
fromJSON(flatten = TRUE) %>%
as_tibble()
if (nrow(df_act) != 0)
act_vec[[i]] <- df_act
i <- i + 1L
}
df_activities <- act_vec %>%
bind_rows() %>%
mutate(start_date = ymd_hms(start_date))
}</code></pre>
<p>The resulting data frame consists of one row per activity:</p>
<pre class="r"><code>## # A tibble: 605 x 60
## resource_state name distance moving_time elapsed_time total_elevation~ type
## <int> <chr> <dbl> <int> <int> <dbl> <chr>
## 1 2 "Hes~ 31153. 4699 5267 450 Ride
## 2 2 "Bam~ 5888. 2421 2869 102. Run
## 3 2 "Lin~ 33208. 4909 6071 430 Ride
## 4 2 "Mon~ 74154. 10721 12500 641 Ride
## 5 2 "Cha~ 34380 5001 5388 464. Ride
## 6 2 "Mor~ 5518. 2345 2563 49.1 Run
## 7 2 "Bin~ 10022. 3681 6447 131 Run
## 8 2 "Tru~ 47179. 8416 10102 898 Ride
## 9 2 "Sho~ 32580. 5646 6027 329. Ride
## 10 2 "Mit~ 33862. 5293 6958 372 Ride
## # ... with 595 more rows, and 53 more variables: workout_type <int>, id <dbl>,
## # external_id <chr>, upload_id <dbl>, start_date <dttm>,
## # start_date_local <chr>, timezone <chr>, utc_offset <dbl>,
## # start_latlng <list>, end_latlng <list>, location_city <lgl>,
## # location_state <lgl>, location_country <chr>, start_latitude <dbl>,
## # start_longitude <dbl>, achievement_count <int>, kudos_count <int>,
## # comment_count <int>, athlete_count <int>, photo_count <int>, ...</code></pre>
<p><br>
<font size="4"><strong>2. Preprocess activities</strong></font>
<br>
Make sure that all ID columns have a character format and improve the column names.</p>
<table>
<thead>
<tr class="header">
<th align="left">name</th>
<th align="left">command</th>
<th align="left">pattern</th>
<th align="left">cue_mode</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">df_act</td>
<td align="left">pre_process_act(df_act_raw, athlete_id)</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
</tbody>
</table>
<pre class="r"><code>pre_process_act <- function(df_act_raw, athlete_id) {
df_act <- df_act_raw %>%
mutate(across(contains("id"), as.character),
`athlete.id` = athlete_id)
}</code></pre>
<p><br>
<font size="4"><strong>3. Extract activity IDs</strong></font>
<br>
Use <code>dplyr::pull()</code> to extract all activity IDs.</p>
<table>
<thead>
<tr class="header">
<th align="left">name</th>
<th align="left">command</th>
<th align="left">pattern</th>
<th align="left">cue_mode</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">act_ids</td>
<td align="left">pull(distinct(df_act, id))</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
</tbody>
</table>
</div>
<div id="read-measurements" class="section level2">
<h2>Read Measurements</h2>
<p><font size="4"><strong>1. Read the ‘stream’ data from Strava</strong></font>
<br>
A ‘stream’ is a nested list (JSON format) with all available measurements of the corresponding activity.</p>
<p>To get the <br>available variables and turn the result into a data frame, define a helper function <code>read_activity_stream</code>. This function takes an ID of an activity and an authentication token, which you created earlier.</p>
<p>The target is defined with dynamic branching which maps over all activity IDs. Define the <code>cue mode</code> as <code>never</code> to make sure that every target runs exactly once.</p>
<table>
<thead>
<tr class="header">
<th align="left">name</th>
<th align="left">command</th>
<th align="left">pattern</th>
<th align="left">cue_mode</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">df_meas</td>
<td align="left">read_activity_stream(act_ids, my_sig)</td>
<td align="left">map(act_ids)</td>
<td align="left">never</td>
</tr>
</tbody>
</table>
<pre class="r"><code>read_activity_stream <- function(id, sig) {
act_url <-
parse_url(stringr::str_glue("https://www.strava.com/api/v3/activities/{id}/streams"))
access_token <- sig$credentials$access_token[[1]]
r <- modify_url(act_url,
query = list(
access_token = access_token,
keys = str_glue(
"distance,time,latlng,altitude,velocity_smooth,cadence,watts,
temp,moving,grade_smooth"
)
)) %>%
GET()
stop_for_status(r)
fromJSON(content(r, as = "text"), flatten = TRUE) %>%
as_tibble() %>%
mutate(id = id)
}</code></pre>
<p><br>
<font size="4"><strong>2. Bind the single targets into one data frame</strong></font>
<br>
You can do this using <code>dplyr::bind_rows()</code>.</p>
<table>
<thead>
<tr class="header">
<th align="left">name</th>
<th align="left">command</th>
<th align="left">pattern</th>
<th align="left">cue_mode</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">df_meas_all</td>
<td align="left">bind_rows(df_meas)</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
</tbody>
</table>
<p>The data now is represented by one row per measurement series:</p>
<pre class="r"><code>## # A tibble: 4,821 x 6
## type data series_type original_size resolution id
## <chr> <list> <chr> <int> <chr> <chr>
## 1 moving <lgl [4,706]> distance 4706 high 62186~
## 2 latlng <dbl [4,706 x 2]> distance 4706 high 62186~
## 3 velocity_smooth <dbl [4,706]> distance 4706 high 62186~
## 4 grade_smooth <dbl [4,706]> distance 4706 high 62186~
## 5 distance <dbl [4,706]> distance 4706 high 62186~
## 6 altitude <dbl [4,706]> distance 4706 high 62186~
## 7 heartrate <int [4,706]> distance 4706 high 62186~
## 8 time <int [4,706]> distance 4706 high 62186~
## 9 moving <lgl [301]> distance 301 high 62138~
## 10 latlng <dbl [301 x 2]> distance 301 high 62138~
## # ... with 4,811 more rows</code></pre>
<p><br>
<font size="4"><strong>3. Turn the data into a wide format</strong></font></p>
<table>
<thead>
<tr class="header">
<th align="left">name</th>
<th align="left">command</th>
<th align="left">pattern</th>
<th align="left">cue_mode</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">df_meas_wide</td>
<td align="left">meas_wide(df_meas_all)</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
</tbody>
</table>
<pre class="r"><code>meas_wide <- function(df_meas) {
pivot_wider(df_meas, names_from = type, values_from = data)
}</code></pre>
<p>In this format, every activity is one row again:</p>
<pre class="r"><code>## # A tibble: 605 x 14
## series_type original_size resolution id moving latlng velocity_smooth
## <chr> <int> <chr> <chr> <list> <list> <list>
## 1 distance 4706 high 6218628649 <lgl ~ <dbl ~ <dbl [4,706]>
## 2 distance 301 high 6213800583 <lgl ~ <dbl ~ <dbl [301]>
## 3 distance 4905 high 6179655557 <lgl ~ <dbl ~ <dbl [4,905]>
## 4 distance 10640 high 6160486739 <lgl ~ <dbl ~ <dbl [10,640]>
## 5 distance 4969 high 6153936896 <lgl ~ <dbl ~ <dbl [4,969]>
## 6 distance 2073 high 6115020306 <lgl ~ <dbl ~ <dbl [2,073]>
## 7 distance 1158 high 6097842884 <lgl ~ <dbl ~ <dbl [1,158]>
## 8 distance 8387 high 6091990268 <lgl ~ <dbl ~ <dbl [8,387]>
## 9 distance 5587 high 6073551706 <lgl ~ <dbl ~ <dbl [5,587]>
## 10 distance 5281 high 6057232328 <lgl ~ <dbl ~ <dbl [5,281]>
## # ... with 595 more rows, and 7 more variables: grade_smooth <list>,
## # distance <list>, altitude <list>, heartrate <list>, time <list>,
## # cadence <list>, watts <list></code></pre>
<p><br>
<font size="4"><strong>4. Preprocess and unnest the data</strong></font></p>
<p>The column <code>latlng</code> needs special attention, because it contains latitude and longitude information. Separate the two measurements before unnesting all list columns.</p>
<table>
<thead>
<tr class="header">
<th align="left">name</th>
<th align="left">command</th>
<th align="left">pattern</th>
<th align="left">cue_mode</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">df_meas_pro</td>
<td align="left">meas_pro(df_meas_wide)</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
</tbody>
</table>
<pre class="r"><code>meas_pro <- function(df_meas_wide) {
df_meas_wide %>%
mutate(
lat = map_if(
.x = latlng,
.p = ~ !is.null(.x),
.f = ~ .x[, 1]
),
lng = map_if(
.x = latlng,
.p = ~ !is.null(.x),
.f = ~ .x[, 2]
)
) %>%
select(-c(latlng, original_size, resolution, series_type)) %>%
unnest(where(is_list))
}</code></pre>
<p>After this step, every row is one point in time and every column is a measurement at this point in time (if there was any activity at that moment).</p>
<pre class="r"><code>## # A tibble: 2,176,926 x 12
## id moving velocity_smooth grade_smooth distance altitude heartrate time
## <chr> <lgl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 621862~ FALSE 0 1.8 0 527 149 0
## 2 621862~ TRUE 0 1.2 5 527. 150 1
## 3 621862~ TRUE 0 0.9 10.9 527. 150 2
## 4 621862~ TRUE 5.68 0.8 17 527. 150 3
## 5 621862~ TRUE 5.81 0.8 23.3 527. 150 4
## 6 621862~ TRUE 5.88 0.8 29.4 527. 150 5
## 7 621862~ TRUE 6.13 0.8 35.6 527. 151 6
## 8 621862~ TRUE 6.15 0 41.6 527. 150 7
## 9 621862~ TRUE 6.14 0 47.8 527. 150 8
## 10 621862~ TRUE 6.13 0.8 53.9 527. 150 9
## # ... with 2,176,916 more rows, and 4 more variables: cadence <dbl>,
## # watts <dbl>, lat <dbl>, lng <dbl></code></pre>
</div>
<div id="create-visualisation" class="section level2">
<h2>Create Visualisation</h2>
<p>Visualize the final data by displaying the geospatial information in the data. Every facet is one activity. Keep the rest of the plot as minimal as possible.</p>
<table>
<thead>
<tr class="header">
<th align="left">name</th>
<th align="left">command</th>
<th align="left">pattern</th>
<th align="left">cue_mode</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">gg_meas</td>
<td align="left">vis_meas(df_meas_pro)</td>
<td align="left">NA</td>
<td align="left">thorough</td>
</tr>
</tbody>
</table>
<pre class="r"><code>vis_meas <- function(df_meas_pro) {
df_meas_pro %>%
filter(!is.na(lat)) %>%
ggplot(aes(x = lng, y = lat)) +
geom_path() +
facet_wrap( ~ id, scales = "free") +
theme(
axis.line = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
legend.position = "bottom",
panel.background = element_blank(),
panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
plot.background = element_blank(),
strip.text = element_blank()
)
}</code></pre>
<p><img src="gg_meas.png" width="1050" /></p>
<p>And there it is: All your Strava data in a few tidy data frames and a nice-looking plot. Future updates to the data shouldn’t take too long, because only measurements from new activities will be downloaded. With all your Strava data up to date, there are a lot of appealing possibilities for further data analyses of your fitness data.</p>
<p><em>Note from the Editor: Julian’s post neatly breaks down complex tasks, walking readers through the steps as well as rationale of his decisions. His use of the targets package demonstrates how an organized workflow enables replicability and ease. In addition, Julian showcases how the R programming language can fulfill a vision sparked by one’s passions. It is an inspiring example of how we can use R to create something that is informative, beautiful, and personal.</em></p>
</div>
<div class="footnotes">
<hr />
<ol>
<li id="fn1"><p>You can edit your R environment by running <code>usethis::edit_r_environ()</code>, saving the keys, and then restarting R.<a href="#fnref1" class="footnote-back">↩︎</a></p></li>
</ol>
</div>
<script>window.location.href='https://rviews.rstudio.com/2021/11/22/strava-data/';</script>
Deploying xaringan Slides with GitHub Pages
https://rviews.rstudio.com/2021/11/18/deploying-xaringan-slides-a-ten-step-github-pages-workflow/
Thu, 18 Nov 2021 00:00:00 +0000https://rviews.rstudio.com/2021/11/18/deploying-xaringan-slides-a-ten-step-github-pages-workflow/
<script src="/2021/11/18/deploying-xaringan-slides-a-ten-step-github-pages-workflow/index_files/header-attrs/header-attrs.js"></script>
<script src="/2021/11/18/deploying-xaringan-slides-a-ten-step-github-pages-workflow/index_files/clipboard/clipboard.min.js"></script>
<link href="/2021/11/18/deploying-xaringan-slides-a-ten-step-github-pages-workflow/index_files/xaringanExtra-clipboard/xaringanExtra-clipboard.css" rel="stylesheet" />
<script src="/2021/11/18/deploying-xaringan-slides-a-ten-step-github-pages-workflow/index_files/xaringanExtra-clipboard/xaringanExtra-clipboard.js"></script>
<script>window.xaringanExtraClipboard(null, {"button":"<i class=\"fa fa-clipboard\"><\/i> Copy Code","success":"<i class=\"fa fa-check\" style=\"color: #90BE6D\"><\/i> Copied!","error":"Press Ctrl+C to Copy"})</script>
<link href="/2021/11/18/deploying-xaringan-slides-a-ten-step-github-pages-workflow/index_files/font-awesome/css/all.css" rel="stylesheet" />
<link href="/2021/11/18/deploying-xaringan-slides-a-ten-step-github-pages-workflow/index_files/font-awesome/css/v4-shims.css" rel="stylesheet" />
<script src="/2021/11/18/deploying-xaringan-slides-a-ten-step-github-pages-workflow/index_files/fitvids/fitvids.min.js"></script>
<p><em>Silvia Canelón is a researcher, community organizer, and R educator. Her research leverages electronic health record data to study pregnancy-related outcomes, and her organizing values data literacy and communication as ways to build power and effect change.</em></p>
<p>This post will guide you step-by-step through the process of creating an HTML xaringan slide deck and deploying it to the web for easy sharing with others. We will be using the <code>xaringan</code> package to build the slide deck, GitHub to help us host our slides for free with GitHub Pages, and the <code>usethis</code> package to help us out along the way. You will get the most out of this workflow if you are already familiar with R Markdown and GitHub, and if you have already connected RStudio (or your preferred IDE) to Git and GitHub.<a href="#fn1" class="footnote-ref" id="fnref1"><sup>1</sup></a> The post will not cover the nuts and bolts of xaringan or talk about slide design & customization, but you can find lots of <a href="#learn-more">learning resources</a> listed at the end.</p>
<div id="choose-your-own-adventure" class="section level1">
<h1>Choose your own adventure</h1>
<ul>
<li><p><strong>Option 1:</strong> Start at the <a href="#the-ten-step-workflow">beginning of the workflow</a> to make a slide deck using the R Markdown template built into the <code>xaringan</code> package. The built-in template doubles as documentation for the <code>xaringan</code> package, so it is a great way to familiarize yourself with the package features, but it also includes a lot of content that will probably want to remove and modify when creating your presentation.</p></li>
<li><p><strong>Option 2:</strong> Start with an <a href="https://spcanelon.github.io/RLadies-xaringan-template">R-Ladies themed xaringan template</a> (embedded below). This is an example slide deck originally created as a teaching tool to highlight some of the main features of the <code>xaringan</code> package, and to demo some customization that incorporates the R-Ladies CSS theme built into xaringan. Please feel welcome to use/modify it to suit your needs! When you are ready, you can follow the steps immediately below 👇 to download the files to your machine, and then skip down to <a href="#initialize-version-control-with-git">Initialize version control with git</a>.</p></li>
</ul>
<pre class="r"><code>usethis::use_course(
repo_spec = "spcanelon/RLadies-xaringan-template",
destdir = "filepath/for/your/presentation"
)</code></pre>
<p><br></p>
<blockquote>
<p>Note: After copying the files to your machine you’ll probably want to rename the file folder to whatever makes sense for your presentation.</p>
</blockquote>
<p><br></p>
<div class="shareagain" style="min-width:300px;margin:1em auto;">
<iframe src="https://spcanelon.github.io/RLadies-xaringan-template" width="400" height="300" style="border:2px solid currentColor;" loading="lazy" allowfullscreen></iframe>
<script>fitvids('.shareagain', {players: 'iframe'});</script>
</div>
<p><br></p>
<blockquote>
<p>Try navigating through the slides ☝️ with your left/right arrow keys and press the letter “P” on your keyboard to see some notes in Presenter View.</p>
</blockquote>
</div>
<div id="the-ten-step-workflow" class="section level1">
<h1>The Ten-Step Workflow</h1>
<div id="packages" class="section level2">
<h2>Packages</h2>
<p>This workflow was developed using:</p>
<table>
<thead>
<tr class="header">
<th>Software / package</th>
<th>Version</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>R</td>
<td>4.0.3</td>
</tr>
<tr class="even">
<td>RStudio</td>
<td>1.4.1103</td>
</tr>
<tr class="odd">
<td><code>xaringan</code></td>
<td>0.19</td>
</tr>
<tr class="even">
<td><code>usethis</code></td>
<td>2.0.0</td>
</tr>
</tbody>
</table>
<pre class="r"><code>install.packages("xaringan")
install.packages("usethis")</code></pre>
</div>
<div id="creating-your-xaringan-slide-deck" class="section level2">
<h2>Creating your xaringan slide deck</h2>
<p><strong>1. Create a new RStudio project for your presentation:</strong></p>
<pre class="r"><code>usethis::create_project("filepath/for/your/presentation/repo-name")</code></pre>
<p><br></p>
<blockquote>
<p>📍 If you’re not sure where you are on your computer, check your working directory with <code>getwd()</code> and use it as a filepath reference point</p>
</blockquote>
<!--Output:
```r
New project 'rladies-xaringan-template' is nested inside an existing project '/filepath/for/the/presentation/', which is rarely a good idea.
If this is unexpected, the here package has a function, `here::dr_here()` that reveals why '/filepath/for/the/presentation/' is regarded as a project.
Do you want to create anyway?
1: Absolutely not
2: Yup
3: No
Selection: 2
```
-->
<p><br></p>
<p><strong>2. Create a xaringan deck using a xaringan template:</strong><br>
<em>File</em> > <em>New File</em> > <em>R Markdown</em> > <em>From Template</em> > <em>Ninja Presentation</em> > <em>OK</em></p>
<p><strong>3. Delete what you don’t need and save your R Markdown file with whatever name you like.</strong> If you pick <code>index.Rmd</code> the live link you share at the end will be relatively short.</p>
<p><strong>4. Render HTML slides from the open Rmd file using xaringan’s infinite moon reader:</strong></p>
<pre class="r"><code> xaringan::infinite_moon_reader()</code></pre>
</div>
<div id="initialize-version-control-with-git" class="section level2">
<h2>Initialize version control with git</h2>
<p><strong>5. Initialize version control of your slides with git:</strong></p>
<pre class="r"><code>usethis::use_git()</code></pre>
<p><br></p>
<p>You’ll be asked if you want to commit the files in your project (with the message “Initial commit”) and then if you want to restart to activate the Git pane. Say yes to both ✅
<br></p>
<blockquote>
<p>Note: At the moment <code>usethis</code> names the primary branch “master” by default. <a href="https://github.com/r-lib/usethis/issues/1341">Issue #1341</a> suggests the option to instead name it “main” is in the works.</p>
</blockquote>
<!--Output:
> usethis::use_git()
✓ Setting active project to '/filepath/for/the/presentation/rladies-xaringan-template'
✓ Initialising Git repo
✓ Adding '.Rhistory', '.Rdata', '.httr-oauth', '.DS_Store' to '.gitignore'
There are 6 uncommitted files:
* '.gitignore'
* 'index_files/'
* 'index.html'
* 'index.Rmd'
* 'libs/'
* 'rladies-xaringan-template.Rproj'
Is it ok to commit them?
1: Yup
2: Negative
3: No way
Selection: 1
✓ Adding files
✓ Making a commit with message 'Initial commit'
● A restart of RStudio is required to activate the Git pane
Restart now?
1: Yes
2: Nope
3: Not now
Selection:
-->
<p><br></p>
<p><strong>6. Connect your local project with a GitHub repo:</strong></p>
<pre class="r"><code>usethis::use_github()</code></pre>
<p><br></p>
<blockquote>
<p>You could use the function argument <code>private = TRUE</code> to create a private GitHub repository. But you may have to remember to change the visibility before <a href="#deploying-your-slides">deploying to GitHub Pages</a>.</p>
</blockquote>
<!--Output:
> usethis::use_github(private = TRUE)
ℹ Defaulting to https Git protocol
✓ Setting active project to '/filepath/for/the/presentation/rladies-xaringan-template'
✓ Checking that current branch is default branch ('master')
✓ Creating private GitHub repository 'spcanelon/rladies-xaringan-template'
✓ Setting remote 'origin' to 'https://github.com/spcanelon/rladies-xaringan-template.git'
✓ Pushing 'master' branch to GitHub and setting 'origin/master' as upstream branch
✓ Opening URL 'https://github.com/spcanelon/rladies-xaringan-template'
-->
<p><br><br />
<strong>7. Your new GitHub repo with all of your xaringan project files will automatically open up in your browser</strong></p>
<blockquote>
<p>Repo for the R-Ladies xaringan template:<br>
<a href="https://github.com/spcanelon/RLadies-xaringan-template" class="uri">https://github.com/spcanelon/RLadies-xaringan-template</a></p>
</blockquote>
</div>
<div id="making-and-committing-changes-to-your-slides" class="section level2">
<h2>Making and committing changes to your slides</h2>
<p><strong>8. Edit your slides as you wish.</strong> Commit often! And then push to GitHub. Use the tools provided by the Git pane in RStudio, or use the following commands in the Terminal:</p>
<pre class="bash"><code># Step 1: Stage all modified files
git add .</code></pre>
<p><br></p>
<pre class="bash"><code># Step 2: Describe the changes you made to your files
git commit -m "<A brief but descriptive commit message>"</code></pre>
<p><br></p>
<blockquote>
<p>Consider writing a commit message that finishes the following sentence:<a href="#fn2" class="footnote-ref" id="fnref2"><sup>2</sup></a> “If applied, this commit will…” (e.g. “Change the slide theme”, “Add hello slide”)</p>
</blockquote>
<p><br></p>
<pre class="bash"><code># Step 3: Push the changes to your GitHub repository
git push</code></pre>
</div>
<div id="deploying-your-slides" class="section level2">
<h2>Deploying your slides</h2>
<p><strong>9. When you’re ready to deploy your slides, you can use the <code>usethis::use_github_pages()</code> function</strong> which makes the process of deploying via GitHub Pages super easy. I recommend pointing <code>branch</code> to the name of your primary branch.</p>
<pre class="r"><code>usethis::use_github_pages(branch = "master")</code></pre>
<p><br></p>
<blockquote>
<p>Note: Your repository must be <strong>public</strong> for your deployed slides to be available publicly, unless you have a paid GitHub account.</p>
</blockquote>
<p><br></p>
<blockquote>
<p>Also, you only need to follow this step <em>once</em> to deploy your slides to the web. As long as you remember to push to your repo any changes that you make to your slides (Rmd and HTML), GitHub Pages will know how to render them.</p>
</blockquote>
<!--Output:
> usethis::use_github_pages(branch = "master")
✓ Setting active project to '/Users/scanelon/Box/2-Teaching/R-Projects/R-Ladies/RLadies-xaringan-template'
✓ Activating GitHub Pages for 'spcanelon/rladies-xaringan-template'
✓ GitHub Pages is publishing from:
● URL: 'https://spcanelon.github.io/RLadies-xaringan-template/'
● Branch: 'master'
● Path: '/'
-->
<p><strong>10. Visit the link provided to see your newly deployed slides!</strong> 🚀<br>Don’t panic if you don’t see them right away, sometimes it takes a little time. This is the link you will share with the world when you present. Notice it looks <em>very</em> similar to your GitHub repo link.
<br></p>
<blockquote>
<p>Link to the R-Ladies xaringan template rendered slides:<br>
<a href="https://spcanelon.github.io/RLadies-xaringan-template" class="uri">https://spcanelon.github.io/RLadies-xaringan-template</a></p>
</blockquote>
</div>
</div>
<div id="bonus-steps" class="section level1">
<h1>Bonus steps</h1>
<p>11. Go to the <a href="https://github.com/spcanelon/RLadies-xaringan-template">repository home page</a> and find the About section on the right hand side. Add a description of your presentation and the link to your slides, that way your presentation is easily available to anyone visiting your repo.</p>
<p>12. Check out Garrick Aden-Buie’s blog post Sharing Your xaringan Slides to learn how to <a href="https://www.garrickadenbuie.com/blog/sharing-xaringan-slides/#create-a-social-media-card">create a social media card</a> for your slides and use your new link to share your slides in more places (e.g. <a href="https://www.garrickadenbuie.com/blog/sharing-xaringan-slides/#embed-your-slides">embedded on a website</a>, etc.)</p>
<p>13. This GitHub Pages workflow is not exclusive to xaringan slides! Try it out with any other HTML file.</p>
</div>
<div id="learn-more" class="section level1">
<h1>Learn more</h1>
<div id="foundation" class="section level2">
<h2>Foundation</h2>
<ul>
<li><a href="https://spcanelon.github.io/xaringan-basics-and-beyond/index.html">Sharing Your Work with xaringan • Silvia Canelón</a> – workshop site</li>
<li><a href="https://silvia.rbind.io/talk/2020-12-17-introduccion-xaringan/">Introducción al Paquete xaringan • Silvia Canelón</a> – R-Ladies Meetup</li>
<li><a href="https://arm.rbind.io/slides/xaringan.html">Making Slides with R Markdown • Alison Hill</a> – workshop slides</li>
<li><a href="https://slides.yihui.org/xaringan/">Presentation Ninja • xaringan Official Document</a> – package documentation</li>
<li><a href="https://bookdown.org/yihui/rmarkdown/xaringan.html">Chapter 7 xaringan Presentations • R Markdown: The Definitive Guide</a> – book chapter</li>
</ul>
</div>
<div id="sharing-your-slides" class="section level2">
<h2>Sharing your slides</h2>
<ul>
<li><a href="https://www.garrickadenbuie.com/blog/sharing-xaringan-slides/">Sharing Your xaringan Slides • Garrick Aden‑Buie</a> – blog post</li>
<li><a href="https://jhelvy.github.io/xaringanBuilder/">Functions For Building Xaringan Slides To Different Outputs. • xaringanBuilder</a> – package site</li>
<li><a href="https://alison.rbind.io/talk/2020-sharing-short-notice/">Sharing on Short Notice • Alison Hill & Desirée De Leon</a> – video resource for deploying via Netlify</li>
</ul>
</div>
<div id="making-your-slides-extra-special" class="section level2">
<h2>Making your slides extra special</h2>
<ul>
<li><a href="https://presentable-user2021.netlify.app/">Professional, Polished, Presentable • Garrick Aden‑Buie & Silvia Canelón • useR!2021</a> – workshop site</li>
<li><a href="https://github.com/yihui/xaringan/wiki">Home · yihui/xaringan Wiki • GitHub</a> – wiki of customizations for xaringan</li>
<li><a href="https://www.garrickadenbuie.com/talk/extra-great-slides-nyhackr/">Making Extra Great Slides • Garrick Aden‑Buie</a> – talk & slides with xaringan overview and featuring CSS styling and xaringanthemer</li>
<li><a href="https://www.katiejolly.io/blog/2021-03-16/designing-slides">Applying design guidelines to slides with {xaringanthemer} • katie jolly</a> – blog post</li>
<li><a href="https://pkg.garrickadenbuie.com/xaringanExtra/#/?id=xaringanextra">A playground of extensions for xaringan • xaringanExtra</a> – package site</li>
<li><a href="https://pkg.garrickadenbuie.com/xaringanthemer/">Custom xaringan CSS Themes • xaringanthemer</a> – package site</li>
</ul>
<p><em>Note from the Editor: Silvia’s post is a mini masterpiece of clear, concise writing that elucidates complex technology within the narrow context of explaining a single well-defined task. Silvia does not attempt to say everything she knows about the subject, and she resists digressions that might obscure the path she is laying out. It is an example of achieving clarity through saying less.</em></p>
</div>
</div>
<div class="footnotes">
<hr />
<ol>
<li id="fn1"><p><a href="https://happygitwithr.com/rstudio-git-github.html">Chapter 12 Connect RStudio to Git and GitHub | Happy Git and GitHub for the useR</a><a href="#fnref1" class="footnote-back">↩︎</a></p></li>
<li id="fn2"><p><a href="https://chris.beams.io/posts/git-commit/#imperative">How to Write a Git Commit Message | Chris Beams</a><a href="#fnref2" class="footnote-back">↩︎</a></p></li>
</ol>
</div>
<script>window.location.href='https://rviews.rstudio.com/2021/11/18/deploying-xaringan-slides-a-ten-step-github-pages-workflow/';</script>
An R Community Public Library
https://rviews.rstudio.com/2021/11/04/bookdown-org/
Thu, 04 Nov 2021 00:00:00 +0000https://rviews.rstudio.com/2021/11/04/bookdown-org/
<p>If you haven’t recently visited <a href="https://bookdown.org/">bookdown.org</a>, RStudio’s free site for publishing books written with the <a href="https://github.com/rstudio/bookdown">bookdown</a> R package, you many be amazed at what is available. Currently, there are over one hundred fifty titles listed under the <a href="https://bookdown.org/home/archive/">Books</a> tab. These are written in a panoply of languages including Bulgarian, Chinese, English, French, German, Hindi, Italian, Japanese, Korean, Lithuanian (maybe), Norwegian, Portuguese, Russian, Slovenian (I think) and Vietnamese. The breadth of topics is extraordinary! Most books are concerned with R programming or statistical analyses, but you can find the odd volume of <a href="https://bookdown.org/gorodnichy/andre/">Russian poetry</a> or treatise on <a href="https://blairfix.github.io/capital_as_power/why-write-a-book-about-capital.html#capitalism-without-capital">Capital</a>. Even with the aid of the bubble chart of tags there are hours of browsing here.</p>
<iframe id="tags"
title="Bookdown Topics"
width="100%"
height="300"
src="https://bookdown.org/home/tags/">
</iframe>
<p>The sophistication of the content ranges from student notes to texts that have been published in hardcover. The latter include:</p>
<ul>
<li><a href="https://adv-r.hadley.nz/">Advanced R</a></li>
<li><a href="https://advanced-r-solutions.rbind.io/">Advanced R Solutions</a></li>
<li><a href="https://bookdown.org/roback/bookdown-BeyondMLR/">Beyond Multiple Linear Regression</a></li>
<li><a href="https://bookdown.org/yihui/blogdown/">blogdown: Creating Websites with R Markdown</a></li>
<li><a href="https://bookdown.org/yihui/bookdown/">bookdown: Authoring Books and Technical Documents with R Markdown</a><br /></li>
<li><a href="https://blairfix.github.io/capital_as_power/">CAPITAL AS POWER: A Study of Order and Creorder</a></li>
<li><a href="https://bookdown.org/aclark/chess/">Chess Encounters</a></li>
<li><a href="https://jokergoo.github.io/ComplexHeatmap-reference/book/">ComplexHeatmap Complete Reference</a></li>
<li><a href="https://compgenomr.github.io/book/">Computational Genomics with R</a></li>
<li><a href="https://www.datascienceatthecommandline.com/1e/">Data Science at the Command Line, 1e </a><br /></li>
<li><a href="https://datascienceineducation.com/">Data Science in Education Using R</a><br /></li>
<li><a href="https://livebook.datascienceheroes.com/">Data Science Live Book</a><br /></li>
<li><a href="https://rkabacoff.github.io/datavis/">Data Visualization with R</a><br /></li>
<li><a href="https://csgillespie.github.io/efficientR/">https://csgillespie.github.io/efficientR/</a></li>
<li><a href="https://engineering-shiny.org/">Engineering Production-Grade Shiny Apps</a></li>
<li><a href="https://bookdown.org/rdpeng/exdata/">Exploratory Data Analysis with R</a></li>
<li><a href="https://ema.drwhy.ai/">Explanatory Model Analysis</a></li>
<li><a href="https://otexts.com/fpp2/">Forecasting: Principles and Practice (2nd ed)</a></li>
<li><a href="https://clauswilke.com/dataviz/">Fundamentals of Data Visualization</a></li>
<li><a href="https://geocompr.robinlovelace.net/">Geocomputation with R</a><br /></li>
<li><a href="https://rstudio-education.github.io/hopr/">Hands-On Programming with R</a></li>
<li><a href="https://plotly-r.com/">Interactive web-based data visualization with R, plotly, and shiny</a></li>
<li><a href="https://rafalab.github.io/dsbook/">Introduction to Data Science</a><br /></li>
<li><a href="https://rc2e.com/">R Cookbook, 2nd Edition</a></li>
<li><a href="https://r4ds.had.co.nz/">R for Data Science</a></li>
<li><a href="https://argoshare.is.ed.ac.uk/healthyr_book/">R for Health Data Science</a></li>
<li><a href="https://r-graphics.org/">R Graphics Cookbook, 2nd edition</a></li>
<li><a href="https://gedevan-aleksizde.github.io/rmarkdown-cookbook/">R Markdown</a><br /></li>
<li><a href="https://bookdown.org/yihui/rmarkdown-cookbook/">R Markdown Cookbook</a></li>
<li><a href="https://bookdown.org/yihui/rmarkdown/">R Markdown: The Definitive Guide</a><br /></li>
<li><a href="https://r-pkgs.org/">R Packages</a></li>
<li><a href="https://bookdown.org/rdpeng/rprogdatascience/">R Programming for Data Science</a></li>
<li><a href="https://moderndive.com/">Statistical Inference via Data Science</a></li>
<li><a href="https://bookdown.org/pbaumgartner/wiss-arbeiten/">Studieren und Forschen mit dem Internet</a><br /></li>
<li><a href="https://smltar.com/">Supervised Machine Learning for Text Analysis in R</a></li>
<li><a href="https://bookdown.org/rbg/surrogates/">Surrogates</a><br /></li>
<li><a href="https://info201.github.io/">Technical Foundations of Informatics</a></li>
<li><a href="https://www.tidytextmining.com/">Text Mining with R</a></li>
</ul>
<p>Happy Reading!! And, please let us know if you would like review one of these books.</p>
<script>window.location.href='https://rviews.rstudio.com/2021/11/04/bookdown-org/';</script>
September 2021: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2021/10/28/september-2021-top-40-new-cran-packages/
Thu, 28 Oct 2021 00:00:00 +0000https://rviews.rstudio.com/2021/10/28/september-2021-top-40-new-cran-packages/
<p>Two hundred twenty new packages stuck to CRAN in September. Here are my “Top 40” picks in fourteen categories: Art, Computational Methods, Data, Econometrics, Finance and Insurance, Genomics, Machine Learning, Medicine, Networks and Graphs, Science, Statistics, Time Series, Utilities, and Visualization.</p>
<h3 id="art">Art</h3>
<p><a href="https://cran.r-project.org/package=rfishdraw">rfishdraw</a> v0.1.0: Automatically generates fish drawings using the <a href="https://github.com/LingDong-/fishdraw">fishdraw</a> JavaScript library. See the <a href="https://cran.r-project.org/web/packages/rfishdraw/vignettes/rfishdraw-vegnette.html">vignette</a>.</p>
<p><img src="rfishdraw.png" height = "300" width="500" alt="Line drawing of a fish"></p>
<h3 id="computational-mehods">Computational Mehods</h3>
<p><a href="https://cran.r-project.org/package=abmR">abmR</a> v1.0.4: Supplies tools for running agent-based models (ABM) as discussed in <a href="https://www.biorxiv.org/content/10.1101/2021.09.15.460374v1">Gochanour et al. (2021)</a> including two movement functions based on the <a href="https://journals.aps.org/pr/abstract/10.1103/PhysRev.36.823">Ornstein-Uhlenbeck model (1930)</a>. See the <a href="https://www.bengochanour.com/abmr">vignette</a> to get started.</p>
<p><img src="abmR.png" height = "400" width="400" alt="Simulated movement on a map of Europe"></p>
<p><a href="https://cran.r-project.org/package=SemiEstimate">SemiEstimate</a> v1.1.3: Implements an improved method of two-step Newton-Raphson iteration based on <a href="https://arxiv.org/abs/2108.07928">implicit profiling</a>. See the <a href="https://cran.r-project.org/web/packages/SemiEstimate/vignettes/Code.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=SimEngine">SimEngine</a> v1.0.0: Implements functions for structuring, maintaining, running, and debugging statistical simulations on both local and cluster-based computing environments. Emphasis is placed on <a href="https://avi-kenny.github.io/SimEngine/">documentation</a> and scalability. There is an <a href="https://cran.r-project.org/web/packages/SimEngine/vignettes/SimEngine.html">Introduction</a>, an example <a href="https://cran.r-project.org/web/packages/SimEngine/vignettes/example_1.html">Power Calculation</a>, and a vignette <a href="https://cran.r-project.org/web/packages/SimEngine/vignettes/example_2.html">Comparing SE Estimators</a>.</p>
<p><img src="SimEngine.png" height = "300" width="500" alt="Line plot comparing estimators"></p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=asylum">asylum</a> v1.0.1: Provides <a href="https://www.gov.uk/government/statistics/immigration-statistics-year-ending-june-2021">data on asylum and resettlement</a> from the UK Home Office. See <a href="https://cran.r-project.org/web/packages/asylum/readme/README.html">README</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=hockeyR">hockeyR</a> v0.1.1: Provides functions to scrape hockey play-by-play data from <a href="https://www.nhl.com/">NHL.com</a> and <a href="https://www.hockey-reference.com/">Hockey-Reference.com</a> including standings, player stats, and jersey number history. There is a <a href="https://cran.r-project.org/web/packages/hockeyR/vignettes/hockeyR.html">Getting Started Guide</a> and a vignette on <a href="https://cran.r-project.org/web/packages/hockeyR/vignettes/hockey-ref-scrapers.html">Scraping</a>.</p>
<p><a href="https://cran.r-project.org/package=yowie">yowie</a> v0.1.0: Provides longitudinal wages data sets and several demographic variables from the <a href="https://www.nlsinfo.org/content/cohorts/nlsy79/get-data">National Longitudinal Survey of Youth</a> from 1979 to 2018 including: the wages data from the cohort whose highest grade completed is up to high school; the wages data of the high school dropouts and; the demographic data of the cohort in the survey year 1979. See the <a href="https://cran.r-project.org/web/packages/yowie/vignettes/intro.html">vignette</a> for details.</p>
<p><img src="yowie.png" height = "300" width="300" alt="Plots of wages data by year"></p>
<h3 id="econometrics">Econometrics</h3>
<p><a href="https://cran.r-project.org/package=COINr">COINr</a> v0.5.5: Implements a development environment for composite indicators and scoreboards including utilities for construction (indicator selection, denomination, imputation, data treatment, normalization, weighting and aggregation) and analysis (multivariate analysis, correlation plotting. Look <a href="https://bluefoxr.github.io/COINrDoc/">here</a> for an online book, and see the <a href="https://cran.r-project.org/web/packages/COINr/vignettes/Overview.html">vignette</a> for an extended overview.</p>
<p><img src="COINr.png" height = "400" width="400" alt="Plot of framework for an index"></p>
<p><a href="https://cran.r-project.org/package=spflow">spflow</a> v0.1.0: Provides functions to estimate spatial econometric models of origin-destination flows which may exhibit spatial autocorrelation in both the dependent variable and the explanatory variables. See <a href="https://onlinelibrary.wiley.com/doi/10.1111/j.1467-9787.2008.00573.x?__cf_chl_jschl_tk__=pmd_uU3GYgF2MB9QotpSVXhFXciPWWzPKYTf8SW7EHjxWmI-1635285331-0-gqNtZGzNAlCjcnBszQ8R">LeSage and Pace (2008)</a> for information on the model, <a href="https://www.tse-fr.eu/fr/publications/revisiting-estimation-methods-spatial-econometric-interaction-models">Dargel (2021)</a> for information on the estimation procedures, and the <a href="https://cran.r-project.org/web/packages/spflow/vignettes/paris_commute_flows.html">vignette</a> for examples.</p>
<p><img src="spflow.png" height = "300" width="300" alt="Spatial maps of population and other variables"></p>
<h3 id="finance-and-insurance">Finance and Insurance</h3>
<p><a href="https://cran.r-project.org/package=DOSPortfolio">DOSPortfolio</a> v0.1.0: Implements dynamic optimal shrinkage estimators for the weights of the global minimum variance portfolio reconstructed at given reallocation points as derived in <a href="https://arxiv.org/abs/2106.02131">Bodnar et al. (2021)</a>. See the <a href="https://cran.r-project.org/web/packages/DOSPortfolio/vignettes/introduction.html">Introduction</a>.</p>
<p><a href="https://cran.r-project.org/package=SPLICE">SPLICE</a> v1.0.0: Extends the individual claim simulator <a href="https://cran.r-project.org/package=SynthETIC">SynthETIC</a> to simulate the evolution of case estimates of incurred losses through the lifetime of an insurance claim. See <a href="https://arxiv.org/abs/2109.04058">Taylor & Wang (2021)</a> for background and the <a href="https://cran.r-project.org/web/packages/SPLICE/vignettes/SPLICE-demo.html">vignette</a> to get started.</p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=MAnorm2">MAnorm2</a> v1.2.0: Implements a method for normalizing ChIP-seq signals across individual samples or groups of samples and a system of statistical models for calling differential ChIP-seq signals between two or more biological conditions. Refer to <a href="https://genome.cshlp.org/content/31/1/131">Tu et al. (2021)</a> and <a href="https://www.biorxiv.org/content/10.1101/2021.07.27.453915v1">Chen et al. (2021)</a> for the statistical details. The <a href="https://cran.r-project.org/web/packages/MAnorm2/vignettes/MAnorm2_vignette.html">vignette</a> provides several examples.</p>
<p><img src="MAnorm2.png" height = "300" width="500" alt="Before and after normalization MA plots"></p>
<p><a href="https://cran.r-project.org/package=RevGadgets">RevGadgets</a> v1.0.0: Provides functions to process and visualize the output of complex phylogenetic analyses from the <a href="https://revbayes.github.io/">RevBayes</a> phylogenetic graphical modeling software. Look <a href="https://revbayes.github.io/tutorials/intro/revgadgets">here</a> for a tutorial.</p>
<p><img src="RevGadgets.png" height = "300" width="500" alt="Circular plot of ancestral-state estimates"></p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=morphemepiece">morphemepiece</a> v1.0.1: Provides functions to tokenize text into morphemes ether by table lookup or a modified wordpiece tokenization algorithm. There is a vignette on testing the <a href="https://cran.r-project.org/web/packages/morphemepiece/vignettes/algorithm_test.html">fall-through algorithm</a> and another on <a href="https://cran.r-project.org/web/packages/morphemepiece/vignettes/generating_vocab.html">Generating a Vocabulary</a>.</p>
<p><a href="https://cran.r-project.org/package=NIMAA">NIMAA</a> v0.1.0: Implements a pipeline for nominal data mining, which can effectively find special relationships between data. See <a href="https://www.biorxiv.org/content/10.1101/2021.03.18.436040v3">Jafari et al. (2021)</a> for a description of the method and the <a href="https://cran.r-project.org/web/packages/NIMAA/vignettes/NIMAA-vignette.html">vignette</a> for an introduction.</p>
<p><img src="NIMAA.png" height = "300" width="500" alt="Bipartite plot"></p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=gapclosing">gapclosing</a> v1.0.2: Provides functions to estimate the disparities across categories (e.g. Black and white) that persists if a treatment variable (e.g. college) is equalized. See <a href="https://osf.io/preprints/socarxiv/gx4y3/">Lundberg (2021)</a> for the methodology and the <a href="https://cran.r-project.org/web/packages/gapclosing/vignettes/gapclosing.html">vignette</a> for an overview with examples.</p>
<p><img src="gapclosing.png" height = "300" width="500" alt="Disparity plot of mean outcome by category"></p>
<p><a href="https://cran.r-project.org/package=iDOVE">iDOVE</a> v1.3: Implements a nonparametric maximum likelihood method for assessing potentially time-varying vaccine efficacy against SARS-CoV-2 infection under staggered enrollment and time-varying community transmission, allowing crossover of placebo volunteers to the vaccine arm. See <a href="https://academic.oup.com/cid/advance-article/doi/10.1093/cid/ciab630/6321290">Lin et al. (2021)</a> for background and the <a href="https://cran.r-project.org/web/packages/iDOVE/vignettes/iDOVE_vignette.pdf">vignette</a> for the details.</p>
<p><a href="https://cran.r-project.org/package=powerly">powerly</a> v1.5.2: Implements the sample size computation method for network models proposed by <a href="https://psyarxiv.com/j5v7u/">Constantin et al. (2021)</a> which takes the form of a three-step recursive algorithm to find an optimal sample size given a model specification and a performance measure of interest. See <a href="https://cran.r-project.org/web/packages/powerly/readme/README.html">README</a> for an example.</p>
<p><img src="powerly.png" height = "400" width="600" alt="Poster showing methodology"></p>
<p><a href="https://cran.r-project.org/package=ppseq">ppseq</a> v0.1.1: Provides functions to design clinical trials using sequential predictive probability monitoring. See the <a href="https://cran.r-project.org/web/packages/ppseq/vignettes/one_sample_expansion.html">vignette</a> for details.</p>
<h3 id="networks-and-graphs">Networks and Graphs</h3>
<p><a href="https://cran.r-project.org/package=multigraphr">multigrapher</a> v0.1.0: Implements methods and models for analyzing multigraphs as introduced by <a href="https://www.exeley.com/journal_of_social_structure/doi/10.21307/joss-2019-011">Shafie (2015)</a> including methods to study local and global properties and goodness of fit tests. See <a href="https://www.tandfonline.com/doi/abs/10.1080/0022250X.2016.1219732?journalCode=gmas20">Shafle (2016)</a>. The <a href="https://cran.r-project.org/web/packages/multigraphr/vignettes/multigraphr.html">vignette</a> provides an introduction.</p>
<p><img src="multigrapher.png" height = "400" width="600" alt="Examples of multigraphs"></p>
<p><a href="https://cran.r-project.org/package=nevada">nevada</a> v0.1.0: Implements a statistical framework for network-valued data analysis which leverages the complexity of the space of distributions on graphs. See <a href="https://www.sciencedirect.com/science/article/abs/pii/S0167947319302518?via%3Dihub">Lovato et al. (2020)</a> and <a href="https://rss.onlinelibrary.wiley.com/doi/10.1111/rssc.12463">Lovato et al. (2021)</a> for the statistical background, and the <a href="https://cran.r-project.org/web/packages/nevada/vignettes/nevada.html">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=robber">robber</a> v0.2.2: Implementation of a variety of methods to compute the robustness of ecological interaction networks with binary interactions as described in <a href="https://arxiv.org/abs/1910.10512">Chabert-Liddell et al. (2021)</a>. There is a vignette on <a href="https://cran.r-project.org/web/packages/robber/vignettes/topological-analysis.html">Topological Analysis</a>.</p>
<p><img src="robber.png" height = "400" width="400" alt="Plots comparing the influence of structure on robustness"></p>
<h3 id="science">Science</h3>
<p><a href="https://cran.r-project.org/package=argoFloats">argoFloats</a> v1.0.3: Supports the analysis of oceanographic data recorded by Argo autonomous drifting profiling floats. See <a href="https://www.frontiersin.org/articles/10.3389/fmars.2021.635922/full">Kelley et al. (2021)</a> for more on the scientific context and applications. There is an <a href="https://cran.r-project.org/web/packages/argoFloats/vignettes/argoFloats.html">Introduction</a> and a vignette on <a href="https://cran.r-project.org/web/packages/argoFloats/vignettes/qc.html">Quality Control and Adjusted Data</a>.</p>
<p><img src="argoFloats.png" height = "400" width="400" alt="Spatial plot of Arfo floats off the Bahamas"></p>
<p><a href="https://cran.r-project.org/package=biosurvey">biosurvey</a> v0.1.1: Provides tools that allow users to plan systems of sampling sites with the goals of increasing the efficiency of biodiversity monitoring. See <a href="https://onlinelibrary.wiley.com/doi/10.1111/j.1466-8238.2011.00662.x">Arita et al. (2011)</a> and <a href="https://journals.ku.edu/jbi/article/view/4801">Soberón & Cavner (2015)</a> for background. There are vignettes on <a href="https://cran.r-project.org/web/packages/biosurvey/vignettes/biosurvey_preparing_data.html">Preparing Data</a>, <a href="https://cran.r-project.org/web/packages/biosurvey/vignettes/biosurvey_selecting_sites.html">Selecting Sample Sites</a>, <a href="https://cran.r-project.org/web/packages/biosurvey/vignettes/biosurvey_selection_with_preselected_sites.html">Using Preselected Points</a>, and <a href="https://cran.r-project.org/web/packages/biosurvey/vignettes/biosurvey_testing_module.html">Testing Efficacy of Selected Sites</a>.</p>
<p><img src="biosurvey.png" height = "300" width="500" alt="Plots contrasting environmental space vs. geographic space"></p>
<p><a href="https://cran.r-project.org/package=HostSwitch">HostSwitch</a> v0.1.0: Provides functions to aims to investigate the dynamics of the host switch in the population of an organism that interacts with current and potential hosts over generations. The underlying model is based on <a href="https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0139225">Araujo et al. (2015)</a>. See the <a href="https://cran.r-project.org/web/packages/HostSwitch/vignettes/HostSwitch.html">vignette</a> for an example.</p>
<p><img src="HostSwitch.png" height = "300" width="500" alt="Plot of distributions of phenotypes by number of generations"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=cvam">cvam</a> v0.9.2: Extends R’s implementation of categorical variables (factors) to handle coarsened observations and implements log-linear models for coarsened categorical data, including latent-class models. There is a vignette describing <a href="https://cran.r-project.org/web/packages/cvam/vignettes/UnderstandingCoarsenedFactorsInCvam.pdf">Coarsened Factors</a> and another on <a href="https://cran.r-project.org/web/packages/cvam/vignettes/FittingLogLinearModelsInCvam.pdf">Fitting Log-linear Models</a>.</p>
<p><a href="https://cran.r-project.org/package=JustifyAlpha">JustifyAlpha</a> v0.1.1: Provides functions to justify alpha levels for statistical hypothesis tests by avoiding Lindley’s paradox, or by minimizing or balancing error rates. See <a href="https://psyarxiv.com/ts4r6/">Maier & Lakens (2021)</a> for the theory and the <a href="https://cran.r-project.org/web/packages/JustifyAlpha/vignettes/Introduction_to_JustifyAlpha.html">vignette</a> for an introduction.</p>
<p><img src="JustifyAlpha.png" height = "300" width="500" alt="Plots of error rate vs. alpha level"></p>
<p><a href="https://cran.r-project.org/package=sphunif">sphunif</a> v1.0.1: Implements functions to test for uniformity on circles and hyperspheres. See <a href="https://arxiv.org/abs/2008.09897">García-Portugués et al. (2020)</a> for background and the <a href="https://arxiv.org/abs/2008.09897">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=spatialRF">spatialRF</a> v1.1.3: Implements methods to automatically generate and select spatial predictors for spatial regression with Random Forest. See <a href="https://www.sciencedirect.com/science/article/abs/pii/S0304380006000925?via%3Dihub">Dray et al. (2006)</a> and RFsp <a href="https://peerj.com/articles/5518/">Hengl et al. (2017)</a>. Look <a href="https://blasbenito.github.io/spatialRF/">here</a> for documentation and examples.</p>
<p><img src="spatialRF.png" height = "400" width="400" alt="Grid of prediction graphs"></p>
<p><a href="https://cran.r-project.org/package=vdra">vdra</a> v1.0.0: Implements three protocols for performing secure linear, logistic, and Cox regression on vertically partitioned data across several data partners in such a way that data is not shared among data partners. See <a href="https://ieeexplore.ieee.org/document/4476748">Slavkovic et. al. (2007)</a> for background. There is an <a href="https://cran.r-project.org/web/packages/vdra/vignettes/An-Introduction-to-the-VDRA-Package.html">Introduction</a> and vignettes on <a href="https://cran.r-project.org/web/packages/vdra/vignettes/How-to-Use-the-VDRA-Package-with-PopMedNet.html">Using PopMedNet</a>, <a href="https://cran.r-project.org/web/packages/vdra/vignettes/VDRA-Communications-and-Files.html">Communications and Files</a>, and <a href="https://cran.r-project.org/web/packages/vdra/vignettes/VDRA-Workflow.html">Workflow</a>.</p>
<p><img src="vdra.png" height = "300" width="500" alt="Diagram of information flow among data partners"></p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=GlarmaVarSel">GlarmaVarSel</a> v1.0: Implements functions for variable selection in high-dimensional sparse GLARMA models. See <a href="https://arxiv.org/abs/2007.08623v1">Gomtsyan et al. (2020)</a> for the theory and the <a href="https://cran.r-project.org/web/packages/GlarmaVarSel/vignettes/GlarmaVarSel.html">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=mrf">mrf</a> v0.5.1: Implements a method to forecast univariate times series using a feature extraction algorithm based on the Haar wavelet transform. See the <a href="https://cran.r-project.org/web/packages/mrf/vignettes/mrf.html">vignette</a>.</p>
<p><img src="mrf.png" height = "300" width="500" alt="Plot of electricity demand"></p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=colorblindcheck">colorblindcheck</a> v1.0.0: Provides functions to compare color palettes with simulations of color vision deficiencies - deuteranopia, protanopia, and tritanopia. It includes a calculation of distances between colors and creates summaries of differences between color palettes and simulations of color vision deficiencies. See the <a href="http://www.vis4.net/blog/2018/02/automate-colorblind-checking/">post</a> by G. Aisch for background and the <a href="https://cran.r-project.org/web/packages/colorblindcheck/vignettes/intro-to-colorblindcheck.html">vignette</a> for details.</p>
<p><img src="colorblindcheck.png" height = "400" width="400" alt="Chart showing how colors ar perceived by people with various forms of colorblindness"></p>
<p><a href="https://cran.r-project.org/package=filearray">filearray</a> v0.1.1: Implements file-backed arrays for out-of-memory computation using gigabyte-level multi-threaded read/write via <code>OpenMP</code>. The <a href="https://cran.r-project.org/web/packages/filearray/vignettes/performance.html">vignette</a> compares performance with native R.</p>
<p><a href="https://cran.r-project.org/package=httr2">httr2</a> v0.1.1: Implements tools for creating and modifying HTTP requests, executing them, and then processing the results. <code>httr2</code> is a modern re-imagining of <code>httr</code> that uses a pipe-based interface and solves more of the problems that API wrapping packages face. See the vignettes <a href="https://cran.r-project.org/web/packages/httr2/vignettes/httr2.html">httr2</a> and <a href="https://cran.r-project.org/web/packages/httr2/vignettes/wrapping-apis.html">Wrapping APIs</a>.</p>
<p><a href="https://cran.r-project.org/package=quadtree">quadtree</a> v0.1.2: Provides region quadtrees for working with spatial data, which allow for variable-sized cells. There are vignettes on <a href="https://cran.r-project.org/web/packages/quadtree/vignettes/quadtree-code.html">code</a>, <a href="https://cran.r-project.org/web/packages/quadtree/vignettes/quadtree-creation.html">creation</a>, <a href="https://cran.r-project.org/web/packages/quadtree/vignettes/quadtree-lcp.html">lcp</a>, and <a href="https://cran.r-project.org/web/packages/quadtree/vignettes/quadtree-usage.html">usage</a>.</p>
<p><img src="quadtree.png" height = "300" width="500" alt="Illustration of Quadtree Structure"></p>
<p><a href="https://cran.r-project.org/package=tabxplor">tabxplor</a> v1.0.2: Implements tools to create, manipulate, and color highlight cross-tables, and export them to <code>Excel</code> or <code>HTML</code> with formats and colors. See the <a href="https://cran.r-project.org/web/packages/tabxplor/vignettes/tabxplor.html">vignette</a>.</p>
<p><img src="tabxplor.png" height = "300" width="500" alt="Table with color highlighting"></p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=bittermelon">bittermelon</a> v0.1.3: Provides functions for creating and modifying bitmaps with special emphasis on bitmap fonts and their glyphs including native read/write support for the <code>hex</code> and <code>yaff</code> bitmap font formats. Look <a href="https://trevorldavis.com/R/bittermelon/">here</a> for documentation.</p>
<p><img src="bittermelon.png" height = "300" width="300" alt="Bitmap rendering of a Go Board"></p>
<p><a href="https://CRAN.R-project.org/package=d3po">d3po</a> v0.3.2: Implements an Apache licensed alternative to <code>Highcharter</code> which provides functions for interactive visualization for <code>Markdown</code> and <code>Shiny</code>. See the <a href="https://cran.r-project.org/web/packages/d3po/vignettes/d3po.html">vignette</a> for examples.</p>
<p><img src="d3po.png" height = "400" width="400" alt="Example of bubblechart"></p>
<p><a href="https://cran.r-project.org/package=ggHoriPlot">ggHoriPlot</a> v1.0.0: implements <code>geom_horizon()</code> and other functions for building horizon plots with <code>ggplot2</code>. There is an <a href="https://cran.r-project.org/web/packages/ggHoriPlot/vignettes/ggHoriPlot.html">Introduction</a> and a <a href="https://cran.r-project.org/web/packages/ggHoriPlot/vignettes/examples.html">vignette</a> with examples.</p>
<p><img src="ggHoriPlot.png" height = "300" width="500" alt="Horizon plot showing content along human genome"></p>
<p><a href="https://cran.r-project.org/package=plotbb">plotbb</a> v0.0.6: Provides a proof of concept for implementing a grammar for base R plots.See the <a href="https://cran.r-project.org/web/packages/plotbb/vignettes/plotbb.html">vignette</a>.</p>
<p><img src="plotbb.png" height = "200" width="350" alt="Enhanced base R scatter plot"></p>
<p><a href="https://cran.r-project.org/package=semptools">semptools</a> v0.2.9.3: Implements functions for customizing structural equation plots that can be chained using a pipe operator. There is a <a href="https://cran.r-project.org/web/packages/semptools/vignettes/semptools.html">Quick Start Guide</a>, and vignettes on <a href="https://cran.r-project.org/web/packages/semptools/vignettes/keep_or_drop_nodes.html">Nodes</a>, <a href="https://cran.r-project.org/web/packages/semptools/vignettes/layout_matrix.html">Matrix Layout</a>, <a href="https://cran.r-project.org/web/packages/semptools/vignettes/quick_start_cfa.html">CFA</a>, and <a href="https://cran.r-project.org/web/packages/semptools/vignettes/quick_start_sem.html">SEM</a>.</p>
<p><img src="semptools.png" height = "400" width="400" alt="Plot depicting inter-factor covariances"></p>
<script>window.location.href='https://rviews.rstudio.com/2021/10/28/september-2021-top-40-new-cran-packages/';</script>
A beginner's guide to Shiny modules
https://rviews.rstudio.com/2021/10/20/a-beginner-s-guide-to-shiny-modules/
Wed, 20 Oct 2021 00:00:00 +0000https://rviews.rstudio.com/2021/10/20/a-beginner-s-guide-to-shiny-modules/
<script src="/2021/10/20/a-beginner-s-guide-to-shiny-modules/index_files/header-attrs/header-attrs.js"></script>
<p><em>This post by Emily Riederer is the winning entry in our recent <a href="https://rviews.rstudio.com/2021/08/04/r-views-blog-contest/">Call for Documentation</a> contest. Emily is a Senior Analytics Manager at Capital One where she leads a team building internal analytical tools including R packages, datamarts, and Shiny apps. Outside of work, Emily can be found sharing more code and ideas about analytics on her <a href="https://emilyriederer.netlify.com/">website</a>, Twitter (<span class="citation">@emilyriederer</span>) and GitHub (<span class="citation">@emilyriederer</span>).</em></p>
<p>Shiny modules are often taught as an advanced topic, but they can also be a great way for novice Shiny developers to start building more complex applications. If you already are an R user who likes to <strong>think and write functions</strong> and <strong>understand Shiny basics</strong> (i.e. reactivity), then modules <strong>for certain types of tasks</strong> (discussed at the end of this post) are an excellent way to up your game.</p>
<p>Shiny’s tendency toward monolithic scripts and <em>lack</em> of function-based thinking in introductory materials felt so unlike normal R programming. So, not only is it <em>possible</em> to learn modules early, it may actually be decidedly easier than the alternative depending on your frame of mind.</p>
<p>In this post, I walk through a toy example of building a reporting app from the <code>flights</code> data in the <a href="https://cran.r-project.org/package=nycflights13">nycflights13</a> package to demonstrate how modules help scale basic Shiny skills.</p>
<div id="why-modules" class="section level2">
<h2>Why Modules?</h2>
<p>Modules act like functions by wrapping up sets of Shiny UI and server elements. You may wonder why you cannot just accomplish this with the normal R functions. The reason for this is a bit technical and is explained well in <em>Mastering Shiny</em>. However, the technical knowledge needed to understand “why functions don’t work” should not make modules an advanced topic. If you see the value of writing functions, you are more than ready to take advantage of modules in app development.</p>
</div>
<div id="motivating-example" class="section level2">
<h2>Motivating Example</h2>
<p>For the sake of argument, let’s pretend that we are building an airline dashboard to track travel delays against established thresholds. We have the following requirements:</p>
<ul>
<li>Let users pick a month of interest to visualize</li>
<li>For each metric of interest, users should be able to:
<ul>
<li>See a time-series plot of the average daily value of the metric</li>
<li>Download a PNG of the plot</li>
<li>Read a text summary of how often the value breached the threshold</li>
</ul></li>
<li>The metrics of interest are:
<ul>
<li>Average departure delay</li>
<li>Average arrival delay</li>
<li>Proportion of daily flights with an arrival delay exceeding 5 minutes</li>
</ul></li>
</ul>
<p>Below is a preview of the final application. The full app is currently hosted in <a href="https://emilyriederer.shinyapps.io/shiny-modules-demo/">ShinyApps.io</a> and the code available <a href="https://github.com/emilyriederer/demo-shiny-modules">on GitHub</a>. It would not win any beauty contests, but its simple style allows us to focus on modules in the code.</p>
<div class="figure">
<img src="https://github.com/emilyriederer/docs-submission/blob/master/shiny-modules/app-photo.PNG?raw=true" alt="" />
<p class="caption">Two line graphs for departure and arrival times where we see variation compared to the average</p>
</div>
</div>
<div id="set-up" class="section level2">
<h2>Set-Up</h2>
<pre class="r"><code>library(shiny)
library(nycflights13)
library(dplyr)</code></pre>
<pre><code>##
## Attaching package: 'dplyr'</code></pre>
<pre><code>## The following objects are masked from 'package:stats':
##
## filter, lag</code></pre>
<pre><code>## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union</code></pre>
<pre class="r"><code>library(ggplot2)</code></pre>
<p>To understand the following explanation, it helps to familiarize yourself with the data. We filter the <code>flights</code> data down to a single airline and aggregate the results by day.</p>
<pre class="r"><code>ua_data <-
nycflights13::flights %>%
filter(carrier == "UA") %>%
mutate(ind_arr_delay = (arr_delay > 5)) %>%
group_by(year, month, day) %>%
summarize(
n = n(),
across(ends_with("delay"), mean, na.rm = TRUE)
) %>%
ungroup()</code></pre>
<pre><code>## `summarise()` has grouped output by 'year', 'month'. You can override using the `.groups` argument.</code></pre>
<pre class="r"><code>head(ua_data)</code></pre>
<pre><code>## # A tibble: 6 x 7
## year month day n dep_delay arr_delay ind_arr_delay
## <int> <int> <int> <int> <dbl> <dbl> <dbl>
## 1 2013 1 1 165 7.65 6.27 0.476
## 2 2013 1 2 170 12.8 7.04 0.458
## 3 2013 1 3 159 8.66 -2.76 0.357
## 4 2013 1 4 161 6.84 -9.86 0.180
## 5 2013 1 5 117 9.66 0.786 0.274
## 6 2013 1 6 137 9.79 3.53 0.409</code></pre>
<p>Next, we define the plotting function that we will use to visualize a month-long timeseries of data for each metric.</p>
<pre class="r"><code>viz_monthly <- function(df, y_var, threshhold = NULL) {
ggplot(df) +
aes(
x = .data[["day"]],
y = .data[[y_var]]
) +
geom_line() +
geom_hline(yintercept = threshhold, color = "red", linetype = 2) +
scale_x_continuous(breaks = seq(1, 29, by = 7)) +
theme_minimal()
}</code></pre>
<p>For example, to visualize the average arrival delay by day for all of March and compare it to a threshold of 10 minutes, we can write:</p>
<pre class="r"><code>ua_data %>%
filter(month == 3) %>%
viz_monthly("arr_delay", threshhold = 10)</code></pre>
<p><img src="/2021/10/20/a-beginner-s-guide-to-shiny-modules/index_files/figure-html/unnamed-chunk-4-1.png" width="672" /></p>
</div>
<div id="one-module-at-a-time" class="section level2">
<h2>One Module at a Time</h2>
<p>Modules don’t just help organize your code; they help you organize your <em>thinking</em>. Given our app requirements, it might feel overwhelming where to start. Filtering the data? Making the plots? Wiring up buttons? Inevitably, when juggling many components, you’re likely to introduce a bug by copy-pasting a line with the wrong <code>id</code> or getting nested parentheses out of whack.</p>
<p>Instead, modules essentially allow your to write <em>many simple Shiny apps</em> and compose them together.</p>
<p>For example, we might decide that first we just want to focus on a very simple app: given a monthly subset of the data, a metric, and a threshold of interest. Let’s write a simple text summary of the flights performance. We now know we just need to define a UI (<code>text_ui</code>) with a single call to <code>textOutput()</code>, a server (<code>text_server</code>) that does a single calculation and calls <code>renderText()</code>. Best of all, we can immediately see whether or not our “app” works by writing a minimalist testing function (<code>text_demo</code>) which renders the text for a small, fake dataset.</p>
<p>Those steps are implemented in a file called <code>mod-text.R</code>:</p>
<p>You can find all of the code for this tutorial in this <a href="https://github.com/emilyriederer/demo-shiny-modules">demo Shiny application</a> repository.
We can follow the same pattern to create a module for the plot itself (in the file <a href="https://github.com/emilyriederer/demo-shiny-modules/blob/master/mod-plot.R"><code>mod-plot.R</code></a>) consisting of a UI (<code>plot_ui</code>), a server (<code>plot_server</code>), and a testing function (<code>plot_demo</code>). This module is responsible for plotting one metric and allowing users to download the results.</p>
</div>
<div id="composing-modules" class="section level2">
<h2>Composing Modules</h2>
<p>We now have a text module and a plot module. However, for each metric of interest, we want to produce <em>both</em>. We could call these two modules one-at-a-time, but we can also compose multiple modules together so that we can produce in single commands everything that we need for a given metric.</p>
<p>With all of the underlying plot and text module logic abstracted, our metric module definition (in the <code>mod-metr.R</code> file) is very clean and simple:</p>
<pre class="r"><code># metric module ----
metric_ui <- function(id) {
fluidRow(
text_ui(NS(id, "metric")),
plot_ui(NS(id, "metric"))
)
}
metric_server <- function(id, df, vbl, threshhold) {
moduleServer(id, function(input, output, session) {
text_server("metric", df, vbl, threshhold)
plot_server("metric", df, vbl, threshhold)
})
}
metric_demo <- function() {
df <- data.frame(day = 1:30, arr_delay = 1:30)
ui <- fluidPage(metric_ui("x"))
server <- function(input, output, session) {
metric_server("x", reactive({df}), "arr_delay", 15)
}
shinyApp(ui, server)
}</code></pre>
<p>Again, we can test that these components went together as we intended by running the <code>metric_demo()</code> function. We see the text from our text module on top of the plot and button from our plot module:</p>
<div class="figure">
<img src="https://github.com/emilyriederer/docs-submission/blob/master/shiny-modules/mod-demo.PNG?raw=true" alt="" />
<p class="caption">Line graph for flight arrival times where we see how many days exceeded the average</p>
</div>
<p>This may be overkill for a simple app, but composing modules is very useful as your application grows in complexity. Everything you bundle into a module gives you a license to forget about how the next layer lower is implemented and frees up your mind to take on the next challenge.</p>
</div>
<div id="putting-it-all-together" class="section level2">
<h2>Putting it all together</h2>
<p>Finally, we are ready to write our complete application in a file called <code>flights-app.R</code>:</p>
<pre class="r"><code>viz_monthly <- function(df, y_var, threshhold = NULL) {
ggplot(df) +
aes(
x = .data[["day"]],
y = .data[[y_var]]
) +
geom_line() +
geom_hline(yintercept = threshhold, color = "red", linetype = 2) +
scale_x_continuous(breaks = seq(1, 29, by = 7)) +
theme_minimal()
}
# text module ----
text_ui <- function(id) {
fluidRow(
textOutput(NS(id, "text"))
)
}
text_server <- function(id, df, vbl, threshhold) {
moduleServer(id, function(input, output, session) {
n <- reactive({sum(df()[[vbl]] > threshhold)})
output$text <- renderText({
paste("In this month",
vbl,
"exceeded the average daily threshhold of",
threshhold,
"a total of",
n(),
"days")
})
})
}
text_demo <- function() {
df <- data.frame(day = 1:30, arr_delay = 1:30)
ui <- fluidPage(text_ui("x"))
server <- function(input, output, session) {
text_server("x", reactive({df}), "arr_delay", 15)
}
shinyApp(ui, server)
}
# plot module ----
plot_ui <- function(id) {
fluidRow(
column(11, plotOutput(NS(id, "plot"))),
column( 1, downloadButton(NS(id, "dnld"), label = ""))
)
}
plot_server <- function(id, df, vbl, threshhold = NULL) {
moduleServer(id, function(input, output, session) {
plot <- reactive({viz_monthly(df(), vbl, threshhold)})
output$plot <- renderPlot({plot()})
output$dnld <- downloadHandler(
filename = function() {paste0(vbl, '.png')},
content = function(file) {ggsave(file, plot())}
)
})
}
plot_demo <- function() {
df <- data.frame(day = 1:30, arr_delay = 1:30)
ui <- fluidPage(plot_ui("x"))
server <- function(input, output, session) {
plot_server("x", reactive({df}), "arr_delay")
}
shinyApp(ui, server)
}
# metric module ----
metric_ui <- function(id) {
fluidRow(
text_ui(NS(id, "metric")),
plot_ui(NS(id, "metric"))
)
}
metric_server <- function(id, df, vbl, threshhold) {
moduleServer(id, function(input, output, session) {
text_server("metric", df, vbl, threshhold)
plot_server("metric", df, vbl, threshhold)
})
}
metric_demo <- function() {
df <- data.frame(day = 1:30, arr_delay = 1:30)
ui <- fluidPage(metric_ui("x"))
server <- function(input, output, session) {
metric_server("x", reactive({df}), "arr_delay", 15)
}
shinyApp(ui, server)
}</code></pre>
<pre class="r"><code># load libraries ----
library(nycflights13)
library(shiny)
library(ggplot2)
library(dplyr)
# data prep ----
ua_data <-
nycflights13::flights %>%
filter(carrier == "UA") %>%
mutate(ind_arr_delay = (arr_delay > 5)) %>%
group_by(year, month, day) %>%
summarize(
n = n(),
across(ends_with("delay"), mean, na.rm = TRUE)
) %>%
ungroup()
# full application ----
ui <- fluidPage(
titlePanel("Flight Delay Report"),
sidebarLayout(
sidebarPanel = sidebarPanel(
selectInput("month", "Month",
choices = setNames(1:12, month.abb),
selected = 1
)
),
mainPanel = mainPanel(
h2(textOutput("title")),
h3("Average Departure Delay"),
metric_ui("dep_delay"),
h3("Average Arrival Delay"),
metric_ui("arr_delay"),
h3("Proportion Flights with >5 Min Arrival Delay"),
metric_ui("ind_arr_delay")
)
)
)
server <- function(input, output, session) {
output$title <- renderText({paste(month.abb[as.integer(input$month)], "Report")})
df_month <- reactive({filter(ua_data, month == input$month)})
metric_server("dep_delay", df_month, vbl = "dep_delay", threshhold = 10)
metric_server("arr_delay", df_month, vbl = "arr_delay", threshhold = 10)
metric_server("ind_arr_delay", df_month, vbl = "ind_arr_delay", threshhold = 0.5)
}
shinyApp(ui, server)</code></pre>
<p>You can find all of the code for this tutorial in this <a href="https://github.com/emilyriederer/demo-shiny-modules">demo Shiny application</a> repository.</p>
<p>Notice how few lines of code this file requires to create all of our components and interactions! We’ve eliminated much of the dense code, nesting, and potential duplication we might have encountered if trying to write our application without modules. The top-level code is accessible, semantic, and declarative. It is easy to understand the intent of each line and which pieces of UI and server logic are responsible for which components.</p>
<p>Not all modules are made alike, and in this walk-through I chose simple tasks to demonstrate. Note that our modules <em>consume</em> a reactive variable (data) from the environment, but they do not attempt to <em>alter</em> the global environment or <em>exchange</em> information between them. Modules that simply consume reactives are the easiest way to start out.</p>
<p><em>Note from the Editor: Emily’s winning entry displays several characteristics of good technical writing. She is laser focused on her audience: R users who have some Shiny experience but who are not familiar with modules. Emily’s prose is direct, simple, informal and engaging. Reading it, I feel as if Emily is beside me showing me how things work, and that she cares about me understanding it. Emily’s code is spacious, and laid out to be read by others. And maybe not so obvious on the first reading, Emily’s writing is disciplined. It is clear that she knows a lot more about things than she has has put into the post, but is working under self imposed constraints in pursuit of clarity.</em></p>
</div>
<script>window.location.href='https://rviews.rstudio.com/2021/10/20/a-beginner-s-guide-to-shiny-modules/';</script>
FDA and the Dynamics of Curves
https://rviews.rstudio.com/2021/10/14/fda-and-the-dynamics-of-curves/
Thu, 14 Oct 2021 00:00:00 +0000https://rviews.rstudio.com/2021/10/14/fda-and-the-dynamics-of-curves/
<script src="/2021/10/14/fda-and-the-dynamics-of-curves/index_files/header-attrs/header-attrs.js"></script>
<p>An elegant application of Functional Data Analysis is to model longitudinal data as a curve and then study the curve’s dynamics. For example, in pharmacokinetics and other medical studies analyzing multiple measurements of drug or protein concentrations in blood samples, it may be interest to determine if the concentrations in subjects undergoing one type of treatment rise quicker than those undergoing an alternative treatment. In this post, I will generate some plausible fake data for measurements taken over time for two groups of subjects, use the techniques of Functional Data Analysis to represent these data as a continuous curve for each subject, and look at some of the dynamic properties of the curves, in particular their velocities and accelerations.</p>
<div id="synthetic-data" class="section level3">
<h3>Synthetic Data</h3>
<p>The <a href="https://cran.r-project.org/package=fdaoutlier">fdaoutlier</a> package contains functions to generate a number of stochastic models with a mechanism to generate reasonable outliers for each type of model. THe curves produced by model 4 look like they can serve plausible synthetic concentration curves. Instead of thinking of normal curves and outliers, I imagine the two related sets of curves to be the results of two different treatments influencing some measured concentration curve. In the example below, the curves associated with <strong>treatment 2</strong> are of the form: <span class="math display">\[X_i(t) = \mu t(1 - t)^m + e_i(t),\]</span>
while those associated with <strong>treatment 1</strong> are of the form:
<span class="math display">\[X_i(t) = \mu(1 - t)t^m + e_i(t)\]</span> where:</p>
<ul>
<li><span class="math inline">\(t\in [0,1]\)</span>,</li>
<li><span class="math inline">\(e_i(t)\)</span> is a Gaussian process with zero mean and covariance function of the form: <span class="math display">\[\gamma(s,t) = \alpha\exp\{-\beta|t-s|^\nu\},\]</span></li>
<li><span class="math inline">\(m\)</span> is a constant</li>
<li><span class="math inline">\(\mu\)</span> is the mean value</li>
<li><span class="math inline">\(\alpha\)</span>, <span class="math inline">\(\beta\)</span>, and <span class="math inline">\(\nu\)</span> are coefficients in the covariance function</li>
</ul>
<pre class="r"><code>library(fdaoutlier)
library(tidyverse)
library(fda)
library(gganimate)
library(gridExtra)</code></pre>
<p>The following code generates two different sets of longitudinal data from Model 4 which is described in the <a href="https://cran.r-project.org/web/packages/fdaoutlier/vignettes/simulation_models.html">vignette</a> to the <a href="https://cran.r-project.org/package=fdaoutlier">fdaoutlier</a> package.</p>
<pre class="r"><code>set.seed(95139)
n_curves <- 100
n_obs <- 50
mod4 <- simulation_model4(n = n_curves, p = n_obs, outlier_rate = .5, seed = 50, plot = FALSE)
index <- 1:n_curves
index1 <- mod4$true_outliers
# curves_mat is an n_curves x n_obs matrix
curves_mat <- mod4$data
treat <- rep(2,n_obs)
curves <- data.frame(index, treat, curves_mat)
curves <- curves %>% mutate(treat = if_else((index %in% index1),1,2))</code></pre>
<p>There are 50 curves for each treatment and 50 points for each curve. This is probably the simplest case possible, and it is good enough to show how to explore the dynamics of curves. However, if you work with real longitudinal data you know that things are rarely this simple. But please be assured that FDA can deal with considerably more complexity, including a variable number of measurements for each subject, different measurement times for each subject, and situations where you have far fewer than 50 points for each subject. I have explored some of these situations in previous posts. For example, look <a href="https://rviews.rstudio.com/2021/05/14/basic-fda-descriptive-statistics-with-r/">here</a> to see how to work with different time points, and <a href="https://rviews.rstudio.com/2021/07/08/exploratory-fda-with-sparse-data/">here</a> for some ideas for working with sparse data. The first link above also points to basic references that should help you to get started with your data.</p>
<p>Now, I reformat the data into a long form data frame and plot both sets of curves.</p>
<pre class="r"><code>time <- 1:n_obs
curves_l <- pivot_longer(curves, cols = !c("index", "treat"), names_to = "Xval") %>%
mutate(time = rep(time,100), .before = "treat", treat = as.factor(treat)) %>%
dplyr::select(-Xval)
p <- curves_l %>% ggplot(aes(time,value, color = treat)) +
geom_line(aes(group = index)) +
scale_color_manual(values=c("navy blue", "dark grey")) +
ggtitle("Model 4 Curves")
p</code></pre>
<p><img src="/2021/10/14/fda-and-the-dynamics-of-curves/index_files/figure-html/unnamed-chunk-3-1.png" width="672" /></p>
<p>So far we just have plots based on a relatively small number of data points. Nevertheless, our eyes extrapolate, and we imagine seeing two sets of continuous curves with one set clearly rising to its maximum value faster than the other set. But we really don’t have continuous curves yet, we just have points.</p>
<p>The next step is to invoke the mathematics of FDA to embed the points in an infinite dimensional vector space where the data for each subject is modeled by a continuous function (curve). Exactly how this happens is a bit involved, but the general idea is that we create a basis and then use the data and some techniques from the linear algebra of Hilbert spaces to estimate the time dependent coefficients that enable modeling each subject’s data points as a linear combination of the basis functions. So, from here on out we are not going to be working with the raw data anymore. We will be working with vector space models of the data. The upside is that we can now now have real curves (continuous function), and can calculate the values of the functions and other properties such as the first and second derivatives at any time point. If you are interested in the math, please have a look at the references listed at the bottom of my post on <a href="https://rviews.rstudio.com/2021/06/10/functional-pca-with-r/">Functional PCA</a>.</p>
</div>
<div id="modeling-the-data-as-functions-with-a-b-spline-basis" class="section level3">
<h3>Modeling the data as functions with a B-Spline Basis</h3>
<p>Here we use the function <code>fda::create.bspline.basis()</code> to create a B-Spline basis covering the interval of our observations. The plot of the curves above indicates that specifying a knot at every multiple of 5 ought to be adequate for representing our data. Note that using cubic splines <code>n_order</code> = 4 ensures that the splines will have continuous first and second derivatives at the knots.</p>
<pre class="r"><code>knots = c(seq(0,n_obs,5)) #Location of knots
n_knots = length(knots) #Number of knots
n_order = 4 # order of basis functions: for cubic b-splines: order = 3 + 1
n_basis = length(knots) + n_order - 2;
spline_basis = create.bspline.basis(rangeval = c(0,n_obs), nbasis = n_basis, norder = n_order)
#plot(spline_basis)</code></pre>
<p>The following code uses the function <code>fda::Data2fda()</code> and the <code>spline-basis</code> to convert the Model 4 data points into functions and produce one fda object for each of the two groups of treatments.</p>
<pre class="r"><code># df1 is an (n_curves/2) x (n_obs) matrix
df1 <- curves_mat[index1,] # data for treatment 1
index2 <- index[!(index %in% index1)]
df2 <- curves_mat[index2,] # data for treatment 2
# Use the b-spline basis to create represent the curves as vectors in the function space
df1_obj <- Data2fd(argvals = 1:n_obs, y = t(df1), basisobj = spline_basis, lambda = 0.5)
df2_obj <- Data2fd(argvals = 1:n_obs, y = t(df2), basisobj = spline_basis, lambda = 0.5)</code></pre>
</div>
<div id="computing-derivatives" class="section level3">
<h3>Computing Derivatives</h3>
<p>Here we evaluate each function along with its first and second derivatives at a finer time scale than we used to originally display our data.</p>
<pre class="r"><code>tfine <- seq(0,50,by=.5)
# Each matrix is 101 x 50 rows are different times, columns are curves
pos1 <- as.vector(eval.fd(tfine, df1_obj)); pos2 <- as.vector(eval.fd(tfine, df2_obj))
vel1 <- as.vector(eval.fd(tfine, df1_obj,1)); vel2 <- as.vector(eval.fd(tfine, df2_obj,1))
acc1 <- as.vector(eval.fd(tfine, df1_obj,2)); acc2 <- as.vector(eval.fd(tfine, df2_obj,2)) </code></pre>
<p>Note that the velocities and accelerations computed above were returned as matrices. We convert them to vectors and put them into a data frame for plotting.</p>
<pre class="r"><code>time <- rep(tfine,50)
id1 <- rep(1:50,each=101)
id2 <- rep(51:100,each=101)
derv1 <- data.frame(time, id1, pos1, vel1, acc1)
derv2 <- data.frame(time, id2, pos2, vel2, acc2)
pv1 <- derv1 %>% ggplot(aes(time,vel1,col=id1)) + geom_line(aes(group = id1)) + ggtitle("Velocity Treatment 1")
pv2 <- derv2 %>% ggplot(aes(time,vel2,col=id2)) + geom_line(aes(group = id2)) + ggtitle("Velocity Treatment 2")
pa1 <- derv1 %>% ggplot(aes(time,acc1,col=id1)) + geom_line(aes(group = id1)) +ggtitle("Acceleration Treatment 1")
pa2 <- derv2 %>% ggplot(aes(time,acc2,col=id2)) + geom_line(aes(group = id2)) + ggtitle("Acceleration Treatment 2")
grid.arrange(pv1, pa1, pv2, pa2, nrow = 2,ncol = 2, padding = unit(1, "line"))</code></pre>
<p><img src="/2021/10/14/fda-and-the-dynamics-of-curves/index_files/figure-html/unnamed-chunk-7-1.png" width="672" /></p>
<p>The velocities for treatment 1 head upwards before they decrease while the velocities for treatment 2 go straight down, and the curve up again. The accelerations for treatment 1 slope downward slightly while those of treatment two slope upward. So the plots indicate that the two sets of curves look like they behave differently.</p>
</div>
<div id="testing-for-differences" class="section level3">
<h3>Testing for Differences</h3>
<p>We can test for differences using the function <code>fda::tperm.fd()</code> which implements a resampling method to do pointwise t-tests. The functional data representing the curves for the two samples are combined in a single array and the labels for the curves are randomly shuffled. Recalculating the maximum value of the t-statistic for each point enables computing a null distribution. Then, at each time point, the observed data are compared with the 1 - <span class="math inline">\(\alpha\)</span> quantile of the null distribution.</p>
<p>The plot below shows the result of performing the t-test to compare the first derivatives of the two treatments. I use the function <code>fda.deriv.fd()</code> to calculate the first derivative for each treatment on the fly, just to show another way of doing things in the <code>fda</code> package. You can easily modify the code to compare accelerations.</p>
<pre class="r"><code>dfdt1 <- deriv.fd(df1_obj,1)
dfdt2 <- deriv.fd(df2_obj,1)
tres <- tperm.fd(dfdt1,dfdt2,plotres=FALSE)
max_q <- tres$qval
tres_dat <-tibble(time = tres$argvals, t_values = tres$Tvals,
q_vals = tres$qvals.pts)
p <- tres_dat %>% ggplot(aes(time,t_values, colour = "t_value")) + geom_line() +
geom_line(aes(time, q_vals, colour = "q_vals")) +
geom_line(aes(time, max_q,colour = "max_q"), linetype= "dashed") +
labs(x = "time", y = "") +
ggtitle("Statistics for Pointwise t-test")
p</code></pre>
<p><img src="/2021/10/14/fda-and-the-dynamics-of-curves/index_files/figure-html/unnamed-chunk-8-1.png" width="672" /></p>
<p>The blue curve shows the t-statistic for the observed values. The green curve represents the 95% quantiles, and the dashed red line is the 95% quantile of the maximum of null distribution t-statistics. The t-test confirms that the derivatives are indeed different except in the regions of overlap around time = 10 and time = 40.</p>
</div>
<div id="examine-phase-plots" class="section level3">
<h3>Examine Phase Plots</h3>
<p>Phase plots are useful for evaluating how the curves develop in the abstract <em>phase space</em> created by looking at position versus velocity, or velocity versus acceleration. Here we pick three curves from each treatment and plot velocity versus acceleration.</p>
<pre class="r"><code>phase1 <- derv1 %>% filter(id1 %in% 15:17)
phase2 <- derv2 %>% filter(id2 %in% 51:53)
pph1 <- phase1 %>% ggplot(aes(vel1,acc1,col=id1)) + geom_point() + ggtitle("Treat 1 v vs. acc")
pph2 <- phase2 %>% ggplot(aes(vel2,acc2,col=id2)) + geom_point() + ggtitle("Treat 2 v vs. acc")
grid.arrange(pph1, pph2, ncol = 2, padding = unit(1, "line"))</code></pre>
<p><img src="/2021/10/14/fda-and-the-dynamics-of-curves/index_files/figure-html/unnamed-chunk-9-1.png" width="672" />
Based on this small sample, it certainly appears that the curves associated with the two different treatments inhabit different regions of phase space.</p>
<p>Finally, it is easy and helpful to animate a phase diagram to show how a function develops in phase space over time. The animation below shows the first curve for treatment 1.</p>
<pre class="r"><code>pos <- eval.fd(tfine, df2_obj[1])
vel <- eval.fd(tfine, df2_obj[1],1)
acc <- eval.fd(tfine, df2_obj[1],2)
phase_dat <- tibble(tfine, vel, acc)
p <- ggplot(phase_dat, aes(vel,acc)) + geom_point() + ggtitle("Trajectory in Phase Space")
anim <- p + transition_time(tfine) + shadow_mark()
anim_save("anim.gif", anim)
#anim</code></pre>
<p><img src="anim.gif" /></p>
</div>
<script>window.location.href='https://rviews.rstudio.com/2021/10/14/fda-and-the-dynamics-of-curves/';</script>
August 2021: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2021/09/27/august-2021-top-40-new-cran-packages/
Mon, 27 Sep 2021 00:00:00 +0000https://rviews.rstudio.com/2021/09/27/august-2021-top-40-new-cran-packages/
<p>One hundred sixty new packages covering a wide array of topics made it to CRAN in August. I thought I would emphasize the breadth of topics by expanding the number of categories organizing my “Top 40” selections beyond core categories that appear month after month. Here are my picks in fourteen categories: Archaeology, Computational Methods, Data, Education, Finance, Forestry, Genomics, Machine Learning, Medicine, Science, Statistics, Time Series, Utilities, and Visualization. Based on informal impressions formed over the last several months, I believe a new category combining applications in forestry, animal populations, climate change could become a regular core category.</p>
<h3 id="archaeology">Archaeology</h3>
<p><a href="https://cran.r-project.org/package=DIGSS">DIGSS</a> v1.0.2: Provides a simulation tool to estimate the rate of success that surveys including user-specific characteristics have in identifying archaeological sites given specific parameters of survey area, survey methods, and site properties. See <a href="https://www.cambridge.org/core/journals/american-antiquity/article/abs/effectiveness-of-subsurface-testing-a-simulation-approach/B667DE186230F25072CA7B2F002783A7">Kintigh (1988)</a> for background and the <a href="https://cran.r-project.org/web/packages/DIGSS/vignettes/DIGSS.html">vignette</a> for examples.</p>
<p><img src="DIGSS.png" height = "400" width="400" alt="Example of a field map with artifacts plotted"></p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=simlandr">simlandr</a> v0.1.1: Provides a set of tools for constructing potential landscapes for dynamical systems using Monte-Carlo simulation which is especially suitable for formal psychological models. There are vignettes on <a href="https://cran.r-project.org/web/packages/simlandr/vignettes/simulation.html">Dynamic Models and Simulations</a>, <a href="https://cran.r-project.org/web/packages/simlandr/vignettes/landscape.html">Constructing Potential Landscapes</a>, and <a href="https://cran.r-project.org/web/packages/simlandr/vignettes/barrier.html">Calculating the Lowest Elivation Path</a>.</p>
<p><img src="simlandr.png" height = "400" width="400" alt="Barrier Simulation Plot"></p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=metaboData">metaboData</a> v0.6.2: Provides access to remotely stored <a href="https://github.com/aberHRML/metaboData/releases">data sets</a> from a variety of biological sample matrices analyzed using mass spectrometry metabolomic analytical techniques. See the <a href="https://cran.r-project.org/web/packages/metaboData/vignettes/metaboData.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=metadat">metadat</a> v1.0-0: Contains a collection of data sets useful for teaching meta analysis. See <a href="https://cran.r-project.org/web/packages/metadat/readme/README.html">README</a> for more information.</p>
<p><a href="https://cran.r-project.org/package=nflreadr">nflreadr</a> v1.1.0: Provides functions for downloading data from the GitHub repository for the <a href="https://github.com/nflverse">nflverse project</a>. There is a brief <a href="https://cran.r-project.org/web/packages/nflreadr/vignettes/exporting_nflreadr.html">Introduction</a> and several short vignettes that serve as the data dictionary for the various files <a href="https://cran.r-project.org/web/packages/nflreadr/vignettes/dictionary_draft_picks.html">Draft Picks</a>, <a href="https://cran.r-project.org/web/packages/nflreadr/vignettes/dictionary_ff_rankings.html">Rankings</a>, etc.</p>
<p><a href="https://cran.r-project.org/package=OCSdata">OCSdata</a> v1.0.2: Provides functions to access and download data from the <a href="https://www.opencasestudies.org/">Open Case Studies</a> repositories on <a href="https://github.com/opencasestudies">GitHub</a>. See the <a href="https://cran.r-project.org/web/packages/OCSdata/vignettes/instructions.html">vignette</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=rATTAINS">rATTAINS</a> v0.1.2: Implements an interface to United States Environmental Protection Agency (EPA) <a href="https://www.epa.gov/waterdata/attains">ATTAINS</a> database used to track information provided by states about water quality assessments conducted under federal Clean Water Act requirements. There is a <a href="https://cran.r-project.org/web/packages/rATTAINS/vignettes/Introduction.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=taylor">taylor</a> v0.2.1: Provides access to a curated data set of Taylor Swift songs, including lyrics and audio characteristics. Data comes <a href="https://genius.com/artists/Taylor-swift">Genius</a> and the <a href="https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02">Spotify</a> API. See <a href="https://cran.r-project.org/web/packages/taylor/readme/README.html">README</a> for examples,</p>
<p><img src="taylor.gif" height = "300" width="300" alt="Apple Music gif of Taylor Swify"></p>
<h3 id="education">Education</h3>
<p><a href="https://CRAN.R-project.org/package=karel">karel</a> v0.1.0: Provides an R implementation of Karel the robot, a programming language for teaching introductory concepts about general programming in an interactive and fun way, by writing programs to make Karel achieve tasks in the world she lives in. There are several vignettes including one on <a href="https://cran.r-project.org/web/packages/karel/vignettes/control_es_4.html">Control Structures</a> and another on <a href="https://cran.r-project.org/web/packages/karel/vignettes/descomp_es_3.html">Algorithmic Decomposition</a>.</p>
<p><img src="karel.gif" height = "300" width="500" alt="Gif of karel the robot moving along"></p>
<p><a href="https://cran.r-project.org/package=roger">roger</a> v0.99-0: Implements tools for grading the coding style and documentation of R scripts. This is the R component of <a href="https://gitlab.com/roger-project">Roger the Omni Grader</a>, an automated grading system for computer programming projects based on Unix shell scripts. Look <a href="https://roger-project.gitlab.io/">here</a> for more information.</p>
<h3 id="finance">Finance</h3>
<p><a href="https://cran.r-project.org/package=dispositionEffect">dispositionEffect</a> v1.0.0: Implements four different methodologies to evaluate the presence of the <a href="https://en.wikipedia.org/wiki/Disposition_effect">disposition effect</a> and other irrational investor behaviors based on investor transactions and financial market data. There is a <a href="https://cran.r-project.org/web/packages/dispositionEffect/vignettes/getting-started.html">Getting Started Guide</a>, and vignettes on <a href="https://cran.r-project.org/web/packages/dispositionEffect/vignettes/de-analysis.html">Analysis</a>, <a href="https://cran.r-project.org/web/packages/dispositionEffect/vignettes/de-parallel.html">Disposition Effects in Parallel</a>, and <a href="https://cran.r-project.org/web/packages/dispositionEffect/vignettes/de-timeseries.html">Time Series Disposition Effects</a>.</p>
<p><img src="dispositionEffect.png" height = "300" width="500" alt="Plot showing volatility and Disposition Effect"></p>
<p><a href="https://cran.r-project.org/package=HDShOP">HDShOP</a> v0.1.1: Provides functions to construct shrinkage estimators of high-dimensional mean-variance portfolios and performs high-dimensional tests on optimality of a given portfolio. See <a href="https://www.sciencedirect.com/science/article/abs/pii/S0377221717308494?via%3Dihub">Bodnar et al. (2018)</a>, <a href="https://ieeexplore.ieee.org/document/8767989">Bodnar et al. (2019)</a>, and <a href="https://ieeexplore.ieee.org/document/9258421">Bodnar et al. (2020)</a> for background.</p>
<p><a href="https://cran.r-project.org/package=tcsinvest">tcsinvest</a> v0.1.1: Implements an interface to the <a href="https://tinkoffcreditsystems.github.io/invest-openapi/">Tinkoff Investments API</a> which enables analysts and traders can interact with account and market data from within R. Clients for both REST and Streaming protocols have been implemented. There is a <a href="https://cran.r-project.org/web/packages/tcsinvest/vignettes/base.html">vignette</a>.</p>
<h3 id="forestry">Forestry</h3>
<p><a href="https://cran.r-project.org/package=APAtree">APAtree</a> v1.0.1: Provides functions to map the area potentially available (APA) using the approach from <a href="https://academic.oup.com/forestry/article/85/5/567/650068">Gspaltl et al. (2012)</a> and also aggregation functions to calculate stand characteristics based on APA-maps and the neighborhood diversity index as described in <a href="https://www.sciencedirect.com/science/article/pii/S1470160X2100738X?via%3Dihub">Glatthorn (2021)</a>. See the <a href="https://cran.r-project.org/web/packages/APAtree/vignettes/APAtree-vignette.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=efdm">efdm</a> v0.1.0: Implements the European Forestry Dynamics Model (<a href="https://ec.europa.eu/jrc/en/european-forestry-dynamics-model">EFDM</a>), a large-scale forest model that simulates the development of a forest and estimates volume of wood harvested for any given forested area. See <a href="https://op.europa.eu/en/publication-detail/-/publication/4715d130-0803-4e99-abed-915fec152c7b/language-en">Packalen et al. (2015)</a> for background and the <a href="https://cran.r-project.org/web/packages/efdm/vignettes/example.html">vignette</a> for examples.</p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=molnet">molnet</a> v0.1.0: Implements a network analysis pipeline that enables integrative analysis of multi-omics data including metabolomics. It allows for comparative conclusions between two different conditions, such as tumor subgroups, healthy vs. disease, or generally control vs. perturbed. The case study presented in the <a href="https://cran.r-project.org/web/packages/molnet/vignettes/Molnet_Vignette.html">vignette</a> uses data published by <a href="https://www.cell.com/cell/fulltext/S0092-8674(20)31400-8?_returnURL=https%3A%2F%2Flinkinghub.elsevier.com%2Fretrieve%2Fpii%2FS0092867420314008%3Fshowall%3Dtrue">Krug (2020)</a>.</p>
<p><img src="molnet.png" height = "300" width="500" alt="Illustration of network analysis pipeline"></p>
<p><a href="https://cran.r-project.org/package=simtrait">simtrait</a> v1.0.21P Provides functions to simulate complex traits given a SNP genotype matrix and model parameters with an emphasis on avoiding common biases due to the use of estimated allele frequencies. Traits can follow three models: random coefficients, fixed effect sizes, and multivariate normal. GWAS method benchmarking functions as described in <a href="https://www.biorxiv.org/content/10.1101/858399v1">Yao and Ochoa (2019)</a> are also provided. See the <a href="https://cran.r-project.org/web/packages/simtrait/vignettes/simtrait.html">vignette</a>.</p>
<p><img src="simtrait.png" height = "300" width="500" alt="Plot showing agreement of theoretical and RC kinship covariance matrices"></p>
<p><a href="https://cran.r-project.org/package=statgenIBD">statgenIBD</a> v1.0.1: Provides functions to calculate biparental, three and four-way crosses Identity by Descent (<a href="https://en.wikipedia.org/wiki/Identity_by_descent">IBD</a>) probabilities using Hidden Markov Models and inheritance vectors following <a href="https://www.jstor.org/stable/29713">Lander & Green (1987)</a> and <a href="https://www.pnas.org/content/108/11/4488">Huang (2011)</a>. See the <a href="https://cran.r-project.org/web/packages/statgenIBD/vignettes/IBDCalculations.html">vignette</a> for examples.</p>
<p><img src="statgenIBD.png" height = "300" width="500" alt="Plot of IBD probabilities"></p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=text2map">text2map</a> v0.1.0: Provides functions for computational text analysis for the social sciences including functions for working with word embeddings, text networks, and document-term matrices. For background on the methods used see <a href="https://link.springer.com/article/10.1007%2Fs42001-019-00048-6">Stoltz and Taylor (2019)</a>, <a href="https://link.springer.com/article/10.1007%2Fs42001-020-00075-8">Taylor and Stoltz (2020)</a>, <a href="https://sociologicalscience.com/articles-v7-23-544/">Taylor and Stoltz (2020)</a>, and <a href="https://www.sciencedirect.com/science/article/abs/pii/S0304422X21000504?via%3Dihub">Stoltz and Taylor (2021)</a>. There is a <a href="https://cran.r-project.org/web/packages/text2map/vignettes/CMDist-concept-movers-distance.html">Quick Start Guide</a> and a vignette on <a href="https://cran.r-project.org/web/packages/text2map/vignettes/concept-class-analysis.html">Concept Class Analysis</a>.</p>
<p><img src="text2map.png" height = "300" width="500" alt="Plot illustrating closeness of concepts"></p>
<p><a href="https://cran.r-project.org/package=NPRED">NPRED</a> v1.0.5: Uses partial informational correlation (PIC) to identify the meaningful predictors from a large set of potential predictors. Details can be found in <a href="https://agupubs.onlinelibrary.wiley.com/doi/full/10.1002/2013WR013845">Sharma & Mehrotra, (2014)</a>, <a href="https://www.sciencedirect.com/science/article/abs/pii/S1364815216301578?via%3Dihub">Sharma et al.(2016)</a>, and <a href="https://www.sciencedirect.com/science/article/abs/pii/S0309170805002137?via%3Dihub">Mehrotra & Sharma (2006)</a>. See the <a href="https://cran.r-project.org/web/packages/NPRED/vignettes/NPRED.html">vignette</a> for examples.</p>
<p><img src="NPRED.png" height = "300" width="500" alt="Illustration of using partial weights"></p>
<p><a href="https://cran.r-project.org/package=stabiliser">stabiliser</a> v0.1.0: Implements an approach to variable selection through stability selection and the use of an objective threshold based on permuted data. See <a href="https://www.nature.com/articles/s41598-020-79317-8">Lima et al (2021)</a> and <a href="https://rss.onlinelibrary.wiley.com/doi/10.1111/j.1467-9868.2010.00740.x">Meinshausen & Buhlmann (2010)</a> for details and the <a href="https://cran.r-project.org/web/packages/stabiliser/vignettes/stabiliser.html">vignette</a> for an example.</p>
<p><img src="stabiliser.png" height = "500" width="300" alt="Plot measuring stability of variables"></p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=dreamer">dreamer</a> v3.0.0: Fits longitudinal dose-response models utilizing a Bayesian model averaging approach as outlined in <a href="https://onlinelibrary.wiley.com/doi/10.1002/bimj">Gould (2019)</a> for both continuous and binary responses. See the <a href="https://cran.r-project.org/web/packages/dreamer/vignettes/dreamer.html">vignette</a>.</p>
<p><img src="dreamer.png" height = "300" width="500" alt="Plot from dreamer package"></p>
<p><a href="https://cran.r-project.org/package=smartDesign">smartDesign</a> v0.72: Implements the SMART trial design, as described by <a href="https://www.tandfonline.com/doi/abs/10.1080/19466315.2021.1883472?journalCode=usbr20">He et al. (2021)</a> which includes multiple stages of randomization where participants are randomized to an initial treatment in the first stage and then subsequently re-randomized between treatments in the following stage. There is a <a href="https://cran.r-project.org/web/packages/smartDesign/vignettes/DTR.html">Dynamic Treatment Tutorial</a> and a <a href="https://cran.r-project.org/web/packages/smartDesign/vignettes/SST.html">Sequential Design Tutorial</a>.</p>
<h3 id="science">Science</h3>
<p><a href="https://cran.r-project.org/package=bootf2">bootf2</a> v0.4.1: Provides functions to compare dissolution profiles with confidence intervals of the <a href="https://cran.r-project.org/web/packages/bootf2/vignettes/bootf2.html">similarity factor f2</a> and also functions to simulate dissolution profiles. There are multiple vignettes including and <a href="https://cran.r-project.org/web/packages/bootf2/vignettes/introduction.html">Introduction</a> a <a href="https://cran.r-project.org/web/packages/bootf2/vignettes/sim.dp.html">Simulation Example</a>.</p>
<p><img src="bootf2.png" height = "300" width="500" alt="Plot of dissolution profiles."></p>
<p><a href="https://cran.r-project.org/package=track2KBA">track2KBA</a> v1.0.1: Provides functions to prepare and analyze animal tracking data in order to identify areas of potential interest for population level conservation. See <a href="https://onlinelibrary.wiley.com/doi/10.1111/ddi.12411">Lascelles et al. (2016)</a> for background on the methodology employed and the <a href="https://cran.r-project.org/web/packages/track2KBA/vignettes/track2kba_workflow.html">vignette</a> for examples and workflow.</p>
<p><img src="track2KBA.png" height = "400" width="300" alt="Plot shows estimated minimum number of birds in space around breeding island."></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=chyper">chyper</a> v0.3.1: Provides functions to work with the conditional hypergeometric distribution. See the <a href="https://cran.r-project.org/web/packages/chyper/vignettes/Guide.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=sprtt">sprtt</a> v0.1.0: Provides functions to perform sequential t-tests including those of <a href="https://academic.oup.com/sf/article-abstract/27/2/170/1991955">Wald (1947)</a>, <a href="https://www.jstor.org/stable/2332385?origin=crossref">Rushton (1950)</a>, <a href="https://www.jstor.org/stable/2334026?origin=crossref">Rushton (1952)</a>, and <a href="https://www.jstor.org/stable/2333131?origin=crossref">Hajnal (1961)</a>. There is an <a href="https://cran.r-project.org/web/packages/sprtt/vignettes/usage-sprtt.html">Introduction</a> to the package, a <a href="https://cran.r-project.org/web/packages/sprtt/vignettes/use-case.html">Use Case</a>, and a vignette on the <a href="https://cran.r-project.org/web/packages/sprtt/vignettes/sequential_testing.html">Sequential t-test</a>.</p>
<p><a href="https://cran.r-project.org/package=SurvMetrics">SurvMetrics</a> v0.3.5: Implements popular evaluation metrics commonly used in survival prediction including Concordance Index, Brier Score, Integrated Brier Score, Integrated Square Error, Integrated Absolute Error and Mean Absolute Error. For detailed information, see <a href="https://projecteuclid.org/journals/annals-of-applied-statistics/volume-2/issue-3/Random-survival-forests/10.1214/08-AOAS169.full">Ishwaran et al. (2008)</a> and <a href="https://link.springer.com/article/10.1007%2Fs10985-016-9372-1">Moradian et al. (2017)</a>. The <a href="https://cran.r-project.org/web/packages/SurvMetrics/vignettes/SurvMetrics-vignette.html">vignette</a> offers examples.</p>
<p><img src="SurvMetrics.png" height = "400" width="300" alt="Boxplot comparing models"></p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=DCSmooth">DCSmooth</a> v1.0.2: Implements nonparametric smoothing techniques for data on a lattice or functional time series which allow for modeling a dependency structure of the error terms of the nonparametric regression model. See <a href="https://www.tandfonline.com/doi/abs/10.1198/106186002420">Beran & Feng (2002)</a>, <a href="https://www.jstor.org/stable/2533197?origin=crossref">Mueller & Wang (1994)</a>, <a href="https://ideas.repec.org/p/pdn/ciepap/144.html">Feng & Schaefer (2021)</a>, and <a href="https://ideas.repec.org/p/pdn/ciepap/143.html">Schaefer & Feng (2021)</a> for the background and the <a href="https://cran.r-project.org/web/packages/DCSmooth/vignettes/DCSmooth.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=STFTS">STFTS</a> v0.1.0: Implements statistical hypothesis tests of functional time series including a functional stationarity test, a functional trend stationarity test and a functional unit root test.</p>
<p><a href="https://cran.r-project.org/package=WASP">WASP</a> v1.4.1: Implements wavelet-based variance transformation methods for system modeling and prediction. For details see <a href="https://agupubs.onlinelibrary.wiley.com/doi/10.1029/2019WR026962">Jiang et al. (2020)</a>, <a href="https://www.sciencedirect.com/science/article/abs/pii/S1364815220309646?via%3Dihub">Jiang et al. (2020)</a>, and <a href="https://www.sciencedirect.com/science/article/abs/pii/S0022169421008660?via%3Dihub">Jiag et al. (2021)</a> There is a <a href="https://cran.r-project.org/web/packages/WASP/vignettes/WASP.html">vignette</a> with examples.</p>
<p><img src="WASP.png" height = "300" width="500" alt="Plot showing Daubechies wavelets"></p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=ExpImage">ExpImage</a> v0.2.0: Provides an image editing tool for researchers which includes functions for segmentation and for obtaining biometric measurements. There are several vignettes including: <a href="https://cran.r-project.org/web/packages/ExpImage/vignettes/Contagem_de_bovinos.html">Contagem de bovinos</a>, <a href="https://cran.r-project.org/web/packages/ExpImage/vignettes/Contagem_de_objetos.html">Contagem de objetos</a>, and <a href="https://cran.r-project.org/web/packages/ExpImage/vignettes/Edicao_de_imagens.html">Como editar imagens</a>.</p>
<p><img src="ExpImage.png" height = "300" width="300" alt="Image of leaf with seeds to be counted"></p>
<p><a href="https://cran.r-project.org/package=meltr">meltr</a> v1.0.0: Provides functions to read non-rectangular data, such as ragged forms of csv (comma-separated values), tsv (tab-separated values), and fwf (fixed-width format) files. See <a href="https://cran.r-project.org/web/packages/meltr/readme/README.html">README</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=plumbertableau">plumbertableau</a> v0.1.0: Implements tools for building <code>plumber</code> APIs that can be used in <a href="https://www.tableau.com/">Tableau</a> workbooks. There is a package <a href="https://cran.r-project.org/web/packages/plumbertableau/vignettes/introduction.html">Introduction</a> and vignettes on <a href="https://cran.r-project.org/web/packages/plumbertableau/vignettes/r-developer-guide.html">Writing Extensions</a>, <a href="https://cran.r-project.org/web/packages/plumbertableau/vignettes/tableau-developer-guide.html">Using Extensions in Tableau</a>, and <a href="https://cran.r-project.org/web/packages/plumbertableau/vignettes/publishing-extensions.html">Publishing Extensions to RStudio Connect</a>.</p>
<p><a href="https://cran.r-project.org/package=string2path">string2path</a> v0.0.2: Provides functions to extract glyph information from a font file, translate the outline curves to flattened paths or tessellated polygons, and return the results as a <code>data.frame</code>. See <a href="https://cran.r-project.org/web/packages/string2path/readme/README.html">README</a> for an example.</p>
<p><img src="string2path.png" height = "300" width="500" alt="Japanese kana and kanji as glyphs on an x-y grid"></p>
<p><a href="https://cran.r-project.org/package=trackdown">trackdown</a> v1.0.0: Uses <a href="https://www.google.com/drive/">Googel Drive</a> to implement tools for collaborative writing and editing of R Markdown and Sweave documents. There are some <a href="https://cran.r-project.org/web/packages/trackdown/vignettes/trackdown-tech-notes.html">Tech Notes</a> and vignettes on <a href="https://cran.r-project.org/web/packages/trackdown/vignettes/trackdown-features.html">Features</a> and <a href="https://cran.r-project.org/web/packages/trackdown/vignettes/trackdown-workflow.html">Workflow</a>.</p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=aRtsy">aRtsy</a> v0.1.1: Provides algorithms for creating artwork in the <code>ggplot2</code> language that incorporate some form of randomness. See <a href="https://cran.r-project.org/web/packages/aRtsy/readme/README.html">README</a> for examples and package use.</p>
<p><img src="aRtsy.png" height = "200" width="400" alt="aRtsy generated abstract art"></p>
<p><a href="https://cran.r-project.org/package=ggcleveland">ggcleveland</a> v0.1.0: Provides functions to produce <code>ggplot2</code> versions of the visualization tools described in William Cleveland’s book <a href="https://www.amazon.com/Visualizing-Data-William-S-Cleveland/dp/0963488406/ref=sr_1_3?dchild=1&keywords=Visualizing+Data+cleveland&qid=1632504146&sr=8-3"><em>Visualizing Data</em></a>. The <a href="https://cran.r-project.org/web/packages/ggcleveland/vignettes/ggplot-cleveland.html">vignette</a> contains several examples.</p>
<p><img src="ggcleveland.png" height = "200" width="400" alt="William Cleveland inspired qqplots"></p>
<p><a href="https://cran.r-project.org/package=ggtikz">ggtikz</a> v0.0.1: Provides tools to annotate <code>ggplot2</code> plots with <a href="https://www.overleaf.com/learn/latex/TikZ_package">TikZ</a> code using absolute data or relative coordinates. See the <a href="https://cran.r-project.org/web/packages/ggtikz/vignettes/examples.pdf">vignette</a>.</p>
<p><img src="ggtikz.png" height = "300" width="300" alt="Scatter plot annotated with text and lines"></p>
<p><a href="https://cran.r-project.org/package=tidycharts">tidycharts</a> v0.1.2: Provides functions to generate charts compliant with the International Business Communication Standards (<a href="https://www.ibcs.com/">IBCS</a>) including unified bar widths, colors, chart sizes, etc. There is a <a href="https://cran.r-project.org/web/packages/tidycharts/vignettes/Getting_Started.html">Getting Started</a> guide and vignettes on <a href="https://cran.r-project.org/web/packages/tidycharts/vignettes/EDA-for-palmer-penguins-data-set.html">EDA</a>, <a href="https://cran.r-project.org/web/packages/tidycharts/vignettes/customize-package.html">Customization</a>, and <a href="https://cran.r-project.org/web/packages/tidycharts/vignettes/join_charts.html">Joining Charts</a>.</p>
<p><img src="tidycharts.png" height = "300" width="500" alt="tidycharts IBCS compliant histogram"></p>
<script>window.location.href='https://rviews.rstudio.com/2021/09/27/august-2021-top-40-new-cran-packages/';</script>
July 2021: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2021/08/26/july-2021-top-40-new-cran-packages/
Thu, 26 Aug 2021 00:00:00 +0000https://rviews.rstudio.com/2021/08/26/july-2021-top-40-new-cran-packages/
<p>One hundred eighty-three new packages stuck to CRAN in July. Here are my “Top 40” picks in eleven categories: Data, Ecology, Finance, Genomics, Machine Learning, Medicine, Science, Statistics, Time Series, Utilities, and Visualization. Although I don’t have any formal specification for these categories, I do my best to main my subjective sense of consistency from month to month. Nevertheless, watching the monthly ebb and flow of the number of packages that fit into the various categories is interesting. This month, developers seemed to be focused on utilities. I classified forty-five packages as utilities this month.</p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=beans">beans</a> v0.1.0: Contains data on 13,611 beans from <a href="https://www.sciencedirect.com/science/article/abs/pii/S0168169919311573?via%3Dihub">Koklu and Ozkan (2020)</a>. The beans have been quantified using 16 morphologic image features and labeled with one of 6 values.</p>
<p><a href="https://CRAN.R-project.org/package=geckor">geckor</a> v0.1.1: Provides functions to collect current and historical cryptocurrency market data using the public <a href="https://www.coingecko.com/en/api">CoinGecko API</a>. There is a brief <a href="https://cran.r-project.org/web/packages/geckor/vignettes/supported-currencies-and-exchanges.html">overview</a> and vignettes on <a href="https://cran.r-project.org/web/packages/geckor/vignettes/current-data.html">Current</a> and <a href="https://cran.r-project.org/web/packages/geckor/vignettes/historical-data.html">Historical</a> market data.</p>
<p><a href="https://cran.r-project.org/package=ISLR2">ISLR2</a> v1.0: Contains the data sets used in the book <a href="https://www.statlearning.com/"><em>An Introduction to Statistical Learning with Applications in R, Second Edition</em></a>.</p>
<p><a href="https://cran.r-project.org/package=sageR">sageR</a> v0.3.0: Provides the data sets used in the book <em>Statistiques pour l’économie et la gestion, Théorie et applications en entreprise</em>. Look <a href="https://fbertran.github.io/sageR/">here</a> for descriptions of the data with code and plots.</p>
<p><img src="sageR.png" height = "500" width="500"></p>
<h3 id="ecology">Ecology</h3>
<p><a href="https://cran.r-project.org/package=DA">DA</a> v1.2.0: Provides functions for Discriminant Analysis (DA) for evolutionary inference, especially population genetic structure and community structure inference as described in <a href="https://www.authorea.com/users/304610/articles/460985-da-ecological-and-evolutionary-inference-using-supervised-discriminant-analysis?commit=668bd97318a7646fd432e4824228415ed209b692">Qin et al. (2020)</a>. See the <a href="https://cran.r-project.org/web/packages/DA/vignettes/DA.html">Introduction</a>.</p>
<p><img src="DA.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=Ostats">Ostats</a> v0.1.0: Provides functions to calculate O-statistics, or overlap statistics, which measure the degree of community-level trait overlap. See <a href="https://onlinelibrary.wiley.com/doi/10.1111/ecog.03641">Read et al. (2018)</a> for background. There is an <a href="https://cran.r-project.org/web/packages/Ostats/vignettes/Ostats-introduction.html">Introduction</a> and a vignette on <a href="https://cran.r-project.org/web/packages/Ostats/vignettes/Ostats-multivariate.html">Multivariate Ostats</a>.</p>
<p><img src="Ostats.png" height = "400" width="400"></p>
<h3 id="finance">Finance</h3>
<p><a href="https://cran.r-project.org/package=ffp">ffp</a> v0.1.0: Implements numerical entropy-pooling for scenario analysis as described in <a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=1696802">Meucci (2010)</a> See the <a href="https://cran.r-project.org/web/packages/ffp/vignettes/Replicating-Meucci-Paper.html">vignette</a>.</p>
<p><img src="ffp.png" height = "300" width="500"></p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=utr.annotation">utr.annotation</a> v1.0.4: Implements a fast tool for annotating potential deleterious variants in the untranslated regions for both human and mouse species. See <a href="https://www.biorxiv.org/content/10.1101/2021.06.23.449510v2">Liu & Dougherty (2021)</a> for background and the <a href="https://cran.r-project.org/web/packages/utr.annotation/vignettes/introduction.pdf">vignette</a> for and introduction and examples.</p>
<p><a href="https://cran.r-project.org/package=OmicNavigator">OmicNavigator</a> v1.4.3: Provides a for interactive exploration of the results from ‘omics’ experiments to facilitate novel discoveries from high-throughput biology. There is a <a href="https://cran.r-project.org/web/packages/OmicNavigator/vignettes/OmicNavigatorUsersGuide.pdf">User’s Guide</a> and a vignette on the package’s <a href="https://cran.r-project.org/web/packages/OmicNavigator/vignettes/OmicNavigatorAPI.pdf">API</a>.</p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=BOSO">BOSO</a> v1.0.3: Implements the BiLevel Optimization Selector Operator feature selection algorithm for linear regression as described in <a href="https://www.biorxiv.org/content/10.1101/2020.11.18.388579v1">Valcarcel et al. (2020)</a>. See the <a href="https://cran.r-project.org/web/packages/BOSO/vignettes/BOSO.htm">vignette</a> for examples.</p>
<p><img src="Boso.png" height = "400" width="500"></p>
<p><a href="https://cran.r-project.org/package=FeatureTerminatoR">FeatureTerminatoR</a> v1.0.0: Implements a feature selection engine that removes features with minimal predictive power. See <a href="https://link.springer.com/article/10.1007%2Fs40595-018-0107-y">Boughaci (2018)</a> for background and the <a href="https://cran.r-project.org/web/packages/FeatureTerminatoR/vignettes/feature_terminatoR_howto.html">vignette</a> for and example.</p>
<p><a href="https://cran.r-project.org/package=hhcartr">hhcartr</a> v1.0.0: Implements the HHCART-G algorithm described in <a href="https://onlinelibrary.wiley.com/doi/10.1111/anzs.12275">Wickramarachchi et al. (2019)</a>. See the <a href="https://cran.r-project.org/web/packages/hhcartr/vignettes/hhcartr.pdf">vignette</a>.</p>
<p><img src="hhcartr.png" height = "500" width="400"></p>
<p><a href="https://cran.r-project.org/package=recometrics">recometrics</a> v0.1.3: Implements evaluation metrics for implicit-feedback recommender systems based on low-rank matrix factorization models, given the fitted model matrices and data. See the <a href="https://cran.r-project.org/web/packages/recometrics/vignettes/Evaluating_recommender_systems.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=tidylda">tidylda</a> v0.0.1: Implements an algorithm for Latent Dirichlet Allocation (LDA) as described in <a href="https://www.jmlr.org/papers/volume3/blei03a/blei03a.pdf">Blei et at. (2003)</a> using <a href="https://www.tidyverse.org/">tidyverse</a> principles. See <a href="https://cran.r-project.org/web/packages/tidylda/readme/README.html">README</a> for an overview.</p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=dcurves">dcurves</a> v0.2.0: Implements a decision curve analysis method for evaluating and comparing prediction models that incorporates clinical consequences and requires only the data set on which the models are tested. See <a href="https://journals.sagepub.com/doi/10.1177/0272989X06295361">Vickers (2006)</a>, <a href="https://bmcmedinformdecismak.biomedcentral.com/articles/10.1186/1472-6947-8-53">Vickers (2008)</a>, and <a href="https://onlinelibrary.wiley.com/doi/10.1002/bimj.201800240">Pfeiffer (2020)</a> for background, and the <a href="https://cran.r-project.org/web/packages/dcurves/vignettes/dca.html">vignette</a> for examples.</p>
<p><img src="dcurves.png" height = "200" width="300"></p>
<p><a href="https://cran.r-project.org/package=KHQ">KHQ</a> v0.2.0: Provides methods to calculate scores for each dimension of the The King’s Health Questionnaire <a href="https://obgyn.onlinelibrary.wiley.com/doi/10.1111/j.1471-0528.1997.tb11006.x">(KHQ)</a> ; converts KHQ item scores to <a href="https://journals.sagepub.com/doi/10.1177/0272989X07301820">KHQ5D</a> scores; and also calculates the utility index of the KHQ5D. See the <a href="https://cran.r-project.org/web/packages/KHQ/vignettes/KHQ.html">vignette</a>.</p>
<h3 id="science">Science</h3>
<p><a href="https://cran.r-project.org/package=AvInertia">AvInertia</a> v0.0.1: Provides functions to compute the center of gravity and moment of inertia tensor of any flying bird. See the <a href="https://cran.r-project.org/web/packages/AvInertia/vignettes/how-to-analyze-data.html">vignette</a> for some insight into bird design.</p>
<p><a href="https://cran.r-project.org/package=bayesnec">bayesnec</a> v1.0.1: Provides functions to fit dose concentration response curves to toxicity data, and derive No-Effect-Concentration (NEC), No-Significant-Effect-Concentration (NSEC), and Effect-Concentration (of specified percentage ‘x’, ECx) thresholds from non-linear models fitted using Bayesian MCMC fitting methods via <a href="https://cran.r-project.org/web/packages/brms/index.html">brms</a> and <a href="https://mc-stan.org/">Stan</a>. There are vignettes on <a href="https://cran.r-project.org/web/packages/bayesnec/vignettes/example1.html">Single model usage</a>, <a href="https://cran.r-project.org/web/packages/bayesnec/vignettes/example2.html">Multi model usage</a>, <a href="https://cran.r-project.org/web/packages/bayesnec/vignettes/example2b.html">Model details</a>, <a href="https://cran.r-project.org/web/packages/bayesnec/vignettes/example3.html">Priors</a>, and <a href="https://cran.r-project.org/web/packages/bayesnec/vignettes/example4.html">Comparing posterior predictions</a>.</p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=itdr">itdr</a> v1.0: Provides functions to estimate the sufficient dimension reduction subspaces, i.e., central mean subspace or central subspace in regression, using Fourier transformation proposed by <a href="https://www.tandfonline.com/doi/abs/10.1198/016214506000000140">Zhu & Zeng (2006)</a>, the convolution transformation proposed by <a href="https://www.sciencedirect.com/science/article/pii/S0047259X0900147X?via%3Dihub">Zeng & Zhu (2010)</a>, and an iterative Hessian transformation methods proposed by <a href="https://projecteuclid.org/journals/annals-of-statistics/volume-30/issue-2/Dimension-reduction-for-conditional-mean-in-regression/10.1214/aos/1021379861.full">Cook & Li (2002)</a>. See the <a href="https://cran.r-project.org/web/packages/itdr/vignettes/itdr-vignette.html">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=mlfit">mlfit</a> v0.5.2: Extends the [Iterative Proportional Fitting] <a href="https://trid.trb.org/view/881554">(IPF)</a> algorithm which operates on count data to nested structures with constraints. See <a href="https://www.research-collection.ethz.ch/bitstream/handle/20.500.11850/39167/eth-3088-01.pdf?sequence=1&isAllowed=y">Müller & Axhausen (2011)</a> for background and look <a href="https://mlfit.github.io/mlfit/">here</a> for and example.</p>
<p><a href="https://cran.r-project.org/package=optimall">optimall</a> v0.1.0: Provides functions for the survey sampling design process with specific tools for multi-wave and multi-phase designs. Users can perform optimum allocation according to <a href="https://www.jstor.org/stable/2342192?origin=crossref">Neyman (1934)</a> or <a href="https://www.tandfonline.com/doi/abs/10.1080/00031305.2012.733679">Wright (2012)</a>. There is a <a href="https://cran.r-project.org/web/packages/optimall/vignettes/optimall-vignette.html">User’s Guide</a>, there are vignettes <a href="https://cran.r-project.org/web/packages/optimall/vignettes/Multiwave-Object.html">Multiwave Object</a> and <a href="https://cran.r-project.org/web/packages/optimall/vignettes/using-optimall_shiny.html">Splitting Strata with Optimall Shiny</a>.</p>
<p><a href="https://cran.r-project.org/package=posterior">posterior</a> v1.0.1: Provides tools for both users and package developers for fitting and working with Bayesian models; including tools to: efficiently convert between different formats of draws from distributions, provide consistent methods for common operations, provide summaries in convenient formats, and implement state of the art posterior inference diagnostics. See <a href="https://projecteuclid.org/journals/bayesian-analysis/volume-16/issue-2/Rank-Normalization-Folding-and-Localization--An-Improved-R%cb%86-for/10.1214/20-BA1221.full">Vehtari et al. (2021)</a> for background. There is an <a href="https://cran.r-project.org/web/packages/posterior/vignettes/posterior.html">Introduction</a> and a vignette on the <a href="https://cran.r-project.org/web/packages/posterior/vignettes/rvar.html">Random Variable Datatype</a>.</p>
<p><a href="https://cran.r-project.org/package=PropensitySub">PropensitySub</a> v0.2.0: Provides functions to estimate treatment effects in strata via inverse probability weighting or propensity score matching when subjects have missing strata labels. See the <a href="https://cran.r-project.org/web/packages/PropensitySub/vignettes/how_to.html">vignette</a> for examples.</p>
<p><img src="psub.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=ReplicationSuccess">ReplicationSuccess</a> v1.0.0: Provides utilities for the design and analysis of replication studies featuring both traditional methods based on statistical significance and more recent methods such as the skeptical p-value <a href="https://rss.onlinelibrary.wiley.com/doi/10.1111/rssa.12493">Held L. (2020)</a>, the harmonic mean chi-squared test <a href="https://rss.onlinelibrary.wiley.com/doi/10.1111/rssc.12410">Held, L. (2020)</a>, and intrinsic credibility <a href="https://royalsocietypublishing.org/doi/10.1098/rsos.181534">Held, L. (2019)</a>. See the <a href="https://cran.r-project.org/web/packages/ReplicationSuccess/vignettes/ReplicationSuccess.pdf">vignette</a> for examples.</p>
<p><img src="RS.png" height = "200" width="400"></p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=kinematics">kinematics</a> V1.0.0: Provides functions to analyze time series representing two-dimensional movements. It accepts a data frame with a time (t), horizontal (x) and vertical (y) coordinate as columns, and returns several dynamical properties such as speed, acceleration or curvature. See the <a href="https://cran.r-project.org/web/packages/kinematics/vignettes/example.html">vignette</a> for examples.</p>
<p><img src="kinematics.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=profoc">profoc</a> v0.8.3: Provides methods to combine probabilistic forecasts using CRPS learning algorithms proposed in <a href="https://arxiv.org/abs/2102.00968">Berrisch & Ziel (2021)</a> including multiple online learning algorithms such as Bernstein online aggregation as described in <a href="https://arxiv.org/abs/1404.1356">Wintenberger (2014)</a>.</p>
<p><a href="https://cran.r-project.org/package=tscopula">tscopula</a> v0.2.1: Provides functions for the analysis of time series using copula models. See <a href="https://www.mdpi.com/2227-9091/9/1/14"> McNeil (2021)</a> and <a href="https://arxiv.org/abs/2006.11088">Bladt & McNeil (2020)</a> for background. There are vignettes on <a href="https://cran.r-project.org/web/packages/tscopula/vignettes/bitcoin.html">Bitcoin Analysis</a>, <a href="https://cran.r-project.org/web/packages/tscopula/vignettes/tscm_models.html">Models with Margins</a>, <a href="https://cran.r-project.org/web/packages/tscopula/vignettes/tscopulas.html">Basic Time Series Copula Processes</a>, and <a href="https://cran.r-project.org/web/packages/tscopula/vignettes/vtscopulas.html">Copula Processes with V-Transforms</a>.</p>
<p><img src="tscopula.png" height = "300" width="500"></p>
<h3 id="utility">Utility</h3>
<p><a href="https://cran.r-project.org/package=codemeta">codemeta</a> v0.1.0: Provides core utilities to generate metadata with a minimum of dependencies as specified by the <a href="https://codemeta.github.io/">Codemata Project</a>. See <a href="https://cran.r-project.org/web/packages/codemeta/readme/README.html">README</a> for examples.</p>
<p><img src="codemeta.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=ctf">ctf</a> v0.1.0: Provides functions to read and write data in Column Text Format (CTF), a new tabular data format that is a simple column store. See the <a href="https://cran.r-project.org/web/packages/ctf/vignettes/overview.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=fedmatch">fedmatch</a> v2.0.2: Provides tools for matching two un-linked data sets using exact matches, fuzzy matches, or multi-variable matches. There is an <a href="https://cran.r-project.org/web/packages/fedmatch/vignettes/Intro-to-fedmatch.html">Introduction</a> and vignettes on <a href="https://cran.r-project.org/web/packages/fedmatch/vignettes/Fuzzy-matching.html">Fuzzy Matching</a>, <a href="https://cran.r-project.org/web/packages/fedmatch/vignettes/Multivar_matching.html">Multivar Matching</a>, <a href="https://cran.r-project.org/web/packages/fedmatch/vignettes/Using-tier-match.html">Tier Matching</a>, and <a href="https://cran.r-project.org/web/packages/fedmatch/vignettes/Using-clean-strings.html">Using clean_strings</a>.</p>
<p><a href="https://cran.r-project.org/package=fusen">fusen</a> v0.2.4: Implements a method to use R Markdown to build an R package. Users start by including documentation, functions, examples and tests in the same file. Then inflating the R Markdown template copies the relevant chunks and sections in the appropriate files required for package development. There is an <a href="https://cran.r-project.org/web/packages/fusen/vignettes/How-to-use-fusen.html">Introduction</a> and a <a href="https://cran.r-project.org/web/packages/fusen/vignettes/Maintain-packages-with-fusen.html">vignette</a> on maintaining packages.</p>
<p><a href="https://cran.r-project.org/package=katex">katex</a> v1.10: Provides functions to convert <a href="https://www.latex-project.org/">LaTeX</a> math expressions to HTML and <a href="https://www.w3.org/Math/">MATHML</a> for use in markdown documents or package manual pages in a way which eliminates the need for embedding the <a href="https://www.mathjax.org/">MathJax</a> library into your web pages. See the <a href="https://cran.r-project.org/web/packages/katex/vignettes/katex-tests.html">vignette</a>.</p>
<p><img src="katex.png" height = "200" width="300"></p>
<p><a href="https://cran.r-project.org/package=pacs">pacs</a> v0.3.3: Provides utilities for CRAN package maintainers and R packages developers, including tools for validating packages and exploring the complexity of a specific package. See <a href="https://cran.r-project.org/web/packages/pacs/readme/README.html">README</a> for a list of features and examples.</p>
<p><a href="https://cran.r-project.org/package=RcppFarmHash">RcppFarmHash</a> v0.0.2 Implements an interface to the The Google <a href="https://opensource.googleblog.com/2014/03/introducing-farmhash.html">FarmHash</a> family of hash functions is used by the Google <a href="https://cloud.google.com/bigquery">BigQuery</a> data warehouse. Look <a href="https://dirk.eddelbuettel.com/code/rcpp.farmhash.html">here</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=shinyauthr">shinyauthr</a> v10.0: Provides in-app user authentication for Shiny applications, allowing developers to secure publicly hosted apps and build dynamic user interfaces from user information. See <a href="https://cran.r-project.org/web/packages/shinyauthr/readme/README.html">README</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=tangram.pipe">tantram.pipe</a> v1.0.0: Allows users to build tables with customizable rows by specifying the type of data to use for each row, as well as how to handle missing data and the types of comparison tests to run on the table columns. See the <a href="https://cran.r-project.org/web/packages/tangram.pipe/vignettes/Customizable-Table-Building.html">vignette</a>.</p>
<p><img src="tangram.png" height = "300" width="600"></p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=chameleon">chameleon</a> v0.2-0: Provides functions to assign distinct colors to arbitrary multi-dimensional data, considering its structure. See the <a href="https://cran.r-project.org/web/packages/chameleon/vignettes/examples.html">vignette</a> for examples.</p>
<p><img src="chameleon.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=deeptime">deeptime</a> v0.1.0: Extends plotting packages such as <code>ggplot2</code> and <code>lattice</code> to facilitate the plotting of data over long time intervals, including, but not limited to, geological, evolutionary, and ecological data. Look <a href="https://github.com/willgearty/deeptime">here</a> for examples.</p>
<p><img src="deeptime.png" height = "300" width="600"></p>
<p><a href="https://cran.r-project.org/package=figpatch">figpatch</a> v0.1.0.1: Provides functions to arrange external figures with <code>patchwork</code> alongside <code>ggplot2</code> plots. See <a href="https://cran.r-project.org/web/packages/figpatch/readme/README.html">README</a> for examples.</p>
<p><img src="patchwork.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=spiralize">spiralize</a> v1.0.2: Provides functions to visualize data along an <a href="https://en.wikipedia.org/wiki/Archimedean_spiral">Archimedean spiral</a> which has the advantages of being able to visualize data with very a long axis with high resolution and reveal periodic patterns in time series. Look <a href="https://cran.r-project.org/web/packages/spiralize/vignettes/spiralize.html">here</a> for links to the five vignettes.</p>
<p><img src="spiralize.png" height = "500" width="500"></p>
<script>window.location.href='https://rviews.rstudio.com/2021/08/26/july-2021-top-40-new-cran-packages/';</script>
R / Medicine 2021
https://rviews.rstudio.com/2021/08/12/r-medicine-2021/
Thu, 12 Aug 2021 00:00:00 +0000https://rviews.rstudio.com/2021/08/12/r-medicine-2021/
<p><img src="rmed.png" height = "500" width="100%"></p>
<p><a href="https://r-medicine.com/">R/Medicine 2021</a>, the premier conference for the use of R in clinical applications is less than two weeks away! This conference reflects the increasing importance of data science, computational statistics and machine learning to clinical applications, and emphasizes the effectiveness of the R language as a vehicle for making data driven medicine accessible to clinicians with diverse backgrounds. The two conference keynote talks <em>Bringing Machine Learning Models to the Bedside</em> by <a href="https://medicine.umich.edu/dept/lhs/karandeep-singh-md-mmsc">Karandeep Singh</a> and <em>Dissecting Algorithmic Bias</em> by <a href="https://publichealth.berkeley.edu/people/ziad-obermeyer/">Ziad Obermeyer</a> directly address important technical and ethical issues confronting modern data driven medicine.</p>
<p>R/Medicine will offer six short courses spread out over the two days of August 24th and August 25th. These courses are <strong>included in the registration price</strong>. The Tuesday short courses will be:</p>
<ul>
<li><em>Secure Medical Data Collection: Best Practices with Excel, and Leveling Up to REDCap and collaboratoR</em> taught by Peter Higgins, Will Beasley, Kenneth McLean</li>
<li><em>Intro to R for Medical Data</em> taught by Ted Laderas, Daniel Chen, Mara Alexeev</li>
<li><em>An Introductory R Guide for Targeted Maximum Likelihood Estimation in Medical Research</em> taught by Ehsan Karim</li>
</ul>
<p>The Wednesday short courses will be:</p>
<ul>
<li><em>Mapping Spatial Health Data</em> taught by Marynia Kolak</li>
<li><em>Reproducible Research with R</em> taught by Alison Hill and Stephan Kadauke</li>
<li><em>From SAS to R</em> taught by Joe Korszun</li>
</ul>
<p>The conference will proper will run from 11:00 to 19:30 EDT on Thursday, August 26th, and from 10:50 to 18:00 EDT on Friday, August 27th. The <a href="https://r-medicine.com/schedule/">full schedule is here</a>. Priced at only $50 full fare, $25 for academics and $10 for students and trainees, this is an affordable, important conference that you will not want to miss.</p>
<h3 id="you-can-register-here-https-bit-ly-2vlqger">You can <a href="https://bit.ly/2VLqGer"><strong>register here</strong></a>.</h3>
<p>To get an idea of the international scope of the conference, and a feel for what the virtual conference experience might be like, have a look at the <em>R Journal</em> article written by the organizing team about last year’s conference: <a href="https://journal.r-project.org/archive/2021-1/rmed2020.pdf"><em>R Medicine 2020: The Power of Going
Virtual</em></a>.</p>
<p>And finally, to get an idea of the various ways that R is contributing to getting everyday work done in clinical practice: the following are the packages from the Medicine category that made it to my lists of “Top 40” new CRAN packages in posts over the past twelve months.</p>
<h3 id="top-40-picks-for-new-cran-packages-for-medicine">“Top 40” Picks for new CRAN Packages for Medicine</h3>
<p><a href="https://cran.r-project.org/package=afdx">afdx</a> v1.1.1: Provides functions to estimate diagnosis performance (Sensitivity, Specificity, Positive predictive value, Negative predicted value) of a diagnostic test when there is no golden standard by estimating the attributable fraction using either a <a href="https://cran.r-project.org/web/packages/afdx/vignettes/af_logit_exponential.html">logitexponential model</a> or a <a href="https://cran.r-project.org/web/packages/afdx/vignettes/latentclass.html">latent class model</a>.</p>
<p><a href="https://cran.r-project.org/package=aldvmm">aldvmm</a> v0.8.4: Fits health state utility adjusted limited dependent variable mixture models, i.e. finite mixtures of normal distributions with an accumulation of density mass at the limits, and a gap between 100% quality of life and the next smaller utility value. See <a href="https://journals.sagepub.com/doi/10.1177/1536867X1501500307">Alava and Wailoo (2015)</a> for background and the <a href="https://cran.r-project.org/web/packages/aldvmm/vignettes/aldvmm_vignette.pdf">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=babsim.hospital">babsim.hospital</a> v11.5.14: Implements a discrete-event simulation model for a hospital resource planning. Motivated by the challenges faced by health care institutions in the current COVID-19 pandemic, it can be used by health departments to forecast demand for intensive care beds, ventilators, and staff resources. See <a href="https://www.jstatsoft.org/article/view/v090i02">Ucar, Smeets & Azcorra (2019)</a>, <a href="https://www.rcpjournals.org/content/futurehosp/6/1/17">Lawton & McCooe (2019)</a> and the <a href="https://www.th-koeln.de/informatik-und-ingenieurwissenschaften/babsimhospital_78996.php">website</a> for background, and the <a href="https://cran.r-project.org/web/packages/babsim.hospital/vignettes/babsim-vignette-introduction.pdf">vignette</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=beats">beats</a> v0.1.1: Provides functions to import data from UFI devices and process electrocardiogram (ECG) data. It also includes a Shiny app for finding and exporting heart beats. See <a href="https://cran.r-project.org/web/packages/beats/readme/README.html">README</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=bhmbasket">bhmbasket</a> v0.9.1: Provides functions to evaluate basket trial designs with binary endpoints using Bayesian hierarchical models and Bayesian decision rules. See <a href="https://journals.sagepub.com/doi/10.1177/1740774513497539">Berry et al. (2013)</a>, <a href="https://onlinelibrary.wiley.com/doi/abs/10.1002/pst.1730">Neuenschwander et al. (2016)</a> and <a href="https://link.springer.com/article/10.1177%2F2168479014533970">Fisch et al. (2015)</a> for background and the <a href="https://cran.r-project.org/web/packages/bhmbasket/vignettes/reproduceExNex.html">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=bp">bp</a> v1.0.1: Provides functions to aid in the analysis of blood pressure data of all forms by providing both descriptive and visualization tools for researchers. There is a <a href="https://cran.r-project.org/web/packages/bp/vignettes/bp.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=card">card</a> v0.1.0: Provides tools to help assess the autonomic regulation of cardiovascular physiology with respect to electrocardiography, circadian rhythms, and the clinical risk of autonomic dysfunction on cardiovascular health through the perspective of epidemiology and causality. For background on the analysis of circadian rhythms through cosinor analysis see <a href="https://tbiomed.biomedcentral.com/articles/10.1186/1742-4682-11-16">Cornelissen (2014)</a> and <a href="https://www.tandfonline.com/doi/abs/10.1080/09291010600903692">Refinetti et al. (2014)</a>. There are two vignettes: <a href="https://cran.r-project.org/web/packages/card/vignettes/circadian.html">circadian</a> and <a href="https://cran.r-project.org/web/packages/card/vignettes/cosinor.html">cosinor</a>.</p>
<p><a href="https://cran.r-project.org/package=causalCmprsk">causalCmprisk</a> v1.0.0: Provides functions to estimate average treatment effects of two static treatment regimes on time-to-event outcomes with competing events. The method uses propensity scores weighting for emulation of baseline randomization. See the <a href="https://cran.r-project.org/web/packages/causalCmprsk/vignettes/cmp_rsk_RHC.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=ccoptimalmatch">ccoptimalmatch</a> v0.1.0: Uses sub-sampling to create pseudo-observations of controls to optimally match cases with controls. See <a href="https://bmcmedresmethodol.biomedcentral.com/articles/10.1186/s12874-021-01256-3">Mamoiris (2021)</a> for the theory and the <a href="https://cran.r-project.org/web/packages/ccoptimalmatch/vignettes/ccoptimalmatching_vignette.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=CHOIRBM">CHOIRBM</a> v0.0.2: Provides functions for visualizing body map data collected with the Collaborative Health Outcomes Information Registry <a href="https://choir.stanford.edu/">CHOIR)</a>. See the <a href="https://cran.r-project.org/web/packages/CHOIRBM/vignettes/plot-one-patient.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=clinDataReview">clinDataReview</a> v1.1.0: Provides functions to create interactive tables, listings and figures and associated reports for exploratory analysis in a clinical trial setting. There are vignettes on <a href="https://cran.r-project.org/web/packages/clinDataReview/vignettes/clinDataReview-dataPreprocessing.html">Prerocessing</a>, <a href="https://cran.r-project.org/web/packages/clinDataReview/vignettes/clinDataReview-dataVisualization.html">Visualization</a>, and <a href="https://cran.r-project.org/web/packages/clinDataReview/vignettes/clinDataReview-reporting.html">Creating Reports</a>.</p>
<p><a href="https://cran.r-project.org/package=clinUtils">clinUtils</a> v0.0.4: Provides utility functions to facilitate importing, exploring, and reporting clinical data along with datasets in <a href="https://www.cdisc.org/standards/foundational/sdtm">SDTM</a> and <a href="https://www.cdisc.org/standards/foundational/adam">ADaM</a> format. See the <a href="https://cran.r-project.org/web/packages/clinUtils/vignettes/clinUtils-vignette.html">Introduction</a>.</p>
<p><a href="https://cran.r-project.org/package=cmprskcoxmsm">cmprskcoxmsm</a> v0.2.0: Provides functions to estimate treatment effect a under marginal structure model for the cause-specific hazard of competing risk events. Functions also estimate the risk of the potential outcomes, risk difference and risk ratio. See <a href="https://www.tandfonline.com/doi/abs/10.1198/016214501753168154">Hernan et al. (2001)</a> for the theory and the <a href="https://cran.r-project.org/web/packages/cmprskcoxmsm/vignettes/weight_cause_cox.pdf">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=coder">coder</a> v0.13.5: Provides functions to classify individuals or items based on external code data identified by regular expressions. A typical use case considers patients with medically coded data, such as codes from the International Classification of Diseases. There is an <a href="https://cran.r-project.org/web/packages/coder/vignettes/coder.html">overview</a> and vignettes on <a href="https://cran.r-project.org/web/packages/coder/vignettes/classcodes.html">class codes</a>, <a href="https://cran.r-project.org/web/packages/coder/vignettes/Interpret_regular_expressions.html">interpreting regular expressions</a>, and <a href="https://cran.r-project.org/web/packages/coder/vignettes/ex_data.html">example data</a>.</p>
<p><a href="https://cran.r-project.org/package=covid19us">covid19us</a> v0.1.2: Implements wrapper around the <a href="https://covidtracking.com/api/">COVID Tracking Project API</a> providing data on cases of COVID-19 in the US.</p>
<p><a href="https://cran.r-project.org/package=covidcast">covidcast</a> v0.4.2: Provides an interface to Delphi’s <a href="https://cmu-delphi.github.io/delphi-epidata/api/covidcast.html">COVIDcast Epidata</a> including tools for data access, maps and time series plotting, and basic signal processing, and a collection of numerous indicators relevant to the COVID-19 pandemic in the United States. There is a <a href="https://cran.r-project.org/web/packages/covidcast/vignettes/covidcast.html">Getting Started Guide</a>, and vignettes on <a href="https://cran.r-project.org/web/packages/covidcast/vignettes/correlation-utils.html">Computing Signal Correlations</a>, <a href="https://cran.r-project.org/web/packages/covidcast/vignettes/external-data.html">Combining Data Sources</a>, <a href="https://cran.r-project.org/web/packages/covidcast/vignettes/multi-signals.html">Manipulating Multiple Signals</a>, and <a href="https://cran.r-project.org/web/packages/covidcast/vignettes/plotting-signals.html">Plotting and Mapping Signals</a>.</p>
<p><a href="https://cran.r-project.org/package=dataquieR">dataQuieR</a> v1.0.4: Provides functions to assess data quality issues in studies. See the <a href="https://www.tmf-ev.de/EnglishSite/Home.aspx">TMF Guideline</a> and the <a href="https://dfg-qa.ship-med.uni-greifswald.de">DFG Project</a> for background, and the <a href="https://cran.r-project.org/web/packages/dataquieR/vignettes/DQ-report-example.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=epigraphdb">epigraphdb</a> v0.2.1: Provides access to the <a href="https://epigraphdb.org">EpiGraphDB</a> platform. There is an <a href="https://cran.r-project.org/web/packages/epigraphdb/vignettes/using-epigraphdb-r-package.html">overview</a>, vignettes on the <a href="https://cran.r-project.org/web/packages/epigraphdb/vignettes/using-epigraphdb-api.html">API</a>, <a href="https://cran.r-project.org/web/packages/epigraphdb/vignettes/meta-functionalities.html">Platform Functionality</a>, <a href="https://cran.r-project.org/web/packages/epigraphdb/vignettes/meta-functionalities.html">Meta Functions</a> and three case studies on <a href="https://cran.r-project.org/web/packages/epigraphdb/vignettes/case-1-pleiotropy.html">SNP protein associations</a>, <a href="https://cran.r-project.org/web/packages/epigraphdb/vignettes/case-2-alt-drug-target.html">Drug Targets</a> and <a href="https://cran.r-project.org/web/packages/epigraphdb/vignettes/case-3-literature-triangulation.html">Causal Evidence</a></p>
<p><a href="https://cran.r-project.org/package=EpiNow2">EpiNow2</a> v1.2.1: Provides functions to estimate the time-varying reproduction number, rate of spread, and doubling time using a range of open-source tools <a href="https://wellcomeopenresearch.org/articles/5-112/v1">Abbott et al. (2020)</a> for background, <a href="https://www.medrxiv.org/content/10.1101/2020.06.18.20134858v3">Gostic et al. (2020)</a> for current best practices, and <a href="https://cran.r-project.org/web/packages/EpiNow2/readme/README.htm">README</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=escalation">escalation</a> v0.1.2: Implements methods for working with dose-finding clinical trials and includes a common interface to various dose-finding methodologies such as the continual reassessment method (CRM) by <a href="https://www.jstor.org/stable/pdf/2531628.pdf?seq=1">O’Quigley et al. (1990)</a>, the Bayesian optimal interval design (BOIN) by <a href="https://mdanderson.elsevierpure.com/en/publications/bayesian-optimal-interval-designs-for-phase-i-clinical-trials">Liu & Yuan (2015)</a>, and the 3+3 described by <a href="https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.4780131802">Korn et al. (1994)</a>. There are vignettes on <a href="https://cran.r-project.org/web/packages/escalation/vignettes/DosePaths.html">Working with dose-paths</a>, <a href="https://cran.r-project.org/web/packages/escalation/vignettes/DoseSelectorInterface.html">Working with dose selectors</a>, and
<a href="https://cran.r-project.org/web/packages/escalation/vignettes/Simulation.html">Simulating dose-escalation trials</a>.</p>
<p><a href="https://cran.r-project.org/package=eventglm">eventglm</a> v1.0.2 Implements methods for doing event history regression for marginal estimands, including cumulative incidence the restricted mean survival, as described in the methodology reviewed in <a href="https://journals.sagepub.com/doi/10.1177/0962280209105020">Andersen & Perme (2010)</a>. See the <a href="https://cran.r-project.org/web/packages/eventglm/vignettes/example-analysis.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=eventTrack">eventTrack</a> v1.0.0: Implements the hybrid framework for event prediction in clinical trials as described in <a href="https://www.sciencedirect.com/science/article/pii/S155171441100139X?via%3Dihub">Fang & Zheng (2011)</a>. See the <a href="https://cran.r-project.org/web/packages/eventTrack/vignettes/eventTrack.html">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=goldilocks">goldilocks</a> v0.3.0: Implements the Goldilocks adaptive trial design for a time to event outcome using a piecewise exponential model and conjugate Gamma prior distributions as described in <a href="https://www.tandfonline.com/doi/abs/10.1080/10543406.2014.888569?journalCode=lbps20">Broglio et al. (2014)</a>. See the <a href="https://cran.r-project.org/web/packages/goldilocks/vignettes/broglio.html">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=healthyR">healthyR</a> v0.1.1: Implements hospital data analysis workflow tools including modeling tools, and tools to review common administrative hospital data such as average length of stay, readmission rates, average net pay amounts by service lines, and more. See the <a href="https://cran.r-project.org/web/packages/healthyR/vignettes/getting-started.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=hlaR">hlaR</a> v0.1.0: Implements a tool for the eplet analysis of donor and recipient HLA (human leukocyte antigen) mismatches. There are vignettes on <a href="https://cran.r-project.org/web/packages/hlaR/vignettes/allele-haplotype.html">Imputation</a> and <a href="https://cran.r-project.org/web/packages/hlaR/vignettes/eplet-mm.html">Eplet Mismatch</a> and a <a href="https://emory-larsenlab.shinyapps.io/hlar_shiny/">Shiny App</a> as well.</p>
<p><a href="https://cran.r-project.org/package=inTextSummaryTable">inTextSummaryTable</a> v3.0.1: Provides functions to create tables of summary statistics or counts for clinical data for <a href="https://www.pharmasug.org/proceedings/2015/CP/PharmaSUG-2015-CP04.pdf">TLFs</a>. These tables can be exported as in-text table for a Clinical Study Report in MS Word format or a presentation MS PowerPoint format, or as interactive table. There is an <a href="https://cran.r-project.org/web/packages/inTextSummaryTable/vignettes/inTextSummaryTable-introduction.html">Introduction</a> and six more vignettes including <a href="https://cran.r-project.org/web/packages/inTextSummaryTable/vignettes/inTextSummaryTable-aesthetics.html">Aesthetics</a> and <a href="https://cran.r-project.org/web/packages/inTextSummaryTable/vignettes/inTextSummaryTable-visualization.html">Visualization</a>.</p>
<p><a href="https://cran.r-project.org/package=IPDfromKM">IPDfromKM</a> v0.1.10: Implements a method to reconstruct individual patient data from Kaplan-Meier (KM) survival curves, visualize and assess the accuracy of the reconstruction, and perform secondary analysis on the reconstructed data. The package also implements iterative KM estimation algorithm proposed in <a href="https://bmcmedresmethodol.biomedcentral.com/articles/10.1186/1471-2288-12-9">Guyot (2012)</a>.</p>
<p><a href="https://cran.r-project.org/package=metaSurvival">metaSurvival</a> v0.1.0: Provides a function to assess information from a summary survival curve and test the between-strata heterogeneity. See the <a href="https://github.com/shubhrampandey/metaSurvival">GitHub repo</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=nCov2019">nCov2019</a> v0.4.4: Implements an interface to <a href="https://disease.sh/">disease.sh - Open Disease Data API</a> to access real time and historical data of COVID-19 cases, vaccine and therapeutics data. There is a <a href="https://cran.r-project.org/web/packages/nCov2019/vignettes/nCov2019.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=NHSDataDictionaRy">NHSDataDictionaRy</a> v1.2.1: Provides a common set of simplified web scraping tools for working with the <a href="https://datadictionary.nhs.uk/data_elements_overview.html">NHS Data Dictionary</a>.This package was commissioned by the <a href="https://nhsrcommunity.com/">NHS-R community</a> to provide this consistency of lookups. See the <a href="https://cran.r-project.org/web/packages/NHSDataDictionaRy/vignettes/introduction.html">vignette</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=NMADiagT">NMADiagT</a> v0.1.2: Implements the hierarchical summary receiver operating characteristic model developed by <a href="doi:10.1093/biostatistics/kxx025">Ma et al. (2018)</a> and the hierarchical model developed by <a href="doi:10.1080/01621459.2018.1476239">Lian et al. (2019)</a> for performing meta-analysis. It is able to simultaneously compare one to five diagnostic tests within a missing data framework.</p>
<p><a href="https://cran.r-project.org/package=packDAMipd">packDAMipd</a> v0.1.2: Provides functions to construct both time-homogenous and time-dependent Markov models for cost-effectiveness analyses, perform decision analyses, and conduct deterministic and probabilistic sensitivity analyses. There are vignettes on <a href="https://cran.r-project.org/web/packages/packDAMipd/vignettes/Deterministic_sensitivity_analysis.html">deterministic</a> and <a href="https://cran.r-project.org/web/packages/packDAMipd/vignettes/Probabilstic_sensitivity_analysis.html">probabilistic</a> sensitivity analyses, <a href="https://cran.r-project.org/web/packages/packDAMipd/vignettes/Simple_sick_sicker.html">simple</a> “sick-sicker” models, <a href="https://cran.r-project.org/web/packages/packDAMipd/vignettes/Sick_sicker_age_dependent.html">age-dependent</a> “sick-sicker” models, and <a href="https://cran.r-project.org/web/packages/packDAMipd/vignettes/cycle_dependent.html">cycle dependent</a> models.</p>
<p><a href="https://cran.r-project.org/package=patientProfilesVis">patientProfilesVis</a> v2.0.1: Provides functions to create patient specific profile visualizations for exploration, diagnostic or monitoring purposes during a clinical trial which display the evolution of parameters such as laboratory measurements, ECG data, vital signs, adverse events and more. There is <a href="https://cran.r-project.org/web/packages/patientProfilesVis/vignettes/patientProfiles-template-SDTM.html">template</a> for creating patient profiles from CDISC SDTM datasets, and an <a href="https://cran.r-project.org/web/packages/patientProfilesVis/vignettes/patientProfilesVis-introduction.html">Introduction</a> to the package.</p>
<p><a href="https://cran.r-project.org/package=psrwe">psrwe</a> v1.2: Provides tools to incorporate real-world evidence (RWE) into regulatory and health care decision making and includes functions which implement the PS-integrated RWE analysis methods proposed in <a href="https://www.tandfonline.com/doi/abs/10.1080/10543406.2019.1657133?journalCode=lbps20">Wang et al. (2019)</a>, <a href="https://www.tandfonline.com/doi/abs/10.1080/10543406.2019.1684309?journalCode=lbps20">Wang et al. (2020)</a>, and <a href="https://www.tandfonline.com/doi/abs/10.1080/10543406.2020.1730877?journalCode=lbps20">Chen et al. (2020)</a>. There is a <a href="https://cran.r-project.org/web/packages/psrwe/vignettes/vignette.html">vignette</a> on propensity score integration.</p>
<p><a href="https://cran.r-project.org/package=QDiabetes">QDiabetes</a> v1.0-2: Calculates the risk of developing type 2 diabetes using risk prediction algorithms derived by <a href="https://clinrisk.co.uk/ClinRisk/Welcome.html">ClinRisk</a>. Look <a href="https://github.com/Feakster/qdiabetes">here</a> for information and examples.</p>
<p><a href="https://cran.r-project.org/package=raveio">raveio</a> v0.0.3: implements an interface to the <a href="https://openwetware.org/wiki/RAVE">RAVE</a> (R analysis and visualization of human intracranial electroencephalography data) project which aims at analyzing brain recordings from patients with electrodes placed on the cortical surface or inserted into the brain. See <a href="https://www.biorxiv.org/content/10.1101/2020.06.02.129676v1">Mafnotti et al. (2020)</a> for background.</p>
<p><a href="https://cran.r-project.org/package=reconstructKM">reconstructKM</a> v0.3.0: Provides functions for reconstructing individual-level data (time, status, arm) from Kaplan-MEIER curves published in academic journals. See <a href="https://www.nejm.org/doi/10.1056/NEJMc1808567">Sun et al. (2018)</a> for background and the <a href="https://cran.r-project.org/web/packages/reconstructKM/vignettes/introduction.html">vignette</a> for the reconstruction procedure.</p>
<p><a href="https://cran.r-project.org/package=ReviewR">RevieweR</a> v2.3.6: Implements a portable <code>Shiny</code> tool to explore patient-level electronic health record data and perform chart review in a single integrated framework. This tool supports the <a href="https://www.ohdsi.org/data-standardization/the-common-data-model/">OMOP</a> common data model as well as the <a href="https://mimic.physionet.org/">MIMIC-III</a> data model, and chart review through a <a href="https://www.project-redcap.org/">REDCap</a> API. See the <a href="https://reviewr.thewileylab.org/">RevieweR Website</a> for more information. There are several vignettes including <a href="https://cran.r-project.org/web/packages/ReviewR/vignettes/deploy_local.html">Local</a>, <a href="https://cran.r-project.org/web/packages/ReviewR/vignettes/deploy_docker.html">Docker</a>, <a href="https://cran.r-project.org/web/packages/ReviewR/vignettes/deploy_bigquery.html">BigQuery</a> and <a href="https://cran.r-project.org/web/packages/ReviewR/vignettes/deploy_server.html">Shiny Server</a> deployment and performing a <a href="https://cran.r-project.org/web/packages/ReviewR/vignettes/usage_perform_chart_review.html">Chart Review</a>.</p>
<p><a href="https://cran.r-project.org/package=RHRT">RHRT</a> v1.0.1: Provides methods to scan RR interval data for Premature Ventricular Complexes and parameterise and plot the resulting Heart Rate Turbulence. See <a href="https://www.thelancet.com/journals/lancet/article/PIIS0140-6736(98)08428-1/fulltext">Schmidt et al. (1999)</a> and <a href="https://iopscience.iop.org/article/10.1088/1361-6579/ab98b3">Blesius et al. (2020)</a> and the <a href="https://cran.r-project.org/web/packages/RHRT/vignettes/rhrt-vignette.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=SAMBA">SAMBA</a> v0.9.0: Implements several methods, as proposed in <a href="doi:10.1101/2019.12.26.19015859">Beesley & Mukherjee (2020)</a> for obtaining bias-corrected point estimates along with valid standard errors using electronic health records data with misclassifird EHR-derived disease status. See the <a href="https://cran.r-project.org/web/packages/SAMBA/vignettes/UsingSAMBA.html">vignette</a> for details.</p>
<p><a href="https://cran.r-project.org/package=SteppedPower">SteppedPower</a> v0.1.0: Provides tools for power and sample size calculations and design diagnostics for longitudinal mixed models with a focus on stepped wedge designs using methods introduced in <a href="https://www.sciencedirect.com/science/article/pii/S1551714406000632?via%3Dihub">Hussey and Hughes (2007)</a> and extensions discussed in <a href="https://journals.sagepub.com/doi/10.1177/0962280220932962">Li et al. (2020)</a>. See the <a href="https://cran.r-project.org/web/packages/SteppedPower/vignettes/Getting_Started.html">vignette</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=tboot">tboot</a> v0.2.0: Provides functions to simulate clinical trial data with realistic correlation structures and assumed efficacy levels by using a tilted bootstrap resampling approach. There is a tutorial on <a href="https://cran.r-project.org/web/packages/tboot/vignettes/tboot.html">The Tilted Bootstrap</a> and another on <a href="https://cran.r-project.org/web/packages/tboot/vignettes/tboot_bmr.html">Bayesian Marginal Reconstruction</a>.</p>
<p><a href="https://cran.r-project.org/package=Tplyr">Tplyr</a> v0.1.3: Implement a tool to simplify table creation and the data manipulation necessary to create clinical reports. There is a <a href="https://cran.r-project.org/package=Tplyr">Getting Started Guide</a>, and vignettes on <a href="https://cran.r-project.org/web/packages/Tplyr/vignettes/desc.html">Layers</a>, <a href="https://cran.r-project.org/web/packages/Tplyr/vignettes/options.html">Options</a>, and <a href="https://cran.r-project.org/web/packages/Tplyr/vignettes/table.html">Tables</a>.</p>
<p><a href="https://cran.r-project.org/package=visR">visR</a> v0.2.0: Provides functions to generate clinical graphs and tables with sensible defaults based on graphical principles as described in: <a href="https://onlinelibrary.wiley.com/doi/10.1002/pst.1912">Vandemeulebroecke et al. (2018)</a>, <a href="https://ascpt.onlinelibrary.wiley.com/doi/10.1002/psp4.12455">Vandemeulebroecke et al. (2019)</a>, and <a href="https://bmjopen.bmj.com/content/9/9/e030215">Morris et al. (2019)</a>. Vignettes include <a href="https://cran.r-project.org/web/packages/visR/vignettes/CDISC_ADaM.html">Survival Analysis using CDISC ADaM standard</a>, <a href="https://cran.r-project.org/web/packages/visR/vignettes/Consort_flow_diagram.html">Creating Consort Flow Diagram</a>, <a href="https://cran.r-project.org/web/packages/visR/vignettes/Styling_KM_plots.html">Styling Survival Plots</a> and <a href="https://cran.r-project.org/web/packages/visR/index.html">Survival Analysis</a>.</p>
<script>window.location.href='https://rviews.rstudio.com/2021/08/12/r-medicine-2021/';</script>
R Views Call for Documentation
https://rviews.rstudio.com/2021/08/04/r-views-blog-contest/
Wed, 04 Aug 2021 00:00:00 +0000https://rviews.rstudio.com/2021/08/04/r-views-blog-contest/
<p>We at R Views believe that the R ecosystem, centered around CRAN and Bioconductor, is the world’s largest open repository of statistical knowledge. R packages provide implementations and examples for a tremendous number of statistical methods, procedures, and algorithms. Yet, the virtual library of the R ecosystem is far from being complete. There is plenty of room for examples that explore some little travelled path of computational statistics or illuminate a familiar field with clarity. We invite you to contribute to expanding the knowledge available in the R ecosystem through blogging.</p>
<p>Documentation for R packages begins with the package pdf file which provides a detailed description for each individual function, indicates relationships among functions and often includes references to the statistical and scientific literature. Going down an organizational level you can view the source code for each function. Moving up a level, README files and package vignettes provide a coherent overview of the capabilities of the package as a whole and often include example and elaborate use cases.</p>
<p>While the burden to explain what R packages do falls mainly on package authors, all of us data scientists, statisticians, researchers, students and “ordinary” R users can add to the knowledge encoded in R by elaborating on the capabilities of R functions and packages, developing additional examples and contributing statistical analyses in areas where we may have developed some expertise.</p>
<p><img src="https://imgs.xkcd.com/comics/unpublished_discoveries.png" height = "300" width="500">
<sup><a href="https://www.explainxkcd.com/wiki/index.php/1805:_Unpublished_Discoveries">xkcd 1805 Unpublished Discoveries</a></sup></p>
<p>We are not talking about Nobel Laureate work here. But nearly everyone who regularly uses R has some gem stashed away somewhere. We are looking to mine those gems and organize them in a way that can be shared with the R Community.</p>
<p>We are asking you to please dig up your gem and organize it into a blog post. Tell us what your gem does, how it works, and why it is of some value. Some of the most popular R Views posts introduce technical topics by providing R based tutorials. Others show how to efficiently accomplish everyday tasks or present an elegant calculation or visualization. Think in terms of a well explained example, or if you are really ambitious, you could write that package vignette that you wish existed. Look below for some guidance on more elaborate ideas.</p>
<h2 id="call-for-posts">Call for Posts</h2>
<p>Please submit you posts using the following form: <a href="https://rstd.io/rviews-2021">rstd.io/rviews-2021</a>. All submissions will appear on the <a href="https://community.rstudio.com/c/60"><em>Call for Docs</em></a> page on the RStudio Community Site, and you will need an RStudio Community profile.</p>
<p>The deadline for submission is <strong>Friday, September 23, 2021</strong>. We planning awards of a sort to the best entries and would like to announce these by November 1, 2021.</p>
<h3 id="awards">Awards</h3>
<p>The award categories and the associated prizes are as follows:</p>
<ul>
<li><strong>Honorable Mentions</strong>:
<ul>
<li>One year free RStudio Cloud Premium</li>
<li>A bunch of hex stickers of RStudio packages</li>
</ul></li>
<li><strong>Runners Up</strong>:
<ul>
<li>All prizes listed above, plus</li>
<li>Some number of RStudio t-shirts, books, and mugs (worth up to $200)</li>
</ul></li>
<li><strong>Grand Prizes</strong>:
<ul>
<li>All prizes listed above, plus</li>
<li>Special & persistent recognition by RStudio in the form of a winners page, and a badge that will be publicly visible on your RStudio Community profile</li>
<li>A selected group of submissions will be invited to appear on R Views</li>
</ul></li>
</ul>
<p><sup>* Please note that we may not be able to send t-shirts, books, or other larger items to non-US addresses.</sup><br>
<sup>* Please note that all articles on R Views will go through an editorial review before being published there.</sup><br>
<sup>* With the author’s permission, some posts may appear on R Views before the awards announcements. </sup>.</p>
<h3 id="announcement">Announcement</h3>
<p>The names and work of all winners will be highlighted in an announcement on R Views, and we will announce them on RStudio’s social platforms, including RStudio Community (unless the winner prefers not to be mentioned).</p>
<h2 id="need-inspiration">Need inspiration?</h2>
<ul>
<li>Edgar Ruiz <a href="https://rviews.rstudio.com/2019/06/19/a-gentle-intro-to-tidymodels/">Gentle Introduction to tidymodels</a> is a good example of a homemade package vignette.</li>
<li>Jonathan Regenstein’s series on <a href="https://rviews.rstudio.com/categories/reproducible-finance-with-r/">Reproducible Finance with R</a> presents several masterful examples of Financial use cases.</li>
</ul>
<h2 id="guidance">Guidance</h2>
<ul>
<li>Posts should be well-written, contain enough code to support the main argument and have a few plots and/or tables.</li>
<li><strong>Novelty</strong> - We are looking for original content. That is, your article should not have appeared on blogging platforms, other than your personal website or blog.</li>
<li><strong>Contribution</strong> - Your article should provide novel insight and utility. For example, an exploration of a package or use case that is currently poorly documented will be better received than one which already has excellent documentation and vignettes either on CRAN or in the R community.</li>
<li><strong>Reproducible</strong> - Your submission will need to link to a repo which includes an .Rmd file that reproduces all code, images, and other output in the submitted article. If there is code that requires special resources, such as access to a private database, it is fine to simply refer to these in your repo.</li>
<li><strong>Please confine your posts to less than 1,000 words</strong>, excluding code and image captions. Your article should be self-contained, but may refer to additional content on your repo or personal website.</li>
</ul>
<h3 id="categories">Categories</h3>
<ul>
<li><strong>Homemade Package Vignette</strong> - Package authors put in a lot of effort to build their library and the documentation that supports it, but they can’t cover everything. They may not have developed a vignette yet, or written additional documentation explaining the set of functionality that is especially useful.
With this type of article, introduce readers to a package – or small group of packages – highlighting interesting features or extensions. It should not replicate any existing documentation, instead it should be distinct from – and complementary to – any existing package documentation.</li>
<li><strong>Entry Point into a Topic</strong> - It’s often daunting to get started as you’re exploring a new field or approaching a new problem or methodology. It’s incredibly pleasing when you find the resource that serves as your entry point into that new domain, demystifying the space, pointing out useful packages and examples, getting you started on your work. With this article type, explore resources centered around one problem, highlighting how R helps you approach it.</li>
</ul>
<script>window.location.href='https://rviews.rstudio.com/2021/08/04/r-views-blog-contest/';</script>
June 2021: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2021/07/26/june-2021-top-40-new-cran-packages/
Mon, 26 Jul 2021 00:00:00 +0000https://rviews.rstudio.com/2021/07/26/june-2021-top-40-new-cran-packages/
<p>One hundred ninety-seven new packages made it to CRAN in June. Here are my selections for the “Top 40” in ten categories: Computational Methods, Data, Finance, Genomics, Machine Learning, Medicine, Statistics, Time Series, Utilities, and Visualization. The Medicine category includes multiple packages for medical reporting and table building. Note that eight new packages were removed from CRAN by the time I began my research for this post on July 16th, so they were not considered for the “Top 40”.</p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=disordR">disordR</a> v0.0-2: Provides tools for manipulating values of associative maps which are stored in arbitrary order. When associating keys with values one needs both parts to be in 1-1 correspondence. See the <a href="https://cran.r-project.org/web/packages/disordR/vignettes/disordR.html">vignette</a> for the theory and examples.</p>
<p><a href="https://cran.r-project.org/package=ICvectorfields">ICvectorfields</a> v0.0.2: Provides functions for converting time series of spatial abundance or density data in raster format to vector fields of population movement using the digital image correlation technique. See the <a href="https://cran.r-project.org/web/packages/ICvectorfields/vignettes/Using_ICvectorfields.html">vignette</a>.</p>
<p><img src="ICvectorfields.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=rim">rim</a> v0.4.1: Provides an interface to the computer algebra system <a href="https://maxima.sourceforge.io/">Maxima</a> which includes running Maxima commands from within R, generating output in LaTeX and <a href="https://www.w3.org/Math/">MathML</a> and R Markdown. Look <a href="https://rcst.github.io/rim/">here</a> for examples.</p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=PlanetNICFI">PlanetNICFI</a> v1.0.3: Provides functions to download and process <a href="https://www.planet.com/nicfi/">Planet NICFI</a> satellite imagery from Norway’s International Climate and Forest Initiative utilizing the <a href="https://developers.planet.com/docs/basemaps/reference/#tag/Basemaps-and-Mosaics">Planet Mosaics API</a>. See the <a href="https://cran.r-project.org/web/packages/PlanetNICFI/vignettes/planet_nicfi_functionality.html">vignette</a>.</p>
<p><img src="PlanetNICFI.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=rgovcan">rgovcan</a> v1.0.3: Provides access to data and other resources available through the <a href="https://open.canada.ca/en">Canadian Open Government portal</a>. See <a href="https://cran.r-project.org/web/packages/rgovcan/readme/README.html">README</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=wcde">wcde</a> v0.0.1: Implements an interface to the <a href="http://dataexplorer.wittgensteincentre.org/">Wittgenstein Human Capital Data Explorer</a>. See the <a href="https://cran.r-project.org/web/packages/wcde/vignettes/intro.html">vignette</a> for an overview.</p>
<p><img src="wcde.png" height = "500" width="300"></p>
<h3 id="finance">Finance</h3>
<p><a href="https://cran.r-project.org/package=etrm">etrm</a> v1.0.1: Provides functions to perform core tasks within Energy Trading and Risk Management including calculating maximum smoothness forward price curves for electricity and natural gas contracts with flow delivery, as presented in <a href="https://jod.pm-research.com/content/15/1/52">Benth et al. (2007)</a> and portfolio insurance trading strategies for price risk management in the forward market as described in <a href="https://www.sciencedirect.com/science/article/abs/pii/0304405X76900246?via%3Dihub">Black (1976)</a>. There are vignettes describing the <a href="https://cran.r-project.org/web/packages/etrm/vignettes/msfc_forward_curve.html">Maximum Smoothness Forward Curve</a> and <a href="https://cran.r-project.org/web/packages/etrm/vignettes/portfolio_insurance_strategies.html">Portfolio Insurance Trading Strategies</a>.</p>
<p><img src="etrm.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=mshap">mshap</a> v0.1.0: Provides functions to compute <em>mSHAP</em> values on two-part models as proposed by <a href="https://arxiv.org/abs/2106.08990">Matthews & Hartman (2021)</a> using the <em>TreeSHAP</em> algorithm described in <a href="https://www.nature.com/articles/s42256-019-0138-9">Lundberg et al. (2020)</a>. See the vignettes <a href="https://cran.r-project.org/web/packages/mshap/vignettes/mSHAP.html">mSHAP</a> and <a href="https://cran.r-project.org/web/packages/mshap/vignettes/mshap_plots.html">mshap plots</a>.</p>
<p><img src="mshap.png" height = "400" width="400"></p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=harmony">harmony</a> v0.1.0: Implements the harmony algorithm for single cell integration described in <a href="https://www.nature.com/articles/s41592-019-0619-0">Korsunsky et al. (2019)</a>. See the <a href="https://cran.r-project.org/web/packages/harmony/vignettes/quickstart.html">vignette</a>.</p>
<p><img src="harmony.jpeg" height = "300" width="500"></p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=AutoScore">AutoScore</a> v0.2.0: Implements an interpretable machine learning framework to automate the development of a clinical scoring model for predefined outcomes. See <a href="https://medinform.jmir.org/2020/10/e21798/">Xie et al. 2020</a> for the details, and the <a href="https://cran.r-project.org/web/packages/AutoScore/vignettes/Guide_book.html">Guide Book</a> to get started.</p>
<p><img src="AutoScore.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=daiR">daiR</a> v0.9.0: Implements an interface for the Google Cloud Services <a href="https://cloud.google.com/document-ai/">Document AI API</a> with additional tools for output file parsing and text reconstruction. See the <a href="https://dair.info/">package website</a> for more information and examples. There are six vignettes including a <a href="https://cran.r-project.org/web/packages/daiR/vignettes/using_document_ai.html">User Guide</a>, <a href="https://cran.r-project.org/web/packages/daiR/vignettes/basics.html">Basic processing</a>, and <a href="https://cran.r-project.org/web/packages/daiR/vignettes/extracting_tables.html">Extracting Tables</a>.</p>
<p><img src="daiR.png" height = "500" width="300"></p>
<p><a href="https://cran.r-project.org/package=luz">luz</a> v0.1.0: Implements a high level interface to <a href="https://en.wikipedia.org/wiki/Torch_(machine_learning)">torch</a> providing utilities to reduce the the amount of code needed for common tasks, abstract away torch details and make the same code work on both CPUs and GPUs. See <a href="https://arxiv.org/abs/2002.04688">Howard et al. (2020)</a> and <a href="https://zenodo.org/record/3828935#.YPitIxNKj0o">Falcon et al. (2019)</a> for background and the vignettes <a href="https://cran.r-project.org/web/packages/luz/vignettes/get-started.html">Get started with Luz</a>, <a href="https://cran.r-project.org/web/packages/luz/vignettes/custom-loop.html">Custom Loops</a> and <a href="https://cran.r-project.org/web/packages/luz/vignettes/accelerator.html">Accelerator API</a>.</p>
<p><a href="https://cran.r-project.org/package=mcboost">mcboost</a> v0.3.0: Implements <a href="https://proceedings.mlr.press/v80/hebert-johnson18a.html">Multi-Calibration Boosting</a> and <a href="https://arxiv.org/abs/1805.12317">Multi-Accuracy Boosting</a> to for the multi-calibrate the predictions of machine learning models. See the vignettes <a href="https://cran.r-project.org/web/packages/mcboost/vignettes/mcboost_basics_extensions.html">Basics and Extensions</a> and <a href="https://cran.r-project.org/web/packages/mcboost/vignettes/mcboost_example.html">Health Survey Example</a>.</p>
<p><a href="https://cran.r-project.org/package=RFpredInterval">RFpredInterval</a> v1.0.2: Implements various prediction interval methods with random forests and boosted forests. See <a href="https://arxiv.org/abs/2106.08217">Alakus et al. (2021)</a> and <a href="https://journals.sagepub.com/doi/10.1177/0962280219829885">Roy and Larocque (2020)</a> for the mathematical background.</p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=aldvmm">aldvmm</a> v0.8.4: Fits health state utility adjusted limited dependent variable mixture models, i.e. finite mixtures of normal distributions with an accumulation of density mass at the limits, and a gap between 100% quality of life and the next smaller utility value. See <a href="https://journals.sagepub.com/doi/10.1177/1536867X1501500307">Alava and Wailoo (2015)</a> for background and the <a href="https://cran.r-project.org/web/packages/aldvmm/vignettes/aldvmm_vignette.pdf">vignette</a> for an example.</p>
<p><img src="aldvmm.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=clinDataReview">clinDataReview</a> v1.1.0: Provides functions to create interactive tables, listings and figures and associated reports for exploratory analysis in a clinical trial setting. There are vignettes on <a href="https://cran.r-project.org/web/packages/clinDataReview/vignettes/clinDataReview-dataPreprocessing.html">Prerocessing</a>, <a href="https://cran.r-project.org/web/packages/clinDataReview/vignettes/clinDataReview-dataVisualization.html">Visualization</a>, and <a href="https://cran.r-project.org/web/packages/clinDataReview/vignettes/clinDataReview-reporting.html">Creating Reports</a>.</p>
<p><img src="clin.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=clinUtils">clinUtils</a> v0.0.4: Provides utility functions to facilitate importing, exploring, and reporting clinical data along with datasets in <a href="https://www.cdisc.org/standards/foundational/sdtm">SDTM</a> and <a href="https://www.cdisc.org/standards/foundational/adam">ADaM</a> format. See the <a href="https://cran.r-project.org/web/packages/clinUtils/vignettes/clinUtils-vignette.html">Introduction</a>.</p>
<p><a href="https://cran.r-project.org/package=inTextSummaryTable">inTextSummaryTable</a> v3.0.1: Provides functions to create tables of summary statistics or counts for clinical data for <a href="https://www.pharmasug.org/proceedings/2015/CP/PharmaSUG-2015-CP04.pdf">TLFs</a>. These tables can be exported as in-text table for a Clinical Study Report in MS Word format or a presentation MS PowerPoint format, or as interactive table. There is an <a href="https://cran.r-project.org/web/packages/inTextSummaryTable/vignettes/inTextSummaryTable-introduction.html">Introduction</a> and six more vignettes including <a href="https://cran.r-project.org/web/packages/inTextSummaryTable/vignettes/inTextSummaryTable-aesthetics.html">Aesthetics</a> and <a href="https://cran.r-project.org/web/packages/inTextSummaryTable/vignettes/inTextSummaryTable-visualization.html">Visualization</a>.</p>
<p><img src="inText.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=patientProfilesVis">patientProfilesVis</a> v2.0.1: Provides functions to create patient specific profile visualizations for exploration, diagnostic or monitoring purposes during a clinical trial which display the evolution of parameters such as laboratory measurements, ECG data, vital signs, adverse events and more. There is <a href="https://cran.r-project.org/web/packages/patientProfilesVis/vignettes/patientProfiles-template-SDTM.html">template</a> for creating patient profiles from CDISC SDTM datasets, and an <a href="https://cran.r-project.org/web/packages/patientProfilesVis/vignettes/patientProfilesVis-introduction.html">Introduction</a> to the package.</p>
<p><img src="patient.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=RHRT">RHRT</a> v1.0.1: Provides methods to scan RR interval data for Premature Ventricular Complexes and parameterise and plot the resulting Heart Rate Turbulence. See <a href="https://www.thelancet.com/journals/lancet/article/PIIS0140-6736(98)08428-1/fulltext">Schmidt et al. (1999)</a> and <a href="https://iopscience.iop.org/article/10.1088/1361-6579/ab98b3">Blesius et al. (2020)</a> and the <a href="https://cran.r-project.org/web/packages/RHRT/vignettes/rhrt-vignette.html">vignette</a> for examples.</p>
<p><img src="RHRT.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=visR">visR</a> v0.2.0: Provides functions to generate clinical graphs and tables with sensible defaults based on graphical principles as described in: <a href="https://onlinelibrary.wiley.com/doi/10.1002/pst.1912">Vandemeulebroecke et al. (2018)</a>, <a href="https://ascpt.onlinelibrary.wiley.com/doi/10.1002/psp4.12455">Vandemeulebroecke et al. (2019)</a>, and <a href="https://bmjopen.bmj.com/content/9/9/e030215">Morris et al. (2019)</a>. Vignettes include <a href="https://cran.r-project.org/web/packages/visR/vignettes/CDISC_ADaM.html">Survival Analysis using CDISC ADaM standard</a>, <a href="https://cran.r-project.org/web/packages/visR/vignettes/Consort_flow_diagram.html">Creating Consort Flow Diagram</a>, <a href="https://cran.r-project.org/web/packages/visR/vignettes/Styling_KM_plots.html">Styling Survival Plots</a> and <a href="https://cran.r-project.org/web/packages/visR/index.html">Survival Analysis</a>.</p>
<p><img src="visR.png" height = "300" width="500"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=admix">admix</a> v0.3.2: Implements several methods to estimate the unknown quantities related to two-component admixture models, where the two components can belong to any distribution. See <a href="https://link.springer.com/article/10.3103%2FS1066530710010023">Bordes & Vandekerkhove (2010)</a>, <a href="https://rss.onlinelibrary.wiley.com/doi/10.1111/rssb.12148">Patra & Sen (2016)</a>, and <a href="https://hal.archives-ouvertes.fr/hal-03201760">Milhaud et al. (2021)</a> for background. There are vignettes on <a href="https://cran.r-project.org/web/packages/admix/vignettes/admixture-clustering.html">Clusterine</a>, <a href="https://cran.r-project.org/web/packages/admix/vignettes/admixture-weight-estimation.html">Estimation</a>, and <a href="https://cran.r-project.org/web/packages/admix/vignettes/test-hypothesis.html">Hypothesis Testing</a>.</p>
<p><a href="https://cran.r-project.org/package=ahMLE">ahMLE</a> v1.18: Implements methods for fitting additive hazards model which include the maximum likelihood method as well as Aalen’s method for estimating the additive hazards model. See <a href="https://arxiv.org/abs/2004.06156">Chengyuan Lu(2021)</a> for details and the <a href="https://cran.r-project.org/web/packages/ahMLE/vignettes/ahMLE_manual.html">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=bayesrules">bayesrules</a> v0.0.1: Provides datasets and functions used for analysis and visualizations in the online <a href="https://www.bayesrulesbook.com">Bayes Rules</a> book. There is a vignette on <a href="https://cran.r-project.org/web/packages/bayesrules/vignettes/conjugate-families.html">Conjugate Families</a> and another on <a href="https://cran.r-project.org/web/packages/bayesrules/vignettes/model-evaluation.html">Model Evaluation</a>.</p>
<p><img src="bayesrules.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=dbglm">dbglm</a> v1.0.0: Provides a function to fit generalized linear models on moderately large datasets, by taking an initial sample, fitting in memory, then evaluating the score function for the full data in the database. See <a href="https://www.tandfonline.com/doi/abs/10.1080/10618600.2019.1610312?journalCode=ucgs20">Lumley (2019)</a> for the details.</p>
<p><a href="https://cran.r-project.org/package=fasano.franceschini.test">fasano.franceschini.test</a> v1.0.1: Implements the the 2-D Kolmogorov-Smirnov (KS) two-sample test as defined in <a href="https://academic.oup.com/mnras/article/225/1/155/1007281">Fasano & Franceschini (1987)</a>. See the <a href="https://cran.r-project.org/web/packages/fasano.franceschini.test/vignettes/fasano-franceschini-test.html">vignette</a> for examples.</p>
<p><img src="ff.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=flatness">flatness</a> v0.1.4: Provides S3 classes, plotting functions, indices and tests to analyze the flatness of histograms including functions for flatness tests introduced in <a href="https://journals.ametsoc.org/view/journals/mwre/136/6/2007mwr2219.1.xml">Jolliffe & Primo (2008)</a>, flatness indices described in <a href="https://journals.ametsoc.org/view/journals/mwre/147/2/mwr-d-18-0369.1.xml">Wilks (2019)</a>, and the procedure for multiple hypothesis described in <a href="https://rss.onlinelibrary.wiley.com/doi/10.1111/j.2517-6161.1995.tb02031.x">Benjamini & Hochberg (1995)</a>. See the <a href="https://cran.r-project.org/web/packages/flatness/vignettes/flatness.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=outlierensembles">outlierensembles</a> v0.1.0: Provides ensemble functions for detecting outliers and anomalies including a new method based on Item Response Theory described in <a href="https://arxiv.org/abs/2106.06243">Kandanaarachchi (2021)</a> and methods described in <a href="https://epubs.siam.org/doi/10.1137/1.9781611972825.90">Schubert et al. (2012)</a>, <a href="https://www.sciencedirect.com/science/article/pii/S1570868316301240?via%3Dihub">Chiang et al. (2017)</a>, and <a href="https://dl.acm.org/doi/10.1145/2830544.2830549">Aggarwal and Sathe (2015)</a>. See the <a href="https://cran.r-project.org/web/packages/outlierensembles/vignettes/outlierensembles.html">vignette</a> for examples.</p>
<p><img src="outlier.png" height = "300" width="250"></p>
<p><a href="https://cran.r-project.org/package=susieR">susieR</a> v0.11.42: Implements methods for variable selection in linear regression based on the <em>Sum of Single Effects</em> model, as described in <a href="https://www.biorxiv.org/content/10.1101/501114v4">Wang et al (2020)</a>. The <em>Iterative Bayesian Stepwise Selection</em> algorithm allows fitting models to large data sets with thousands of samples and hundreds of thousands of variables. There are ten short vignettes including <a href="https://cran.r-project.org/web/packages/susieR/vignettes/trendfiltering_derivations.pdf">Trend Fitting</a> and a <a href="https://cran.r-project.org/web/packages/susieR/vignettes/mwe.html">minimal example</a>.</p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=psdr">psdr</a> v1.0.1: Provides functions to generate and compare power spectral density plots given time series data and to compare the dominant frequencies of multiple groups of time series. Look <a href="https://www.mathworks.com/help/matlab/ref/fft.html">here</a> and <a href="https://www.mathworks.com/help/signal/ug/power-spectral-density-estimates-using-fft.html">here</a> for the mathematical background. For examples look <a href="https://yhhc2.github.io/psdr/articles/Introduction.html">here</a> or see this <a href="https://cran.r-project.org/web/packages/psdr/vignettes/Examples.html">vignette</a>. There is also an <a href="https://cran.r-project.org/web/packages/psdr/vignettes/Introduction.html">Introduction</a>.</p>
<p><img src="psdr.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=proteus">proteus</a> v1.0.0 Implements a <em>Sequence-to-Sequence Variational Model</em> for time-feature analysis based on a wide range of different distributions. Look <a href="https://rpubs.com/giancarlo_vercellino/proteus">here</a> for an overview with examples.</p>
<p><img src="proteus.png" height = "300" width="500"></p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=archive">archive</a> v1.0.2: Implements bindings to <a href="http://www.libarchive.org">libarchive</a>, the multi-format archive and compression library which offer connections and direct extraction for many archive formats including <code>tar</code>, <code>ZIP</code>, <code>7-zip</code>, <code>RAR</code>, <code>CAB</code> and compression formats including <code>gzip</code>, <code>bzip2</code>, <code>compress</code>, <code>lzma</code> and <code>xz</code>. See <a href="https://cran.r-project.org/web/packages/archive/readme/README.html">README</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=pasadr">pasadr</a> v1.0: Implements the anomaly detection method described in <a href="https://dl.acm.org/doi/10.1145/3243734.3243781">Aoudi et al. (2018)</a>.</p>
<p><a href="https://cran.r-project.org/package=recogito">recogito</a> v0.1.1: Provides <code>htmlwidgets</code> bindings to the <a href="https://github.com/recogito/recogito-js">recogito</a> and <a href="https://github.com/recogito/annotorious">annotorious</a> libraries to annotate text and areas of interest in images. See <a href="https://cran.r-project.org/web/packages/recogito/readme/README.html">README</a> to get started.</p>
<p><img src="recogito.gif" height = "500" width="600"></p>
<p><a href="https://cran.r-project.org/package=rextendr">rextendr</a> v0.2.0: Provides functions to compile and load <a href="https://www.rust-lang.org/">Rust</a> code from R along with helper functions to create R packages that use Rust code. There is a vignette on <a href="https://cran.r-project.org/web/packages/rextendr/vignettes/package.html">Using Rust code in R packages</a> and another on <a href="https://cran.r-project.org/web/packages/rextendr/vignettes/setting_up_rust.html">Setting up Rust</a>.</p>
<p><a href="https://cran.r-project.org/package=shinymeta">shinymeta</a> v0.2.0.1: Provides tools for capturing logic in a Shiny app and exposing it as code that can be run outside of Shiny (e.g., from an R console). It also provides tools for bundling both the code and results to the end user. See <a href="https://cran.r-project.org/web/packages/shinymeta/readme/README.html">README</a> for examples</p>
<p><img src="shinymeta.gif" height = "300" width="400"></p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=dynplot">dynplot</a> v1.1.1: Provides functions to visualize a single-cell trajectory as a graph or dendrogram as a dimensionality reduction or heatmap of the expression data, or a comparison between two trajectories as a pairwise scatterplot or dimensionality reduction projection. See <a href="https://www.nature.com/articles/s41587-019-0071-9">Saelens et al. (2019)</a> for background and the <a href="https://cran.r-project.org/web/packages/dynplot/vignettes/plotting-a-toy.html">vignette</a> for examples.</p>
<p><img src="dynplot.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=gridpattern">gridpattern</a> 0.2.1: Provides <em>grid grabs</em> to fill in a user-defined plot area with various patterns, including geometric and image-based patterns, and support for custom user-defined patterns. There is a <a href="https://cran.r-project.org/web/packages/gridpattern/vignettes/tiling.html">vignette</a>.</p>
<p><img src="gridpattern.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=netplot">netplot</a> v0.1-1: Implements a graph visualization engine that puts an emphasis on aesthetics while providing default parameters that yield <em>out-of-the-box-nice</em> visualizations. There is a vignette with <a href="https://cran.r-project.org/web/packages/netplot/vignettes/base-and-grid.html">base plot </a> examples, and another showing graph drawing with <a href="https://cran.r-project.org/web/packages/netplot/vignettes/examples.html">netplot</a>.</p>
<p><img src="netplot.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=NGLVieweR">NGLVieweR</a> v1.3.1: Implements an <a href="https://www.htmlwidgets.org/">htmlwidgets</a> interface to <a href="http://nglviewer.org/ngl/api/">NGL.js</a> enabling users to visualize and interact with protein databank <a href="https://www.rcsb.org/">PDB</a> and structural files in R and Shiny applications. See the <a href="https://cran.r-project.org/web/packages/NGLVieweR/vignettes/NGLVieweR.html">vignette</a> for examples.</p>
<p><img src="NGLVieweR.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=precisePlacement">precisePlacement</a> v0.1.0: Provides a selection of tools that make it easier to place elements onto a base R plot exactly where you want them. See the <a href="https://cran.r-project.org/web/packages/precisePlacement/vignettes/Overview.html">vignette</a> for an overview.</p>
<p><img src="precise.png" height = "300" width="300"></p>
<script>window.location.href='https://rviews.rstudio.com/2021/07/26/june-2021-top-40-new-cran-packages/';</script>
Exploratory Functional PCA with Sparse Data
https://rviews.rstudio.com/2021/07/08/exploratory-fda-with-sparse-data/
Thu, 08 Jul 2021 00:00:00 +0000https://rviews.rstudio.com/2021/07/08/exploratory-fda-with-sparse-data/
<script src="/2021/07/08/exploratory-fda-with-sparse-data/index_files/header-attrs/header-attrs.js"></script>
<script src="/2021/07/08/exploratory-fda-with-sparse-data/index_files/htmlwidgets/htmlwidgets.js"></script>
<script src="/2021/07/08/exploratory-fda-with-sparse-data/index_files/plotly-binding/plotly.js"></script>
<script src="/2021/07/08/exploratory-fda-with-sparse-data/index_files/typedarray/typedarray.min.js"></script>
<script src="/2021/07/08/exploratory-fda-with-sparse-data/index_files/jquery/jquery.min.js"></script>
<link href="/2021/07/08/exploratory-fda-with-sparse-data/index_files/crosstalk/css/crosstalk.css" rel="stylesheet" />
<script src="/2021/07/08/exploratory-fda-with-sparse-data/index_files/crosstalk/js/crosstalk.min.js"></script>
<link href="/2021/07/08/exploratory-fda-with-sparse-data/index_files/plotly-htmlwidgets-css/plotly-htmlwidgets.css" rel="stylesheet" />
<script src="/2021/07/08/exploratory-fda-with-sparse-data/index_files/plotly-main/plotly-latest.min.js"></script>
<p>I have written about the basics of Functional Data Analysis in three prior posts. In <a href="https://rviews.rstudio.com/2021/05/04/functional-data-analysis-in-r/">Post 1</a>, I used the <a href="https://cran.r-project.org/package=fda"><code>fda</code></a> package to introduce the fundamental concept of using basis vectors to represent longitudinal or time series data as a curve in an abstract vector space. In <a href="https://rviews.rstudio.com/2021/05/14/basic-fda-descriptive-statistics-with-r/">Post 2</a>, I continued to rely on the <code>fda</code> package to show basic FDA descriptive statistics. In <a href="https://rviews.rstudio.com/2021/06/10/functional-pca-with-r/">Post 3</a>, I introduced Functional PCA with the help of the <a href="https://cran.r-project.org/package=fdapace"><code>fdapace</code></a> package. In this post, I pick up where that last post left off and look at how one might explore a sparse, longitudinal data set with the FPCA tools provided in the <code>fdapace</code> package. I will begin by highlighting some of the really nice tools available in the <a href="https://cran.r-project.org/package=brolgar"><code>brolgar</code></a> package for doing exploratory longitudinal data analysis. While the first three posts made do with artificial data constructed with an algorithm for generating data from a Wiener Process, in this post I’ll use the <code>wages</code> data set available in <code>brolgar</code>.</p>
<p><code>brolgar</code> is a beautiful, tidyverse inspired package, based on the <a href="https://tsibble.tidyverts.org/"><code>tsibble</code></a> data structure that offers a number of super helpful functions for visualizing and manipulating longitudinal data. See the arXiv paper <a href="https://arxiv.org/abs/2012.01619">Tierney, Cook and Prvan (2021)</a> for an overview, and the seven package vignettes for examples. Collectively, these vignettes offer a pretty thorough exploration of the <code>wages</code> data set. Using <code>wages</code> for this post should provide a feeling for what additional insight FDA may have to offer.</p>
<div id="longitudinal-data" class="section level3">
<h3>Longitudinal Data</h3>
<p>Let’s look at the data. <code>wages</code> contains measurements on hourly wages associated with years of experience in the workforce along with several covariates for male high school dropouts who were between 14 and 17 years old when first measured. In what follows, I will use only<code>ln_wages</code>, the natural log of wages in 1990 dollars, and <code>xp</code> the number of years of work experience.</p>
<pre class="r"><code>library(brolgar)
library(fdapace)
library(tidyverse)
library(plotly)
dim(wages)</code></pre>
<pre><code>## [1] 6402 9</code></pre>
<pre class="r"><code>head(wages)</code></pre>
<pre><code>## # A tsibble: 6 x 9 [!]
## # Key: id [1]
## id ln_wages xp ged xp_since_ged black hispanic high_grade
## <int> <dbl> <dbl> <int> <dbl> <int> <int> <int>
## 1 31 1.49 0.015 1 0.015 0 1 8
## 2 31 1.43 0.715 1 0.715 0 1 8
## 3 31 1.47 1.73 1 1.73 0 1 8
## 4 31 1.75 2.77 1 2.77 0 1 8
## 5 31 1.93 3.93 1 3.93 0 1 8
## 6 31 1.71 4.95 1 4.95 0 1 8
## # … with 1 more variable: unemploy_rate <dbl></code></pre>
<p>A summary of the variables shows that wages vary from 2 dollars per hour to a high of about 73 dollars per hour. Time varies between 0 and almost 13 years.</p>
<pre class="r"><code>wages %>% select(ln_wages, xp) %>% summary()</code></pre>
<pre><code>## ln_wages xp id
## Min. :0.708 Min. : 0.001 Min. : 31
## 1st Qu.:1.591 1st Qu.: 1.609 1st Qu.: 3194
## Median :1.842 Median : 3.451 Median : 6582
## Mean :1.897 Mean : 3.957 Mean : 6301
## 3rd Qu.:2.140 3rd Qu.: 5.949 3rd Qu.: 9300
## Max. :4.304 Max. :12.700 Max. :12543</code></pre>
<p>Next, we construct the <code>tsibble</code> data structure to make use of some of the very convenient <code>brolgar</code> sampling functions, and count the number of observations for each subject.</p>
<pre class="r"><code>wages_t <- as_tsibble(wages,
key = id,
index = xp,
regular = FALSE)
num_obs <- wages_t %>% features(ln_wages,n_obs)
summary(num_obs$n_obs)</code></pre>
<pre><code>## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.00 5.00 8.00 7.21 9.00 13.00</code></pre>
<p>Just like the <code>brolgar</code> package vignettes, we filter out subjects with less than 3 observations. Then we use the <code>sample_n_keys()</code> function to generate a random sample of 10 wages versus year’s experience curves and plot them.</p>
<pre class="r"><code>df <- wages_t %>% add_n_obs() %>% filter(n_obs > 3)
set.seed(123)
df %>%
sample_n_keys(size = 10) %>%
ggplot(aes(x = xp, y = ln_wages, group = id, color = id)) +
geom_line()</code></pre>
<p><img src="/2021/07/08/exploratory-fda-with-sparse-data/index_files/figure-html/unnamed-chunk-4-1.png" width="672" /></p>
<p><code>brolgar</code> makes it easy to generates lots of panels with small numbers of curves in order to get a feel for the data.</p>
<pre class="r"><code>df %>% ggplot(aes(x = xp, y = ln_wages, group = id, colour = id)) +
geom_line() +
facet_sample(n_per_facet = 3, n_facets = 20)</code></pre>
<p><img src="/2021/07/08/exploratory-fda-with-sparse-data/index_files/figure-html/unnamed-chunk-5-1.png" width="672" /></p>
<p>Finally, for comparison with the plots produced by <code>fdapace</code> we plot the curves for the first two subjects in the <code>tsibble</code>.</p>
<pre class="r"><code>df %>% filter(id == 31 | id == 36) %>%
ggplot(aes(x = xp, y = ln_wages, group = id, color = id)) +
geom_line()</code></pre>
<p><img src="/2021/07/08/exploratory-fda-with-sparse-data/index_files/figure-html/unnamed-chunk-6-1.png" width="672" /></p>
<p>We finish our initial look at the data by noting that we are really dealing with sparse data here. Some curves have only 4 measurements, no curve has more than 13 measurements, and all subjects were measured at different times. This is a classic longitudinal data set.</p>
</div>
<div id="functional-pca" class="section level3">
<h3>Functional PCA</h3>
<p>As I mentioned in my previous post, Principal Components by Conditional Expectation (PACE), described in <a href="https://anson.ucdavis.edu/~mueller/jasa03-190final.pdf">Yao, Müller & Wang (2005)</a>, was designed for sparse data. The method works by pooling the data. Curves are not individually smoothed. Instead, estimates of the FPC scores are obtained from the entire ensemble of data. (See equation (5) in the reference above.)</p>
<p>The first step towards using FPCA functions in the <a href="https://cran.r-project.org/package=brolgar"><code>fdapace</code></a> package is to reshape the data so that the time and wages data for each subject are stored as lists in separate columns of a <code>tibble</code> where each row contains all of the data for a single id. (Standard <code>dplyr</code> operations might not work as expected on a <code>tsibble</code>.) The following code pulls just the required data into a <code>tibble</code> before the <code>dplyr</code> code in the somewhat untidy ‘for loop’ builds the data structure we will use for the analysis.</p>
<pre class="r"><code>df2 <- df %>% select(id, xp, ln_wages) %>% as_tibble()
uid <- unique(df2$id)
N <- length(uid)
Wages <- rep(0,N)
Exp <- rep(0,N)
for (k in 1:N){
Wages[k] <- df2 %>% filter(id == uid[k]) %>% select(ln_wages) %>% pull() %>% list()
Exp[k] <- df2 %>% filter(id == uid[k]) %>% select(xp) %>% pull() %>% list()
}
df3 <- tibble( uid, Wages, Exp )
glimpse(df3)</code></pre>
<pre><code>## Rows: 764
## Columns: 3
## $ uid <int> 31, 36, 53, 122, 134, 145, 155, 173, 207, 222, 223, 226, 234, 24…
## $ Wages <list> <1.491, 1.433, 1.469, 1.749, 1.931, 1.709, 2.086, 2.129>, <1.98…
## $ Exp <list> <0.015, 0.715, 1.734, 2.773, 3.927, 4.946, 5.965, 6.984>, <0.31…</code></pre>
<p>he <code>FPCA()</code> function computes the functional principal components. Note that in the function call the input data are the two columns of lists we created above. The <code>dataType</code> parameter specifies the data as being sparse. <code>error = FALSE</code> means we are using a simple model that does not account for unobserved error. <code>kernel =</code>epan` means that the we are using the <a href="https://www.gabormelli.com/RKB/Epanechnikov_Kernel">Epanechnikov</a> for smoothing the pooled data to compute the mean and covariance. (For this data set, Epanechnikov seems to yield better results than the default Gaussian kernel.)</p>
<pre class="r"><code>res_wages <- FPCA(df3$Wages,df3$Exp, list(dataType='Sparse', error=FALSE, kernel='epan', verbose=TRUE))</code></pre>
<p>The plot method for the resulting <code>FPCA</code> object provides a visual summary of the results. Going clockwise from the upper left, the Design Plot shows that collectively the data are fairly dense over the support except at the upper range near twelve years. The computed mean function for the data shows a little dip in wages near the beginning and then a clear upward trend until it abruptly drops towards the end. The first three eigenfunctions are plotted at the bottom right, and the scree plot at the bottom left shows that the first eigenfunction accounts for about 60% of the total variation and that it takes about eight eigenfunctions to account for 99% of the variance. Note that the default label for the <em>time</em> access in all of the <code>fdapace</code> plots is <em>s</em> for support.</p>
<pre class="r"><code>plot(res_wages)</code></pre>
<p><img src="/2021/07/08/exploratory-fda-with-sparse-data/index_files/figure-html/unnamed-chunk-9-1.png" width="672" />
We can obtain the exact estimates for the <em>cumulative Fraction of Variance Explained</em> by picking <code>cumFVE</code> out of the <code>FPCA</code> object.</p>
<pre class="r"><code>round(res_wages$cumFVE,3)</code></pre>
<pre><code>## [1] 0.591 0.739 0.806 0.860 0.908 0.936 0.957 0.975 0.983 0.989 0.993</code></pre>
<p>The following plot shows the smoothed curves estimated for the first two subjects. These are the same subject plotted in the third plot above. The circles indicate the input data. Everything looks pretty good here.</p>
<pre class="r"><code>CreatePathPlot(res_wages, subset=1:2, main = 'Estimated Paths for IDs 31 and 36'); grid()</code></pre>
<p><img src="/2021/07/08/exploratory-fda-with-sparse-data/index_files/figure-html/unnamed-chunk-11-1.png" width="672" />
But looking at just one more subject shows how quickly things can apparently go off the rails. The green curve for subject id 53 after 1.77 years is pure algorithmic imagination. Although there are several data points in the first two years, there is nothing thereafter.</p>
<pre class="r"><code>CreatePathPlot(res_wages, subset= 1:3, showMean=TRUE)</code></pre>
<p><img src="/2021/07/08/exploratory-fda-with-sparse-data/index_files/figure-html/unnamed-chunk-12-1.png" width="672" /></p>
<p>The value of the FPCA analysis lies in estimating the mean function and the covariance operator which are constructed from the pooled data, and not in predicting an individual paths.</p>
<p>The covariance surface is easily plotted with the help of the extractor function <code>GetCovSurface()</code> which fetches the time grid and associated covariance surface stored in the <code>FPCA</code> object. These are in the right format for a three dimensional, interactive <code>plotly</code> visualization. Rotating the plot and changing the viewing angle reveals quite a bit about the details of the estimated covariance surface.</p>
<pre class="r"><code>covS <- GetCovSurface(df3$Wages,df3$Exp)
x <- covS$workGrid
Surf <- covS$cov
fig <- plot_ly(x = x, y = x, z = ~Surf) %>%
add_surface(contours = list(
z = list(show=TRUE,usecolormap=TRUE,
highlightcolor="#ff0000", project=list(z=TRUE))))
fig <- fig %>%
layout(scene = list(camera=list(eye = list(x=1.87, y=0.88, z=-0.64))))
fig</code></pre>
<div id="htmlwidget-1" style="width:672px;height:480px;" class="plotly html-widget"></div>
<script type="application/json" data-for="htmlwidget-1">{"x":{"visdat":{"3e4258572446":["function () ","plotlyVisDat"]},"cur_data":"3e4258572446","attrs":{"3e4258572446":{"x":[0.001,0.25498,0.50896,0.76294,1.01692,1.2709,1.52488,1.77886,2.03284,2.28682,2.5408,2.79478,3.04876,3.30274,3.55672,3.8107,4.06468,4.31866,4.57264,4.82662,5.0806,5.33458,5.58856,5.84254,6.09652,6.3505,6.60448,6.85846,7.11244,7.36642,7.6204,7.87438,8.12836,8.38234,8.63632,8.8903,9.14428,9.39826,9.65224,9.90622,10.1602,10.41418,10.66816,10.92214,11.17612,11.4301,11.68408,11.93806,12.19204,12.44602,12.7],"y":[0.001,0.25498,0.50896,0.76294,1.01692,1.2709,1.52488,1.77886,2.03284,2.28682,2.5408,2.79478,3.04876,3.30274,3.55672,3.8107,4.06468,4.31866,4.57264,4.82662,5.0806,5.33458,5.58856,5.84254,6.09652,6.3505,6.60448,6.85846,7.11244,7.36642,7.6204,7.87438,8.12836,8.38234,8.63632,8.8903,9.14428,9.39826,9.65224,9.90622,10.1602,10.41418,10.66816,10.92214,11.17612,11.4301,11.68408,11.93806,12.19204,12.44602,12.7],"z":{},"alpha_stroke":1,"sizes":[10,100],"spans":[1,20],"type":"surface","contours":{"z":{"show":true,"usecolormap":true,"highlightcolor":"#ff0000","project":{"z":true}}},"inherit":true}},"layout":{"margin":{"b":40,"l":60,"t":25,"r":10},"scene":{"camera":{"eye":{"x":1.87,"y":0.88,"z":-0.64}},"xaxis":{"title":[]},"yaxis":{"title":[]},"zaxis":{"title":"Surf"}},"hovermode":"closest","showlegend":false,"legend":{"yanchor":"top","y":0.5}},"source":"A","config":{"showSendToCloud":false},"data":[{"colorbar":{"title":"Surf","ticklen":2,"len":0.5,"lenmode":"fraction","y":1,"yanchor":"top"},"colorscale":[["0","rgba(68,1,84,1)"],["0.0416666666666667","rgba(70,19,97,1)"],["0.0833333333333334","rgba(72,32,111,1)"],["0.125","rgba(71,45,122,1)"],["0.166666666666667","rgba(68,58,128,1)"],["0.208333333333333","rgba(64,70,135,1)"],["0.25","rgba(60,82,138,1)"],["0.291666666666667","rgba(56,93,140,1)"],["0.333333333333333","rgba(49,104,142,1)"],["0.375","rgba(46,114,142,1)"],["0.416666666666667","rgba(42,123,142,1)"],["0.458333333333333","rgba(38,133,141,1)"],["0.5","rgba(37,144,140,1)"],["0.541666666666667","rgba(33,154,138,1)"],["0.583333333333333","rgba(39,164,133,1)"],["0.625","rgba(47,174,127,1)"],["0.666666666666667","rgba(53,183,121,1)"],["0.708333333333333","rgba(79,191,110,1)"],["0.75","rgba(98,199,98,1)"],["0.791666666666667","rgba(119,207,85,1)"],["0.833333333333333","rgba(147,214,70,1)"],["0.875","rgba(172,220,52,1)"],["0.916666666666667","rgba(199,225,42,1)"],["0.958333333333333","rgba(226,228,40,1)"],["1","rgba(253,231,37,1)"]],"showscale":true,"x":[0.001,0.25498,0.50896,0.76294,1.01692,1.2709,1.52488,1.77886,2.03284,2.28682,2.5408,2.79478,3.04876,3.30274,3.55672,3.8107,4.06468,4.31866,4.57264,4.82662,5.0806,5.33458,5.58856,5.84254,6.09652,6.3505,6.60448,6.85846,7.11244,7.36642,7.6204,7.87438,8.12836,8.38234,8.63632,8.8903,9.14428,9.39826,9.65224,9.90622,10.1602,10.41418,10.66816,10.92214,11.17612,11.4301,11.68408,11.93806,12.19204,12.44602,12.7],"y":[0.001,0.25498,0.50896,0.76294,1.01692,1.2709,1.52488,1.77886,2.03284,2.28682,2.5408,2.79478,3.04876,3.30274,3.55672,3.8107,4.06468,4.31866,4.57264,4.82662,5.0806,5.33458,5.58856,5.84254,6.09652,6.3505,6.60448,6.85846,7.11244,7.36642,7.6204,7.87438,8.12836,8.38234,8.63632,8.8903,9.14428,9.39826,9.65224,9.90622,10.1602,10.41418,10.66816,10.92214,11.17612,11.4301,11.68408,11.93806,12.19204,12.44602,12.7],"z":[[0.0331322070546811,0.0318695963697909,0.0306084275995855,0.0293443616254352,0.028072629395297,0.0267906480987916,0.0255006756921525,0.0242120268543572,0.0229422198561734,0.0217163929495041,0.0205645744597996,0.0195170186693932,0.0185987116402154,0.0178248600414893,0.0171991275937116,0.0167153708708982,0.0163621251457203,0.016127955920449,0.0160055878036825,0.0159933918024623,0.0160938921540552,0.0163099523455379,0.0166398999476985,0.0170729652007625,0.0175861660276314,0.0181434002723871,0.018697160461305,0.0191929524421927,0.0195760566546932,0.0197996745792023,0.0198329265466436,0.019666951979124,0.0193177557384191,0.0188253291304183,0.0182494927870589,0.0176634036179944,0.0171456377144425,0.0167714924650897,0.0166040332006384,0.0166856083812501,0.0170309009009039,0.0176227077845935,0.0184112786443383,0.0193172496887705,0.0202373545430986,0.0210516141248012,0.0216308185565193,0.0218436758463872,0.0215636271123677,0.0206756173712682,0.0190828850096431],[0.0318695963697909,0.031511328351703,0.0310844213553877,0.0305886167447588,0.0300221313024635,0.0293838087120821,0.0286753652366703,0.0279034036844076,0.0270807724091334,0.0262268026862442,0.0253660533977032,0.0245255219649181,0.0237308522495712,0.0230026783208871,0.0223544820291294,0.0217928829847496,0.0213202272841608,0.0209382638901337,0.0206512098636519,0.0204668224419947,0.0203949617226654,0.0204440719199803,0.0206166411527903,0.0209048771066281,0.0212876675483224,0.0217295972350372,0.0221825046990564,0.0225897571489521,0.0228929803263033,0.0230403620782594,0.0229950257762506,0.0227416870288337,0.0222901364657058,0.0216749595037037,0.0209518737204194,0.0201916473732674,0.0194725899040552,0.0188723116905523,0.0184592270070578,0.0182843430388284,0.0183741443774614,0.0187255391079382,0.0193036144352677,0.0200423581397086,0.0208478281555037,0.021602876289728,0.0221726533066038,0.0224106243518809,0.0221653460138802,0.0212884113617055,0.0196435736264059],[0.0306084275995855,0.0310844213553877,0.0314203443157761,0.0316211732112498,0.0316899997689659,0.0316296698778145,0.0314444829686355,0.031141735926594,0.0307328651729079,0.0302339329167516,0.0296652411030064,0.0290499875995216,0.0284121506968899,0.0277741613522838,0.0271552007357069,0.026570865378461,0.0260343645616434,0.0255586067552207,0.0251579795896333,0.0248486796578694,0.0246470601734909,0.024566269920893,0.0246120535026586,0.0247787839835087,0.0250466839220888,0.0253809574004011,0.0257333265645521,0.0260462056967514,0.0262593329966311,0.0263180703825426,0.0261819359281641,0.025831592457205,0.0252727742295653,0.0245364639953456,0.0236756287150415,0.0227594766668228,0.0218662830175306,0.0210755270415093,0.0204597776663962,0.0200767218002543,0.019961924623402,0.0201230862453322,0.0205364563355298,0.0211456469793341,0.0218625706246616,0.0225699549560327,0.0231250360536958,0.0233645023153083,0.023111210667939,0.0221832362790041,0.0204052535287975],[0.0293443616254352,0.0305886167447588,0.0316211732112498,0.0324527742841928,0.0330926122589903,0.033549427345952,0.0338325744107203,0.0339529229691742,0.0339234846317267,0.0337597059483445,0.0334794012503232,0.0331023272155123,0.0326494526229137,0.0321420923387922,0.0316012214453457,0.031047322714557,0.0305008998002475,0.02998334029036,0.0295174074411659,0.0291265943169415,0.0288329729453783,0.0286537846443632,0.0285975020695321,0.0286602597534576,0.0288234546599859,0.0290531349281225,0.0293016258764072,0.0295116403872773,0.0296227592326892,0.0295795907918275,0.0293402725455583,0.028883589112671,0.0282131669338688,0.0273579821762354,0.0263694175927364,0.0253158112109128,0.0242755760487848,0.0233296661615941,0.022553794222206,0.0220106712168221,0.0217426696601811,0.0217654972684213,0.0220634583583041,0.0225866023071851,0.0232496861286319,0.0239327005742675,0.0244828996383591,0.0247187370588077,0.0244365136706508,0.0234204805254652,0.021456414903528],[0.028072629395297,0.0300221313024635,0.0316899997689659,0.0330926122589903,0.0342457668280061,0.035165226524543,0.035867100741192,0.036367996968833,0.0366849499816742,0.0368352230856204,0.0368361319229153,0.036705028868662,0.0364595123559421,0.0361178439234699,0.0356995164882531,0.0352259038660699,0.0347208562860593,0.0342109531388896,0.0337249828906253,0.0332922721567286,0.0329398044529304,0.0326885091584365,0.0325494155058391,0.0325204245478211,0.0325843242153551,0.0327085147322396,0.0328467995228084,0.032943463587786,0.0329395682686644,0.0327808689153244,0.0324261328975807,0.0318542158157446,0.0310683701757549,0.0300969734622301,0.0289908442452867,0.0278180542076627,0.0266573229710324,0.0255907851168261,0.0246965027479584,0.0240408889623787,0.0236712848970544,0.023609124657479,0.0238441881948054,0.0243302842342403,0.0249824555037043,0.0256757120523867,0.0262455376714748,0.0264908882983998,0.0261807728004444,0.0250653643770753,0.0228917047983721],[0.0267906480987916,0.0293838087120821,0.0316296698778145,0.033549427345952,0.035165226524543,0.0365001589179228,0.0375779327997819,0.0384222209715625,0.0390557934481177,0.0394996564073907,0.0397724863651319,0.0398906214993328,0.039868742804271,0.0397211907255714,0.0394636825816669,0.0391150591393827,0.0386985955588714,0.0382423748739331,0.0377783067772102,0.0373396493141163,0.0369573124635487,0.0366556042743079,0.0364482293719683,0.0363352361293477,0.0363013778603103,0.0363161774963071,0.0363359156859208,0.0363077011780925,0.0361755685166264,0.0358880933379644,0.0354064210283272,0.03471116976732,0.0338067269710181,0.0327221039924163,0.0315084612945201,0.0302341663872877,0.0289784558548719,0.0278244848982743,0.0268521019279102,0.0261304237510619,0.0257103226997689,0.0256171332160939,0.0258440117422347,0.0263463244850819,0.0270372918356324,0.0277851146244285,0.0284120989309966,0.0286967926700521,0.028380506127086,0.0271793781075005,0.0248021151327367],[0.0255006756921525,0.0286753652366703,0.0314444829686355,0.0338325744107203,0.035867100741192,0.0375779327997819,0.0389963219307895,0.0401534282277709,0.0410786174610846,0.0417978607923005,0.0423326308575331,0.0426996401654115,0.0429116121443023,0.0429790556104094,0.0429127816213682,0.0427266795680036,0.0424400690487865,0.0420788384185495,0.0416747176013895,0.0412625019030786,0.0408757045452815,0.0405416265908022,0.0402769245879492,0.040084463293372,0.0399518369263898,0.0398516815407925,0.0397438379186396,0.039579424852938,0.0393067502032849,0.0388786081930561,0.0382599652836571,0.0374346055545078,0.0364093221534189,0.0352148242199604,0.0339034295561093,0.0325443539260933,0.0312176325491698,0.0300074319152829,0.0289950491331545,0.0282515992223047,0.0278303977209859,0.0277592460923794,0.0280330007461299,0.0286068255988149,0.0293904679760304,0.0302439668339692,0.0309755461573968,0.0313429736802349,0.0310600244238471,0.0298094247004417,0.0272624847552774],[0.0242120268543572,0.0279034036844076,0.031141735926594,0.0339529229691742,0.036367996968833,0.0384222209715625,0.0401534282277709,0.0415997646370282,0.0427971577911487,0.0437769617221728,0.0445642600859563,0.0451772221872844,0.0456277189660057,0.04592318372548,0.0460694929360384,0.0460744279739409,0.0459510134802218,0.0457197707341108,0.0454089123023939,0.045051980609218,0.0446833151434125,0.0443325374328273,0.0440194809255232,0.0437506202194773,0.0435174524559551,0.0432968591513079,0.0430533531143708,0.0427431422914126,0.0423198800384787,0.041741670224981,0.0409784095422716,0.0400181407658664,0.0388710841047306,0.0375705432865608,0.0361707306601078,0.034742269401235,0.0333663571800869,0.0321283085190226,0.0311107307504811,0.0303862751998386,0.0300098953209992,0.0300107465165768,0.0303840689693109,0.0310834720514554,0.0320140457697783,0.0330268552853245,0.0339157681373235,0.0344181265782517,0.0342211476124548,0.0329756318229061,0.0303172817711952],[0.0229422198561734,0.0270807724091334,0.0307328651729079,0.0339234846317267,0.0366849499816742,0.0390557934481177,0.0410786174610846,0.0427971577911487,0.0442529887701707,0.0454824432758555,0.0465143235143619,0.0473688329525233,0.0480579198058665,0.048586988191066,0.0489577712307832,0.0491720297546636,0.0492355165620847,0.0491612917511296,0.0489712182000815,0.0486947136249981,0.0483647338695585,0.0480120695132449,0.0476596314143326,0.047318167274733,0.0469841324033539,0.0466397997562264,0.0462554189796303,0.04579321924752,0.045213025409274,0.0444790265391244,0.0435668192610594,0.042469482036325,0.0412014299600058,0.0397992897434228,0.0383198276984895,0.0368356380231976,0.035429515100045,0.0341881768360146,0.0331955548265636,0.0325255539276368,0.0322341671793313,0.032351035192074,0.0328707640014087,0.0337444298930393,0.0348717546066247,0.0360946142218224,0.0371929840285189,0.0378850222502866,0.0378333851627186,0.0366595435632467,0.033966503058887],[0.0217163929495041,0.0262268026862442,0.0302339329167516,0.0337597059483445,0.0368352230856204,0.0394996564073907,0.0417978607923005,0.0437769617221728,0.0454824432758555,0.0469544296254086,0.0482248415510343,0.0493159068889525,0.0502401949657233,0.0510020717135082,0.051600337508263,0.0520317811264457,0.0522952875855835,0.0523958186937653,0.052347151470331,0.0521721525117859,0.0518999967310636,0.051560940778863,0.0511802713868282,0.0507732101226357,0.0503419353831115,0.0498750765127259,0.0493495297935976,0.0487342891617836,0.0479959315171738,0.0471052125440611,0.0460438847500474,0.0448105437488646,0.0434243246084322,0.0419257373646328,0.0403746734207767,0.0388462433236286,0.0374253059640954,0.0362003045305237,0.0352565956086472,0.0346691587521296,0.0344945578485685,0.0347622238454742,0.0354653549447156,0.0365518603713253,0.0379158575355582,0.0393904494187039,0.040742988478514,0.0416746727400368,0.0418267364762657,0.0407951715946082,0.0381544909245256],[0.0205645744597996,0.0253660533977032,0.0296652411030064,0.0334794012503232,0.0368361319229153,0.0397724863651319,0.0423326308575331,0.0445642600859563,0.0465143235143619,0.0482248415510343,0.0497295966756182,0.0510522508284168,0.0522060672925228,0.0531950813066915,0.0540164141691486,0.0546634615566294,0.0551297349076588,0.0554129627094953,0.055518616756928,0.0554616372084989,0.0552653191753962,0.0549572900391486,0.0545637429668059,0.0541037683390233,0.053585385320088,0.053004092967106,0.0523440333779606,0.051581464630932,0.0506900638309376,0.0496473902063883,0.0484415545052407,0.0470769076000458,0.0455776199433563,0.0439884858786634,0.0423729877906212,0.0408092384462426,0.0393846008910634,0.038189555773451,0.0373109890085399,0.0368247986457371,0.0367877087338195,0.0372283639033316,0.038137988574964,0.0394610180011997,0.0410862019494618,0.0428389243668108,0.0444759976719848,0.0456848692074931,0.0460896282272149,0.0452658894575249,0.0427651789303845],[0.0195170186693932,0.0245255219649181,0.0290499875995216,0.0331023272155123,0.036705028868662,0.0398906214993328,0.0426996401654115,0.0451772221872844,0.0473688329525233,0.0493159068889525,0.0510522508284168,0.0526018411772825,0.0539782445988262,0.0551855000657116,0.056220099760657,0.0570737433973107,0.0577366805901296,0.058201457900842,0.0584665898396193,0.0585392042675024,0.0584355150619547,0.0581784704229294,0.0577930229923928,0.0573005020972329,0.0567138801987863,0.0560352553140835,0.0552560839383807,0.054360049409957,0.053328049662346,0.0521445050236724,0.0508039225309999,0.0493164881911971,0.0477115747013433,0.0460385277666891,0.0443647670349988,0.04277178250366,0.0413497730546252,0.0401914639491365,0.0393852824208924,0.0390078286098411,0.0391155741302234,0.0397358852831468,0.0408576437369137,0.0424218328801814,0.0443125440979638,0.046349115163758,0.0482806604983484,0.0497849724381056,0.0504742642018614,0.0499099438517527,0.0476271646380002],[0.0185987116402154,0.0237308522495712,0.0284121506968899,0.0326494526229137,0.0364595123559421,0.039868742804271,0.0429116121443023,0.0456277189660057,0.0480579198058665,0.0502401949657233,0.0522060672925228,0.0539782445988262,0.0555697905486779,0.0569847184814562,0.0582196437939824,0.0592661127814069,0.0601133755308818,0.0607514927861801,0.0611745694532348,0.0613835618155174,0.061387750097617,0.0612040069372007,0.0608536489163157,0.0603576672737655,0.0597318805962031,0.058983602697914,0.0581108584551825,0.0571044154250173,0.0559522457302509,0.0546455605943084,0.0531852375642895,0.0515873300079298,0.0498865216933156,0.0481368933504082,0.0464100300839153,0.0447910174000128,0.043373031408999,0.0422510429655798,0.041514840834889,0.0412413717499742,0.0414863944493764,0.042275579018315,0.0435953084654497,0.0453834893143447,0.0475207426909342,0.0498226133977412,0.0520340121657551,0.0538278673371518,0.0548105000575356,0.0545360015284652,0.052530482460023],[0.0178248600414893,0.0230026783208871,0.0277741613522838,0.0321420923387922,0.0361178439234699,0.0397211907255714,0.0429790556104094,0.04592318372548,0.048586988191066,0.0510020717135082,0.0531950813066915,0.0551855000657116,0.0569847184814562,0.0585963735587847,0.0600176639883751,0.061241256945453,0.062257490072733,0.0630567248468819,0.0636317684888794,0.0639801498475518,0.0641057577250964,0.0640191546452811,0.0637360515952995,0.063274057972641,0.062648625762394,0.0618696058873551,0.0609397352232774,0.0598557726821016,0.0586122210548296,0.0572068762776654,0.0556469736621194,0.0539545341813076,0.0521697166573959,0.0503515180409112,0.0485758316043286,0.0469313817098358,0.0455142129926303,0.0444212530086321,0.0437431948848057,0.0435567709287507,0.0439164860155415,0.0448459744950298,0.0463292085754549,0.0483017799036967,0.0506425125125869,0.0531659366943929,0.0556167609033422,0.0576682820873136,0.0589272621375833,0.0589476194755151,0.0572539355838214],[0.0171991275937116,0.0223544820291294,0.0271552007357069,0.0316012214453457,0.0356995164882531,0.0394636825816669,0.0429127816213682,0.0460694929360384,0.0489577712307832,0.051600337508263,0.0540164141691486,0.056220099760657,0.0582196437939824,0.0600176639883751,0.0616121307218852,0.0629978135304456,0.0641678843030938,0.0651154760881114,0.0658351243262892,0.0663240697163271,0.0665833174235592,0.0666181657746142,0.0664378041517355,0.0660537395296178,0.0654772992279524,0.0647170520509045,0.0637773114496324,0.0626586901024346,0.0613610332114099,0.0598882547154044,0.0582539468743659,0.0564863485347136,0.0546314284187607,0.0527533869635769,0.050932558636991,0.0492612081923167,0.0478378833053571,0.0467608548245097,0.0461209398623877,0.0459938501190088,0.0464321946920124,0.0474573139732284,0.0490511191524726,0.0511480492320706,0.0536272691498109,0.0563055137478691,0.0589316217540477,0.0611846483990364,0.062678081017518,0.0629725651941309,0.0615982752030172],[0.0167153708708982,0.0217928829847496,0.026570865378461,0.031047322714557,0.0352259038660699,0.0391150591393827,0.0427266795680036,0.0460744279739409,0.0491720297546636,0.0520317811264457,0.0546634615566294,0.0570737433973107,0.0592661127814069,0.061241256945453,0.0629978135304456,0.0645333100972503,0.0658450782765156,0.0669309523068001,0.0677896675792781,0.068421012364542,0.0688258673468949,0.0690062249473209,0.0689651310582874,0.0687063639849809,0.0682337313746592,0.0675501867353708,0.0666573746184522,0.0655563892916451,0.0642502577019007,0.0627480047056168,0.0610694440316023,0.0592494193188867,0.0573402919545905,0.0554119769009098,0.0535494934426646,0.0518485076341788,0.0504095219009486,0.0493312595848625,0.0487035830371259,0.0486001403838893,0.0490708988766152,0.0501347147520288,0.051772022780174,0.0539176208888705,0.0564535281944212,0.0592021990009788,0.0619210517798117,0.0643001544683514,0.0659655850158709,0.0664909288536984,0.0654181840902741],[0.0163621251457203,0.0213202272841608,0.0260343645616434,0.0305008998002475,0.0347208562860593,0.0386985955588714,0.0424400690487865,0.0459510134802218,0.0492355165620847,0.0522952875855835,0.0551297349076588,0.0577366805901296,0.0601133755308818,0.062257490072733,0.0641678843030938,0.0658450782765156,0.0672913751291343,0.0685105823250321,0.0695073140434355,0.070285971913449,0.0708496397913598,0.0711992024309695,0.0713329478099026,0.0712467515840892,0.0709347669694883,0.070390491316937,0.069608214532828,0.0685850591094622,0.0673238537979696,0.0658367880766665,0.0641492850889093,0.0623031293376317,0.0603578749677877,0.0583899685967409,0.0564896130930861,0.0547558642479761,0.0532906154317949,0.0521920250661299,0.0515477453532323,0.0514281618677676,0.051879779055568,0.0529188175908524,0.0545249656843273,0.0566350945847835,0.0591367698553657,0.061861739126727,0.064580298867567,0.0669983577770905,0.068759722155404,0.0694561217415781,0.0686463861879824],[0.016127955920449,0.0209382638901337,0.0255586067552207,0.02998334029036,0.0342109531388896,0.0382423748739331,0.0420788384185495,0.0457197707341108,0.0491612917511296,0.0523958186937653,0.0554129627094953,0.058201457900842,0.0607514927861801,0.0630567248468819,0.0651154760881114,0.0669309523068001,0.0685105823250321,0.069864660771131,0.0710044800140192,0.0719401604443124,0.0726784629233871,0.0732209509670114,0.0735629059229249,0.0736933452404863,0.0735963371236817,0.0732535753663923,0.0726479601160189,0.0717678054186407,0.0706112552626868,0.0691904418657728,0.0675348095869117,0.065692947907517,0.0637323921756593,0.0617372112051954,0.0598036597815166,0.0580345032357235,0.0565326927574597,0.0553949301746461,0.0547054523864568,0.0545301977218941,0.0549113968697175,0.0558625014438278,0.057363196237199,0.0593541128195264,0.0617309347674406,0.0643380045051197,0.0669623185873697,0.0693297398868033,0.0711059789698952,0.0719049280351492,0.0713059001829667],[0.0160055878036825,0.0206512098636519,0.0251579795896333,0.0295174074411659,0.0337249828906253,0.0377783067772102,0.0416747176013895,0.0454089123023939,0.0489712182000815,0.052347151470331,0.055518616756928,0.0584665898396193,0.0611745694532348,0.0636317684888794,0.0658351243262892,0.0677896675792781,0.0695073140434355,0.0710044800140192,0.0722990125927399,0.0734068810914066,0.0743390128301715,0.0750986315464315,0.0756794756670089,0.076065315001788,0.0762311856672073,0.0761466265710056,0.075780857900844,0.0751093385037901,0.0741206534827394,0.0728224358154073,0.0712451420777093,0.0694429483429996,0.067491651440042,0.0654840517630202,0.0635236807961097,0.0617178308359329,0.060170681698369,0.0589770306205514,0.0582168546282454,0.0579507298666269,0.0582159700752847,0.0590231699298102,0.0603526522165691,0.0621502240248153,0.0643218025811392,0.0667269834018504,0.0691724614632012,0.0714071769938292,0.0731217847031828,0.0739551043288354,0.0735092539496809],[0.0159933918024623,0.0204668224419947,0.0248486796578694,0.0291265943169415,0.0332922721567286,0.0373396493141163,0.0412625019030786,0.045051980609218,0.0486947136249981,0.0521721525117859,0.0554616372084989,0.0585392042675024,0.0613835618155174,0.0639801498475518,0.0663240697163271,0.068421012364542,0.070285971913449,0.0719401604443124,0.0734068810914066,0.0747071348803353,0.0758555631684153,0.0768571240245939,0.0777047859678467,0.0783785506966801,0.0788462522396025,0.0790666738538563,0.0789953500438669,0.0785928135615148,0.0778340945249359,0.0767174138310883,0.0752698128492905,0.0735482048684632,0.0716357088710055,0.0696344276166984,0.0676564827666857,0.0658150176284293,0.0642163197260308,0.0629535863969765,0.0621023879018121,0.061717597256679,0.0618313585729791,0.0624514729788767,0.0635594121154091,0.0651071451363291,0.0670122289257222,0.0691512267404509,0.0713524169495847,0.0733897236751991,0.0749805227340939,0.0757900605957289,0.075444345101303],[0.0160938921540552,0.0203949617226654,0.0246470601734909,0.0288329729453783,0.0329398044529304,0.0369573124635487,0.0408757045452815,0.0446833151434125,0.0483647338695585,0.0518999967310636,0.0552653191753962,0.0584355150619547,0.061387750097617,0.0641057577250964,0.0665833174235592,0.0688258673468949,0.0708496397913598,0.0726784629233871,0.0743390128301715,0.0758555631684153,0.0772451452905528,0.0785136830202586,0.0796533474708173,0.0806412705413001,0.0814399083834682,0.0819996339966568,0.0822642710045249,0.0821798978394456,0.081706164761703,0.0808278827214659,0.0795636374776064,0.0779685686437122,0.0761303232849857,0.0741595405776082,0.0721777216884198,0.070305399846015,0.0686525563853742,0.0673120344566068,0.0663558236564226,0.0658336118704106,0.0657727555273533,0.0661786504479392,0.0670343867389329,0.0682986586983935,0.0699012934552287,0.0717364804592963,0.0736547254506154,0.0754555175425166,0.0768834080097065,0.0776303138573719,0.0773460695850045],[0.0163099523455379,0.0204440719199803,0.024566269920893,0.0286537846443632,0.0326885091584365,0.0366556042743079,0.0405416265908022,0.0443325374328273,0.0480120695132449,0.051560940778863,0.0549572900391486,0.0581784704229294,0.0612040069372007,0.0640191546452811,0.0666181657746142,0.0690062249473209,0.0711992024309695,0.0732209509670114,0.0750986315464315,0.0768571240245939,0.0785136830202586,0.0800736658544262,0.081527673681703,0.0828501372891118,0.0839994229280531,0.084919882111281,0.0855466525199673,0.085813999688535,0.0856671466414864,0.0850758390493886,0.0840460870116161,0.0826259658085248,0.080902954094887,0.0789934166472068,0.0770276203127833,0.0751345617927553,0.0734298575278577,0.072008113536416,0.0709396406065027,0.0702704963000985,0.0700244602327785,0.0702054224577551,0.0707986936857298,0.0717699947986146,0.0730614264944729,0.0745845358079433,0.0762115637406577,0.0777669010031268,0.079021472046981,0.0796929205297642,0.0794537853683119],[0.0166398999476985,0.0206166411527903,0.0246120535026586,0.0285975020695321,0.0325494155058391,0.0364482293719683,0.0402769245879492,0.0440194809255232,0.0476596314143326,0.0511802713868282,0.0545637429668059,0.0577930229923928,0.0608536489163157,0.0637360515952995,0.0664378041517355,0.0689651310582874,0.0713329478099026,0.0735629059229249,0.0756794756670089,0.0777047859678467,0.0796533474708173,0.081527673681703,0.0833153353332167,0.0849875216533874,0.0864990551751751,0.0877900769011238,0.0887900878799529,0.0894252995595545,0.0896298066760721,0.0893596351395245,0.0886065868477193,0.0874072786352219,0.0858433748977925,0.0840320495417437,0.0821095463954886,0.0802129743792947,0.0784651138009087,0.0769648698729929,0.0757836661338225,0.0749665006787499,0.0745356841725799,0.0744951355422329,0.0748332970184869,0.0755231887018097,0.0765188450798398,0.0777482904039718,0.0791041891881894,0.0804342146468295,0.0815338496952199,0.0821445328592555,0.0819594966089163],[0.0170729652007625,0.0209048771066281,0.0247787839835087,0.0286602597534576,0.0325204245478211,0.0363352361293477,0.040084463293372,0.0437506202194773,0.047318167274733,0.0507732101226357,0.0541037683390233,0.0573005020972329,0.0603576672737655,0.063274057972641,0.0660537395296178,0.0687063639849809,0.0712467515840892,0.0736933452404863,0.076065315001788,0.0783785506966801,0.0806412705413001,0.0828501372891118,0.0849875216533874,0.0870201393595641,0.0888990586348729,0.0905611958981878,0.0919328005582537,0.0929357782139176,0.0934975781889819,0.093564362644805,0.0931152728196424,0.0921736423997681,0.0908105091740811,0.08913783903358,0.0872928194407002,0.0854180751676755,0.0836436352676376,0.0820748008423383,0.0807872298262874,0.0798281487438137,0.0792212833346261,0.0789727505795509,0.0790754419614093,0.0795101149518328,0.0802423419962743,0.081215495753131,0.0823409428008623,0.0834874856536821,0.0844727420062443,0.0850593943383111,0.0849588020344645],[0.0175861660276314,0.0212876675483224,0.0250466839220888,0.0288234546599859,0.0325843242153551,0.0363013778603103,0.0399518369263898,0.0435174524559551,0.0469841324033539,0.0503419353831115,0.053585385320088,0.0567138801987863,0.0597318805962031,0.062648625762394,0.0654772992279524,0.0682337313746592,0.0709347669694883,0.0735963371236817,0.0762311856672073,0.0788462522396025,0.0814399083834682,0.0839994229280531,0.0864990551751751,0.0888990586348729,0.0911457744978129,0.0931730359723613,0.0949053043926594,0.096263180544068,0.0971719073718473,0.0975728659467336,0.097436692815716,0.0967748746785305,0.0956455762095412,0.0941502865248955,0.0924209006149407,0.0906006525186964,0.0888246222175502,0.0872050955894278,0.0858245059766227,0.0847356952841487,0.0839671130397174,0.0835297202332216,0.0834225616148196,0.0836348243437206,0.0841433537785074,0.0849057710511616,0.0858503692034513,0.0868648084228072,0.0877862633440928,0.0883959647032726,0.0884207553569314],[0.0181434002723871,0.0217295972350372,0.0253809574004011,0.0290531349281225,0.0327085147322396,0.0363161774963071,0.0398516815407925,0.0432968591513079,0.0466397997562264,0.0498750765127259,0.053004092967106,0.0560352553140835,0.058983602697914,0.0618696058873551,0.0647170520509045,0.0675501867353708,0.070390491316937,0.0732535753663923,0.0761466265710056,0.0790666738538563,0.0819996339966568,0.084919882111281,0.0877900769011238,0.0905611958981878,0.0931730359723613,0.0955556456009848,0.0976322345247785,0.0993240829971134,0.100557818214925,0.101275000146099,0.101443110451299,0.101065832101195,0.100189455009278,0.0989022326285972,0.097325211198836,0.0955960861991019,0.0938504714530358,0.0922059136606917,0.0907525481483566,0.0895514382434187,0.0886389000624342,0.0880335342703454,0.0877424884744388,0.0877643064447572,0.0880870380626791,0.0886816214752877,0.0894916606878204,0.0904215758088382,0.0913257358299202,0.0920015175738187,0.0921890192445248],[0.018697160461305,0.0221825046990564,0.0257333265645521,0.0293016258764072,0.0328467995228084,0.0363359156859208,0.0397438379186396,0.0430533531143708,0.0462554189796303,0.0493495297935976,0.0523440333779606,0.0552560839383807,0.0581108584551825,0.0609397352232774,0.0637773114496324,0.0666573746184522,0.069608214532828,0.0726479601160189,0.075780857900844,0.0789953500438669,0.0822642710045249,0.0855466525199673,0.0887900878799529,0.0919328005582537,0.0949053043926594,0.0976322345247785,0.10003516025407,0.102036986984579,0.103568146491787,0.104574317256765,0.105024910606696,0.104920958426604,0.104300434195248,0.103238788654741,0.101843106124674,0.10024003194464,0.098559962311594,0.0969216927634622,0.0954216709187161,0.0941300950979937,0.093093363656403,0.0923401727443969,0.091887716123396,0.0917449588334424,0.0919112734279505,0.0923701939418145,0.0930792672556463,0.0939578908043491,0.0948756865613284,0.0956443435828908,0.0960157406076288],[0.0191929524421927,0.0225897571489521,0.0260462056967514,0.0295116403872773,0.032943463587786,0.0363077011780925,0.039579424852938,0.0427431422914126,0.04579321924752,0.0487342891617836,0.051581464630932,0.054360049409957,0.0571044154250173,0.0598557726821016,0.0626586901024346,0.0655563892916451,0.0685850591094622,0.0717678054186407,0.0751093385037901,0.0785928135615148,0.0821798978394456,0.085813999688535,0.0894252995595545,0.0929357782139176,0.096263180544068,0.0993240829971134,0.102036986984579,0.104326290372479,0.106127404614697,0.10739266324478,0.108097273867193,0.108244393823937,0.10786831546042,0.107034659498267,0.105836563213491,0.104386463396965,0.102804375737443,0.101205133078558,0.0996879074202355,0.0983307132578995,0.0971905928021063,0.0963078613964445,0.0957113408970778,0.0954214646357943,0.0954491972577069,0.0957901778901475,0.0964148164781206,0.0972560718556443,0.0981973626594604,0.0990635044577494,0.0996175316874479],[0.0195760566546932,0.0228929803263033,0.0262593329966311,0.0296227592326892,0.0329395682686644,0.0361755685166264,0.0393067502032849,0.0423198800384787,0.045213025409274,0.0479959315171738,0.0506900638309376,0.053328049662346,0.0559522457302509,0.0586122210548296,0.0613610332114099,0.0642502577019007,0.0673238537979696,0.0706112552626868,0.0741206534827394,0.0778340945249359,0.081706164761703,0.0856671466414864,0.0896298066760721,0.0934975781889819,0.0971719073718473,0.100557818214925,0.103568146491787,0.106127404614697,0.108175829322502,0.109673444920823,0.110603525948291,0.110974840307782,0.110822298930238,0.110205812197299,0.109207117067596,0.107924291723597,0.106464007765531,0.104932444018865,0.103426784755773,0.102029527482395,0.100806902172034,0.0998109018765983,0.0990827757904326,0.0986552350119151,0.0985512045964603,0.0987782095222593,0.0993188002335625,0.10011850049598,0.101073565803754,0.102021357898257,0.102736190883306],[0.0197996745792023,0.0230403620782594,0.0263180703825426,0.0295795907918275,0.0327808689153244,0.0358880933379644,0.0388786081930561,0.041741670224981,0.0444790265391244,0.0471052125440611,0.0496473902063883,0.0521445050236724,0.0546455605943084,0.0572068762776654,0.0598882547154044,0.0627480047056168,0.0658367880766665,0.0691904418657728,0.0728224358154073,0.0767174138310883,0.0808278827214659,0.0850758390493886,0.0893596351395245,0.093564362644805,0.0975728659467336,0.101275000146099,0.104574317256765,0.10739266324478,0.109673444920823,0.111383857546067,0.112515877824602,0.113085776518446,0.11313222591449,0.112713393545381,0.111903411034972,0.110788305687717,0.109461229512625,0.108016993157218,0.106546529565121,0.105132493899998,0.103847111519071,0.102752419483958,0.101901732035687,0.101340326749818,0.101103449998262,0.101210604058146,0.101656224873726,0.102397931691148,0.103344400801675,0.104345513394756,0.105187564744777],[0.0198329265466436,0.0229950257762506,0.0261819359281641,0.0293402725455583,0.0324261328975807,0.0354064210283272,0.0382599652836571,0.0409784095422716,0.0435668192610594,0.0460438847500474,0.0484415545052407,0.0508039225309999,0.0531852375642895,0.0556469736621194,0.0582539468743659,0.0610694440316023,0.0641492850889093,0.0675348095869117,0.0712451420777093,0.0752698128492905,0.0795636374776064,0.0840460870116161,0.0886065868477193,0.0931152728196424,0.097436692815716,0.101443110451299,0.105024910606696,0.108097273867193,0.110603525948291,0.112515877824602,0.113834054290717,0.114582176500992,0.114804433460968,0.114560320775369,0.113920213195428,0.112961677971017,0.111766452052585,0.1104177482942,0.108997707407521,0.107585206582271,0.106254448586631,0.105074460818783,0.104108931896927,0.103415179632419,0.103040923420831,0.103018007293712,0.103353057139428,0.104015987465594,0.104928133739159,0.105952437353606,0.106888328103055],[0.019666951979124,0.0227416870288337,0.025831592457205,0.028883589112671,0.0318542158157446,0.03471116976732,0.0374346055545078,0.0400181407658664,0.042469482036325,0.0448105437488646,0.0470769076000458,0.0493164881911971,0.0515873300079298,0.0539545341813076,0.0564863485347136,0.0592494193188867,0.0623031293376317,0.065692947907517,0.0694429483429996,0.0735482048684632,0.0779685686437122,0.0826259658085248,0.0874072786352219,0.0921736423997681,0.0967748746785305,0.101065832101195,0.104920958426604,0.108244393823937,0.110974840307782,0.113085776518446,0.114582176500992,0.115494941123467,0.115874222037705,0.115782796235101,0.115290479775698,0.114470159706538,0.113395492262777,0.112139897763217,0.110776336371563,0.109377438541185,0.108015694584173,0.10676338545883,0.10569173692745,0.104868571561808,0.104353732351723,0.104191849914758,0.104402571445975,0.10496906278508,0.105826333685744,0.106851565637909,0.107858882603496],[0.0193177557384191,0.0222901364657058,0.0252727742295653,0.0282131669338688,0.0310683701757549,0.0338067269710181,0.0364093221534189,0.0388710841047306,0.0412014299600058,0.0434243246084322,0.0455776199433563,0.0477115747013433,0.0498865216933156,0.0521697166573959,0.0546314284187607,0.0573402919545905,0.0603578749677877,0.0637323921756593,0.067491651440042,0.0716357088710055,0.0761303232849857,0.080902954094887,0.0858433748977925,0.0908105091740811,0.0956455762095412,0.100189455009278,0.104300434195248,0.10786831546042,0.110822298930238,0.11313222591449,0.114804433460968,0.115874222037705,0.116396969505733,0.116439605607111,0.116073681660397,0.115370703138586,0.114399832477675,0.113227633932602,0.111919278851983,0.11054051606788,0.109159649703249,0.107848711631506,0.106683010165943,0.105738359857973,0.105085579561552,0.104782242435146,0.104862115769381,0.105323231845509,0.106116085261734,0.107133962584367,0.108207633789301],[0.0188253291304183,0.0216749595037037,0.0245364639953456,0.0273579821762354,0.0300969734622301,0.0327221039924163,0.0352148242199604,0.0375705432865608,0.0397992897434228,0.0419257373646328,0.0439884858786634,0.0460385277666891,0.0481368933504082,0.0503515180409112,0.0527533869635769,0.0554119769009098,0.0583899685967409,0.0617372112051954,0.0654840517630202,0.0696344276166984,0.0741595405776082,0.0789934166472068,0.0840320495417437,0.08913783903358,0.0941502865248955,0.0989022326285972,0.103238788654741,0.107034659498267,0.110205812197299,0.112713393545381,0.114560320775369,0.115782796235101,0.116439605607111,0.116601695766022,0.116343710815491,0.115738304031513,0.114853358010791,0.113751798687446,0.1124934301592,0.111138036961544,0.109748815904429,0.108395027857676,0.107152714978651,0.106102529495525,0.105324178609466,0.104887590576054,0.104841501813262,0.105200685521992,0.105933497377517,0.10695177152194,0.108105193171818],[0.0182494927870589,0.0209518737204194,0.0236756287150415,0.0263694175927364,0.0289908442452867,0.0315084612945201,0.0339034295561093,0.0361707306601078,0.0383198276984895,0.0403746734207767,0.0423729877906212,0.0443647670349988,0.0464100300839153,0.0485758316043286,0.050932558636991,0.0535494934426646,0.0564896130930861,0.0598036597815166,0.0635236807961097,0.0676564827666857,0.0721777216884198,0.0770276203127833,0.0821095463954886,0.0872928194407002,0.0924209006149407,0.097325211198836,0.101843106124674,0.105836563213491,0.109207117067596,0.111903411034972,0.113920213195428,0.115290479775698,0.116073681660397,0.116343710815491,0.11617874694784,0.115654261082425,0.114839384688616,0.113796324023148,0.112582235147372,0.111252805074603,0.109866583642804,0.108488883731186,0.107193929179962,0.106064024350804,0.105184925339355,0.104637267764746,0.10448470451514,0.104760160903368,0.105452201444788,0.106493830431803,0.107755996492083],[0.0176634036179944,0.0201916473732674,0.0227594766668228,0.0253158112109128,0.0278180542076627,0.0302341663872877,0.0325443539260933,0.034742269401235,0.0368356380231976,0.0388462433236286,0.0408092384462426,0.04277178250366,0.0447910174000128,0.0469313817098358,0.0492612081923167,0.0518485076341788,0.0547558642479761,0.0580345032357235,0.0617178308359329,0.0658150176284293,0.070305399846015,0.0751345617927553,0.0802129743792947,0.0854180751676755,0.0906006525186964,0.0955960861991019,0.10024003194464,0.104386463396965,0.107924291723597,0.110788305687717,0.112961677971017,0.114470159706538,0.115370703138586,0.115738304031513,0.115654261082425,0.115197657606072,0.114440579543786,0.113446797531765,0.112273291906639,0.110973839594665,0.109603724990492,0.108224442207695,0.106907088500316,0.105733113809483,0.104791298065786,0.10417035678817,0.103947420975635,0.104173656593322,0.104859223430166,0.105960334589026,0.107371136840097],[0.0171456377144425,0.0194725899040552,0.0218662830175306,0.0242755760487848,0.0266573229710324,0.0289784558548719,0.0312176325491698,0.0333663571800869,0.035429515100045,0.0374253059640954,0.0393846008910634,0.0413497730546252,0.043373031408999,0.0455142129926303,0.0478378833053571,0.0504095219009486,0.0532906154317949,0.0565326927574597,0.060170681698369,0.0642163197260308,0.0686525563853742,0.0734298575278577,0.0784651138009087,0.0836436352676376,0.0888246222175502,0.0938504714530358,0.098559962311594,0.102804375737443,0.106464007765531,0.109461229512625,0.111766452052585,0.113395492262777,0.114399832477675,0.114853358010791,0.114839384688616,0.114440579543786,0.113732820598261,0.112782915020332,0.111649540448044,0.110386561338576,0.109047759328712,0.107691903485977,0.106386972828554,0.105212260134586,0.104257101912314,0.10361523764427,0.103374465910063,0.103602363239967,0.104330125041191,0.105537609543634,0.107142928208123],[0.0167714924650897,0.0188723116905523,0.0210755270415093,0.0233296661615941,0.0255907851168261,0.0278244848982743,0.0300074319152829,0.0321283085190226,0.0341881768360146,0.0362003045305237,0.038189555773451,0.0401914639491365,0.0422510429655798,0.0444212530086321,0.0467608548245097,0.0493312595848625,0.0521920250661299,0.0553949301746461,0.0589770306205514,0.0629535863969765,0.0673120344566068,0.072008113536416,0.0769648698729929,0.0820748008423383,0.0872050955894278,0.0922059136606917,0.0969216927634622,0.101205133078558,0.104932444018865,0.108016993157218,0.1104177482942,0.112139897763217,0.113227633932602,0.113751798687446,0.113796324023148,0.113446797531765,0.112782915020332,0.111875121276362,0.110784869490238,0.109567564507343,0.108277140617219,0.106971198287026,0.10571561697311,0.104587524853554,0.103675434780255,0.103075372474765,0.10288218522253,0.103176151056989,0.104006449881658,0.10537453878966,0.107221272697958],[0.0166040332006384,0.0184592270070578,0.0204597776663962,0.022553794222206,0.0246965027479584,0.0268521019279102,0.0289950491331545,0.0311107307504811,0.0331955548265636,0.0352565956086472,0.0373109890085399,0.0393852824208924,0.041514840834889,0.0437431948848057,0.0461209398623877,0.0487035830371259,0.0515477453532323,0.0547054523864568,0.0582168546282454,0.0621023879018121,0.0663558236564226,0.0709396406065027,0.0757836661338225,0.0807872298262874,0.0858245059766227,0.0907525481483566,0.0954216709187161,0.0996879074202355,0.103426784755773,0.106546529565121,0.108997707407521,0.110776336371563,0.111919278851983,0.1124934301592,0.112582235147372,0.112273291906639,0.111649540448044,0.110784869490238,0.10974373936335,0.108583802309521,0.107360319768912,0.106131218338772,0.104961746361344,0.103927768433203,0.103116685438074,0.102624858350806,0.102550506302654,0.102981682926133,0.103980257251917,0.105564530119846,0.107694434575614],[0.0166856083812501,0.0182843430388284,0.0200767218002543,0.0220106712168221,0.0240408889623787,0.0261304237510619,0.0282515992223047,0.0303862751998386,0.0325255539276368,0.0346691587521296,0.0368247986457371,0.0390078286098411,0.0412413717499742,0.0435567709287507,0.0459938501190088,0.0486001403838893,0.0514281618677676,0.0545301977218941,0.0579507298666269,0.061717597256679,0.0658336118704106,0.0702704963000985,0.0749665006787499,0.0798281487438137,0.0847356952841487,0.0895514382434187,0.0941300950979937,0.0983307132578995,0.102029527482395,0.105132493899998,0.107585206582271,0.109377438541185,0.11054051606788,0.111138036961544,0.111252805074603,0.110973839594665,0.110386561338576,0.109567564507343,0.108583802309521,0.107495079258876,0.10635843647708,0.105233110398018,0.104185005564433,0.10328984449144,0.102634201910419,0.102313510365311,0.102426061550053,0.103062381590745,0.104290400275489,0.106138458121161,0.108579766828597],[0.0170309009009039,0.0183741443774614,0.019961924623402,0.0217426696601811,0.0236712848970544,0.0257103226997689,0.0278303977209859,0.0300098953209992,0.0322341671793313,0.0344945578485685,0.0367877087338195,0.0391155741302234,0.0414863944493764,0.0439164860155415,0.0464321946920124,0.0490708988766152,0.051879779055568,0.0549113968697175,0.0582159700752847,0.0618313585729791,0.0657727555273533,0.0700244602327785,0.0745356841725799,0.0792212833346261,0.0839671130397174,0.0886389000624342,0.093093363656403,0.0971905928021063,0.100806902172034,0.103847111519071,0.106254448586631,0.108015694584173,0.109159649703249,0.109748815904429,0.109866583642804,0.109603724990492,0.109047759328712,0.108277140617219,0.107360319768912,0.10635843647708,0.105329925935416,0.104335476670581,0.103442203722576,0.102726300320326,0.102273609833579,0.102177504351418,0.102533352112481,0.103429024147376,0.104931622509005,0.10707193345879,0.10982959053582],[0.0176227077845935,0.0187255391079382,0.0201230862453322,0.0217654972684213,0.023609124657479,0.0256171332160939,0.0277592460923794,0.0300107465165768,0.032351035192074,0.0347622238454742,0.0372283639033316,0.0397358852831468,0.042275579018315,0.0448459744950298,0.0474573139732284,0.0501347147520288,0.0529188175908524,0.0558625014438278,0.0590231699298102,0.0624514729788767,0.0661786504479392,0.0702054224577551,0.0744951355422329,0.0789727505795509,0.0835297202332216,0.0880335342703454,0.0923401727443969,0.0963078613964445,0.0998109018765983,0.102752419483958,0.105074460818783,0.10676338545883,0.107848711631506,0.108395027857676,0.108488883731186,0.108224442207695,0.107691903485977,0.106971198287026,0.106131218338772,0.105233110398018,0.104335476670581,0.103499551655562,0.102793080777742,0.102292254661182,0.102081401508485,0.102250190761531,0.102888025057679,0.104075363901974,0.10587217683983,0.108304635908844,0.111352283115469],[0.0184112786443383,0.0193036144352677,0.0205364563355298,0.0220634583583041,0.0238441881948054,0.0258440117422347,0.0280330007461299,0.0303840689693109,0.0328707640014087,0.0354653549447156,0.038137988574964,0.0408576437369137,0.0435953084654497,0.0463292085754549,0.0490511191524726,0.051772022780174,0.0545249656843273,0.057363196237199,0.0603526522165691,0.0635594121154091,0.0670343867389329,0.0707986936857298,0.0748332970184869,0.0790754419614093,0.0834225616148196,0.0877424884744388,0.091887716123396,0.0957113408970778,0.0990827757904326,0.101901732035687,0.104108931896927,0.10569173692745,0.106683010165943,0.107152714978651,0.107193929179962,0.106907088500316,0.106386972828554,0.10571561697311,0.104961746361344,0.104185005564433,0.103442203722576,0.102793080777742,0.102304063161057,0.102049436620413,0.102109946452767,0.10256902067649,0.103506783839688,0.104992022722983,0.107072464157825,0.109764198317764,0.113041726217119],[0.0193172496887705,0.0200423581397086,0.0211456469793341,0.0225866023071851,0.0243302842342403,0.0263463244850819,0.0286068255988149,0.0310834720514554,0.0337444298930393,0.0365518603713253,0.0394610180011997,0.0424218328801814,0.0453834893143447,0.0483017799036967,0.0511480492320706,0.0539176208888705,0.0566350945847835,0.0593541128195264,0.0621502240248153,0.0651071451363291,0.0682986586983935,0.0717699947986146,0.0755231887018097,0.0795101149518328,0.0836348243437206,0.0877643064447572,0.0917449588334424,0.0954214646357943,0.0986552350119151,0.101340326749818,0.103415179632419,0.104868571561808,0.105738359857973,0.106102529495525,0.106064024350804,0.105733113809483,0.105212260134586,0.104587524853554,0.103927768433203,0.10328984449144,0.102726300320326,0.102292254661182,0.102049436620413,0.102066807188804,0.102418123127492,0.10317716528555,0.104411357542059,0.106174391548663,0.10849840217679,0.11138628362159,0.114804908845702],[0.0202373545430986,0.0208478281555037,0.0218625706246616,0.0232496861286319,0.0249824555037043,0.0270372918356324,0.0293904679760304,0.0320140457697783,0.0348717546066247,0.0379158575355582,0.0410862019494618,0.0443125440979638,0.0475207426909342,0.0506425125125869,0.0536272691498109,0.0564535281944212,0.0591367698553657,0.0617309347674406,0.0643218025811392,0.0670122289257222,0.0699012934552287,0.0730614264944729,0.0765188450798398,0.0802423419962743,0.0841433537785074,0.0880870380626791,0.0919112734279505,0.0954491972577069,0.0985512045964603,0.101103449998262,0.103040923420831,0.104353732351723,0.105085579561552,0.105324178609466,0.105184925339355,0.104791298065786,0.104257101912314,0.103675434780255,0.103116685438074,0.102634201910419,0.102273609833579,0.102081401508485,0.102109946452767,0.102418123127492,0.103068252153533,0.104120637527244,0.105627032920497,0.107624065572147,0.110127276876865,0.113126101434321,0.116579914741623],[0.0210516141248012,0.021602876289728,0.0225699549560327,0.0239327005742675,0.0256757120523867,0.0277851146244285,0.0302439668339692,0.0330268552853245,0.0360946142218224,0.0393904494187039,0.0428389243668108,0.046349115163758,0.0498226133977412,0.0531659366943929,0.0563055137478691,0.0592021990009788,0.061861739126727,0.0643380045051197,0.0667269834018504,0.0691512267404509,0.0717364804592963,0.0745845358079433,0.0777482904039718,0.081215495753131,0.0849057710511616,0.0886816214752877,0.0923701939418145,0.0957901778901475,0.0987782095222593,0.101210604058146,0.103018007293712,0.104191849914758,0.104782242435146,0.104887590576054,0.104637267764746,0.10417035678817,0.10361523764427,0.103075372474765,0.102624858350806,0.102313510365311,0.102177504351418,0.102250190761531,0.10256902067649,0.10317716528555,0.104120637527244,0.105442771078341,0.107177942564458,0.109345907566447,0.111947428967978,0.114961243178256,0.118342017148305],[0.0216308185565193,0.0221726533066038,0.0231250360536958,0.0244828996383591,0.0262455376714748,0.0284120989309966,0.0309755461573968,0.0339157681373235,0.0371929840285189,0.040742988478514,0.0444759976719848,0.0482806604983484,0.0520340121657551,0.0556167609033422,0.0589316217540477,0.0619210517798117,0.064580298867567,0.0669623185873697,0.0691724614632012,0.0713524169495847,0.0736547254506154,0.0762115637406577,0.0791041891881894,0.0823409428008623,0.0858503692034513,0.0894916606878204,0.0930792672556463,0.0964148164781206,0.0993188002335625,0.101656224873726,0.103353057139428,0.104402571445975,0.104862115769381,0.104841501813262,0.10448470451514,0.103947420975635,0.103374465910063,0.10288218522253,0.102550506302654,0.102426061550053,0.102533352112481,0.102888025057679,0.103506783839688,0.104411357542059,0.105627032920497,0.107177942564458,0.109081468818869,0.111343399732056,0.113954504237764,0.116888383585565,0.120100020384222],[0.0218436758463872,0.0224106243518809,0.0233645023153083,0.0247187370588077,0.0264908882983998,0.0286967926700521,0.0313429736802349,0.0344181265782517,0.0378850222502866,0.0416746727400368,0.0456848692074931,0.0497849724381056,0.0538278673371518,0.0576682820873136,0.0611846483990364,0.0643001544683514,0.0669983577770905,0.0693297398868033,0.0714071769938292,0.0733897236751991,0.0754555175425166,0.0777669010031268,0.0804342146468295,0.0834874856536821,0.0868648084228072,0.0904215758088382,0.0939578908043491,0.0972560718556443,0.10011850049598,0.102397931691148,0.104015987465594,0.10496906278508,0.105323231845509,0.105200685521992,0.104760160903368,0.104173656593322,0.103602363239967,0.103176151056989,0.102981682926133,0.103062381590745,0.103429024147376,0.104075363901974,0.104992022722983,0.106174391548663,0.107624065572147,0.109345907566447,0.111343399732056,0.113614179481031,0.11614652614003,0.118916692761225,0.121886586438237],[0.0215636271123677,0.0221653460138802,0.023111210667939,0.0244365136706508,0.0261807728004444,0.028380506127086,0.0310600244238471,0.0342211476124548,0.0378333851627186,0.0418267364762657,0.0460896282272149,0.0504742642018614,0.0548105000575356,0.0589272621375833,0.062678081017518,0.0659655850158709,0.068759722155404,0.0711059789698952,0.0731217847031828,0.0749805227340939,0.0768834080097065,0.079021472046981,0.0815338496952199,0.0844727420062443,0.0877862633440928,0.0913257358299202,0.0948756865613284,0.0981973626594604,0.101073565803754,0.103344400801675,0.104928133739159,0.105826333685744,0.106116085261734,0.105933497377517,0.105452201444788,0.104859223430166,0.104330125041191,0.104006449881658,0.103980257251917,0.104290400275489,0.104931622509005,0.10587217683983,0.107072464157825,0.10849840217679,0.110127276876865,0.111947428967978,0.113954504237764,0.11614652614003,0.11851894361148,0.12105993339361,0.123745862555688],[0.0206756173712682,0.0212884113617055,0.0221832362790041,0.0234204805254652,0.0250653643770753,0.0271793781075005,0.0298094247004417,0.0329756318229061,0.0366595435632467,0.0407951715946082,0.0452658894575249,0.0499099438517527,0.0545360015284652,0.0589476194755151,0.0629725651941309,0.0664909288536984,0.0694561217415781,0.0719049280351492,0.0739551043288354,0.0757900605957289,0.0776303138573719,0.0796929205297642,0.0821445328592555,0.0850593943383111,0.0883959647032726,0.0920015175738187,0.0956443435828908,0.0990635044577494,0.102021357898257,0.104345513394756,0.105952437353606,0.106851565637909,0.107133962584367,0.10695177152194,0.106493830431803,0.105960334589026,0.105537609543634,0.10537453878966,0.105564530119846,0.106138458121161,0.10707193345879,0.108304635908844,0.109764198317764,0.11138628362159,0.113126101434321,0.114961243178256,0.116888383585565,0.118916692761225,0.12105993339361,0.123328316520917,0.125720682867589],[0.0190828850096431,0.0196435736264059,0.0204052535287975,0.021456414903528,0.0228917047983721,0.0248021151327367,0.0272624847552774,0.0303172817711952,0.033966503058887,0.0381544909245256,0.0427651789303845,0.0476271646380002,0.052530482460023,0.0572539355838214,0.0615982752030172,0.0654181840902741,0.0686463861879824,0.0713059001829667,0.0735092539496809,0.075444345101303,0.0773460695850045,0.0794537853683119,0.0819594966089163,0.0849588020344645,0.0884207553569314,0.0921890192445248,0.0960157406076288,0.0996175316874479,0.102736190883306,0.105187564744777,0.106888328103055,0.107858882603496,0.108207633789301,0.108105193171818,0.107755996492083,0.107371136840097,0.107142928208123,0.107221272697958,0.107694434575614,0.108579766828597,0.10982959053582,0.111352283115469,0.113041726217119,0.114804908845702,0.116579914741623,0.118342017148305,0.120100020384222,0.121886586438237,0.123745862555688,0.125720682867589,0.127840734674854]],"type":"surface","contours":{"z":{"show":true,"usecolormap":true,"highlightcolor":"#ff0000","project":{"z":true}}},"frame":null}],"highlight":{"on":"plotly_click","persistent":false,"dynamic":false,"selectize":false,"opacityDim":0.2,"selected":{"opacity":1},"debounce":0},"shinyEvents":["plotly_hover","plotly_click","plotly_selected","plotly_relayout","plotly_brushed","plotly_brushing","plotly_clickannotation","plotly_doubleclick","plotly_deselect","plotly_afterplot","plotly_sunburstclick"],"base_url":"https://plot.ly"},"evals":[],"jsHooks":[]}</script>
<p>The next plot, the <a href="https://en.wikipedia.org/wiki/Modes_of_variation">Modes of Variation Plot</a> shows the modes of variation about the mean for the first two eigenfunctions. The mean function is indicated by the red line. The dark gray shows the variation of the first eigenfunction, and the light gray shows the variation of the second. The plot indicates that all of the subjects begin their careers with similar entry level wages, start to diverge by their second year, reach peak variation around year eight and then begin to converge again by year eleven.</p>
<pre class="r"><code>CreateModeOfVarPlot(res_wages, main = "Modes of Variation of Eigenvectors")</code></pre>
<p><img src="/2021/07/08/exploratory-fda-with-sparse-data/index_files/figure-html/unnamed-chunk-14-1.png" width="672" />
### Some Conclusions</p>
<p>This short post neither presents a comprehensive view of functional principal components analysis, nor does it provide the last word on the <code>wages</code> data set. Nevertheless, juxtaposing the highly visual but traditional exploratory analysis conducted by the authors of the <code>brolgar</code> package with a basic FPCA look does provide some insight into the promise and pitfalls of using FPCA to explore sparse, longitudinal data sets.</p>
<p>On the promise side:</p>
<ol style="list-style-type: decimal">
<li><p>FDA offers a global perspective that facilitates thinking about an individual subject’s <em>time path</em> as a whole. For the <code>wages</code> data set, we see individual trajectories developing in a wages/time space that can be parsimoniously represented, analyzed and compared.</p></li>
<li><p>FPCA works with very sparse data, does not require the same number of observations for each subject, and does not demand that the observations be taken at the same time points.</p></li>
<li><p>There is really no concept of missing data per se, and no need for data imputation. The amount of information required to represent a subject can vary over a wide range.</p></li>
</ol>
<p>As to the pitfalls:</p>
<ol style="list-style-type: decimal">
<li><p>As with plain old multivariate PCA, eigenvectors may not have any obvious meaning, and trajectories in an abstract space may be difficult to interpret.</p></li>
<li><p>There is really no way to avoid the missing data <em>daemon</em>. The <code>wages</code> data set shows the sensitivity of FPCA trajectories to both the number and the locations of the observed data points. It is not possible to reconstruct individual trajectories for which there are too few observations.</p></li>
</ol>
<p>That’s all for now. Thank you for following along.</p>
</div>
<script>window.location.href='https://rviews.rstudio.com/2021/07/08/exploratory-fda-with-sparse-data/';</script>
May 2021: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2021/06/24/may-2021-top-40-new-cran-packages/
Thu, 24 Jun 2021 00:00:00 +0000https://rviews.rstudio.com/2021/06/24/may-2021-top-40-new-cran-packages/
<p>Two hundred five packages made it to CRAN in May, but seven were removed before this post went to print. Here are my “Top40” picks in ten categories: Computational Methods, Data, Genomics, Machine Learning, Medicine, Science, Statistics, Time Series, Utilities, and Visualization.</p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=madgrad">madgrad</a> v0.1.0: Implements MADGRAD, a Momentumized, Adaptive Dual Averaged Gradient method for stochastic optimization. See <a href="https://arxiv.org/abs/2101.11075">Defazio & Jelassi (2021)</a> for details and <a href="https://cran.r-project.org/web/packages/madgrad/readme/README.html">README</a> to get started.</p>
<p><img src="madgrad.gif" height = "250" width="450"></p>
<p><a href="https://cran.r-project.org/package=TriDimRegression">TriDimRegression</a> v1.0.0.0: Provides functions to fit 2D and 3D transformations using <a href="https://mc-stan.org/">Stan</a> which return posterior distributed for fitted parameters. There are vignettes on <a href="https://cran.r-project.org/web/packages/TriDimRegression/vignettes/transformation_matrices.html">Transformation Matrices</a>, <a href="https://cran.r-project.org/web/packages/TriDimRegression/vignettes/calibration.html">Eye Gaze Mapping</a>, and <a href="https://cran.r-project.org/web/packages/TriDimRegression/vignettes/comparing_faces.html">Comparing Faces</a>. See <a href="https://cran.r-project.org/web/packages/TriDimRegression/readme/README.html">README</a> to get started.</p>
<p><img src="Tri.png" height = "300" width="500"></p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=AtmChile">AtmChile</a> v0.1.0: Provides access to air quality and meteorological information from the Chile’s National Air Quality System <a href="https://sinca.mma.gob.cl/">(S.I.N.C.A.)</a>. See <a href="https://cran.r-project.org/web/packages/AtmChile/readme/README.html">READMW</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=basemaps">basemaps</a> v0.0.1: Provides a lightweight interface to access spatial basemaps from open sources such as <a href="https://www.openstreetmap.org/#map=5/38.007/-95.844">OpenStreetMap</a>, <a href="https://www.mapbox.com/">Mapbox</a> and others. See <a href="https://cran.r-project.org/web/packages/basemaps/readme/README.html">README</a> to get started.</p>
<p><img src="basemaps.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=causaldata">causaldata</a> v0.1.1: Contains the data sets to run the example problems in the online causal inference textbooks <a href="https://theeffectbook.net/"><em>The Effect</em></a> and <a href="https://www.hsph.harvard.edu/miguel-hernan/causal-inference-book/"><em>Causal Inference: What If</em></a> and more.</p>
<p><a href="https://cran.r-project.org/package=exoplanets">exoplanets</a> v0.2.1: Provides access to NASA’s <a href="https://exoplanetarchive.ipac.caltech.edu/index.html">Exoplanet Archive</a>. See the <a href="https://cran.r-project.org/web/packages/exoplanets/vignettes/exoplanets.html">vignette</a> to get started.</p>
<p><img src="exoplanets.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=frenchdata">frenchdata</a> v0.1.1: Provides access to Kenneth’s French <a href="http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html">finance data library</a>. See the <a href="https://cran.r-project.org/web/packages/frenchdata/vignettes/basic_usage.html">vignette</a> for basic usage.</p>
<p><img src="frenchdata.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=tradepolicy">tradepolicy</a> v0.5.0: Provides access to the data sets from <a href="https://zenodo.org/record/4277741#.YNIS_TZKj0o">Yotov et al. (2016)</a> along with an <a href="https://r.tiid.org/R_structural_gravity/">online book</a> containing commentary and the code to recreate the original analysis.</p>
<p><img src="trade.png" height = "300" width="500"></p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=artemis">artemis</a> v1.0.7: Provides a modeling framework for the design and analysis of experiments collecting environmental DNA. There is an <a href="https://cran.r-project.org/web/packages/artemis/vignettes/artemis-overview.html">Introduction</a> and also vignettes on <a href="https://cran.r-project.org/web/packages/artemis/vignettes/modeling.html">Modeling eDNA and qPCR Data</a> and <a href="https://cran.r-project.org/web/packages/artemis/vignettes/simulation.html">Simulating eDNA Data</a>.</p>
<p><img src="artemis.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=MAGEE">MAGEE</a> v1.0.0: Provides functions to perform variant set-based main effect tests, gene-environment interaction tests, and joint tests for association, as proposed in <a href="https://onlinelibrary.wiley.com/doi/10.1002/gepi.22351">Wang et al. (2020)</a>. See the <a href="https://cran.r-project.org/web/packages/MAGEE/vignettes/MAGEE.pdf">vignette</a> for details.</p>
<p><a href="https://cran.r-project.org/package=MultIS">MultIS</a> v0.5.1: Implements a bioinformatical approach to detect the multiple integration of viral vectors within the same clone. See the <a href="https://cran.r-project.org/web/packages/MultIS/vignettes/QuickStart.html">vignette</a> for how to use the package.</p>
<p><img src="MultIS.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=TopDom">TopDom</a> v0.10.0: Provides functions to identify topological domains in genomes from Hi-C sequence data as described in <a href="https://academic.oup.com/nar/article/44/7/e70/2467818">Shin et al. (2016)</a>. See <a href="https://cran.r-project.org/web/packages/TopDom/readme/README.html">README</a> to get started.</p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=cjbart">cjbart</a> v0.1.0: Implements a tool for analyzing conjoint experiments using Bayesian Additive Regression Trees (BART), a machine learning method developed by <a href="https://projecteuclid.org/journals/annals-of-applied-statistics/volume-4/issue-1/BART-Bayesian-additive-regression-trees/10.1214/09-AOAS285.full">Chipman & McCulloch (2010)</a>. See the <a href="https://cran.r-project.org/web/packages/cjbart/vignettes/cjbart-demo.html">vignette</a> for examples.</p>
<p><img src="cjbart.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=fastText">fastText</a> v1.0.1: Implements an interface to Facebook’s <a href="https://github.com/facebookresearch/fastText">fastText Library</a>. See <a href="https://direct.mit.edu/tacl/article/doi/10.1162/tacl_a_00051/43387/Enriching-Word-Vectors-with-Subword-Information">Bojanowski et al. (2017)</a> for a description of the algorithm. There is a <a href="https://cran.r-project.org/web/packages/fastText/vignettes/language_identification.html">Benchmark</a> vignette and an <a href="https://cran.r-project.org/web/packages/fastText/vignettes/the_fastText_R_package.html">Introduction</a>.</p>
<p>.</p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=afdx">afdx</a> v1.1.1: Provides functions to estimate diagnosis performance (Sensitivity, Specificity, Positive predictive value, Negative predicted value) of a diagnostic test when there is no golden standard by estimating the attributable fraction using either a <a href="https://cran.r-project.org/web/packages/afdx/vignettes/af_logit_exponential.html">logitexponential model</a> or a <a href="https://cran.r-project.org/web/packages/afdx/vignettes/latentclass.html">latent class model</a>.</p>
<p><img src="afdx.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=covidcast">covidcast</a> v0.4.2: Provides an interface to Delphi’s <a href="https://cmu-delphi.github.io/delphi-epidata/api/covidcast.html">COVIDcast Epidata</a> including tools for data access, maps and time series plotting, and basic signal processing, and a collection of numerous indicators relevant to the COVID-19 pandemic in the United States. There is a <a href="https://cran.r-project.org/web/packages/covidcast/vignettes/covidcast.html">Getting Started Guide</a>, and vignettes on <a href="https://cran.r-project.org/web/packages/covidcast/vignettes/correlation-utils.html">Computing Signal Correlations</a>, <a href="https://cran.r-project.org/web/packages/covidcast/vignettes/external-data.html">Combining Data Sources</a>, <a href="https://cran.r-project.org/web/packages/covidcast/vignettes/multi-signals.html">Manipulating Multiple Signals</a>, and <a href="https://cran.r-project.org/web/packages/covidcast/vignettes/plotting-signals.html">Plotting and Mapping Signals</a>.</p>
<p><img src="covidcast.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=eventTrack">eventTrack</a> v1.0.0: Implements the hybrid framework for event prediction in clinical trials as described in <a href="https://www.sciencedirect.com/science/article/pii/S155171441100139X?via%3Dihub">Fang & Zheng (2011)</a>. See the <a href="https://cran.r-project.org/web/packages/eventTrack/vignettes/eventTrack.html">vignette</a> for an example.</p>
<p><img src="eventTrack.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=goldilocks">goldilocks</a> v0.3.0: Implements the Goldilocks adaptive trial design for a time to event outcome using a piecewise exponential model and conjugate Gamma prior distributions as described in <a href="https://www.tandfonline.com/doi/abs/10.1080/10543406.2014.888569?journalCode=lbps20">Broglio et al. (2014)</a>. See the <a href="https://cran.r-project.org/web/packages/goldilocks/vignettes/broglio.html">vignette</a> for an example.</p>
<h3 id="science">Science</h3>
<p><a href="https://cran.r-project.org/package=CopernicusDEM">CopernicusDEM</a> v1.0.1: Provides an interface to the <a href="https://spacedata.copernicus.eu/explore-more/news-archive/-/asset_publisher/Ye8egYeRPLEs/blog/id/434960">Copernicus DEM</a> Digital Elevation Model of the European Space Agency with 90 and 30 meters resolution using the <a href="https://aws.amazon.com/cli/">AWS CLI</a> command line tool. See the <a href="https://cran.r-project.org/web/packages/CopernicusDEM/vignettes/Copernicus_Digital_Elevation_Models.html">vignette</a> for an example.</p>
<p><img src="DEM.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=nimbleCarbon">nimbleCarbon</a> v0.1.2: Provides functions and a custom probability distribution for Bayesian analyses of radiocarbon dates within the <code>nimble</code> modeling framework, including a suite of functions for prior and posterior predictive checks for demographic inference as described in <a href="https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0251695">Crema & Shoda (2021)</a>. See the <a href="https://cran.r-project.org/web/packages/nimbleCarbon/vignettes/nimble_carbon_vignette.html">Introduction</a>.</p>
<p><img src="nimbleCarbon.png" height = "300" width="500"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=bayesmodels">bayesmodels</a> v0.1.0: Implements a framework to bring a number of Bayesian models into the <code>tidymodels</code> ecosystem. See the <a href="https://cran.r-project.org/web/packages/bayesmodels/vignettes/modeltime-integration.html">vignette</a> for an overview.</p>
<p><img src="bayesmodels.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=div">div</a> v0.3.1: Provides functions to facilitate the analysis of teams in a corporate setting, assess the diversity per grade and job, search for bias and also provides methods to simulate the effects of bias. See <a href="http://www.de-brouwer.com/assets/div/div-white-paper.pdf">De Brouwer (2021)</a> and <a href="https://onlinelibrary.wiley.com/doi/book/10.1002/9781119632757">De Brouwer (2020)</a> for background. Look <a href="http://www.de-brouwer.com/div/">here</a> to get started.</p>
<p><img src="div.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=HotellingEllipse">HotellingEllipse</a> v0.1.1: Provides functions to compute the semi-axes lengths and coordinate points of Hotelling ellipse. See <a href="https://pubs.rsc.org/en/content/articlelanding/2014/AY/C3AY41907J#!divAbstract">Bro & Smilde (2014)</a> and <a href="https://analyticalsciencejournals.onlinelibrary.wiley.com/doi/full/10.1002/cem.2763">Brenton (2016)</a> for background. Look <a href="https://github.com/ChristianGoueguel/HotellingEllipse">here</a> and at the <a href="https://cran.r-project.org/web/packages/HotellingEllipse/vignettes/HotellingEllipse.html">vignette</a> for examples.</p>
<p><img src="Hottelling.png" height = "300" width="500"></p>
<p><a href="https://CRAN.R-project.org/package=makemyprior">makemyprior</a> v1.0.0: Provides tools to construct and visualize joint priors for variance parameters. Vignettes provide examples for <a href="https://cran.r-project.org/web/packages/makemyprior/vignettes/latin_square.html">Latin Square</a>, <a href="https://cran.r-project.org/web/packages/makemyprior/vignettes/make_prior.html">i.i.d. models</a>, <a href="https://cran.r-project.org/web/packages/makemyprior/vignettes/neonatal_mortality.html">neonatal mortality</a>, and <a href="https://cran.r-project.org/web/packages/makemyprior/vignettes/wheat_breeding.html">wheat breeding</a>.</p>
<p><img src="makemyprior.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=Rage">Rage</a> v1.0.0: Provides functions for calculating life history metrics using matrix population models (MPMs) as described in <a href="https://www.biorxiv.org/content/10.1101/2021.04.26.441330v2">Jones et al. (2021)</a>. There is a <a href="https://cran.r-project.org/web/packages/Rage/vignettes/a01_GettingStarted.html">Getting Started Guide</a> and vignettes on <a href="https://cran.r-project.org/web/packages/Rage/vignettes/a02_VitalRates.html">Vital Rates</a>, <a href="https://cran.r-project.org/web/packages/Rage/vignettes/a03_LifeHistoryTraits.html">Life History Traits</a>, <a href="https://cran.r-project.org/web/packages/Rage/vignettes/a04_AgeFromStage.html">Deriving Age</a>, and <a href="https://cran.r-project.org/web/packages/Rage/vignettes/a05_TernaryPlots.html">Ternary Plots</a>.</p>
<p><img src="Rage.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=unusualprofile">unusualprofile</a> v0.1.0: Provides functions to calculate <a href="https://link.springer.com/article/10.1007%2Fs13171-019-00164-5">Mahalanobis distance</a> for every row of a set of outcome variables. There is an <a href="https://cran.r-project.org/web/packages/unusualprofile/vignettes/tutorial_unusualprofile.html">Introduction</a> and a vignette on the <a href="https://cran.r-project.org/web/packages/unusualprofile/vignettes/unusualprofile_calculations.html">calculations</a>.</p>
<p><img src="unusualprofile.png" height = "200" width="400"></p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=gsignal">gsignal</a> v0.3-2: Implements the <a href="https://octave.sourceforge.io/packages.php">Ovtave signal</a> package which provides a variety of signal processing tools, such as signal generation and measurement, correlation and convolution, filtering, filter design, filter analysis and conversion, power spectrum analysis, system identification, decimation and sample rate change, and windowing. See the <a href="https://cran.r-project.org/web/packages/gsignal/vignettes/gsignal.html">vignette</a> for an introduction.</p>
<p><img src="gsignal.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=legion">legion</a> v0.1.0 Provides functions for implementing multivariate state space models such as Vector Exponential Smoothing and Vector Error-Trend-Seasonal models, for time series analysis and forecasting as described in <a href="https://journals.sagepub.com/doi/10.1177/1471082X0901000401">de Silva et al. (2010)</a> There is a <a href="https://cran.r-project.org/web/packages/legion/vignettes/legion.html">Function Overview</a> and vignettes on <a href="https://cran.r-project.org/web/packages/legion/vignettes/ves.html">Vector ES</a> and <a href="https://cran.r-project.org/web/packages/legion/vignettes/vets.html">Vector ETS</a>.</p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=parsermd">parsermd</a> v0.1.2: Implements formal grammar and parser for R Markdown documents using the <a href="https://www.boost.org/doc/libs/1_76_0/libs/spirit/doc/x3/html/index.html">Boost Spirit X3</a> library. It also includes a collection of high level functions for working with the resulting abstract syntax tree. There is a <a href="https://cran.r-project.org/web/packages/parsermd/vignettes/parsermd.html">Getting Started Guide</a> and a vignette on <a href="https://cran.r-project.org/web/packages/parsermd/vignettes/templates.html">Rmd Templates</a>.</p>
<p><a href="https://cran.r-project.org/package=riskmetric">riskmetric</a> v0.1.0: Provides facilities for assessing R packages against a number of metrics to help quantify their robustness. Look <a href="https://pharmar.github.io/riskmetric/">here</a> for background on the package and <a href="https://www.pharmar.org/about/">here</a> for background on the R Consortium, R Validation Hub project. There is a <a href="https://cran.r-project.org/web/packages/riskmetric/riskmetric.pdf">Quick Start Guide</a> and a vignette on <a href="https://cran.r-project.org/web/packages/riskmetric/vignettes/extending-riskmetric.html">Extending riskmetric</a>.</p>
<p><a href="https://cran.r-project.org/package=shinyvalidate">shinyvalidate</a> v0.1.0: Provides functions to improve the user experience of Shiny apps by providing feedback when required inputs are missing, or input values are not valid. See <a href="https://cran.r-project.org/web/packages/shinyvalidate/readme/README.html">README</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=ttt">ttt</a> v1.0: Provides tools to create structured, formatted HTML tables. See the <a href="https://cran.r-project.org/web/packages/ttt/vignettes/ttt-intro.html">vignette</a>.</p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=fitbitViz">fitbitViz</a> v1.0.1: Implements a connection to the <a href="https://dev.fitbit.com/build/reference/web-api/">Fitbit Web API</a> to provide <code>ggplot2</code>, <code>Leaflet</code> and <code>Rayshader</code> visualizations. See the <a href="https://cran.r-project.org/web/packages/fitbitViz/vignettes/fitbit_viz.html">vignette</a> for examples.</p>
<p><img src="fitbitViz.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=ggbreak">ggbreak</a> v0.0.3: Implements scale functions for setting axis breaks for <code>ggplot2</code>. See the <a href="https://cran.r-project.org/web/packages/ggbreak/vignettes/ggbreak.html">vignette</a>.</p>
<p><img src="ggbreak.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=ggpp">ggpp</a> v0.4.0: Provides extensions to <code>ggplot2</code> to add inserts to plots using both <em>native</em> and <a href="https://www.christophenicault.com/post/npc_ggplot2/"><em>npc</em></a> data coordinates. See the <a href="https://cran.r-project.org/web/packages/ggpp/vignettes/grammar-extensions.html">vignette</a> for examples.</p>
<p><img src="ggpp.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=ggseg">ggseg</a> v1.6.3: Implements a <code>ggplot</code> geom for plotting brain atlases using simple features. The largest component of the package is the data for two built-in atlases. See <a href="https://journals.sagepub.com/doi/10.1177/2515245920928009">Mowinckel & Vidal-Piñero (2020)</a> for background. There is an <a href="https://cran.r-project.org/web/packages/ggseg/vignettes/ggseg.html">Introduction</a> along with vignettes on <a href="https://cran.r-project.org/web/packages/ggseg/vignettes/externalData.html">external data</a>, <a href="https://cran.r-project.org/web/packages/ggseg/vignettes/freesurfer_files.html">Freesurfer files</a>, <a href="https://cran.r-project.org/web/packages/ggseg/vignettes/geom-sf.html">using atlases</a>.</p>
<p><img src="ggseg.png" height = "2500" width="550"></p>
<p><a href="https://cran.r-project.org/package=ichimoku">ichimoku</a> v0.2.0: Implements <a href="https://www.investopedia.com/terms/i/ichimokuchart.asp">Ichimoku Kinko Hyo</a>, also commonly known as <a href="https://www.amazon.com/Charts-Trading-Success-Ichimoku-Technique/dp/0956517102">cloud charts</a>, including static and interactive visualizations with tools for creating, backtesting and developing quantitative <em>ichimoku</em> strategies. There is a <a href="https://cran.r-project.org/web/packages/ichimoku/vignettes/reference.html">Reference</a> and a vignette on <a href="https://cran.r-project.org/web/packages/ichimoku/vignettes/strategies.html">Strategies</a>.</p>
<p><img src="ichimoku.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=liminal">liminal</a> v0.1.2: Provides functions for composing interactive visualizations and creating linked interactive graphics for exploratory high-dimensional data analysis. See <a href="https://arxiv.org/abs/2012.06077">Lee et al. (2020)</a> for background. There is a vignette on <a href="https://cran.r-project.org/web/packages/liminal/vignettes/liminal.html">Exploring Non-linear Embeddings</a> and another on the the geometry of <a href="https://cran.r-project.org/web/packages/liminal/vignettes/geometry_parameter_space.html">Parameter Space</a>.</p>
<p><img src="liminal.png" height = "200" width="300"></p>
<p><a href="https://cran.r-project.org/package=mipplot">mipplot</a> v0.3.1: Provides generic functions to produce area, bar, box, and line plots following Integrated Assessment Modeling Consortium <a href="https://www.iamconsortium.org/">(IAMC)</a> submission format in order to visualize climate migration scenarios. See the <a href="https://cran.r-project.org/web/packages/mipplot/vignettes/mipplot-first-steps.html">vignette</a> for first steps.</p>
<p><img src="mipplot.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=qqboxplot">qqboxplot</a> v0.1.0: Implements Q-Q boxplots as an extension to <code>ggplot2</code>. There is a vignette on <a href="https://cran.r-project.org/web/packages/qqboxplot/vignettes/qqboxplot-basic-usage.html">Basic Usage</a> and another that provides <a href="https://cran.r-project.org/web/packages/qqboxplot/vignettes/qqboxplot-paper-replication.html">Examples</a>.
<img src="qqboxplot.png" height = "300" width="500"></p>
<script>window.location.href='https://rviews.rstudio.com/2021/06/24/may-2021-top-40-new-cran-packages/';</script>
Summer Conferences!
https://rviews.rstudio.com/2021/06/17/summer-conferences/
Thu, 17 Jun 2021 00:00:00 +0000https://rviews.rstudio.com/2021/06/17/summer-conferences/
<p>Summer is here, but it is not too late sign up for some summer conferences. The following short list promises interesting speakers, a wide range of topics and plenty of R content.</p>
<p><img src="sc.png" height = "300" width="100%"></p>
<p>June (21 - 23) - The <a href="https://psiweb.org/conferences">PSI 2021</a> conference is online and the <a href="https://psiweb.org/conferences/conference-registration">Registration Portal</a> is still open. Keynote speakers <a href="https://www.ft.com/alan-smith">Alan Smith</a> and <a href="https://www.ft.com/ian-bott">Ian Bott</a> from the Financial Times, and <a href="https://www.statcollab.com/people/janet-wittes/">Janet Wittes</a>, President of the WCG Statistics Collaborative, head the program.</p>
<p>June (21 - 24) - The <a href="https://community.amstat.org/biop/events/ncb/index">Nonclinical Biostatistics Conference 2021</a> is virtual. <a href="https://en.wikipedia.org/wiki/Wendy_L._Martinez">Wendy Martinez</a> of the Bureau of Labor statistics will present <em>A Conversation About Data Ethics</em>, <a href="https://en.wikipedia.org/wiki/Nassim_Nicholas_Taleb">Nassim Taleb</a> of <em>Black Swan</em> fame will deliver the keynote on <em>Statistical Consequences of Fat Tails</em>, and <a href="http://dicook.org/">Di Cook</a> and RStudio’s Carson Sievert will both talk in the Statistical Computational & Visualization Session. <a href="https://community.amstat.org/biop/events/ncb/registration">Registration</a> is open.</p>
<p>July (1 to 2) - <a href="https://r-hta.org/events/workshop/2021/">R for HTA Annual Workshop</a> This online workshop from the Health Technology Assessment Consortium will be focused on R for trial and model-based cost-effectiveness analysis. <a href="https://onlinestore.ucl.ac.uk/conferences-and-events/faculty-of-mathematical-physical-sciences-c06/department-of-statistical-science-f61/f61-workshop-r-for-health-technology-assessment-2021">Registration</a> is open until June 30.</p>
<p>July (5 - 9) - <a href="https://user2021.r-project.org/">useR!2021</a> looks like it is going to be a blockbuster of a conference. The <a href="https://user2021.r-project.org/program/keynotes/">keynote talks</a> alone would be worth the price of admission. This exceptional lineup comprises a remarkably diverse, international group of long-time contributors, new faces, R developers, statisticians, journalists, and educators representing the global R community and speaking on a wide range of topics. I am very pleased to be presenting <em>A little bit about RStudio</em> on July 9 at UTC 9PM. <a href="https://user2021.r-project.org/participation/registration/">Registration</a> closes on June 25.</p>
<p>July (28 - 30) - <a href="https://juliacon.org/2021/">Juliacon 2021</a> will be online and everywhere and <strong>Free</strong>! Long time R contributor <a href="http://janvitek.org/">Jan Vitek</a>, Xiaoye Li of the Lawrence Livermore National Laboratory, and Soumith Chintala of Facebook AI Research will be the keynote speakers. It is free but you need to <a href="https://juliacon.org/2021/tickets/">Register</a>.</p>
<p>Aug (8 - 12) - The <a href="https://ww2.amstat.org/meetings/jsm/2021/">JSM</a> will be online. A keyword search using R and Shiny will turn up quite a few interesting talks. I am particularly looking forward to <a href="https://ww2.amstat.org/meetings/jsm/2021/onlineprogram/AbstractDetails.cfm?abstractid=318815">the talk</a> <em>Simulating Clinical Trials Data with Synthetic.Cdisc.Data and Respectables]</em> by Gabe Becker and Adrian Waddell and <a href="https://ww2.amstat.org/meetings/jsm/2021/onlineprogram/ActivityDetails.cfm?sessionid=220593">the session</a> on <em>Tools to Enable the Use of R by the Biopharmaceutical Industry in a Regulatory Setting</em> which contains five talks from members of the R Consortium’s <a href="https://www.pharmar.org/">R Validation Hub</a> working group.</p>
<p>August (24 - 27) - <a href="https://r-medicine.com/">R/Medicine 2021</a> is online and on track to repeat the last year’s international success. <a href="https://bit.ly/3zuZPTj">Registration</a> is open. The deadline for submitting <a href="https://r-medicine.com/abstract">Abstracts</a> is June 25. Workshops being planned include:</p>
<ul>
<li>R/Med 101: Intro to R for Clinicians and Healthcare Professionals</li>
<li>R Markdown for Reproducible Research (R<sup>3</sup>)</li>
<li>SAS 2 R: Getting off the Island!</li>
<li>From Excel to R+REDcap</li>
<li>Spatial Analysis of Healthcare Data</li>
</ul>
<p>Sept (6 to 9) - <a href="https://rss.org.uk/training-events/conference2021/">RSS 2021 International Conference</a> The Royal Statistical Society conference hopes to be in person in Manchester, UK. The <a href="https://rss.org.uk/training-events/conference2021/conference-programme/">keynote speakers</a> will be Tom Chivers and David Chivers,
Melinda Mills, Jonty Rougier, Eric Tchetgen Tchetgen,
Bin Yu, and <strong>Hadley Wickham</strong>. Submissions for poster presentations are currently open with a deadline of July 1. Registration is open with an early booking discount available until June 4.</p>
<script>window.location.href='https://rviews.rstudio.com/2021/06/17/summer-conferences/';</script>
Functional PCA with R
https://rviews.rstudio.com/2021/06/10/functional-pca-with-r/
Thu, 10 Jun 2021 00:00:00 +0000https://rviews.rstudio.com/2021/06/10/functional-pca-with-r/
<script src="/2021/06/10/functional-pca-with-r/index_files/header-attrs/header-attrs.js"></script>
<p>In two previous posts, <a href="https://rviews.rstudio.com/2021/05/04/functional-data-analysis-in-r/">Introduction to Functional Data Analysis with R</a> and <a href="https://rviews.rstudio.com/2021/05/14/basic-fda-descriptive-statistics-with-r/">Basic FDA Descriptive Statistics with R</a>, I began looking into FDA from a beginners perspective. In this post, I would like to continue where I left off and investigate Functional Principal Components Analysis (FPCA), the analog of ordinary Principal Components Analysis in multivariate statistics. I’ll begin with the math, and then show how to compute FPCs with R.</p>
<p>As I have discussed previously, although the theoretical foundations of FDA depend on some pretty advanced mathematics, it is not necessary to master this math to do basic analyses. The R functions in the various packages insulate the user from most of the underlying theory. Nevertheless, attaining a deep understanding of what the R functions are doing, or looking into any of the background references requires some level of comfort with the notation and fundamental mathematical ideas.</p>
<p>I will define some of the basic concepts and then provide a high level roadmap of the mathematical argument required to develop FPCA from first principals. It is my hope that if you are a total newcomer to Functional Data Analysis you will find this roadmap useful in apprehending the big picture. This synopsis closely follows the presentation by Kokoszka and Reimherr (Reference 1. below).</p>
<p>We are working in <span class="math inline">\(\mathscr{H}\)</span>, a separable <a href="https://en.wikipedia.org/wiki/Hilbert_space#:~:text=A%20Hilbert%20space%20is%20a,of%20calculus%20to%20be%20used.">Hilbert space</a> of square integrable random functions where each random function, <span class="math inline">\(X(\omega,t)\)</span>, where <span class="math inline">\(\omega \in \Omega\)</span> the underlying space of probabilistic outcomes, and <span class="math inline">\(t \in [0,1]\)</span>. (After the definitions below, I will suppress the independent variables and in most equations assume <span class="math inline">\(EX = 0\)</span>.)</p>
<div id="definitions" class="section level3">
<h3>Definitions</h3>
<ul>
<li>A Hilbert Space <span class="math inline">\(\mathscr{H}\)</span> is an infinite dimensional vector space with an inner product denoted by <span class="math inline">\(<.,.>\)</span>. In our case, the <em>vectors</em> are functions.</li>
<li><span class="math inline">\(\mathscr{H}\)</span> is separable if there exists an orthonormal basis. That is, there is an orthogonal collection of functions <span class="math inline">\((e_i)\)</span> in <span class="math inline">\(\mathscr{H}\)</span> such that <span class="math inline">\(<e_i,e_j>\; = 0\)</span> if <span class="math inline">\(i = j\)</span> and 0 otherwise, and every function in <span class="math inline">\(\mathscr{H}\)</span> can be represented as a linear combination of these functions.</li>
<li>The inner product of two functions <span class="math inline">\(X\)</span> and <span class="math inline">\(Y\)</span> in <span class="math inline">\(\mathscr{H}\)</span> is defined as <span class="math inline">\(<X,Y>\; = \int X(\omega,t) Y(\omega,t)dt\)</span>.</li>
<li>The norm of <span class="math inline">\(X\)</span> is defined in terms of the inner product: <span class="math inline">\(\parallel X(\omega) \parallel ^2\; = \int X(\omega, t)^2 dt < \infty\)</span>.</li>
<li><span class="math inline">\(X\)</span> is said to be square integrable if <span class="math inline">\(E\parallel X(\omega) \parallel ^2 < \infty\)</span>.</li>
<li>The <a href="https://math.stackexchange.com/questions/1687111/understanding-the-definition-of-the-covariance-operator">covariance operator</a> <span class="math inline">\(C(y): \mathscr{H} \Rightarrow \mathscr{H}\)</span> for any square integrable function <span class="math inline">\(X\)</span> is given by: <span class="math inline">\(C(y) = E[<X - EX,y>(X - EX)]\)</span></li>
</ul>
</div>
<div id="the-road-to-functional-principal-components" class="section level3">
<h3>The Road to Functional Principal Components</h3>
<p>As we have seen, the fundamental idea of Functional Data Analysis is to represent a function <span class="math inline">\(X\)</span> by a linear combination of basis elements. In the previous posts we showed how to accomplish this using a basis constructed from more or less arbitrarily selected B-spline vectors. But, is there a an empirical, some would say <em>natural</em> basis that can be estimated from the data? The answer is yes, and that is what FPCA is all about.</p>
<p>A good way to start is to look at the distance between a vector <span class="math inline">\(X\)</span> and its projection down into the space spanned by some finite, p-dimensional basis <span class="math inline">\((u_k)\)</span> which is expressed in the following equation,</p>
<p><span class="math inline">\(D = E\parallel X - \sum_{k=1}^{p}<X, u_k>u_k\parallel^2\)</span> <span class="math inline">\((*)\)</span></p>
<p>This expands out to:</p>
<p><span class="math inline">\(= E [< (X - \sum_{k=1}^{p}<X, u_k>u_k, X - \sum_{k=1}^{p}<X, u_k>u_k)>]\)</span></p>
<p>and with a little algebra this:</p>
<p><span class="math inline">\(= E\parallel X \parallel^2 - \sum_{k=1}^{p}E<X, u_k>^2\)</span></p>
<p>It should be clear that we would want to find a basis that makes <span class="math inline">\(D\)</span> as small as possible, and that minimizing <span class="math inline">\(D\)</span> is equivalent to maximizing the term to be subtracted in the line above.</p>
<p>A little algebra shows that, <span class="math inline">\(E<X, u_k>^2 \;=\; <C(u_k),u_k>\)</span> where <span class="math inline">\(C(u_k)\)</span> is the covariance operator defined above.</p>
<p>Now, we are almost at our destination. There is a theorem (e.g. Theorem 11.4.1 in reference 1.) that says for any fixed number of basis elements p, the distance D above is minimized if <span class="math inline">\(u_j = v_j\)</span> where the <span class="math inline">\(v_j\)</span> are the eigenfunctions of <span class="math inline">\(C(y)\)</span> with respect to the unit norm. From this it follows that <span class="math inline">\(E<X, v_j>^2 \;=\; <C(v_,),v_j>\; =\; <\lambda_j, v_j>\; =\; \lambda_j\)</span>.</p>
<p>Going back to equation <span class="math inline">\((*)\)</span>, we can expand <span class="math inline">\(X\)</span> in terms of the basis <span class="math inline">\((v_j)\)</span> so <span class="math inline">\(D = 0\)</span> and we have what is called the <a href="https://en.wikipedia.org/wiki/Karhunen%E2%80%93Lo%C3%A8ve_theorem">Karhunen–Loève</a> expansion: <span class="math inline">\(X = \mu + \sum_{j=1}^{\infty}\xi_jv_j\)</span></p>
<p>where:</p>
<ul>
<li><span class="math inline">\(\mu = EX\)</span><br />
</li>
<li>The deterministic basis functions <span class="math inline">\((v_j)\)</span> are called the <em>functional principal components</em></li>
<li>The <span class="math inline">\((v_j)\)</span> have unit norm and are unique up to their signs. (You can work with <span class="math inline">\(v_j\)</span> or <span class="math inline">\(-v_j\)</span>.)</li>
<li>The eigenvalues are such that: <span class="math inline">\(\lambda_1 > \lambda_2 > . . . \lambda_p\)</span></li>
<li>The random variables <span class="math inline">\(\xi_j =\; <X - \mu,v_j>\)</span> are called the <em>scores</em>.</li>
<li><span class="math inline">\(E\xi_j = 0\)</span>, <span class="math inline">\(E\xi_j^2 = \lambda_j\)</span> and <span class="math inline">\(E|\xi_i\xi_j| = 0,\; if\; i\;\neq\;j\)</span>.</li>
</ul>
<p>And finally, with one more line:<br />
<span class="math inline">\(\sum_{j=1}^{\infty}\lambda_j \: = \: \sum_{j=1}^{\infty}E[<X,v_j>^2] = E\sum_{j=1}^{\infty}<X,v_j>^2 \; = \; E\parallel X \parallel^2 \; < \infty\)</span></p>
<p>we arrive at our destination, the variance decomposition:
<span class="math inline">\(E\parallel X - \mu \parallel^2 \;= \;\sum_{j=1}^{\infty}\lambda_j\)</span></p>
</div>
<div id="lets-calculate" class="section level3">
<h3>Let’s Calculate</h3>
<p>Now that we have enough math to set the context, let’s calculate. We will use the same simulated Brownian motion data that we used in the previous posts, and also construct the same B-spline basis that we used before and save it in the fda object <code>W.obj</code>. I won’t repeat the code here.</p>
<p>The following plot shows <strong>120</strong> simulated curves, each having <strong>1000</strong> points scattered over the interval <strong>[0, 100]</strong>. Each curve has unique observation times over that interval.</p>
<p><img src="/2021/06/10/functional-pca-with-r/index_files/figure-html/unnamed-chunk-1-1.png" width="672" />
For first attempt at calculating functional principal components we’ll use the <code>pca.fd()</code> function from the <code>fda</code> package. So set up wise, we are picking up our calculations exactly where we left off in the previous post. As before, the basis representations of these curves are packed into the fda object <code>W.obj</code>. The function <code>pca.fd()</code> takes <code>W.obj</code> as input. It needs the non-orthogonal B-spline basis to seed its computations and the estimate the covariance matrix and the orthogonal eigenvector basis <span class="math inline">\(v_j\)</span>. The <code>nharm = 5</code> parameter requests computing 5 eigenvalues.</p>
<p>The method of calculation roughly follows the theory outlined above. It starts with a basis representation of the functions, computes the covariance matrix, and calculates the eigenfunctions.</p>
<pre class="r"><code>fun_pca <- pca.fd(W.obj, nharm = 5)</code></pre>
<p>The object produced by <code>pca.fd()</code> is fairly complicated. For example, the list <code>fun_pca$harmonics</code> does not contain the eignevectors themselves, but rather coefficients that enable the eigenvectors to be computed from the original basis. However, because there is a special plot method for <code>plot.pca.fd()</code> it is easy to plot the eigenvectors.</p>
<pre class="r"><code>plot(fun_pca$harmonics, lwd = 3)</code></pre>
<p><img src="/2021/06/10/functional-pca-with-r/index_files/figure-html/unnamed-chunk-3-1.png" width="672" /></p>
<pre><code>## [1] "done"</code></pre>
<p>It is also to obtain the eivenvalues <span class="math inline">\(\lambda_j\)</span>,</p>
<pre class="r"><code>fun_pca$values</code></pre>
<pre><code>## [1] 37.232207 3.724524 1.703604 0.763120 0.547976 0.389431 0.196101
## [8] 0.163289 0.144052 0.116587 0.089307 0.057999 0.054246 0.050683
## [15] 0.042738 0.035107 0.031283 0.024905 0.019079 0.016428 0.011657
## [22] 0.007392 0.002664</code></pre>
<p>and, the proportion of the variance explained by each eigenvalue.</p>
<pre class="r"><code>fun_pca$varprop</code></pre>
<pre><code>## [1] 0.81965 0.08199 0.03750 0.01680 0.01206</code></pre>
</div>
<div id="a-different-approach" class="section level3">
<h3>A Different Approach</h3>
<p>So far in this short series of FDA posts, I have been mostly using the <code>fda</code> package to calculate. In 2003 when it was released, it was ground breaking work. It is still the package that you are most likely to find when doing internet searches, and is the foundation for many subsequent R packages. However, as the <a href="https://cran.r-project.org/web/views/FunctionalData.html">CRAN Task View</a> on Functional Data Analysis indicates, new work in FDA has resulted in several new R packages. The more recent <a href="https://cran.r-project.org/package=fdapace"><code>fdapace</code></a> takes a different approach to calculating principal components. The package takes its name from the <strong>(PACE)</strong> Principal Components by Conditional Expectation algorithm described in the paper by Yao, Müller and Wang (Reference 4. below). The package <a href="https://cran.r-project.org/web/packages/fdapace/vignettes/fdapaceVig.html">vignette</a> is exemplary. It describes the methods of calculation, develops clear examples and provides a list of references to guide your reading about PACE and FDA in general.</p>
<p>A very notable feature of the PACE algorithm is that it is designed specifically to work with sparse data. The vignette describes the two different methods of calculation that package functions employ for sparse and non-sparse data. In this post, In this post we are not working with sparse data, but hope to do so in the future. See the vignette for examples of FPCA with sparse data.</p>
<pre class="r"><code>library(fdapace)</code></pre>
<p>The <code>fdapace</code> package requires data for the functions (curves) and associated times be organized in lists. We begin by using the <code>fdapace::CheckData()</code> function to check the data set up in the tibble <code>df</code>. (See previous post on descriptive statistics for the details on the data construction.)</p>
<pre class="r"><code>CheckData(df$Curve,df$Time)</code></pre>
<p>No error message is generated, so we move on th having the <code>FPCA()</code> function calculate the FPCA outputs including:</p>
<pre class="r"><code>W_fpca <- FPCA(df$Curve,df$Time)</code></pre>
<p>the eigenvalues:</p>
<pre class="r"><code>W_fpca$lambda</code></pre>
<pre><code>## [1] 37.5386 3.2098 1.0210 0.3533</code></pre>
<p>the cumulative percentage of variance explained by the eigenvalue</p>
<pre class="r"><code>W_fpca$cumFVE</code></pre>
<pre><code>## [1] 0.8875 0.9634 0.9875 0.9959</code></pre>
<p>and the scores:</p>
<pre class="r"><code>head(W_fpca$xiEst)</code></pre>
<pre><code>## [,1] [,2] [,3] [,4]
## [1,] 0.8187 1.1971 -1.77755 0.20087
## [2,] -8.7396 2.4165 -0.33768 -0.10565
## [3,] -2.7517 -0.4879 -0.06747 -0.13953
## [4,] 3.9218 0.9419 0.39098 -0.25449
## [5,] -1.4400 0.7691 2.11549 -0.59947
## [6,] 7.3952 0.5114 -2.16391 0.05199</code></pre>
<p>All of these are in fairly good agreement with what we computed above. I am, however, a little surprised by the discrepancy in the value of the second eigenvalue. The default plot method for <code>FPCA()</code> produces a plot indicating the density of the data, a plot of the mean of the functions reconstructed from the eigenfunction expansion, a scree plot of the eigenvalues and a plot of the first three eigenfunctions.</p>
<pre class="r"><code>plot(W_fpca)</code></pre>
<p><img src="/2021/06/10/functional-pca-with-r/index_files/figure-html/unnamed-chunk-12-1.png" width="672" /></p>
<p>Finally, it has probably already occurred to you that if you know the eigenvalues and scores, the Karhunen–Loève expansion can be used to simulate random functions. It can be shown that for the Wiener process:</p>
<p><span class="math inline">\(v_j(t) = \sqrt2 sin(( j - \frac{1}{2})\pi t)\)</span> and <span class="math inline">\(\lambda_j = \frac{1}{(j - \frac{1}{2})^2\pi^2}\)</span></p>
<p>This gives us:</p>
<p><span class="math inline">\(W(t) = \sum_{j=1}^{\infty} \frac {\sqrt2}{(j - \frac{1}{2})\pi)} N_j sin(( j - \frac{1}{2})\pi t\)</span></p>
<p>where the <span class="math inline">\(N_j \:are\; iid \;N(0,1)\)</span>.</p>
<p>The <code>fdapace</code> function <code>fdapace::Wiener()</code> uses this information to simulate an alternative, smoothed version of the Brownian motion, Wiener process.</p>
<pre class="r"><code>set.seed(123)
w <- Wiener(n = 1, pts = seq(0,1, length = 100))
t <- 1:100
df_w <- tibble(t, as.vector(w))
ggplot(df_w, aes(x = t, y = w)) + geom_line()</code></pre>
<p><img src="/2021/06/10/functional-pca-with-r/index_files/figure-html/unnamed-chunk-13-1.png" width="576" /></p>
<p>In future posts, I hope to continue exploring the <code>fdapace</code> package, including its ability to work with sparse data.</p>
</div>
<div id="references" class="section level3">
<h3>References</h3>
<p>I found the following references particularly helpful.</p>
<ol style="list-style-type: decimal">
<li>Kokoszka, P. and Reimherr, M. (2017). <a href="https://www.amazon.com/Introduction-Functional-Analysis-Chapman-Statistical-ebook/dp/B075Z9QCV9/ref=sr_1_1?dchild=1&keywords=Introduction+to+functional+data+analysis&qid=1623276309&sr=8-1"><em>Introduction to Functional Data Analysis</em></a>. CRC.</li>
<li>Hsing, T and Eubank, R. (2015). <a href="https://www.amazon.com/Theoretical-Foundations-Functional-Introduction-Probability/dp/0470016914/ref=sr_1_1?dchild=1&keywords=theoretical+foundations+of+functional+data+analysis&qid=1623276176&sr=8-1"><em>Theoretical Foundations of Functional Data Analysis, with an Introduction to Linear Operators</em></a> Wiley</li>
<li>Wang, J., Chiou, J. and Müller, H. (2015). <a href="https://arxiv.org/pdf/1507.05135.pdf"><em>Review of Functional Data Analysis</em></a></li>
<li>Yao, F., Müller, H, Wang, J. (2012). <a href="https://anson.ucdavis.edu/~mueller/jasa03-190final.pdf"><em>Functional Data Analysis for Sparse Longitudinal Data</em></a> JASA J100, I 470</li>
</ol>
</div>
<script>window.location.href='https://rviews.rstudio.com/2021/06/10/functional-pca-with-r/';</script>
R for Public Health
https://rviews.rstudio.com/2021/06/02/r-for-public-health/
Wed, 02 Jun 2021 00:00:00 +0000https://rviews.rstudio.com/2021/06/02/r-for-public-health/
<p>The COVID19 pandemic has raised the profile of public health workers at all levels from the nurses and doctors working on the front lines at our hospitals, to high level state and federal public health officials. I think its a good bet that eighteen months ago few of us had any clear idea about how the public health care system works, or thought much about the people charged with the awesome responsibility to keep us safe. We are all a little bit wiser now. It strikes me as obvious that we will have a continuing need to improve our public health systems and that this need will create opportunities for data scientists to make significant contributions, in research, logistics, data management, reporting, public communication and many more areas. The <a href="https://blog.rstudio.com/2021/05/18/managing-covid-vaccine-distribution-with-a-little-help-from-shiny/">recent post</a> by my colleague Jesse Mostipak describes how R and Shiny made a big difference in the nitty gritty work required to roll out vaccine distribution in West Virginia. This four minute video about how the West Virginia Army National Guard built a COVID vaccine inventory management system is inspiring.</p>
<div style="text-align:center">
<iframe width="400" height="250" src="https://www.youtube.com/embed/CYilc-rEgjg" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<p>The following are some R resources that you may find helpful if you are seeking to increase your R skills with a eye toward public health applications. Some may be useful to public health professionals seeking to learn R, others may be interesting to R users who want to investigate data science in a public health context.</p>
<h3 id="courses">Courses</h3>
<ul>
<li><p>The Johns Hopkins Graduate Institute of Epidemiology and Biostatistics has a slew of of <a href="https://www.jhsph.edu/departments/epidemiology/continuing-education/graduate-summer-institute-of-epidemiology-and-biostatistics/">summer courses</a> (many of them online), including <a href="https://www.jhsph.edu/departments/epidemiology/continuing-education/graduate-summer-institute-of-epidemiology-and-biostatistics/courses/introduction-to-r-for-public-health-researchers.html">Introduction to R For Public Health Researchers</a>.</p></li>
<li><p>If you are feeling optimistic about traveling and can make your to Estonia this summer you might consider <a href="http://bendixcarstensen.com/SPE/">Statistical Practice in Epidemiology using R</a>.</p></li>
<li><p>If you hurry, you may be able to get into the Coursera course offered by Imperial College London <a href="https://www.coursera.org/specializations/statistical-analysis-r-public-health">Statistical Analysis with R for Public Health Specialization</a>.</p></li>
<li><p>There are several <a href="https://www.classcentral.com/course/introduction-statistics-data-analysis-pu-13079">Coursera Courses</a> for R in a public health context.</p></li>
<li><p>Frank Harrell’s free online course <a href="https://hbiostat.org/bbr/">Biostatistics for Biomedical Research</a>, available on YouTube: <a href="https://www.youtube.com/channel/UC-o_ZZ0tuFUYn8e8rf-QURA">BBRcourse</a>, is an excellent introduction to the basic statistical concepts underlying all medical applications.</p></li>
</ul>
<h3 id="books">Books</h3>
<p>If you can learn on your own with the help of a good book, here are some ideas.</p>
<p><img src="Handbook.png" height = "300" width="500"></p>
<ul>
<li><p><a href="https://epirhandbook.com/contact-tracing-1.html">The Epidemiologist R Handbook</a>: R for applied epidemiology and public health is a delightful, brief, modern introduction to R that covers the basics of the <a href="https://www.tidyverse.org/">Tidyverse</a>, <a href="https://rmarkdown.rstudio.com/">R Markdown</a>, <a href="https://shiny.rstudio.com/">Shiny</a> and <a href="https://rdatatable.gitlab.io/data.table/">data.table</a>.</p></li>
<li><p><a href="https://web.stanford.edu/class/bios221/book/">Modern Statistics for Modern Biology</a>: This book is focused more on genomics than public health applications, but it is probably the best introductory statistical text available. The modern statistics part in the title means statistics as a data driven, computational based science. Every topic is illustrated with well-crafted R code and visualizations. The book is great read.</p></li>
<li><p><a href="https://bookdown.org/taragonmd/phds/">Population Health Data Science with R</a>: An introduction to R by authors who see population health as a systems framework for studying and improving the health of populations through collective action and learning.</p></li>
<li><p><a href="https://global.oup.com/academic/product/epidemiology-with-r-9780198841333?cc=us&lang=en&#">Epidemiology with R</a>: This is a new, reasonably priced book that covers the basics. It emphasizes reproducibility with R Markdown. Code examples are written in a base R style that matches the extensively used <a href="https://cran.r-project.org/package=Epi">Epi</a> package.</p></li>
</ul>
<h3 id="r-packages">R Packages</h3>
<p>If working through a book on you own seems too much of a stretch, then digest an R package or two. Here are a few examples of packages on public health themes with sufficient documentation to make interesting self-learning projects.</p>
<ul>
<li><p><a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5931789/">EpiModel</a>: An R Package for Mathematical Modeling of Infectious Disease over Networks</p></li>
<li><p><a href="https://cran.r-project.org/package=PHEindicatormethods">PHEindicators</a>: Common Public Health Statistics and their Confidence Intervals</p></li>
<li><p><a href="https://www.jstatsoft.org/article/view/v091i12">SimInf</a>: An R Package for Data-Driven Stochastic Disease Simulations</p></li>
<li><p><a href="https://cran.r-project.org/package=SPARSEMODr">SPARSEMODr</a>: Construct spatial, stochastic disease models that show how parameter values fluctuate in response to public health interventions</p></li>
</ul>
<h3 id="shiny">Shiny</h3>
<p>Finally, if you find yourself in a situation similar to the West Virginia Army National Guard team featured in the video, you may just want to teach yourself Shiny. The RStudio <a href="https://shiny.rstudio.com/tutorial/">Shiny Tutorial</a>, along with Hadley Wickham’s book <a href="https://mastering-shiny.org/">Mastering Shiny</a>, is a very good place to start. If you need more structure, you might check out the <a href="https://www.udemy.com/topic/shiny/?utm_source=adwords&utm_medium=udemyads&utm_campaign=DSA_Catchall_la.EN_cc.US&utm_content=deal4584&utm_term=_._ag_95911180068_._ad_436653296108_._kw__._de_c_._dm__._pl__._ti_dsa-437115340933_._li_9032191_._pd__._&matchtype=b&gclid=Cj0KCQjw2NyFBhDoARIsAMtHtZ7tXUSdrjLIvbkpb2BdzwBYYCelutNMt6RUZDCaI7lST-fAXjwwaeQaAumnEALw_wcB">Udemy Courses</a>, or work through the online workshops from <a href="https://library.capture.duke.edu/Panopto/Pages/Viewer.aspx?id=7a59e23a-1f7f-4bd7-8ebc-a943014170b4">Duke University</a> or the <a href="(https://uomresearchit.github.io/r-shiny-course/)">University of Manchester</a>. And by all means, immerse yourself in the examples, posts and podcasts of the <a href="https://shinydevseries.com/">Shiny Developer Series</a>.</p>
<script>window.location.href='https://rviews.rstudio.com/2021/06/02/r-for-public-health/';</script>
April 2021: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2021/05/25/april-2021-top-40-new-cran-packages/
Tue, 25 May 2021 00:00:00 +0000https://rviews.rstudio.com/2021/05/25/april-2021-top-40-new-cran-packages/
<p>One hundred seventy-nine new packages made it to CRAN in April. Here are my “Top 40” picks in twelve categories: Computational Methods, Data, Genomics, Machine Learning, Mathematics, Medicine, Networks, Operations Research, Statistics, Time Series, Utilities, and Visualization.</p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=abess">abess</a> v0.1.0: Provides a toolkit for solving the best subset selection problem in linear regression, logistic regression, Poisson regression, Cox proportional hazard model, multiple-response Gaussian, and multinomial regression. It implements and generalizes algorithms described in <a href="https://www.pnas.org/content/117/52/33117">Zhu et al. (2020)</a> that exploit a novel sequencing-and-splicing technique to guarantee exact support recovery and globally optimal solution in polynomial times. There is an <a href="https://cran.r-project.org/web/packages/abess/vignettes/abess-guide.html">Introduction</a>.</p>
<p><a href="https://cran.r-project.org/package=eat">eat</a> v0.1.0: Provides functions to determine production frontiers and technical efficiency measures through non-parametric techniques based upon regression trees. See <a href="https://www.sciencedirect.com/science/article/abs/pii/S0957417420306072?via%3Dihub">Esteve et al. (2020)</a> for details. There is an <a href="https://cran.r-project.org/web/packages/eat/vignettes/EAT.html">Introduction</a>.</p>
<p><img src="eat.png" height = "300" width="500"></p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=childdevdata">childdevdata</a> v1.1.0: Bundles publicly available data sets with individual milestone data for children aged 0-5 years, with the aim of supporting the construction, evaluation, validation and interpretation of methodologies that aggregate milestone data into informative measures of child development. See <a href="https://cran.r-project.org/web/packages/childdevdata/readme/README.html">README</a>.</p>
<p><img src="child.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=datagovindia">datagovindia</a> v0.0.3: Allows users to search the <a href="https:data.gov.in/ogpl_apis">open data platform</a> of the government of India to communicate with the more than 80,000 available APIs. See the <a href="https://cran.r-project.org/web/packages/datagovindia/vignettes/datagovindia_vignette.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=lehdr">lehdr</a> v0.2.4: Provides functions to query the <a href="https://lehd.ces.census.gov/data/lodes/LODES7/">LODES FTP server</a> to obtain longitudinal <a href="https://lehd.ces.census.gov/">Employer-Household Dynamics</a> data and optionally aggregate Census block-level data. See the <a href="https://cran.r-project.org/web/packages/lehdr/vignettes/getting_started.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=rbioapi">rbioapi</a> v0.7.0: Provides a consistent R interface to the Biologic Web Services API and fully supports <a href="https://cran.r-project.org/web/packages/rbioapi/vignettes/rbioapi_mieaa.html">miEAA</a>, <a href="https://cran.r-project.org/web/packages/rbioapi/vignettes/rbioapi_panther.html">PANTHER</a>, <a href="https://cran.r-project.org/web/packages/rbioapi/vignettes/rbioapi_reactome.html">Reactome</a>, <a href="https://cran.r-project.org/web/packages/rbioapi/vignettes/rbioapi_string.html">String</a>, and <a href="https://cran.r-project.org/web/packages/rbioapi/vignettes/rbioapi_uniprot.html">UniProt</a>. See this <a href="https://cran.r-project.org/web/packages/rbioapi/vignettes/rbioapi.html">vignette</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=tidywikidatar">tidywikidatar</a> v0.2.0: Provides functions to query <a href="https://wikidata.org/">Wilidata</a>, get tidy data frames in response, and cache data in a local <code>SQLite</code> database. See <a href="https://cran.r-project.org/web/packages/tidywikidatar/readme/README.html">README</a>.</p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=protti">protti</a> v0.1.1: Provides functions and workflows for proteomics quality control and data analysis of both limited proteolysis-coupled mass spectrometry and regular bottom-up proteomics experiments. See <a href="https://www.nature.com/articles/nbt.2999">Feng et. al. (2014)</a> for background. There are vignettes for various workflows: <a href="https://cran.r-project.org/web/packages/protti/vignettes/data_analysis_dose_response_workflow.html">Dose Response</a>, <a href="https://cran.r-project.org/web/packages/protti/vignettes/data_analysis_single_dose_treatment_workflow.html">Single Treatment Dose Response</a>, <a href="https://cran.r-project.org/web/packages/protti/vignettes/input_preparation_workflow.html">Input Preparation</a>, and <a href="https://cran.r-project.org/web/packages/protti/vignettes/quality_control_workflow.html">Quality Control</a>.</p>
<p><img src="protti.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=Rediscover">Rediscover</a> v0.1.0: Implements an optimized method for identifying mutually exclusive genomic events based on the Poisson-Binomial distribution that takes into account that some samples are more mutated than others. See <a href="https://genomebiology.biomedcentral.com/articles/10.1186/s13059-016-1114-x">Canisius et al. (2016)</a>. The <a href="https://cran.r-project.org/web/packages/Rediscover/vignettes/Rediscover.html">vignette</a> provides an introduction.</p>
<p><img src="Rediscover.png" height = "300" width="500"></p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=geocmeans">geocmeans</a> v0.1.1: Provides functions to apply spatial fuzzy unsupervised classification, visualize and interpret results, as well as indices for estimating the spatial consistency and classification quality. See <a href="https://www.sciencedirect.com/science/article/abs/pii/S0031320306003451?via%3Dihub">Cai et al. (2007)</a>, <a href="https://www.sciencedirect.com/science/article/abs/pii/S1051200412002357?via%3Dihub">Zaho et al. (2013)</a>, and <a href="https://journals.openedition.org/cybergeo/36414">Gelb & Appaericio (2021)</a> for background. There is an <a href="https://cran.r-project.org/web/packages/geocmeans/vignettes/introduction.html">Introduction</a> and an additional <a href="https://cran.r-project.org/web/packages/geocmeans/vignettes/adjustinconsistency.html">vignette</a>.</p>
<p><img src="geocmeans.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=Rforestry">Rforestry</a> v0.9.0.4: Provides fast implementations of Honest Random Forests, Gradient Boosting, and Linear Random Forests, with an emphasis on inference and interpretability. See <a href="https://arxiv.org/abs/1906.06463">Kunzel et al. (2019)</a>. See <a href="https://cran.r-project.org/web/packages/Rforestry/readme/README.html">README</a> to get started.</p>
<h3 id="mathematics">Mathematics</h3>
<p><a href="https://cran.r-project.org/package=elasdics">elasdics</a> v0.1.2: Provides functions to align curves and to compute mean curves based on the elastic distance defined in the square-root-velocity framework. For information on the framework see <a href="https://link.springer.com/book/10.1007%2F978-1-4939-4020-2">Srivastava and Klassen (2016)</a>, For more theoretical details see <a href="https://arxiv.org/abs/2104.11039">Steyer et al. (2021)</a></p>
<p><a href="https://cran.r-project.org/package=jordan">jordan</a> v1.0-1: Provides functions to manipulate Jordan Algebras, commutative but non-associative algebraic structures that satisfy the Jordan Identify: (xy)x<sup>2</sup> = x(yx<sup>2</sup>). See <a href="http://math.nsc.ru/LBRT/a1/files/mccrimmon.pdf">McCrimmon (204)</a>.</p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=ccoptimalmatch">ccoptimalmatch</a> v0.1.0: Uses sub-sampling to create pseudo-observations of controls to optimally match cases with controls. See <a href="https://bmcmedresmethodol.biomedcentral.com/articles/10.1186/s12874-021-01256-3">Mamoiris (2021)</a> for the theory and the <a href="https://cran.r-project.org/web/packages/ccoptimalmatch/vignettes/ccoptimalmatching_vignette.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=nCov2019">nCov2019</a> v0.4.4: Implements an interface to <a href="https://disease.sh/">disease.sh - Open Disease Data API</a> to access real time and historical data of COVID-19 cases, vaccine and therapeutics data. There is a <a href="https://cran.r-project.org/web/packages/nCov2019/vignettes/nCov2019.html">vignette</a>.</p>
<p><img src="nCov2019.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=hlaR">hlaR</a> v0.1.0: Implements a tool for the eplet analysis of donor and recipient HLA (human leukocyte antigen) mismatches. There are vignettes on <a href="https://cran.r-project.org/web/packages/hlaR/vignettes/allele-haplotype.html">Imputation</a> and <a href="https://cran.r-project.org/web/packages/hlaR/vignettes/eplet-mm.html">Eplet Mismatch</a> and a <a href="https://emory-larsenlab.shinyapps.io/hlar_shiny/">Shiny App</a> as well.</p>
<p><a href="https://cran.r-project.org/package=ReviewR">RevieweR</a> v2.3.6: Implements a portable <code>Shiny</code> tool to explore patient-level electronic health record data and perform chart review in a single integrated framework. This tool supports the <a href="https://www.ohdsi.org/data-standardization/the-common-data-model/">OMOP</a> common data model as well as the <a href="https://mimic.physionet.org/">MIMIC-III</a> data model, and chart review through a <a href="https://www.project-redcap.org/">REDCap</a> API. See the <a href="https://reviewr.thewileylab.org/">RevieweR Website</a> for more information. There are several vignettes including <a href="https://cran.r-project.org/web/packages/ReviewR/vignettes/deploy_local.html">Local</a>, <a href="https://cran.r-project.org/web/packages/ReviewR/vignettes/deploy_docker.html">Docker</a>, <a href="https://cran.r-project.org/web/packages/ReviewR/vignettes/deploy_bigquery.html">BigQuery</a> and <a href="https://cran.r-project.org/web/packages/ReviewR/vignettes/deploy_server.html">Shiny Server</a> deployment and performing a <a href="https://cran.r-project.org/web/packages/ReviewR/vignettes/usage_perform_chart_review.html">Chart Review</a>.</p>
<p><img src="RevieweR.png" height = "300" width="500"></p>
<h3 id="networks">Networks</h3>
<p><a href="https://CRAN.R-project.org/package=greed">greed</a> v0.5.1: Provides an ensemble of algorithms to enable clustering of networks and data matrices with different type of generative models. Model selection and clustering is performed in combination by optimizing the Integrated Classification Likelihood. The optimization is performed with a combination of greedy local search and a genetic algorithm. See <a href="https://arxiv.org/abs/2002.11577">Côme et al. (2021)</a> for background and the vignettes on <a href="https://cran.r-project.org/web/packages/greed/vignettes/GMM.html">Gaussian Mixture Models</a> and <a href="https://cran.r-project.org/web/packages/greed/vignettes/graph-clustering-with-sbm.html">Clustering</a>.</p>
<p><img src="greed.png" height = "400" width="400"></p>
<h3 id="operations-research">Operations Research</h3>
<p><a href="https://cran.r-project.org/package=critpath">critpath</a> v0.1.2: Provides functions to compute critical paths, schedules, <a href="https://www.investopedia.com/terms/p/pert-chart.asp">PERT</a> charts and <a href="https://en.wikipedia.org/wiki/Gantt_chart">Gantt</a> charts. There is a vignette on <a href="https://cran.r-project.org/web/packages/critpath/vignettes/CPMandPERT.html">CPM and PERT</a> and another on the <a href="https://cran.r-project.org/web/packages/critpath/vignettes/LESS.html">LESS Method</a>.</p>
<p><img src="critpath.png" height = "350" width="350"></p>
<p><a href="https://cran.r-project.org/package=himach">himach</a> v0.1.2: Provides functions to compute the best routes between airports for supersonic aircraft flying subsonic over land. There is an <a href="https://cran.r-project.org/web/packages/himach/vignettes/Supersonic_Routes.html">Introduction to Supersonic Routing</a> and a vignette on <a href="https://cran.r-project.org/web/packages/himach/vignettes/Supersonic_Routes_in_depth.html">Advanced Supersonic Routing</a>.</p>
<p><img src="himach.png" height = "350" width="350"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=convdistr">convdistr</a> v1.5.3: Provides functions to compute convolutions of probability distributions via a method that creates a new random number function for individual random samples from the random generator function of each distribution. There is an <a href="https://cran.r-project.org/web/packages/convdistr/vignettes/using-convdistr.html">Introduction</a> and a vignette on <a href="https://cran.r-project.org/web/packages/convdistr/vignettes/sample_size.html">Sample Size</a>.</p>
<p><img src="convdistr.png" height = "350" width="500"></p>
<p><a href="https://cran.r-project.org/package=gamlss.lasso">gamlss.lasso</a> v1.0-0: Provides an interface for extra high-dimensional smooth functions for Generalized Additive Models for Location Scale and Shape (GAMLSS) including lasso, ridge, elastic net and least angle regression. The <a href="https://www.gamlss.com/">gamlss website</a> provides considerable information.</p>
<p><img src="gamlss.jpeg" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=GGMnonreg">GGMnonreg</a> v1.0.0: Provides functions to estimate non-regularized Gaussian graphical models, Ising models, and mixed graphical models. See <a href="https://www.tandfonline.com/doi/abs/10.1080/00273171.2019.1575716?journalCode=hmbr20">Williams et al. (2019)</a>, <a href="https://bpspsychub.onlinelibrary.wiley.com/doi/abs/10.1111/bmsp.12173">Williams & Rast (2019)</a>, and <a href="https://psyarxiv.com/fb4sa/">Williams (2020)</a> for details. <a href="https://cran.r-project.org/web/packages/GGMnonreg/readme/README.html">README</a> contains examples.</p>
<p><img src="GGMnonreg.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=relevance">relevance</a> v1.1: Implements the concepts of relevance and significance measures introduced in <a href="https://stat.ethz.ch/~stahel/relevance/stahel-relevance2103.pdf">Stahel (2021)</a> to augment inference with p-values. See the <a href="https://cran.r-project.org/web/packages/relevance/vignettes/relevance-descr.pdf">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=sasfunclust">sasfunclust</a> v1.0.0: Implements the sparse and smooth functional clustering method described in <a href="https://arxiv.org/abs/2103.15224">Centofanti et al. (2021)</a> that aims to classify a sample of curves into homogeneous groups while jointly detecting the most informative portions of domain. See <a href="https://cran.r-project.org/web/packages/sasfunclust/readme/README.html">README</a> to get started.</p>
<p><img src="sasfunclust.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=survMS">survMS</a> v0.0.1: Provides functions to simulate data from the <a href="https://www.sciencedirect.com/science/article/pii/S0169716103230248">Accelerated Hazard</a>, <a href="https://en.wikipedia.org/wiki/Accelerated_failure_time_model">Accelerated Failure Time</a>, and <a href="https://socialsciences.mcmaster.ca/jfox/Books/Companion-2E/appendix/Appendix-Cox-Regression.pdf">Cox</a> survival models. See <a href="https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.2059">Bender et al. (2004)</a> for the methods used to implement the Cox model, and the <a href="https://cran.r-project.org/web/packages/survMS/vignettes/how-to-simulate-survival-models.html">vignette</a> and <a href="https://github.com/mathildesautreuil/survMS/">GitHub</a> for an introduction and examples.</p>
<p><img src="survMS.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=TestGardener">TestGardener</a> v0.1.4: Provides functions to develop, evaluate, and score multiple choice examinations, psychological scales, questionnaires, and similar types of data involving sequences of choices among one or more sets of answers. See <a href="https://www.mdpi.com/2624-8611/2/4/26">Ramsay et al. (2020)</a> and <a href="https://journals.sagepub.com/doi/10.3102/1076998619885636">Ramsay et al. (2019)</a> for the methodology and the vignettes <a href="https://cran.r-project.org/web/packages/TestGardener/vignettes/SDSAnalysis.html">Symptom Distress Analysis</a> and <a href="https://cran.r-project.org/web/packages/TestGardener/vignettes/SweSATQuantitativeAnalysis.html">SweSAT Quantitative Analysis</a>.</p>
<p><img src="TestG.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=wpa">wpa</a> v1.5.0: Provides opinionated functions to enable easier and faster analysis of Workplace Analytics data. See the <a href="https://cran.r-project.org/web/packages/wpa/vignettes/intro-to-wpa.html">vignette</a> for an introduction.</p>
<p><img src="wpa.png" height = "400" width="400"></p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=garchmodels">garchmodels</a> v0.1.1: Implements a framework for using <a href="https://www.investopedia.com/terms/g/garch.asp#:~:text=GARCH%20is%20a%20statistical%20modeling,an%20autoregressive%20moving%20average%20process.">GARCH</a> models with the <code>tidymodels</code> ecosystem. It includes both univariate and multivariate methods from the <code>rugarch</code> and <code>rmgarch</code> packages. There is a <a href="https://cran.r-project.org/web/packages/garchmodels/vignettes/getting-started.html">Getting Started Guide</a> and a <a href="https://cran.r-project.org/web/packages/garchmodels/vignettes/tuning_univariate_algorithms.html">vignette</a> on tuning univariate GARCH models.</p>
<p><img src="garchmodels.png" height = "600" width="400"></p>
<p><a href="https://cran.r-project.org/package=tensorTS">tensorTS</a> v0.1.1: Provides functions for estimating, simulating and predicting factor and autoregressive models for matrix and tensor valued time series. See <a href="https://arxiv.org/abs/1905.07530">Chen et al. (2020)</a>, <a href="https://www.sciencedirect.com/science/article/abs/pii/S0304407620302050?via%3Dihub">Chen et al. (2020)</a>, and <a href="https://arxiv.org/abs/2006.02611">Han et al. (2020)</a> for the math.</p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=diffmatchpatch">diffmatchpatch</a> v0.1.0: Implements a wrapper for Google’s <a href="https://github.com/google/diff-match-patch">diff-match-patch</a> library. It provides basic tools for computing diffs, finding fuzzy matches, and constructing / applying patches to strings. See <a href="https://github.com/google/diff-match-patch">README</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=erify">erify</a> v0.2.0: Provides several validator functions to check if arguments passed by users have valid types, lengths, etc., and if not, to generate informative and good-formatted error messages in a consistent style. See the <a href="https://cran.r-project.org/web/packages/erify/vignettes/erify.html">vignette</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=juicr">juicr</a> v0.1: Provides a GUI interface for automating data extraction from multiple images containing scatter and bar plots, semi-automated tools to tinker with extraction attempts, and a fully-loaded point-and-click manual extractor with image zoom, calibrator, and classifier. See the <a href="https://cran.r-project.org/web/packages/juicr/vignettes/juicr_basic_vignette_v0.1.pdf">vignette</a> for examples, and the <a href="https://www.youtube.com/c/LajeunesseLab/">Youtube channel</a> for a course on meta analysis.</p>
<p><a href="https://CRAN.R-project.org/package=mailmerge">mailmerge</a> v 0.2.1: Allows users to mail merge using markdown documents and gmail, parse markdown documents as the body of email, use the <code>yaml</code> header to specify the subject line of the email, preview the email in the RStudio viewer pane, and send (draft) email using <code>gmailr</code>. See the <a href="https://cran.r-project.org/web/packages/mailmerge/vignettes/introduction.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=m61r">m61r</a> v0.0.2: Provides <code>dplyr</code> and <code>tidyr</code> like data manipulation functions using only base R and no dependencies. See the <a href="https://cran.r-project.org/web/packages/m61r/vignettes/base_r.pdf">vignette</a> for examples.</p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=flametree">flametree</a> v0.1.2: Implements a generative art system for producing tree-like images using an L-system to create the structures. See <a href="https://cran.r-project.org/web/packages/flametree/readme/README.html">README</a> to get started.</p>
<p><img src="flametree.png" height = "500" width="500"></p>
<p><a href="https://cran.r-project.org/package=leafdown">leafdown</a> v1.0.0: Provides drill down functionality for <code>leaflet</code> choropleths in <code>shiny</code> apps. There is an <a href="https://cran.r-project.org/web/packages/leafdown/vignettes/Introduction.html">Introduction</a> and a <a href="https://cran.r-project.org/web/packages/leafdown/vignettes/Showcase_electionapp.html">Showcase</a> example.</p>
<p><img src="leafdown.png" height = "600" width="400"></p>
<p><a href="https://cran.r-project.org/package=mapping">mapping</a> v1.2: Provides coordinates, linking and mapping functions for mapping workflows of different geographical statistical units. Geographical coordinates automatically link with the input data to generate maps. See the <a href="https://cran.r-project.org/web/packages/mapping/vignettes/a-journey-into-mapping.html">vignette</a> to get started.</p>
<p><img src="mapping.png" height = "350" width="500"></p>
<p><a href="https://cran.r-project.org/package=materialmodifier">materialmodifier</a> v1.0.0: Provides functions to apply image processing effects to modify the perceived material properties such as gloss, smoothness, and blemishes. Look <a href="https://github.com/tsuda16k/materialmodifier">here</a> for documentation and practical tips of the package is available at</p>
<p><img src="material.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=svplots">svplots</a> v0.1.0: Implements two versions of sample variance plots illustrating the squared deviations from sample variance as described in <a href="https://www.tandfonline.com/doi/abs/10.1080/03610918.2020.1851716?journalCode=lssp20">Wijesuriya (2020)</a>. See the <a href="https://cran.r-project.org/web/packages/svplots/vignettes/Svplots_and_Testing_Hypothes.html">vignette</a>.</p>
<p><img src="svplots.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=vivid">vivid</a> v0.1.0: Provides a suite of plots for displaying variable importance and two-way variable interaction. Plots include partial dependence plots laid out in “pairs plot”” or <a href="https://www.zenplot.com/en?gclid=CjwKCAjwy42FBhB2EiwAJY0yQi2mfla-DMC2uuDglAGzh1mUx4sYyT5p8uEmfWgeMv5gKBh_5V2RDxoC6jEQAvD_BwE">zenplots</a> style. There is an <a href="https://cran.r-project.org/web/packages/vivid/vignettes/vivid.html">Introduction</a> and a <a href="https://cran.r-project.org/web/packages/vivid/vignettes/vividQStart.html">Quick Start Guide</a>.</p>
<p><img src="vivid.png" height = "500" width="300"></p>
<script>window.location.href='https://rviews.rstudio.com/2021/05/25/april-2021-top-40-new-cran-packages/';</script>
Basic FDA Descriptive Statistics with R
https://rviews.rstudio.com/2021/05/14/basic-fda-descriptive-statistics-with-r/
Fri, 14 May 2021 00:00:00 +0000https://rviews.rstudio.com/2021/05/14/basic-fda-descriptive-statistics-with-r/
<script src="/2021/05/14/basic-fda-descriptive-statistics-with-r/index_files/header-attrs/header-attrs.js"></script>
<script src="/2021/05/14/basic-fda-descriptive-statistics-with-r/index_files/htmlwidgets/htmlwidgets.js"></script>
<script src="/2021/05/14/basic-fda-descriptive-statistics-with-r/index_files/plotly-binding/plotly.js"></script>
<script src="/2021/05/14/basic-fda-descriptive-statistics-with-r/index_files/typedarray/typedarray.min.js"></script>
<script src="/2021/05/14/basic-fda-descriptive-statistics-with-r/index_files/jquery/jquery.min.js"></script>
<link href="/2021/05/14/basic-fda-descriptive-statistics-with-r/index_files/crosstalk/css/crosstalk.css" rel="stylesheet" />
<script src="/2021/05/14/basic-fda-descriptive-statistics-with-r/index_files/crosstalk/js/crosstalk.min.js"></script>
<link href="/2021/05/14/basic-fda-descriptive-statistics-with-r/index_files/plotly-htmlwidgets-css/plotly-htmlwidgets.css" rel="stylesheet" />
<script src="/2021/05/14/basic-fda-descriptive-statistics-with-r/index_files/plotly-main/plotly-latest.min.js"></script>
<p>In a previous post, I introduced the topic of Functional Data Analysis (FDA). In that post, I provided some background on Functional Analysis, the mathematical theory that makes FDA possible, identified FDA resources that might be of interest R users, and showed how to turn a series of data points into an FDA object. In this post, I will pick up where I left off and move on to doing some very basic FDA descriptive statistics.</p>
<p>Let’s continue with the same motivating example from last time. We will use synthetic data generated by a Brownian motion process and pretend that it is observed longitudinal data. However, before getting to the statistics, I would like to take a tiny, tidy diversion. The functions in <code>fda</code> and other fundamental FDA R packages require data structured in matrices. Consequently, the examples in the basic FDA reference works (listed below) construct matrices using code that seems to be convenient for the occasion. I think this makes adapting sample code to user data a little harder than it needs to be. There ought to be standard data structures for working with FDA data. I propose tibbles or data frames with function values packed into lists.</p>
<p>The following function generates <code>n_points</code> data points for each of <code>n_curve</code> Brownian motion curves that represent the longitudinal data collected from <code>n_curve</code> subjects.</p>
<pre class="r"><code>library(fda)
library(tidyverse)
library(plotly)
# Function to simulate data
fake_curves <- function(n_curves = 100, n_points = 80, max_time = 100){
ID <- 1:n_curves
x <- vector(mode = "list", length = n_curves)
t <- vector(mode = "list", length = n_curves)
for (i in 1:n_curves){
t[i] <- list(sort(runif(n_points,0,max_time)))
x[i] <- list(cumsum(rnorm(n_points)) / sqrt(n_points))
}
df <- tibble(ID,t,x)
names(df) <- c("ID", "Time", "Curve")
return(df)
}</code></pre>
<p>Notice that each curve is associated with a unique set of random time points that lie in the interval [0, max_time]. Not being restricted to situations where data from all subjects must be observed at the same times is a big deal. However, in practice you may encounter problems that will require curve alignment procedures. We will ignore this for now. Note that the variables <code>Time</code> and <code>Curve</code> contain lists of data points in each cell.</p>
<pre class="r"><code>set.seed(123)
n_curves <- 40
n_points <- 80
max_time <- 100
df <- fake_curves(n_curves = n_curves,n_points = n_points, max_time = max_time)
head(df)</code></pre>
<pre><code>## # A tibble: 6 x 3
## ID Time Curve
## <int> <list> <list>
## 1 1 <dbl [80]> <dbl [80]>
## 2 2 <dbl [80]> <dbl [80]>
## 3 3 <dbl [80]> <dbl [80]>
## 4 4 <dbl [80]> <dbl [80]>
## 5 5 <dbl [80]> <dbl [80]>
## 6 6 <dbl [80]> <dbl [80]></code></pre>
<p>Later on, this kind of structure will be convenient for data sets that contain both FDA curves and other scalar covariates. Note that if you are using the RStudio IDE running the function <code>View(df)</code> will show you an expanded view of the tibble under a tab labeled df that should look something like this:</p>
<p><img src="df.png" height = "400" width="600"></p>
<p>Next, we unpack the data into a long form tibble and plot.</p>
<pre class="r"><code>df_1 <- df %>% select(!c(ID,Curve)) %>% unnest_longer(Time)
df_2 <- df %>% select(!c(ID,Time)) %>% unnest_longer(Curve)
ID <- sort(rep(1:n_curves,n_points))
df_l <- cbind(ID,df_1,df_2)
p <- ggplot(df_l, aes(x = Time, y = Curve, group = ID, col = ID)) +
geom_line()
p</code></pre>
<p><img src="/2021/05/14/basic-fda-descriptive-statistics-with-r/index_files/figure-html/unnamed-chunk-3-1.png" width="672" />
Now that we have the data, remember that FDA treats each curve as a basic data element living in an infinite dimensional vector space. The vectors, <span class="math inline">\(X\)</span>, are random functions: <span class="math inline">\(X: \Omega \Rightarrow \mathscr{H}\)</span> where <span class="math inline">\(\Omega\)</span> is an underlying probability space and <span class="math inline">\(\mathscr{H}\)</span> is typically a complete Hilbert Space of square integrable functions. That is, for each <span class="math inline">\(\omega \in \Omega\)</span>, <span class="math inline">\(\parallel X(\omega) \parallel ^2 = \int X((\omega)(t))^2 dt < \infty\)</span>. In multivariate statistics we work with random variables that live in a Euclidean space, here we are dealing with random functions that live in a Hilbert space. In this context, square integrable means <span class="math inline">\(E \parallel X \parallel ^2 < \infty\)</span>. You will find lucid elaborations of all of this in the references below which I have reproduced below from the previous post.</p>
<p>The bridge from the theory to practice is the ability to represent the random functions as a linear combination of basis vectors. This was the topic of the previous post. Here is some compact code to construct the basis.</p>
<pre class="r"><code>knots = c(seq(0,max_time,5)) #Location of knots
n_knots = length(knots) #Number of knots
n_order = 4 # order of basis functions: for cubic b-splines: order = 3 + 1
n_basis = length(knots) + n_order - 2;
basis = create.bspline.basis(rangeval = c(0,max_time), n_basis)
plot(basis)</code></pre>
<p><img src="/2021/05/14/basic-fda-descriptive-statistics-with-r/index_files/figure-html/unnamed-chunk-4-1.png" width="672" />
This next bit of code formats the data in the long form tibble into the matrix input expected by the <code>fda</code> functions and creates an <code>fda</code> object that contains the coefficients and basis functions used to smooth data. Note the smoothing constant of lambda = .5.</p>
<pre class="r"><code>argvals <- matrix(df_l$Time, nrow = n_points, ncol = n_curves)
y_mat <- matrix(df_l$Curve, nrow = n_points, ncol = n_curves)
W.obj <- Data2fd(argvals = argvals, y = y_mat, basisobj = basis, lambda = 0.5)</code></pre>
<p>Next somewhat anticlimactically after all of the preparation and theory, we use the <code>fda</code> functions <code>mean.fd()</code> and <code>std.fd()</code> to calculate the pointwise mean and standard deviation from information contained in <code>fda</code> object. In order to use these objects to calculate the pointwise confidence interval for the mean it is necessary to construct a couple of new <code>fda</code> objects for the upper and lower curves. Then, we plot the smoothed curves for our data along with the pointwise mean and pointwise 95% confidence bands for the mean.</p>
<pre class="r"><code>W_mean <- mean.fd(W.obj)
W_sd <- std.fd(W.obj)
# Create objects for the standard upper and lower standard deviation
SE_u <- fd(basisobj = basis)
SE_l <- fd(basisobj = basis)
# Fill in the sd values
SE_u$coefs <- W_mean$coefs + 1.96 * W_sd$coefs/sqrt(n_curves)
SE_l$coefs <- W_mean$coefs - 1.96 * W_sd$coefs/sqrt(n_curves)
plot(W.obj, xlab="Time", ylab="", lty = 1)</code></pre>
<pre><code>## [1] "done"</code></pre>
<pre class="r"><code>title(main = "Smoothed Curves")
lines(SE_u, lwd = 3, lty = 3)
lines(SE_l, lwd = 3, lty = 3)
lines(W_mean, lwd = 3)</code></pre>
<p><img src="/2021/05/14/basic-fda-descriptive-statistics-with-r/index_files/figure-html/unnamed-chunk-6-1.png" width="672" />
Finally, we compute the covariance/correlation matrix for our sample of smoothed curves and use <a href="https://plotly.com/r/3d-surface-plots/"><code>plotly</code></a> to create an interactive plot of the three dimensional correlation surface along with a contour map.</p>
<pre class="r"><code>days <- seq(0,100, by=2)
cov_W <- var.fd(W.obj)
var_mat <- eval.bifd(days,days,cov_W)</code></pre>
<pre class="r"><code>fig <- plot_ly(x = days, y = days, z = ~var_mat) %>%
add_surface(contours = list(
z = list(show=TRUE,usecolormap=TRUE, highlightcolor="#ff0000", project=list(z=TRUE))))
fig <- fig %>%
layout(scene = list(camera=list(eye = list(x=1.87, y=0.88, z=-0.64))))
fig</code></pre>
<p><div id="htmlwidget-1" style="width:672px;height:480px;" class="plotly html-widget"></div>
<script type="application/json" data-for="htmlwidget-1">{"x":{"visdat":{"10fc4fe7d04f":["function () ","plotlyVisDat"]},"cur_data":"10fc4fe7d04f","attrs":{"10fc4fe7d04f":{"x":[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100],"y":[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100],"z":{},"alpha_stroke":1,"sizes":[10,100],"spans":[1,20],"type":"surface","contours":{"z":{"show":true,"usecolormap":true,"highlightcolor":"#ff0000","project":{"z":true}}},"inherit":true}},"layout":{"margin":{"b":40,"l":60,"t":25,"r":10},"scene":{"camera":{"eye":{"x":1.87,"y":0.88,"z":-0.64}},"xaxis":{"title":[]},"yaxis":{"title":[]},"zaxis":{"title":"var_mat"}},"hovermode":"closest","showlegend":false,"legend":{"yanchor":"top","y":0.5}},"source":"A","config":{"showSendToCloud":false},"data":[{"colorbar":{"title":"var_mat","ticklen":2,"len":0.5,"lenmode":"fraction","y":1,"yanchor":"top"},"colorscale":[["0","rgba(68,1,84,1)"],["0.0416666666666667","rgba(70,19,97,1)"],["0.0833333333333333","rgba(72,32,111,1)"],["0.125","rgba(71,45,122,1)"],["0.166666666666667","rgba(68,58,128,1)"],["0.208333333333333","rgba(64,70,135,1)"],["0.25","rgba(60,82,138,1)"],["0.291666666666667","rgba(56,93,140,1)"],["0.333333333333333","rgba(49,104,142,1)"],["0.375","rgba(46,114,142,1)"],["0.416666666666667","rgba(42,123,142,1)"],["0.458333333333333","rgba(38,133,141,1)"],["0.5","rgba(37,144,140,1)"],["0.541666666666667","rgba(33,154,138,1)"],["0.583333333333333","rgba(39,164,133,1)"],["0.625","rgba(47,174,127,1)"],["0.666666666666667","rgba(53,183,121,1)"],["0.708333333333333","rgba(79,191,110,1)"],["0.75","rgba(98,199,98,1)"],["0.791666666666667","rgba(119,207,85,1)"],["0.833333333333333","rgba(147,214,70,1)"],["0.875","rgba(172,220,52,1)"],["0.916666666666667","rgba(199,225,42,1)"],["0.958333333333333","rgba(226,228,40,1)"],["1","rgba(253,231,37,1)"]],"showscale":true,"x":[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100],"y":[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100],"z":[[0.0300141214765612,0.015686905073093,0.00564093884922246,0.00447256728960355,0.00995490109738018,0.0130378171941865,0.00725655484167828,-0.00232554798509603,-0.00801467720093724,-0.00790263578918598,-0.00586684380172273,-0.00503976012652639,-0.00456780472318001,-0.00268331461816891,0.000485556784993114,0.00291483970576381,0.00310419846129833,0.00197754095554643,0.00105330118737587,0.00158461271469904,0.00455930865447297,0.0102627510155511,0.0162165565814951,0.0193760713693298,0.0195639488111623,0.0194701497541815,0.0210337796708257,0.0226918603753865,0.0221081111780568,0.0192972748291135,0.0166251175189173,0.0157786309103451,0.015320834914587,0.013141952079488,0.00962070316816562,0.00762430715900963,0.0091589006740241,0.0123535086113619,0.0144475321088493,0.01451241822894,0.0134516599587157,0.012184664428522,0.0113758786592171,0.0115914994526642,0.0126039892034018,0.0133920758986437,0.0132433983079006,0.0128192790963617,0.0130612176454187,0.0134560954089633,0.0120361759133872],[0.015686905073093,0.0226633175061417,0.0244188932917484,0.0250220663890372,0.0258019153407324,0.025348163273158,0.0226239217260867,0.0185622655307192,0.0145795755299542,0.0118809819100223,0.011460364200486,0.0136427970615,0.0161148749202248,0.0160327747314867,0.0135243329261398,0.0116890454110662,0.0127990751660581,0.0153004431188909,0.0167891143432511,0.0173100860678814,0.0193573876765801,0.0245339491722834,0.0304523843988157,0.0338539590040724,0.0343832480444693,0.0345881359849426,0.0363282575780583,0.0382053253515058,0.0380840687391034,0.0356116588086777,0.0322177082620627,0.0291246356267592,0.0264160928835393,0.0239139417559029,0.0219667756937601,0.0214499198734321,0.0229121181584461,0.0255041836435166,0.0280467134870814,0.029803440233887,0.0304812318149881,0.0298735894418936,0.0280434804242242,0.0251388192376269,0.021711875112217,0.0187192720325778,0.0169049313606271,0.0160916414016255,0.0158522428499515,0.01530729642547,0.0131250828735328],[0.00564093884922246,0.0244188932917484,0.0404127823425623,0.0483733511242439,0.0480174477822059,0.0440280234846942,0.0403499317976119,0.0371119657865627,0.0335517590970443,0.0303526265888372,0.0296435643360046,0.0324526349389525,0.035152744283584,0.0331828317842279,0.0272677591173969,0.0234183102217875,0.026004021647384,0.0319101495611166,0.0363122500732657,0.0380973901937379,0.0398641478320654,0.0435528802177005,0.0478255817033191,0.0506029719293355,0.0516070386956147,0.0523610379614717,0.0538230640251236,0.0543773005126641,0.0518705141914604,0.0465888704428848,0.0412579332623144,0.0380833303825961,0.0367667012492371,0.0364074277070802,0.0366508994378863,0.0376885139603343,0.0396474612639257,0.0423031433367703,0.0453253497513456,0.0479775655285843,0.0491169711378746,0.0478109208618154,0.0440381258969864,0.0380544047895784,0.0312487428714465,0.0261432922601097,0.0245335471295971,0.0251112973955133,0.0258242178246622,0.025351634247369,0.0231045235574797],[0.00447256728960355,0.0250220663890372,0.0483733511242439,0.0658210619904763,0.0737960986504746,0.0738656199344664,0.0682277414378763,0.0607111433530042,0.0554453449883687,0.0541034188934748,0.055901990858814,0.059498497561025,0.0617408273533381,0.0592276422063684,0.0532303001501739,0.049692855274256,0.0528918336035986,0.0596210061121686,0.0649634904915878,0.0676832204828881,0.0702249458765112,0.0744621022049338,0.0793427260471337,0.0831343126365808,0.0852729502426609,0.0863633201706759,0.0866778286903351,0.0849565483575114,0.0796664880504596,0.0718051109167692,0.0649003343733642,0.0616710344942862,0.0611598429786833,0.0615355063179176,0.0620058163799042,0.0628176104091112,0.0643008086961966,0.0669369601728294,0.0711766273093092,0.0758858192786237,0.0783459919564488,0.0764513991188953,0.0708230606303023,0.0627955601389712,0.0544365433170178,0.0485467178603732,0.0470326094185766,0.0480965264079801,0.0490696898156232,0.0485475588451775,0.0463898309169458],[0.00995490109738018,0.0258019153407324,0.0480174477822059,0.0737960986504746,0.0971085914615697,0.10870177301888,0.102995904418255,0.0896655781362864,0.081799993583024,0.0833119041988271,0.0889376174543645,0.0937835994937921,0.0960328548021177,0.0947403483065957,0.0913260396462496,0.0895748831718718,0.0921893839315523,0.0971309463344363,0.10129314750544,0.104270865706126,0.108360280334708,0.115145590152833,0.122893279873863,0.129099970422491,0.132632271361622,0.133726780892375,0.132535733834645,0.128635652589831,0.121538220159228,0.112574159748106,0.104893234765713,0.1008406212425,0.0992267908756421,0.098035543560513,0.0965617776673574,0.0954114900412902,0.095367918350293,0.097695246427747,0.103646726979766,0.111458756334261,0.11635087444094,0.114697704490176,0.108018873309467,0.099107724487911,0.0904693162179292,0.084320421295265,0.0821118946249729,0.0822810561400769,0.0825592190496153,0.0817673680001241,0.0798161590756366],[0.0130378171941865,0.025348163273158,0.0440280234846942,0.0738656199344664,0.10870177301888,0.131429901425073,0.130338371899877,0.117199239378325,0.109151554151168,0.111744052608463,0.118935157239576,0.125205625814209,0.129141263988743,0.130406449035972,0.129868680057772,0.129598577985106,0.131177622726623,0.134021491522753,0.137061062815098,0.140530208014422,0.145965791500655,0.154228736045967,0.163249590518587,0.170292721388971,0.174149949926465,0.175140552199302,0.173523514301647,0.169051018118542,0.161419129688686,0.151947374787411,0.143578738926672,0.138481517872149,0.135442907580638,0.132469174994164,0.129046543615972,0.12614119351053,0.124904427310549,0.126970654171923,0.133934823992636,0.143706461230417,0.150509664902736,0.149900457099137,0.143403495752272,0.134024472210158,0.124513190276249,0.117363566209445,0.114287591739835,0.113914062663951,0.114141378734128,0.113797207304149,0.112638483329245],[0.00725655484167828,0.0226239217260867,0.0403499317976119,0.0682277414378763,0.102995904418255,0.130338371899877,0.139688182032744,0.137397260506744,0.133823360055384,0.134174652061097,0.138509726555246,0.146085330009431,0.153846414021606,0.158293537808086,0.158999056330915,0.158607120297858,0.159403311653335,0.16170471194128,0.165336738878575,0.170135419462684,0.175947389971655,0.182424713480816,0.188439315162361,0.192711088947525,0.194949003168609,0.195851100558978,0.195717042964027,0.19308095573795,0.186158898282678,0.176003247922498,0.166502699904055,0.160623618434228,0.15714977087869,0.153889591090921,0.150268773980867,0.147330275514936,0.146229194592453,0.148287939051957,0.154740975922443,0.163838107212786,0.170844469911743,0.171861305927171,0.166853349020735,0.1568316981457,0.144658773502766,0.135048316540061,0.131476061460251,0.132143744571539,0.133992284753065,0.135289287908722,0.135629046967152],[-0.00232554798509603,0.0185622655307192,0.0371119657865627,0.0607111433530042,0.0896655781362864,0.117199239378325,0.137397260506744,0.149021050937968,0.152158909046904,0.150528992318004,0.151479317345255,0.160019309553339,0.17117274984456,0.177717176035795,0.178183990982668,0.176858462579558,0.177467053922628,0.180500336734544,0.185609272525172,0.191740163307645,0.197134651598366,0.200408010855296,0.201792587780331,0.201934709781931,0.201704089367035,0.202193824141059,0.203687257405181,0.203189865661295,0.197077963680589,0.186104880523814,0.175400959541291,0.169000153079858,0.165789629595956,0.1634337203065,0.161065507288953,0.159286823481326,0.158833987946666,0.160725829315896,0.165959553302808,0.173410608511967,0.179832686438706,0.182195069327086,0.178698403652472,0.168035338100033,0.153134227850431,0.141159134579828,0.137488888247712,0.139624747338963,0.143184656221075,0.145766370540687,0.146947457223577],[-0.00801467720093724,0.0145795755299542,0.0335517590970443,0.0554453449883687,0.081799993583024,0.109151554151168,0.133823360055384,0.152158909046904,0.160759913976905,0.162051089760505,0.164280153376763,0.173284826371914,0.184250152549762,0.189965437082023,0.189370893621324,0.18755764430121,0.188800283197836,0.193037568943746,0.199106383544097,0.205431500374914,0.210025584183091,0.211435296519902,0.210414957220078,0.208268791568572,0.20625481507554,0.205584833476341,0.206553546822989,0.205795268916695,0.199235499638045,0.187544239635493,0.176135990325352,0.169354995508846,0.166439337958515,0.165382190838407,0.164904232232213,0.164453645143262,0.163936442039167,0.164963430649948,0.169454935750345,0.176647601384842,0.183094390867664,0.185548505510878,0.182030825701433,0.171074994035733,0.155719029247019,0.143505326205363,0.140040182937765,0.142402140335997,0.145642027044141,0.147207893536936,0.146945012119781],[-0.00790263578918598,0.0118809819100223,0.0303526265888372,0.0541034188934748,0.0833119041988271,0.111744052608463,0.134174652061097,0.150528992318004,0.162051089760505,0.170700287551338,0.179151255634655,0.188978321865683,0.197230041086307,0.200018353165535,0.197936248422864,0.196057767628283,0.198383944655527,0.203844472671486,0.210131452167584,0.215632561163899,0.219431055209156,0.220875817626191,0.220257272829271,0.218115273498233,0.215312661145223,0.21303526611469,0.211703065462037,0.20861645111564,0.200474760734835,0.188090698271463,0.176390333969868,0.169382638465077,0.166692815903987,0.166839231539204,0.168089613361411,0.168461052099373,0.166954905361007,0.166553187359872,0.171034412275775,0.179607818029667,0.186913366283649,0.188377265566261,0.183365368612479,0.172349353976725,0.158581939873738,0.148096884178574,0.14520462632401,0.146838672902345,0.148201202752072,0.147091220206974,0.143904555096121],[-0.00586684380172273,0.011460364200486,0.0296435643360046,0.055901990858814,0.0889376174543645,0.118935157239576,0.138509726555246,0.151479317345255,0.164280153376763,0.179151255634655,0.194134442321539,0.207015416909719,0.215285372260236,0.216547915360939,0.212685614130958,0.20985999742071,0.212748494985508,0.219347973081767,0.226063519070894,0.231102545847802,0.234474791840914,0.236211400126787,0.236115684455659,0.233972826276096,0.230460982724484,0.227151286625036,0.224790732613606,0.220674462452998,0.211423082374906,0.197991035415441,0.185666601415132,0.178728193736514,0.176661049081538,0.177732671916507,0.179763491086094,0.180126859813348,0.177508440228303,0.175920882370973,0.180448181283924,0.19018508658607,0.198237102472678,0.198945893456674,0.192639373221394,0.181216192008275,0.168281008165233,0.159144488146665,0.157417469158103,0.159614774347633,0.1606122604985,0.158391638832914,0.154040475012052],[-0.00503976012652639,0.0136427970615,0.0324526349389525,0.059498497561025,0.0937835994937921,0.125205625814209,0.146085330009431,0.160019309553339,0.173284826371914,0.188978321865683,0.207015416909719,0.226109065876101,0.240714743303262,0.244563014165053,0.239192032493299,0.233947541377799,0.236123607806666,0.243449752785962,0.251354795250806,0.257347545901448,0.261016807203268,0.2621094067394,0.260642534865696,0.256757706272572,0.251901309402189,0.248824606448451,0.248855362704169,0.247400421292272,0.238677363741663,0.223596057395594,0.20975865541166,0.203180237592353,0.202363714525955,0.20396716548771,0.205412522534698,0.204885570505838,0.201735186368487,0.199829771641696,0.203924162419897,0.213173923859123,0.221135350177003,0.222354612483207,0.216311175705738,0.203857529124282,0.189059282651913,0.179195166835087,0.179292120516932,0.184811112138843,0.189007860808978,0.189421680781059,0.187875481454371],[-0.00456780472318001,0.0161148749202248,0.035152744283584,0.0617408273533381,0.0960328548021177,0.129141263988743,0.153846414021606,0.171172749844561,0.184250152549762,0.197230041086307,0.215285372260236,0.240714743303262,0.264141654392061,0.273778057962538,0.269502116479285,0.262858202435585,0.263266344191042,0.269620287478599,0.278215275521839,0.28610711893243,0.29111219571012,0.291611942233209,0.288115755804973,0.281735341820846,0.275199716477354,0.272855206772115,0.276772608953709,0.279639324830909,0.272228571166917,0.255241826705762,0.239308832172306,0.232761966132105,0.23301750425598,0.234863600825815,0.23540920982273,0.234084084927079,0.231119034228133,0.229545466111812,0.23291543691702,0.240652454195423,0.248051476711448,0.25073177323223,0.246327861020472,0.233237750290338,0.215832110290119,0.204454269302239,0.206439741046498,0.216054057681938,0.224544341762145,0.228886688889647,0.231786167715914],[-0.00268331461816891,0.0160327747314867,0.0331828317842279,0.0592276422063684,0.0947403483065957,0.130406449035972,0.158293537808086,0.177717176035795,0.189965437082023,0.200018353165535,0.216547915360938,0.244563014165053,0.273778057962538,0.290572798312891,0.292573151941868,0.288651200741483,0.286737733825309,0.289042514381638,0.296222610813786,0.30611901054109,0.313756619998902,0.315175948630781,0.310969671127717,0.302955086674437,0.294940907638863,0.292727259572112,0.299164990782613,0.304961507880513,0.298318983747391,0.279644005272815,0.261547573354341,0.253979104530278,0.254119171117953,0.25607802348289,0.256769361369846,0.255910333902806,0.253830406873757,0.252820756332902,0.25554153363934,0.261859488272072,0.268847967829996,0.273294804653498,0.271331579071523,0.259269362595121,0.241320972989505,0.22960097427405,0.232798630393512,0.244527788254317,0.254931804696063,0.261016412991644,0.266649722847255],[0.000485556784993114,0.0135243329261398,0.0272677591173969,0.0532303001501739,0.0913260396462496,0.129868680057772,0.158999056330915,0.178183990982668,0.189370893621324,0.197936248422864,0.212685614130957,0.239192032493299,0.269502116479285,0.292573151941868,0.304084866530968,0.306439429693472,0.303057606677035,0.300265425619857,0.30480328575577,0.316236859897483,0.326957094436583,0.33064485798658,0.327388486556694,0.318988840468754,0.309791901709214,0.306688773929157,0.313271127157899,0.319490267082992,0.312455188069513,0.29233381903075,0.272353023428209,0.263086482662052,0.262224030835217,0.264331737959722,0.266211221915455,0.266899648450175,0.266091910995561,0.265725022785431,0.268205597825174,0.273848879004003,0.280878738094951,0.286898206164275,0.28739066816697,0.27767308912116,0.261422740636704,0.250677200915191,0.254094213698673,0.26535821852726,0.274730759985274,0.279843297835096,0.285697207017158],[0.00291483970576381,0.0116890454110662,0.0234183102217875,0.049692855274256,0.0895748831718718,0.129598577985106,0.158607120297858,0.176858462579558,0.18755764430121,0.196057767628283,0.20985999742071,0.233947541377799,0.262858202435585,0.288651200741483,0.306439429693472,0.314389455940099,0.312704592994684,0.309204068220854,0.313232618676246,0.325430199741382,0.337731985119672,0.343248592386973,0.341306289683202,0.332931048721084,0.322502032644519,0.317751596028588,0.322945736593217,0.327901860910561,0.319408078209404,0.29765805792069,0.276251029677522,0.266088035103276,0.26494596200812,0.26741130770582,0.270155472518723,0.271934759777765,0.272178336907421,0.27264423587875,0.275594391087112,0.281489521543979,0.288989130876933,0.296033547649337,0.297999655017049,0.289977868944833,0.275209671095333,0.265087608829077,0.267839041596672,0.277613000565924,0.285352127040801,0.289202483083125,0.294513551512573],[0.00310419846129833,0.0127990751660581,0.026004021647384,0.0528918336035986,0.0921893839315523,0.131177622726623,0.159403311653335,0.177467053922628,0.188800283197836,0.198383944655527,0.212748494985508,0.236123607806666,0.263266344191042,0.286737733825309,0.303057606677035,0.312704592994684,0.317105958549478,0.320795024198311,0.328855480815721,0.341169712939617,0.352418798771269,0.35791411030228,0.356392769700643,0.347634698529288,0.335706140920473,0.328959663575778,0.332178669150744,0.33512445671338,0.324411072215951,0.300642835576825,0.278414340680476,0.269212797906219,0.26966279248818,0.27282133348202,0.275151272423422,0.276521303328098,0.277252984769834,0.278887013123408,0.283196363791438,0.290286387461154,0.298594810104402,0.305911837133245,0.307727613410256,0.299305263018981,0.283911780284874,0.2728180297753,0.274256187773986,0.282911699996743,0.290363130038896,0.294624453490113,0.300145057934403],[0.00197754095554643,0.0153004431188909,0.0319101495611166,0.0596210061121686,0.0971309463344363,0.134021491522753,0.16170471194128,0.180500336734544,0.193037568943746,0.203844472671486,0.219347973081767,0.243449752785962,0.269620287478599,0.289042514381637,0.300265425619857,0.309204068220854,0.320795024198311,0.334779962483662,0.349582114419545,0.363171397029049,0.37306441301572,0.377071908776566,0.374260042755413,0.36420041359492,0.350871125241779,0.342656786946715,0.344349675078645,0.345606385730735,0.332936500117839,0.30749841883916,0.285099361878255,0.277894716559139,0.280884918805161,0.285014172433834,0.286574313382245,0.287204809707052,0.288632814369124,0.292006196968851,0.298266092384556,0.306929616209746,0.316089864753118,0.323293649031453,0.324150294421663,0.314137195281634,0.296837874960971,0.283941985800991,0.2841000136905,0.292396017144489,0.300764836732139,0.306716257668493,0.313335009814453],[0.00105330118737587,0.0167891143432511,0.0363122500732657,0.0649634904915878,0.10129314750544,0.137061062815098,0.165336738878575,0.185609272525172,0.199106383544097,0.210131452167584,0.226063519070894,0.251354795250806,0.278215275521839,0.296222610813786,0.30480328575577,0.313232618676246,0.328855480815721,0.349582114419545,0.370984151742953,0.389094311990697,0.400406401317044,0.402341684864012,0.395951074689911,0.383309110744288,0.369163304706409,0.360934139985263,0.362547165055812,0.36348332400828,0.350264985949383,0.324423770577444,0.302500548182388,0.297055887456202,0.3021188462484,0.307373832604049,0.309134496410136,0.310343729395571,0.313679062288349,0.319603670188119,0.327992114572648,0.337913388479374,0.347630916505408,0.354837546540918,0.35508391850748,0.3437550001667,0.324742995420216,0.310447344309692,0.3101171483734,0.318920635807337,0.328733235184467,0.336661005466127,0.345040636002025],[0.00158461271469904,0.0173100860678814,0.0380973901937379,0.0676832204828881,0.104270865706126,0.140530208014422,0.170135419462684,0.191740163307645,0.205431500374914,0.215632561163899,0.231102545847802,0.257347545901448,0.28610711893243,0.30611901054109,0.316236859897483,0.325430199741382,0.341169712939617,0.363171397029049,0.389094311990697,0.413877394668567,0.429739458769652,0.431049389052446,0.421249419374843,0.406064538201852,0.39155133264059,0.384097988440287,0.386666813598334,0.388458935775705,0.375894171990615,0.350548981412123,0.329156465360131,0.324417648570495,0.330269311677518,0.336262693460866,0.338975973627527,0.342014272811809,0.348387788586863,0.357504949598187,0.367888852076066,0.378410118034793,0.388286895272678,0.39594582808551,0.396587107492231,0.385004366348378,0.365192506093068,0.350347696748992,0.350321470200624,0.359986585156321,0.370722880057251,0.379700972961929,0.389882261546216],[0.00455930865447297,0.0193573876765801,0.0398641478320654,0.0702249458765112,0.108360280334708,0.145965791500655,0.175947389971655,0.197134651598366,0.210025584183091,0.219431055209156,0.234474791840914,0.261016807203268,0.29111219571012,0.313756619998902,0.326957094436583,0.337731985119672,0.352418798771269,0.37306441301572,0.400406401317044,0.429739458769652,0.450915402098339,0.456227225263344,0.448679218709221,0.43399327559022,0.418806196598807,0.410669689965659,0.413411559059499,0.415804873446741,0.40353871876728,0.37793526971434,0.355949790034467,0.350500579454025,0.355639283522414,0.361021505897904,0.363677148260339,0.368010410311134,0.377389876800323,0.389759186059976,0.401796610629334,0.412270451715893,0.422039039195408,0.430764527316019,0.432960884568757,0.422295336741163,0.402562095543856,0.387682358610529,0.387994106900862,0.39774123973533,0.407466892609289,0.415137602465859,0.426143307695915],[0.0102627510155511,0.0245339491722834,0.0435528802177005,0.0744621022049338,0.115145590152833,0.154228736045967,0.182424713480816,0.200408010855296,0.211435296519902,0.220875817626191,0.236211400126787,0.262109406739399,0.291611942233209,0.315175948630781,0.33064485798658,0.343248592386973,0.35791411030228,0.377071908776566,0.402341684864012,0.431049389052446,0.456227225263344,0.471713187952435,0.475315172245749,0.466116373399275,0.44970496080387,0.438174077985257,0.439084189309815,0.440733742656996,0.427329602525772,0.399728810463848,0.375438585067662,0.367819908526032,0.370753134432285,0.373607043309506,0.373997849489237,0.377789201111481,0.389187998900115,0.404339817600011,0.417561860121391,0.427471401556844,0.436985789181323,0.447303940848557,0.452003218086965,0.443239184389206,0.424289997295981,0.409556408396027,0.409624129776975,0.41788435133975,0.423866209365925,0.427140109465569,0.437317726577243],[0.0162165565814951,0.0304523843988157,0.0478255817033191,0.0793427260471338,0.122893279873863,0.163249590518587,0.188439315162361,0.201792587780331,0.210414957220078,0.220257272829271,0.236115684455659,0.260642534865696,0.288115755804973,0.310969671127718,0.327388486556694,0.341306289683202,0.356392769700643,0.374260042755413,0.395951074689911,0.421249419374843,0.448679218709221,0.475315172245749,0.492653238320889,0.491359229692647,0.475083372807843,0.460460307802116,0.458942148751755,0.458992746593247,0.444068798352341,0.414644974161663,0.388213917260719,0.378121765487047,0.378168987573464,0.377661321888484,0.374913305773777,0.377248275544171,0.389748533039457,0.406965494551783,0.421086008099859,0.430464443312404,0.439622691428143,0.450989028425408,0.457544656787058,0.450414823856973,0.432358481381503,0.417768285509471,0.417094601932727,0.42299538157567,0.424227190249541,0.422121121075806,0.430582794486151],[0.0193760713693298,0.0338539590040724,0.0506029719293355,0.0831343126365808,0.129099970422491,0.170292721388971,0.192711088947525,0.201934709781931,0.208268791568572,0.218115273498233,0.233972826276096,0.256757706272572,0.281735341820845,0.302955086674437,0.318988840468754,0.332931048721084,0.347634698529288,0.36420041359492,0.383309110744288,0.406064538201852,0.43399327559022,0.466116373399275,0.491359229692647,0.496771232159396,0.484303531324282,0.470809040547772,0.46829506710943,0.466794883037271,0.451513381679334,0.422953449440548,0.396915965782739,0.38544867037553,0.382926223188107,0.379686126428383,0.374831462072606,0.376230891865352,0.389241041266658,0.407645941943051,0.422630307690389,0.432136955591859,0.440866806017986,0.451495296269285,0.457420609055407,0.450202304850737,0.432455846616029,0.417852599798406,0.416199279096981,0.419921230569029,0.417696722356713,0.411964100245248,0.418921787662896],[0.0195639488111623,0.0343832480444693,0.0516070386956147,0.0852729502426609,0.132632271361622,0.174149949926465,0.194949003168609,0.201704089367035,0.20625481507554,0.215312661145223,0.230460982724484,0.251901309402189,0.275199716477354,0.294940907638863,0.309791901709214,0.322502032644519,0.335706140920473,0.350871125241779,0.369163304706409,0.39155133264059,0.418806196598807,0.44970496080387,0.475083372807843,0.484303531324282,0.4784961826378,0.470560720604065,0.469663561445729,0.467992489536655,0.454029492570107,0.428650367716082,0.40512472162131,0.393582438634855,0.389439068788739,0.384767773448362,0.379374196969909,0.38079646670035,0.394092004671593,0.413050632004732,0.428916568775937,0.439173916265262,0.447546656956644,0.456126506677243,0.459390917895988,0.450343846596568,0.431880843911928,0.416789056124265,0.414162394520702,0.416601552990779,0.413172633257409,0.406482117247161,0.41267686709026],[0.0194701497541815,0.0345881359849426,0.0523610379614717,0.0863633201706759,0.133726780892375,0.175140552199302,0.195851100558978,0.202193824141059,0.205584833476341,0.21303526611469,0.227151286625036,0.248824606448451,0.272855206772115,0.292727259572112,0.306688773929156,0.317751596028588,0.328959663575778,0.342656786946715,0.360934139985263,0.384097988440287,0.410669689965659,0.438174077985257,0.460460307802116,0.470809040547772,0.470560720604065,0.469115575603143,0.472779236162325,0.474077243404792,0.462592335719025,0.439458303186664,0.417359987582511,0.406044181113312,0.401496599158257,0.396577111193187,0.391377322675403,0.393220575043668,0.406984823385701,0.426508784170891,0.443127157996766,0.454057902463434,0.462402232173585,0.469814678020682,0.471139860930387,0.459943837840332,0.439542676278332,0.423002454362375,0.419638658976955,0.422068758056881,0.419303690994989,0.413417849679406,0.41954907849355],[0.0210337796708257,0.0363282575780583,0.0538230640251236,0.0866778286903351,0.132535733834645,0.173523514301647,0.195717042964027,0.203687257405181,0.206553546822989,0.211703065462037,0.224790732613606,0.248855362704169,0.276772608953709,0.299164990782613,0.313271127157899,0.322945736593217,0.332178669150744,0.344349675078645,0.362547165055812,0.386666813598334,0.413411559059499,0.439084189309815,0.458942148751755,0.46829506710943,0.469663561445729,0.472779236162324,0.48360904363182,0.491807243355981,0.483588029512162,0.459842077823593,0.436136545559384,0.424554952905488,0.420693840142059,0.4163763933165,0.411438785581337,0.413730177194226,0.428485347922813,0.449087992599913,0.466245834218447,0.4772629818291,0.486039930540316,0.494647711593813,0.49669230318913,0.484169386589381,0.460711868512451,0.44158988113099,0.437839440090394,0.441536229630547,0.440592365552886,0.436179795156215,0.442730297236699],[0.0226918603753865,0.0382053253515058,0.0543773005126641,0.0849565483575114,0.128635652589831,0.169051018118542,0.19308095573795,0.203189865661295,0.205795268916695,0.20861645111564,0.220674462452998,0.247400421292272,0.279639324830909,0.304961507880513,0.319490267082992,0.327901860910561,0.33512445671338,0.345606385730735,0.36348332400828,0.388458935775705,0.415804873446741,0.440733742656996,0.458992746593247,0.466794883037271,0.467992489536655,0.474077243404792,0.491807243355981,0.507677692879297,0.503896944557904,0.480587427684073,0.455785648259172,0.44368092602074,0.439958344049395,0.436039663502974,0.4316896020926,0.435015834082681,0.451340200927786,0.473390263877326,0.491077480554345,0.501960036355071,0.511242844448911,0.521749517586555,0.525448601144149,0.512201578850094,0.485824153938282,0.464086249148102,0.459953954192522,0.464751205895275,0.46499924937509,0.461199799648683,0.467835041630759],[0.0221081111780568,0.0380840687391034,0.0518705141914604,0.0796664880504596,0.121538220159228,0.161419129688686,0.186158898282678,0.197077963680589,0.199235499638045,0.200474760734835,0.211423082374906,0.238677363741663,0.272228571166917,0.298318983747391,0.312455188069513,0.319408078209404,0.324411072215951,0.332936500117839,0.350264985949383,0.375894171990615,0.40353871876728,0.427329602525772,0.444068798352341,0.451513381679334,0.454029492570107,0.462592335719025,0.483588029512162,0.503896944557905,0.506227456261832,0.48949010008663,0.46879757155209,0.456414732531753,0.450397343347703,0.445509862382192,0.442519137322143,0.448194405159151,0.466632497873868,0.490196733611043,0.508662304073023,0.5197451973432,0.529102197886016,0.539854500427431,0.543599932673212,0.529687626975937,0.502006082931013,0.478983167376673,0.474042569654484,0.478062683511896,0.476929702418906,0.471344663130109,0.476823445684704],[0.0192972748291135,0.0356116588086776,0.0465888704428848,0.0718051109167692,0.112574159748106,0.151947374787411,0.176003247922498,0.186104880523813,0.187544239635493,0.188090698271463,0.197991035415441,0.223596057395594,0.255241826705762,0.279644005272815,0.29233381903075,0.29765805792069,0.300642835576825,0.30749841883916,0.324423770577444,0.350548981412123,0.37793526971434,0.399728810463848,0.414644974161663,0.422953449440548,0.428650367716082,0.439458303186664,0.459842077823594,0.480587427684073,0.48949010008663,0.484230845366375,0.472375416874993,0.460698163707857,0.451088686975665,0.444296767638183,0.442943624095666,0.451521912188858,0.47214524953392,0.497085633467737,0.516481498387758,0.527988647690225,0.53678025377018,0.54578138088254,0.547617292200202,0.532915275809014,0.505573049014237,0.48275875834055,0.476829521694732,0.478590441778143,0.474134533299673,0.465100874572452,0.468674607513855],[0.0166251175189173,0.0322177082620627,0.0412579332623144,0.0649003343733642,0.104893234765713,0.143578738926672,0.166502699904055,0.175400959541291,0.176135990325352,0.176390333969868,0.185666601415132,0.20975865541166,0.239308832172306,0.261547573354341,0.272353023428209,0.276251029677522,0.278414340680476,0.285099361878255,0.302500548182388,0.329156465360131,0.355949790034467,0.375438585067662,0.388213917260719,0.396915965782739,0.40512472162131,0.417359987582511,0.436136545559384,0.455785648259172,0.46879757155209,0.472375416874993,0.468435111231379,0.459422170015031,0.449080840343203,0.441476994009423,0.440606162951622,0.450393539252134,0.472361361980421,0.498432291172835,0.518457243656538,0.529834621887771,0.53751031395185,0.54443319605555,0.544251490695122,0.528812802680059,0.502029288859946,0.479877658124455,0.473702912379025,0.474225042628651,0.467709999290762,0.45657461194633,0.459386589339875],[0.0157786309103451,0.0291246356267592,0.0380833303825961,0.0616710344942862,0.1008406212425,0.138481517872149,0.160623618434228,0.169000153079858,0.169354995508846,0.169382638465077,0.178728193736514,0.203180237592353,0.232761966132105,0.253979104530278,0.263086482662052,0.266088035103276,0.269212797906219,0.277894716559139,0.297055887456202,0.324417648570495,0.350500579454025,0.367819908526032,0.378121765487047,0.38544867037553,0.393582438634855,0.406044181113312,0.424554952905488,0.44368092602074,0.456414732531752,0.460698163707857,0.459422170015031,0.455349888117668,0.449872476135279,0.444155568067038,0.442066619777388,0.450174908996043,0.47205200752875,0.498808781421859,0.518817411678937,0.529109381436008,0.535375475961557,0.541203508738676,0.540263440520645,0.524279252988556,0.497245062359597,0.475425119387053,0.470333511356097,0.472349735238402,0.467288600496787,0.457500998193171,0.461873900988569],[0.015320834914587,0.0264160928835393,0.0367667012492371,0.0611598429786833,0.0992267908756421,0.135442907580638,0.15714977087869,0.165789629595956,0.166439337958515,0.166692815903987,0.176661049081538,0.202363714525955,0.23301750425598,0.254119171117953,0.262224030835217,0.26494596200812,0.26966279248818,0.280884918805161,0.3021188462484,0.330269311677518,0.355639283522414,0.370753134432285,0.378168987573464,0.382926223188107,0.389439068788739,0.401496599158257,0.420693840142059,0.439958344049395,0.450397343347703,0.451088686975665,0.449080840343203,0.449872476135279,0.451376901968089,0.44988736596414,0.448051597036438,0.454871804888492,0.475976224283362,0.502392063128317,0.521892469247847,0.531363112983211,0.536802187192439,0.542042016419592,0.540666665428192,0.524246217019632,0.496956662604507,0.475579902202605,0.472015999154859,0.476445338154734,0.474326860754641,0.467414468485694,0.473757022857713],[0.013141952079488,0.0239139417559029,0.0364074277070802,0.0615355063179176,0.098035543560513,0.132469174994164,0.153889591090921,0.1634337203065,0.165382190838407,0.166839231539204,0.177732671916507,0.20396716548771,0.234863600825815,0.25607802348289,0.264331737959722,0.26741130770582,0.27282133348202,0.285014172433834,0.307373832604049,0.336262693460866,0.361021505897904,0.373607043309506,0.377661321888484,0.379686126428384,0.384767773448362,0.396577111193187,0.4163763933165,0.436039663502974,0.445509862382192,0.444296767638183,0.441476994009423,0.444155568067038,0.44988736596414,0.454087083196024,0.457858625031747,0.467995106514124,0.488749400593422,0.513223984062976,0.532025928598614,0.54248276607584,0.548642488569836,0.552915213701676,0.549990785589102,0.533117094808669,0.506768673133801,0.486646693534791,0.483833995147439,0.488987622430972,0.488309143092758,0.482972478937609,0.489123905867787],[0.00962070316816562,0.0219667756937601,0.0366508994378863,0.0620058163799043,0.0965617776673574,0.129046543615972,0.150268773980867,0.161065507288953,0.164904232232213,0.168089613361412,0.179763491086095,0.205412522534698,0.23540920982273,0.256769361369846,0.266211221915455,0.270155472518723,0.275151272423422,0.286574313382245,0.309134496410136,0.338975973627527,0.363677148260339,0.373997849489237,0.374913305773777,0.374831462072606,0.379374196969909,0.391377322675403,0.411438785581337,0.4316896020926,0.442519137322143,0.442943624095666,0.440606162951622,0.442066619777388,0.448051597036438,0.457858625031747,0.471457839062233,0.489491979422758,0.511752752149262,0.53451075146009,0.55327142593128,0.566188267317039,0.574062810549737,0.576978154350557,0.57168312334756,0.554459777554331,0.530026666886978,0.511538831164126,0.508179224538887,0.51177524286709,0.510371975484521,0.50481592197545,0.508754992172626],[0.00762430715900963,0.0214499198734321,0.0376885139603343,0.0628176104091112,0.0954114900412902,0.12614119351053,0.147330275514936,0.159286823481326,0.164453645143262,0.168461052099373,0.180126859813348,0.204885570505838,0.234084084927079,0.255910333902806,0.266899648450175,0.271934759777765,0.276521303328098,0.287204809707052,0.310343729395571,0.342014272811809,0.368010410311134,0.377789201111481,0.377248275544171,0.376230891865352,0.38079646670035,0.393220575043668,0.413730177194226,0.435015834082681,0.448194405159151,0.451521912188858,0.450393539252133,0.450174908996043,0.454871804888492,0.467995106514124,0.489491979422758,0.515745875129392,0.543133321982381,0.568622932017401,0.58939272141059,0.604032520366637,0.612543973118782,0.614574451294114,0.608108703220587,0.591006647618568,0.567817206203912,0.549778303687962,0.54475151836718,0.545929738009707,0.54330405084826,0.537569126338575,0.540123215159413],[0.0091589006740241,0.0229121181584461,0.0396474612639257,0.0643008086961966,0.095367918350293,0.124904427310549,0.146229194592453,0.158833987946666,0.163936442039167,0.166954905361007,0.177508440228303,0.201735186368487,0.231119034228132,0.253830406873757,0.266091910995561,0.272178336907421,0.277252984769834,0.288632814369124,0.313679062288349,0.348387788586863,0.377389876800323,0.389187998900115,0.389748533039457,0.389241041266658,0.394092004671593,0.406984823385701,0.428485347922813,0.451340200927786,0.466632497873868,0.47214524953392,0.472361361980421,0.47205200752875,0.475976224283362,0.488749400593422,0.511752752149262,0.543133321982381,0.579891489816235,0.615003446952348,0.640693227552964,0.655024335003,0.661899741910047,0.66410144349512,0.658911965568111,0.642567491498452,0.618860277638933,0.599138653325696,0.5916170129157,0.590659911199867,0.587575328027475,0.58300659709459,0.586932405944075],[0.0123535086113619,0.0255041836435166,0.0423031433367703,0.0669369601728294,0.097695246427747,0.126970654171923,0.148287939051957,0.160725829315896,0.164963430649948,0.166553187359872,0.175920882370973,0.199829771641696,0.229545466111812,0.252820756332902,0.265725022785431,0.27264423587875,0.278887013123408,0.292006196968851,0.319603670188119,0.357504949598187,0.389759186059976,0.404339817600011,0.406965494551783,0.407645941943052,0.413050632004732,0.426508784170891,0.449087992599913,0.473390263877326,0.490196733611043,0.497085633467737,0.498432291172835,0.498808781421859,0.502392063128317,0.513223984062976,0.53451075146009,0.568622932017401,0.615003446952348,0.661529964350107,0.693685379505064,0.708373019034013,0.713916640876153,0.716660320288563,0.713043239830729,0.697407018116191,0.672802436012822,0.650989436642837,0.640775220956778,0.637641384304702,0.634093496532438,0.630810773091416,0.636646075038659],[0.0144475321088493,0.0280467134870814,0.0453253497513456,0.0711766273093092,0.103646726979766,0.133934823992636,0.154740975922443,0.165959553302808,0.169454935750345,0.171034412275775,0.180448181283924,0.203924162419897,0.23291543691702,0.25554153363934,0.268205597825174,0.275594391087112,0.283196363791438,0.298266092384556,0.327992114572648,0.367888852076066,0.401796610629334,0.417561860121391,0.421086008099859,0.422630307690389,0.428916568775937,0.443127157996766,0.466245834218447,0.491077480554345,0.508662304073023,0.516481498387758,0.518457243656538,0.518817411678937,0.521892469247847,0.532025928598614,0.55327142593128,0.58939272141059,0.640693227552964,0.693685379505064,0.731958672093633,0.75117309266341,0.759059121077132,0.761790173772067,0.757212197393526,0.741394265942365,0.717420333900737,0.695389236232093,0.68298265091228,0.676993648752599,0.671773520528878,0.668122107397169,0.673287800893748],[0.01451241822894,0.029803440233887,0.0479775655285843,0.0758858192786237,0.111458756334261,0.143706461230417,0.163838107212786,0.173410608511967,0.176647601384842,0.179607818029667,0.19018508658607,0.213173923859123,0.240652454195423,0.261859488272072,0.273848879004003,0.281489521543979,0.290286387461154,0.306929616209746,0.337913388479374,0.378410118034794,0.412270451715893,0.427471401556844,0.430464443312404,0.432136955591859,0.439173916265262,0.454057902463434,0.4772629818291,0.501960036355071,0.5197451973432,0.527988647690225,0.529834621887771,0.529109381436008,0.531363112983211,0.54248276607584,0.566188267317039,0.604032520366637,0.655024335003,0.708373019034013,0.751173092663411,0.778226097529673,0.792040596706031,0.795054719943551,0.788084512150767,0.771682049115599,0.749655104696312,0.72906715082152,0.715289796331835,0.7063609893558,0.698680729923973,0.693144760907573,0.695144568018487],[0.0134516599587157,0.0304812318149881,0.0491169711378746,0.0783459919564488,0.11635087444094,0.150509664902736,0.170844469911743,0.179832686438706,0.183094390867664,0.186913366283649,0.198237102472678,0.221135350177003,0.248051476711448,0.268847967829996,0.280878738094951,0.288989130876933,0.298594810104402,0.316089864753118,0.347630916505408,0.388286895272678,0.422039039195408,0.436985789181323,0.439622691428143,0.440866806017986,0.447546656956644,0.462402232173585,0.486039930540316,0.511242844448911,0.529102197886016,0.53678025377018,0.53751031395185,0.535375475961557,0.536802187192439,0.548642488569836,0.574062810549737,0.612543973118782,0.661899741910047,0.713916640876153,0.759059121077132,0.792040596706031,0.811823445088911,0.818042298701227,0.812281860505905,0.796706957442559,0.77561236261166,0.755422795274529,0.741041135892844,0.730912484310399,0.722030820366355,0.715146602345967,0.714766766980591],[0.012184664428522,0.0298735894418936,0.0478109208618154,0.0764513991188953,0.114697704490176,0.149900457099137,0.171861305927171,0.182195069327086,0.185548505510878,0.188377265566261,0.198945893456674,0.222354612483207,0.25073177323223,0.273294804653498,0.286898206164275,0.296033547649337,0.305911837133245,0.323293649031453,0.354837546540918,0.39594582808551,0.430764527316019,0.447303940848557,0.450989028425408,0.451495296269285,0.456126506677243,0.469814678020682,0.494647711593813,0.521749517586555,0.539854500427431,0.545781380882539,0.54443319605555,0.541203508738676,0.542042016419592,0.552915213701676,0.576978154350557,0.614574451294114,0.66410144349512,0.716660320288563,0.761790173772067,0.795054719943551,0.818042298701227,0.831782934255224,0.834025627384994,0.821986847722224,0.799500733226275,0.777019090184183,0.7626638177211,0.754086287475037,0.746539338907004,0.740315104458059,0.740745009549303],[0.0113758786592171,0.0280434804242242,0.0440381258969864,0.0708230606303023,0.108018873309467,0.143403495752272,0.166853349020735,0.178698403652472,0.182030825701433,0.183365368612479,0.192639373221394,0.216311175705738,0.246327861020472,0.271331579071523,0.28739066816697,0.297999655017049,0.307727613410256,0.324150294421663,0.35508391850748,0.396587107492231,0.432960884568757,0.452003218086965,0.457544656787058,0.457420609055407,0.459390917895988,0.471139860930387,0.49669230318913,0.525448601144149,0.543599932673212,0.547617292200202,0.544251490695122,0.540263440520645,0.540666665428192,0.549990785589103,0.57168312334756,0.608108703220587,0.65891196556811,0.713043239830729,0.757212197393526,0.788084512150767,0.812281860505905,0.834025627384994,0.846204553107233,0.839402248954447,0.816347064838136,0.79191208929948,0.777821061626795,0.771088195639605,0.765329870251256,0.760592032978596,0.763350199941972],[0.0115914994526642,0.0251388192376269,0.0380544047895784,0.0627955601389712,0.099107724487911,0.134024472210158,0.1568316981457,0.168035338100033,0.171074994035733,0.172349353976725,0.181216192008275,0.203857529124282,0.233237750290338,0.259269362595121,0.27767308912116,0.289977868944833,0.299305263018981,0.314137195281635,0.3437550001667,0.385004366348379,0.422295336741163,0.443239184389206,0.450414823856973,0.450202304850737,0.450343846596568,0.459943837840332,0.484169386589381,0.512201578850094,0.529687626975937,0.532915275809014,0.528812802680059,0.524279252988556,0.524246217019632,0.533117094808669,0.554459777554332,0.591006647618568,0.642567491498452,0.697407018116191,0.741394265942365,0.771682049115599,0.79670695744256,0.821986847722224,0.839402248954446,0.837968384106799,0.81921307224918,0.79717672855382,0.783171392528298,0.775419497351596,0.769108763063164,0.764893743882469,0.768895828209003],[0.0126039892034018,0.021711875112217,0.0312487428714465,0.0544365433170178,0.0904693162179292,0.124513190276249,0.144658773502766,0.153134227850431,0.155719029247019,0.158581939873738,0.168281008165233,0.189059282651913,0.215832110290119,0.241320972989505,0.261422740636704,0.275209671095333,0.283911780284874,0.296837874960971,0.324742995420216,0.365192506093068,0.402562095543856,0.424289997295981,0.432358481381503,0.432455846616029,0.431880843911928,0.439542676278332,0.460711868512451,0.485824153938282,0.502006082931013,0.505573049014237,0.502029288859946,0.497245062359597,0.496956662604507,0.5067686731338,0.530026666886978,0.567817206203912,0.618860277638933,0.672802436012822,0.717420333900737,0.749655104696312,0.77561236261166,0.799500733226275,0.816347064838136,0.81921307224918,0.808757619221069,0.793236718475193,0.77965794064671,0.768713844728515,0.759639720544742,0.754464983981018,0.758013176984464],[0.0133920758986437,0.0187192720325778,0.0261432922601097,0.0485467178603732,0.084320421295265,0.117363566209445,0.135048316540061,0.141159134579828,0.143505326205363,0.148096884178574,0.159144488146665,0.179195166835087,0.204454269302239,0.22960097427405,0.250677200915191,0.265087608829077,0.2728180297753,0.283941985800991,0.310447344309692,0.350347696748992,0.387682358610529,0.409556408396027,0.417768285509471,0.417852599798406,0.416789056124265,0.423002454362375,0.44158988113099,0.464086249148102,0.478983167376673,0.48275875834055,0.479877658124455,0.475425119387052,0.475579902202605,0.486646693534791,0.511538831164126,0.549778303687962,0.599138653325696,0.650989436642838,0.695389236232093,0.72906715082152,0.755422795274529,0.777019090184183,0.79191208929948,0.79717672855382,0.793236718475193,0.783864544186173,0.772508441505872,0.760737253457883,0.749743800435967,0.742878890922022,0.745651321486086],[0.0132433983079006,0.0169049313606271,0.0245335471295971,0.0470326094185766,0.0821118946249729,0.114287591739835,0.131476061460251,0.137488888247712,0.140040182937765,0.14520462632401,0.157417469158103,0.179292120516932,0.206439741046498,0.232798630393512,0.254094213698673,0.267839041596672,0.274256187773986,0.2841000136905,0.3101171483734,0.350321470200625,0.387994106900862,0.409624129776975,0.417094601932727,0.416199279096981,0.414162394520702,0.419638658976955,0.437839440090394,0.459953954192522,0.474042569654484,0.476829521694731,0.473702912379025,0.470333511356097,0.472015999154859,0.483833995147439,0.508179224538888,0.54475151836718,0.5916170129157,0.640775220956778,0.68298265091228,0.715289796331835,0.741041135892844,0.7626638177211,0.777821061626796,0.783171392528298,0.77965794064671,0.772508441505872,0.765873337377905,0.758848748779751,0.749517114130461,0.741708533689831,0.745000769558399],[0.0128192790963617,0.0160916414016255,0.0251112973955133,0.0480965264079801,0.0822810561400769,0.113914062663951,0.132143744571539,0.139624747338963,0.142402140335997,0.146838672902345,0.159614774347633,0.184811112138843,0.216054057681938,0.244527788254317,0.26535821852726,0.277613000565924,0.282911699996743,0.292396017144489,0.318920635807337,0.359986585156321,0.39774123973533,0.41788435133975,0.42299538157567,0.419921230569029,0.416601552990779,0.422068758056881,0.441536229630547,0.464751205895275,0.478062683511897,0.478590441778143,0.474225042628651,0.472349735238402,0.476445338154734,0.488987622430972,0.51177524286709,0.545929738009707,0.590659911199867,0.637641384304702,0.676993648752599,0.7063609893558,0.730912484310399,0.754086287475036,0.771088195639605,0.775419497351596,0.768713844728515,0.760737253457883,0.758848748779751,0.75936507004516,0.756232969455926,0.752382638643508,0.759727708669011],[0.0130612176454187,0.0158522428499515,0.0258242178246622,0.0490696898156232,0.0825592190496153,0.114141378734128,0.133992284753065,0.143184656221075,0.145642027044141,0.148201202752072,0.1606122604985,0.189007860808978,0.224544341762145,0.254931804696063,0.274730759985274,0.285352127040801,0.290363130038896,0.300764836732139,0.328733235184467,0.370722880057251,0.407466892609289,0.423866209365925,0.424227190249541,0.417696722356713,0.413172633257409,0.419303690994989,0.440592365552886,0.46499924937509,0.476929702418906,0.474134533299673,0.467709999290762,0.467288600496787,0.474326860754641,0.488309143092758,0.510371975484521,0.54330405084826,0.587575328027474,0.634093496532438,0.671773520528878,0.698680729923973,0.722030820366355,0.746539338907004,0.765329870251256,0.769108763063164,0.759639720544742,0.749743800435966,0.749517114130462,0.756232969455926,0.764217043125277,0.773730616715519,0.790970576667741],[0.0134560954089633,0.01530729642547,0.025351634247369,0.0485475588451775,0.0817673680001241,0.113797207304149,0.135289287908722,0.145766370540687,0.147207893536936,0.147091220206974,0.158391638832914,0.189421680781059,0.228886688889647,0.261016412991644,0.279843297835096,0.289202483083125,0.294624453490113,0.306716257668493,0.336661005466127,0.379700972961929,0.415137602465859,0.427140109465569,0.422121121075806,0.411964100245248,0.406482117247161,0.413417849679406,0.436179795156215,0.461199799648683,0.471344663130109,0.465100874572452,0.45657461194633,0.457500998193171,0.467414468485694,0.482972478937609,0.50481592197545,0.537569126338575,0.58300659709459,0.630810773091416,0.668122107397169,0.693144760907573,0.715146602345967,0.740315104458059,0.760592032978596,0.764893743882469,0.754464983981018,0.742878890922022,0.741708533689831,0.752382638643508,0.773730616715519,0.803127594121945,0.836494412362482],[0.0120361759133872,0.0131250828735328,0.0231045235574797,0.0463898309169458,0.0798161590756366,0.112638483329245,0.135629046967152,0.146947457223577,0.146945012119781,0.143904555096121,0.154040475012052,0.187875481454371,0.231786167715914,0.266649722847255,0.285697207017158,0.294513551512573,0.300145057934403,0.313335009814453,0.345040636002025,0.389882261546216,0.426143307695915,0.437317726577243,0.430582794486151,0.418921787662896,0.41267686709026,0.41954907849355,0.442730297236699,0.467835041630759,0.476823445684704,0.468674607513855,0.459386589339875,0.461873900988569,0.473757022857713,0.489123905867787,0.508754992172626,0.540123215159413,0.586932405944075,0.636646075038659,0.673287800893748,0.695144568018487,0.714766766980591,0.740745009549303,0.763350199941972,0.768895828209003,0.758013176984464,0.745651321486086,0.745000769558399,0.759727708669011,0.790970576667741,0.836494412362482,0.890690855519201]],"type":"surface","contours":{"z":{"show":true,"usecolormap":true,"highlightcolor":"#ff0000","project":{"z":true}}},"frame":null}],"highlight":{"on":"plotly_click","persistent":false,"dynamic":false,"selectize":false,"opacityDim":0.2,"selected":{"opacity":1},"debounce":0},"shinyEvents":["plotly_hover","plotly_click","plotly_selected","plotly_relayout","plotly_brushed","plotly_brushing","plotly_clickannotation","plotly_doubleclick","plotly_deselect","plotly_afterplot","plotly_sunburstclick"],"base_url":"https://plot.ly"},"evals":[],"jsHooks":[]}</script>
This covariance surface for the Brownian motion random walk we are using for data is interesting in its own right. There is a theoretical result that says that the estimate for the covariance function for this process is <span class="math inline">\(\hat{c}(t,s) = min(t,s)\)</span>. You can find the proof in the book by Kokoszka and Reimherr referenced below. Using the mouse to hover over some points in the graph makes this result seem plausible.</p>
<div id="references" class="section level4">
<h4>References</h4>
<div id="books" class="section level5">
<h5>Books</h5>
<ul>
<li>Kokoszka, P. and Reimherr, M. (2017). <em>Introduction to Functional Data Analysis</em>. CRC.</li>
<li>Ramsay, J.O. and Silverman, B.W. (2005). <em>Functional Data Analysis</em>. Springer.</li>
<li>Ramsay, J.0., Hooker, G. and Graves, S. (2009) <em>Functional Data Analysis with R and MATLAB</em> Springer.</li>
</ul>
</div>
<div id="online-resources" class="section level5">
<h5>Online Resources</h5>
<ul>
<li>Cao, J. (2019). <a href="https://www.youtube.com/watch?v=SUp_Nq8NwfE"><em>Functional Data Analysis Course</em></a></li>
<li>Staicu, A. and Park, Y. (2016) <a href="https://www4.stat.ncsu.edu/~staicu/FDAtutorial/"><em>Short Course on Applied Functional Data Analysis</em></a></li>
</ul>
</div>
<div id="recommended-papers" class="section level5">
<h5>Recommended Papers</h5>
<ul>
<li>Sørensen, H. Goldsmith, J. and Sangalli, L. (2013). <a href="https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.5989"><em>An introduction with medical applications fo functional data analysis</em></a> Wiley</li>
<li>Wang, J., Chiou, J. and Müller, H. (2015). <a href="https://arxiv.org/pdf/1507.05135.pdf"><em>Review of Functional Data Analysis</em></a></li>
<li>Yao, F., Müller, H, Wang, J. (2012). <a href="https://anson.ucdavis.edu/~mueller/jasa03-190final.pdf"><em>Functional Data Analysis for Sparse Longitudinal Data</em></a> JASA J100, I 470</li>
</ul>
</div>
</div>
<script>window.location.href='https://rviews.rstudio.com/2021/05/14/basic-fda-descriptive-statistics-with-r/';</script>
Introduction to Functional Data Analysis with R
https://rviews.rstudio.com/2021/05/04/functional-data-analysis-in-r/
Tue, 04 May 2021 00:00:00 +0000https://rviews.rstudio.com/2021/05/04/functional-data-analysis-in-r/
<script src="/2021/05/04/functional-data-analysis-in-r/index_files/header-attrs/header-attrs.js"></script>
<p>Suppose you have data that looks something like this.</p>
<p><img src="/2021/05/04/functional-data-analysis-in-r/index_files/figure-html/unnamed-chunk-1-1.png" width="672" />
This plot might depict 80 measurements for a participant in a clinical trial where each data point represents the change in the level of some protein level. Or it could represent any series of longitudinal data where the measurements are taken at irregular intervals. The curve looks like a time series with obvious correlations among the points, but there are not enough measurements to model the data with the usual time series methods. In a scenario like this, you might find <a href="https://en.wikipedia.org/wiki/Functional_data_analysis">Functional Data Analysis</a> (FDA) to be a viable alternative to the usual multi-level, mixed model approach.</p>
<p>This post is meant to be a “gentle” introduction to doing FDA with R for someone who is totally new to the subject. I’ll show some “first steps” code, but most of the post will be about providing background and motivation for looking into FDA. I will also point out some of the available resources that a newcommer to FDA should find helpful.</p>
<p>FDA is a branch of statistics that deals with data that can be conceptualized as a function of an underlying, continuous variable. The data in FDA are smooth curves (or surfaces) in time or space. To fix a mental model of this idea, first consider an ordinary time series. For example, you might think of the daily closing prices of your favorite stock. The data that make up a time series are the individual points which are considered to be random draws from an underlying stochastic process.</p>
<p>Now, go up a level of abstraction, and consider a space where the whole time series, or rather an imaginary continuous curve that runs through all of your data points is the basic item of analysis. In this conceptual model, the curve comprises an infinite number of points, not just the few you observed. Moreover, unlike in basic time series analysis, the observed points do not need to be equally spaced, and the various curves that make up your data set do not need to be sampled at the same time points.</p>
<p>Mathematically, the curves are modeled as functions that live in an infinite dimensional vector space, what the mathematicians call a <a href="https://iopscience.iop.org/article/10.1088/1742-6596/839/1/012002/pdf">Hilbert Space</a>. One way to think of this is that you are dealing with the ultimate large p small n problem. Each curve has infinitely many points, not just the 3 or 30 or 3,000 you happen to have.</p>
<p>The theory of Hilbert Spaces is part of the area of mathematical analysis called <a href="https://en.wikipedia.org/wiki/Functional_analysis">Functional Analysis</a>, a subject usually introduced as part of a second or third course in mathematical analysis, or perhaps in a course on <a href="https://quantum.phys.cmu.edu/QCQI/qitd114.pdf">Quantum Mechanics</a>.</p>
<p>It would be a heavy lift to expect someone new to Functional Data Analysis to start with the mathematics. Fortunately, this is not really necessary. The practical applications of FDA and the necessary supporting software have been sufficiently developed so that anyone familiar with the basics of ordinary vector spaces should have sufficient background to get started. The salient points to remember are:</p>
<ul>
<li>Hilbert space is an infinite dimensional linear vector space</li>
<li>The vectors in Hilbert space are functions</li>
<li>The inner product of two functions in the Hilbert space is defined as the integral of two functions, but it behaves very much like the familiar dot product.</li>
</ul>
<p>Moreover, for the last twenty years or so mathematical statisticians have been writing R packages to put FDA within the reach of anyone with motivation and minimal R skills. The CRAN Task View on <a href="https://cran.r-project.org/view=FunctionalData">Functional Data Analysis</a> categorizes and provides brief explanations for forty packages that collectively cover most of the established work on FDA. The following graph built with functions from the <a href="https://cran.r-project.org/package=cranly"><code>cranly</code></a> package shows part of the network for two core FDA packages.</p>
<p><img src="fda.png" height = "600" width="100%"></p>
<p>The <a href="https://cran.r-project.org/package=fda"><code>fda</code></a> package emphasized in the network plot above is the logical place for an R user to begin investigating FDA. With thirty-two reverse depends, thirty-eight reverse imports and thirteen reverse suggest, fda is at the root of Functional Data Analysis software for R. Moreover, in a very real sense, it is at the root of modern FDA itself. <code>fda</code> was written to explicate the theory developed in the 2005 book by Ramsay and Silverman<span class="math inline">\(^{1}\)</span>. Kokoszka and Reimnerr state that the first edition of this book published in 1997: “is largely credited with solidifying FDA as an official subbranch of statistics” (p xiv)<span class="math inline">\(^{2}\)</span>. The <a href="https://cran.r-project.org/package=refund"><code>refund</code></a> package is used extensively throughout the book by Kokoszka and Reimnerr.</p>
<div id="first-steps" class="section level3">
<h3>First Steps</h3>
<p>The synthetic data in the figure above were generated by a Wiener, Brownian Motion process, which for the purposes of this post, is just a convenient way to generate a variety of reasonable looking curves. We suppose that the data points shown represent noisy observations generated by a smooth curve f(t). We estimate this curve with the model: <span class="math inline">\(y_{i} = f(t_{i}) + \epsilon_{i}\)</span> where the <span class="math inline">\(\epsilon_{i}\)</span> are normally distributed with mean 0 and variance <span class="math inline">\(\sigma^{2}\)</span>.</p>
<p>Notice that the measurement times are randomly selected within the 100 day window and not uniformly spaced.</p>
<pre class="r"><code>set.seed(999)
n_obs <- 80
time_span <- 100
time <- sort(runif(n_obs,0,time_span))
Wiener <- cumsum(rnorm(n_obs)) / sqrt(n_obs)
y_obs <- Wiener + rnorm(n_obs,0,.05)</code></pre>
<p>Remember that the task ahead is to represent the entire curve of infinitely many points and not just the handful of observed values. Here is where the linear algebra comes in. The curve is treated as a vector in an infinite dimensional vector space, and what we want is something that will serve as a basis for this curve projected down into the subspace where the measurements live. The standard way to do this for non-periodic data is to construct a <a href="https://en.wikipedia.org/wiki/B-spline">B-spline</a> basis. (B-splines or basis splines are splines designed to have properties that make them suitable for representing vectors.) The code that follows is mostly <em>borrowed</em> from Jiguo Cao’s Youtube Video Course<span class="math inline">\(^{3}\)</span> which I very highly recommend for anyone just starting with FDA. In his first five videos, Cao explains B-splines and the placement of knots in great detail and derives the formula used in the code to calculates the number of basis elements from the number of knots and the order of the splines.</p>
<p>Note that we are placing the knots at times equally spaced over the 100 day time span.</p>
<pre class="r"><code>times_basis = seq(0,time_span,1)
knots = c(seq(0,time_span,5)) #Location of knots
n_knots = length(knots) #Number of knots
n_order = 4 # order of basis functions: cubic bspline: order = 3 + 1
n_basis = length(knots) + n_order - 2;
basis = create.bspline.basis(c(min(times_basis),max(times_basis)),n_basis,n_order,knots)
n_basis</code></pre>
<pre><code>## [1] 23</code></pre>
<p>and there are 23 basis vectors.</p>
<p>Next, we use the function <code>eval.basis()</code> to evaluate the basis functions at the times where our data curve was observed The matrix <code>PHI</code> contains the values of the 23 basis functions <span class="math inline">\(\phi_j(t)\)</span> evaluated at 80 points.</p>
<pre class="r"><code>PHI = eval.basis(time, basis)
dim(PHI)</code></pre>
<pre><code>## [1] 80 23</code></pre>
<p>We plot the basis functions and locations of the knots.</p>
<pre class="r"><code>matplot(time,PHI,type='l',lwd=1,lty=1, xlab='time',ylab='basis',cex.lab=1,cex.axis=1)
for (i in 1:n_knots)
{
abline(v=knots[i], lty=2, lwd=1)
}</code></pre>
<p><img src="/2021/05/04/functional-data-analysis-in-r/index_files/figure-html/unnamed-chunk-5-1.png" width="672" /></p>
<p>The plot shows that for interior points, four basis functions contribute to computing the value of any point. The endpoints, however, are computed from a single basis function.</p>
</div>
<div id="estimating-the-basis-coefficients" class="section level3">
<h3>Estimating the Basis Coefficients</h3>
<p>As in ordinary regression, we express the function in terms of the coefficients <span class="math inline">\(c_j\)</span> and basis functions <span class="math inline">\(\phi_j\)</span> using the formula: <span class="math inline">\(f(t) = \sum c_j \phi_j(t)\)</span>. Later we will see how to use built-in <code>fda</code> functions to estimate the coefficients, but now we follow Cao’s lead and calculate everything from first principles.</p>
<p>The following code uses matrix least squares equation <span class="math inline">\(\hat{c} = (\Phi^t\Phi)^{-1} \Phi^{t}y\)</span> to estimate the coefficients.</p>
<pre class="r"><code># Least squares estimate
# estimate basis coefficient
M = ginv(t(PHI) %*% PHI) %*% t(PHI)
c_hat = M %*% Wiener</code></pre>
<p>We compute <span class="math inline">\(\hat{y}\)</span>, the estimates of our observed values, and plot.</p>
<pre class="r"><code>y_hat = PHI %*% c_hat
# Augment data frame for plotting
df <- df %>% mutate(y_hat = y_hat)
p2 <- df %>% ggplot() +
geom_line(aes(x = time, y = Wiener), col = "grey") +
geom_point(aes(x = time, y = y_obs)) +
geom_line(aes(x = time, y = y_hat), col = "red")
p2 + ggtitle("Original curve and least squares estimate") +
xlab("time") + ylab("f(time)")</code></pre>
<p><img src="/2021/05/04/functional-data-analysis-in-r/index_files/figure-html/unnamed-chunk-7-1.png" width="672" />
The gray curve in the plot represents the underlying Brownian motion process, the dots are the observed values (the same as in the first plot), and the red curve represents the least squares “smoothed” estimates.</p>
<p>Now, we work through the matrix calculations to estimate the variance of the noise and the error bars for <span class="math inline">\(\hat{y}\)</span>.</p>
<pre class="r"><code># estimate the variance of noise
## SSE = (Y - Xb)'(Y - Xb)
SSE = t(y_hat-y_obs)%*%(y_hat-y_obs)
sigma2 = SSE/(n_obs-n_basis)
# estimate the variance of the fitted curve
# H is the Hat matrix H
# H = X*inv(X'X)*X``
H = PHI %*% M
varYhat = diag(H %*% H * matrix(sigma2,n_obs,n_obs))
# 95% confidence interval
y_hat025 = y_hat-1.96*sqrt(varYhat)
y_hat975 = y_hat+1.96*sqrt(varYhat)</code></pre>
<p>And, we plot. We have a satisfying smoothed representation of our original curve that looks like it would be and adequate starting point for further study. Note that process of using regression to produce a curve from the basis functions is often referred to as “regression smoothing”</p>
<pre class="r"><code>df <- mutate(df, y_hat025 = y_hat025,
y_hat975 = y_hat975)
#names(df) <- c("time","Wiener","y_hat", "y_hat025", "y_hat975")
p3 <- df %>% ggplot() +
geom_line(aes(x = time, y = Wiener), col = "grey") +
geom_point(aes(x = time, y = y_obs)) +
geom_line(aes(x = time, y = y_hat), col = "red") +
geom_line(aes(x = time, y_hat025), col = "green") +
geom_line(aes(x = time, y_hat975), col = "green")
p3 + ggtitle("Estimated curve with error bars") +
xlab("time") + ylab("f(time)")</code></pre>
<p><img src="/2021/05/04/functional-data-analysis-in-r/index_files/figure-html/unnamed-chunk-9-1.png" width="672" /></p>
<p>We finish for today, by showing how to do the hard work of estimating coefficients and function values with a single line of code using the <code>fda</code> function <code>smooth.basis()</code>. The function takes the arguments <code>argvals</code> the times we want to use for evaluation as a vector (or matrix or array), <code>y</code> the observed values, and <code>fdParobj</code>, an <code>fda</code> object containing the basis elements.</p>
<pre class="r"><code>Wiener_obj <- smooth.basis(argvals = time, y = y_obs, fdParobj = basis)</code></pre>
<p>Here we plot our “hand calculated” curve in red and show the <code>smooth.basis()</code> curve in blue. They are reasonably close, except at the end points, where there is not much data to construct the basis.</p>
<pre class="r"><code>plot(time, Wiener, type = "l", xlab = "time", ylab = "f(time)",
main = "Comparison of fda package and naive smoothing estimates", col = "grey")
lines(time,y_hat,type = "l",col="red")
lines(Wiener_obj, lwd = 1, col = "blue")</code></pre>
<p><img src="/2021/05/04/functional-data-analysis-in-r/index_files/figure-html/unnamed-chunk-11-1.png" width="672" /></p>
<p>Note that we have shown the simplest use of <code>smooth.basis()</code> which is capable of computing penalized regression estimates and more. The <a href="https://www.rdocumentation.org/packages/fda/versions/5.1.9/topics/smooth.basis">examples</a> of using the <code>smooth.basis()</code> function in the <code>fda</code> pdf are extensive and worth multiple blog posts. In general, the pdf level documentation for <code>fda</code> is superb. However, the package lacks vignettes. For a price, the book <em>Functional Data Analysis with R and Matlab</em><span class="math inline">\(^{4}\)</span> supplies the equivalent of several the missing vignettes.</p>
</div>
<div id="next-steps" class="section level3">
<h3>Next Steps</h3>
<p>Once you have a basis representation, what’s next? You may be interested in the following:</p>
<ul>
<li>More exploratory work such as <a href="https://en.wikipedia.org/wiki/Functional_principal_component_analysis">Functional Principal Components Analysis</a>, the analog of principal components analysis.</li>
<li>Clustering curves. See the <a href="https://cran.r-project.org/package=funHDDC">funHDDC</a> package.</li>
<li>Setting up regression models where either the dependent variable, or some of the independent variables, or both are functional objects. See the <a href="https://CRAN.R-project.org/package=refund">refund</a> package and the book by Kokoszka and Reimnerr<span class="math inline">\(^{2}\)</span></li>
<li>Studying the shape of the curves themselves. For example, the shape of a protein concentration curve may convey some clinical meaning. FDA permits studying the velocity and acceleration of curves, offering the possibility of obtaining more information than the standard practice of looking at the area under the curves. You can explore this with the <code>fda</code> package (But be sure to check that the order of your basis functions is adequate to compute derivatives.). See the book by Ramsay, Hooker and Graves<span class="math inline">\(^{4}\)</span>.</li>
<li>Learning what to do when you have sparse data. See the paper by Yao et al. below<span class="math inline">\(^{5}\)</span> and look into the <a href="https://cran.r-project.org/package=fdapace">fdapace</a> package.</li>
<li>Working with two and three dimensional medical images<span class="math inline">\(^{6}\)</span>.</li>
</ul>
<p>I would like to make Functional Data Analysis a regular feature on R Views. If you are working with FDA and would like to post, please let me (<a href="mailto:joseph.rickert@rstudio.com" class="email">joseph.rickert@rstudio.com</a>) know.</p>
</div>
<div id="references" class="section level3">
<h3>References</h3>
<div id="books" class="section level4">
<h4>Books</h4>
<ul>
<li><span class="math inline">\(^{2}\)</span>Kokoszka, P. and Reimherr, M. (2017). <em>Introduction to Functional Data Analysis</em>. CRC.</li>
<li><span class="math inline">\(^{1}\)</span>Ramsay, J.O. and Silverman, B.W. (2005). <em>Functional Data Analysis</em>. Springer.</li>
<li><span class="math inline">\(^{4}\)</span>Ramsay, J.0., Hooker, G. and Graves, S. (2009) <em>Functional Data Analysis with R and MATLAB</em> Springer.</li>
</ul>
</div>
<div id="online-resources" class="section level4">
<h4>Online Resources</h4>
<ul>
<li><span class="math inline">\(^{3}\)</span>Cao, J. (2019). <a href="https://www.youtube.com/watch?v=SUp_Nq8NwfE"><em>Functional Data Analysis Course</em></a></li>
<li>Staicu, A. and Park, Y. (2016) <a href="https://www4.stat.ncsu.edu/~staicu/FDAtutorial/"><em>Short Course on Applied Functional Data Analysis</em></a></li>
</ul>
</div>
<div id="recommended-papers" class="section level4">
<h4>Recommended Papers</h4>
<ul>
<li><span class="math inline">\(^{6}\)</span>Sørensen, H. Goldsmith, J. and Sangalli, L. (2013). <a href="https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.5989"><em>An introduction with medical applications fo functional data analysis</em></a> Wiley</li>
<li>Wang, J., Chiou, J. and Müller, H. (2015). <a href="https://arxiv.org/pdf/1507.05135.pdf"><em>Review of Functional Data Analysis</em></a></li>
<li><span class="math inline">\(^{5}\)</span> Yao, F., Müller, H, Wang, J. (2012). <a href="https://anson.ucdavis.edu/~mueller/jasa03-190final.pdf"><em>Functional Data Analysis for Sparse Longitudinal Data</em></a> JASA J100, I 470</li>
</ul>
</div>
</div>
<script>window.location.href='https://rviews.rstudio.com/2021/05/04/functional-data-analysis-in-r/';</script>
March 2021: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2021/04/22/march-2021-top-40-new-cran-packages/
Thu, 22 Apr 2021 00:00:00 +0000https://rviews.rstudio.com/2021/04/22/march-2021-top-40-new-cran-packages/
<p>By my count, two hundred twenty-one new packages <em>stuck</em> to CRAN in March 2021.<sup>1</sup> Here are my “Top 40” selections in twelve categories: Computational Methods, Data, Engineering, Genomics, Machine Learning, Medicine, Music, Networks, Science, Statistics, Utility, and Visualization. Two of these categories Engineering and Music have only one entry each. However, I decided to give them their own category in order to draw attention to the use of R outside of the mainstream, and I have always lamented the fate of the <em>Miscellaneous</em>. In the same spirit, note that the complete works of <em>the Bard</em> appear in the Data category and that due to <code>tidypaleo</code> <em>Paleoenvironmental</em> is now <em>a thing</em> in R.</p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=gamlss.foreach">gamlss</a> v1.0-5: Implements computationally intensive calculations for Generalized Additive Models for location, scale, and shape as described in <a href="https://rss.onlinelibrary.wiley.com/doi/full/10.1111/j.1467-9876.2005.00510.x">Rigby & Stasinopoulos (2005)</a>.</p>
<p><a href="https://cran.r-project.org/package=waydown">waydown</a> v1.1.0: Implements an algorithm based on the classical Helmholtz decomposition to obtain an approximate potential function for non gradient fields. See <a href="https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1007788">Rodríguez-Sánchez (2020)</a> for background and the <a href="https://cran.r-project.org/web/packages/waydown/vignettes/examples.pdf">vignette</a> for examples.</p>
<p><img src="waydown.png" height = "400" width="600"></p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=aopdata">aopdata</a> v0.2.1: Provides functions to download data from the <a href="https://www.ipea.gov.br/acessooportunidades/en/">Access to Opportunities Project</a> (AOP) which includes annual estimates of access to employment, health and education services by transport mode, as well as data on the spatial distribution of population, schools and health-care facilities at a fine spatial resolution for all cities included in the study. There is an <a href="https://cran.r-project.org/web/packages/aopdata/vignettes/intro_to_aopdata.html">Introduction</a> to the package, and there are vignettes on <a href="https://cran.r-project.org/web/packages/aopdata/vignettes/access_inequality.html">Analyzing Inequality</a>, <a href="https://cran.r-project.org/web/packages/aopdata/vignettes/access_maps.html">Mapping Urban Accessibility</a>, and <a href="https://cran.r-project.org/web/packages/aopdata/vignettes/landuse_maps.html">Mapping Pooulation and Land Use</a>.</p>
<p><img src="aopdata.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=bardr">bardr</a> v0.0.9: Provides R data structures for Shakespeare’s complete works, as provided by <a href="https:www.gutenberg.org/ebooks/100">Project Gutenberg</a>. See <a href="https://cran.r-project.org/web/packages/bardr/readme/README.html">README</a>.</p>
<p><a href="https://cran.r-project.org/package=metro">metro</a> v0.9.1: Provides access to the <a href="https://developer.wmata.com/">Metro Transparent Data Sets API</a> published by the Washington Metropolitan Area Transit Authority, the government agency operating light rail and passenger buses in the Washington D.C. area. See <a href="https://cran.r-project.org/web/packages/metro/readme/README.html">README</a>.</p>
<p><a href="https://cran.r-project.org/package=RAQSAPI">RAQSAPI</a> v2.0.1: Provides functions to retrieve air monitoring data and associated metadata from the US Environmental Protection Agency’s <a href="https://aqs.epa.gov/aqsweb/documents/data_api.html">Air Quality System Service</a>. There are several short vignettes including an <a href="https://cran.r-project.org/web/packages/RAQSAPI/vignettes/Intro.html">Introduction</a> and a vignette on <a href="https://cran.r-project.org/web/packages/RAQSAPI/vignettes/RAQSAPIusagetipsandprecautions.html">Usage tips and precautions</a>.</p>
<p><a href="https://cran.r-project.org/package=troopdata">troopdata</a> v0.1.3: Provides access to U.S. Department of Defense data on overseas military deployments and includes functions for pulling country-year troop deployment and basing data. See <a href="https://cran.r-project.org/web/packages/troopdata/readme/README.html">README</a> to get started</p>
<p><img src="troopdata.png" height = "400" width="600"></p>
<h3 id="engineering">Engineering</h3>
<p><a href="https://cran.r-project.org/package=pipenostics">pipenostics</a> v0.1.7: Implements empirical and data-driven models of heat losses, corrosion diagnostics, reliability and predictive maintenance of pipeline systems which should be of interest to the engineering departments of heat generating and heat transferring companies. See <a href="https://link.springer.com/book/10.1007%2F978-3-319-25307-7">Timashev et al. (2016)</a> and <a href="https://www.sciencedirect.com/science/article/pii/S2214785317313755?via%3Dihub">Reddy (2017)</a> for the methods used and <a href="https://cran.r-project.org/web/packages/pipenostics/readme/README.html">README</a> to get started.</p>
<p><img src="pipenostics.svg" height = "300" width="500"></p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=glmmSeq">glmmSeq</a> v0.1.0: Provides functions to fit negative binomial mixed effects models with matched samples to model expression data. See the <a href="https://cran.r-project.org/web/packages/glmmSeq/vignettes/glmmSeq.html">vignette</a> for examples.</p>
<p><img src="glmmSeq.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=ondisc">ondisc</a> v1.0.0: Implements a method to allow researchers to analyze large-scale single-cell data as and R object stored on disk. There is a tutorial on the the <a href="https://cran.r-project.org/web/packages/ondisc/vignettes/tutorial_odm_class.html">ondisc matrix class</a> and another on <a href="https://cran.r-project.org/web/packages/ondisc/vignettes/tutorial_other_classes.html">Metadata</a>.</p>
<p><a href="https://cran.r-project.org/package=SignacX">SignacX</a> v2.2.0: Implements a neural network trained with flow-sorted gene expression data to classify cellular phenotypes in single cell RNA-sequencing data. See <a href="https://www.biorxiv.org/content/10.1101/2021.02.01.429207v3">Chamberlain et al. (2021)</a> for background. There are seven vignettes including an <a href="https://cran.r-project.org/web/packages/SignacX/vignettes/signac-Seurat_AMP.html">Analysis of Kidney Lupus Data</a> and an <a href="https://cran.r-project.org/web/packages/SignacX/vignettes/signac-Seurat_pbmcs.html">Analysis of PBMCs from 10X Genomics</a>.</p>
<p><img src="SignacX.png" height = "200" width="400"></p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=opitools">opitools</a> v1.0.3: Implements a tool to analyze opinions inherent in a text document relating to a specific subject (A) and assess how opinions expressed with respect to another subject (B) may affect the opinions on subject A. This package has been designed specifically for application to social media datasets, such as Twitter and Facebook. See <a href="https://osf.io/preprints/socarxiv/c32qh/">Adepeju and Jimoh (2021)</a> for an extended example that demonstrates the utility of the approach and the <a href="https://cran.r-project.org/web/packages/opitools/vignettes/opitools-vignette.html">vignette</a> to get started.</p>
<p><img src="opitools.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=poems">poems</a> v1.0.1: Provides a framework of interoperable R6 classes for building ensembles of viable models via the <a href="https://en.wikipedia.org/wiki/Pattern-oriented_modeling">pattern-oriented modeling</a> (POM) approach. The package includes classes for encapsulating and generating model parameters, and managing the POM workflow which includes: model setup; generating model parameters via Latin hyper-cube sampling; running multiple sampled model simulations; collating summary results; and validating and selecting an ensemble of models that best match known patterns. There are two vignettes: <a href="https://cran.r-project.org/web/packages/poems/vignettes/simple_example.pdf">Simple Example</a> and <a href="https://cran.r-project.org/web/packages/poems/vignettes/thylacine_example.pdf">Thylacine Example</a>.</p>
<p><img src="poems.png" height = "300" width="500"></p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=dampack">dampack</a> v1.0.0: Implements a suite of functions for analyzing and visualizing the health economic outputs of mathematical models. See <a href="https://www.cambridge.org/core/books/decision-making-in-health-and-medicine/31FD197195DAE2A6321409568BEFA2DD">Hunink et al. (2014)</a> for the theoretical underpinnings. There are five vignettes including <a href="https://cran.r-project.org/web/packages/dampack/vignettes/basic_cea.html">Basic Cost Effectiveness Analysis</a>, <a href="https://cran.r-project.org/web/packages/dampack/vignettes/psa_analysis.html">Probabilistic Sensitivity Analysis: Analysis</a> and <a href="https://cran.r-project.org/web/packages/dampack/vignettes/voi.html">Value of Information Analysis</a>.</p>
<p><img src="dampack.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=rdecision">rdecision</a> v1.0.3: Provides classes and functions for using decision trees to model health care interventions using cohort models. See <a href="https://www.amazon.com/Decision-Modelling-Economic-Evaluation-Handbooks/dp/0198526628">Briggs et al.</a> for theory and terminology. There are five vignettes including <a href="https://cran.r-project.org/web/packages/rdecision/vignettes/DT01-Sumatriptan.html">Elementary decision tree (Evans 1997)</a> and <a href="https://cran.r-project.org/web/packages/rdecision/vignettes/DT02-Tegaderm.html">Decision tree with PSA</a>.</p>
<p><img src="rdecision.png" height = "300" width="500"></p>
<h3 id="music">Music</h3>
<p><a href="https://cran.r-project.org/package=gm">gm</a> v1.0.2: Implements a high-level language to create music including converting your music to musical scores and audio files. It works with <a href="https://rmarkdown.rstudio.com/">R Markdown</a>, R <a href="https://jupyter.org/">Jupyter Notebooks</a>, and RStudio. There vignette is available in <a href="https://cran.r-project.org/web/packages/gm/vignettes/gm.html">English</a> and in <a href="https://cran.r-project.org/web/packages/gm/vignettes/cn.html">Chinese</a>.</p>
<p><img src="gm.png" height = "300" width="500"></p>
<h3 id="networks">Networks</h3>
<p><a href="https://cran.r-project.org/package=sfnetworks">sfnetworks</a> v0.5.1: Provides a tidy approach to spatial network analysis in the form of classes and functions that enable a seamless interaction between the network analysis package <code>tidygraph</code> and the spatial analysis package <code>sf</code>. There are vignettes on <a href="https://cran.r-project.org/web/packages/sfnetworks/vignettes/structure.html">sf network structure</a>, <a href="https://cran.r-project.org/web/packages/sfnetworks/vignettes/preprocess_and_clean.html">Preprocessing</a>, <a href="https://cran.r-project.org/web/packages/sfnetworks/vignettes/join_filter.html">Spatial joins and filters</a>, <a href="https://cran.r-project.org/web/packages/sfnetworks/vignettes/routing.html">Routing</a>, and <a href="https://cran.r-project.org/web/packages/sfnetworks/vignettes/morphers.html">Spatial morphers</a>.</p>
<p><img src="sfnetworks.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=valhallr">valhallr</a> v0.1.0: Implements an interface to the <a href="https://github.com/valhalla/valhalla">Valhalla</a> routing engine’s API for turn-by-turn routing, isochrones, and origin-destination analyses. See the <a href="https://cran.r-project.org/web/packages/valhallr/vignettes/valhallr.html">vignette</a> for examples.</p>
<p><img src="valhallr.jpeg" height = "300" width="500"></p>
<h3 id="science">Science</h3>
<p><a href="https://cran.r-project.org/package=asteRisk">asteRisk</a> v0.99.4: Provides functions to calculate the positions of satellites given a known state vector. It includes implementations of the SGP4 and SDP4 simplified perturbation models to propagate orbital state vectors. See <a href="https://celestrak.com/NORAD/documentation/spacetrk.pdf">Hoots et al. (1988)</a>, <a href="https://arc.aiaa.org/doi/10.2514/6.2006-6753">Vallado et al. (2012)</a>, and <a href="https://arc.aiaa.org/doi/10.2514/1.9161">Hoots et al. (2014)</a> for background and the <a href="https://cran.r-project.org/web/packages/asteRisk/vignettes/asteRisk.html">vignette</a> for examples.</p>
<p><img src="asteRisk.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=forImage">forImage</a> v0.1.0: Implements a tool to measure the size of foraminifera and other unicellulars and includes functions to guide foraminiferal test biovolume calculations and cell biomass estimations. The volume function includes several microalgae models geometric adaptations based on <a href="https://onlinelibrary.wiley.com/doi/abs/10.1046/j.1529-8817.1999.3520403.x">Hillebrand et al. (1999)</a>, <a href="https://academic.oup.com/plankt/article/25/11/1331/1490055">Sun & Liu (2003)</a>, and <a href="http://siba-ese.unisalento.it/index.php/twb/article/view/106">Vadrucci et al. (2007)</a>. See the <a href="https://cran.r-project.org/web/packages/forImage/vignettes/forImage_vignette.html">vignette</a> to get started.</p>
<p><img src="forImage.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=OpenSpecy">OpenSpecy</a> v0.9.1: Provides functions to analyze, process, identify and share Raman and (FT)IR spectra with functions to implement Savitzky-Golay smoothing in accordance with <a href="https://journals.sagepub.com/doi/10.1366/000370207782597003">Zhao et al. (2007)</a> and identify spectra using an onboard reference library, see <a href="https://journals.sagepub.com/doi/10.1177/0003702820929064">Cowger et al. 2020</a>. Analyzed spectra can be shared via <a href="https://wincowger.shinyapps.io/OpenSpecy/">Shiny App</a>. There is a <a href="https://cran.r-project.org/web/packages/OpenSpecy/vignettes/sop.html">vignette</a>.</p>
<p><img src="OpenSpecy.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=tidypaleo">tidypaleo</a> v0.1.1: Provides functions with a common framework for age-depth model management, stratigraphic visualization, and common statistical transformations with a focus on stratigraphic visualization using <code>ggplot2</code>. There are vignettes on <a href="https://cran.r-project.org/web/packages/tidypaleo/vignettes/age_depth.html">Age-depth Models</a>, <a href="https://cran.r-project.org/web/packages/tidypaleo/vignettes/nested_analysis.html">Nested Analyses</a>, and <a href="https://cran.r-project.org/web/packages/tidypaleo/vignettes/strat_diagrams.html">Stratigraphic Diagrams</a>.</p>
<p><img src="tidypaleo.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=VulnToolkit">VulnToolkit</a> v1.1.2: Provides functions to analyze and summarize tidal data sets and to access to NOAA mean sea level data. See <a href="https://www.sciencedirect.com/science/article/abs/pii/S0272771415002139?via%3Dihub">Hill & Anisfeld (2015)</a> for background and the <a href="https://cran.r-project.org/web/packages/VulnToolkit/vignettes/Tidal_data.html">vignette</a> for examples.</p>
<p><img src="VulnToolkit.png" height = "300" width="500"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=corncob">corncob</a> v0.2.0: Implements functions for modeling correlated count data using the beta-binomial distribution, described in <a href="https://projecteuclid.org/journals/annals-of-applied-statistics/volume-14/issue-1/Modeling-microbial-abundances-and-dysbiosis-with-beta-binomial-regression/10.1214/19-AOAS1283.short">Martin et al. (2020)</a>. See the <a href="https://cran.r-project.org/web/packages/corncob/vignettes/corncob-intro.pdf">vignette</a> for an introduction.</p>
<p><img src="corncob.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=hawkesbow">hawkesbow</a> v1.0.2: Implements an estimation method for <a href="https://arxiv.org/pdf/1507.02822.pdf#:~:text=The%20Hawkes%20process%20(HP)%20is,trade%20orders%2C%20or%20bank%20defaults.">Hawkes processes</a> when count data are only observed in discrete time, using a spectral approach derived from the Bartlett spectrum. See <a href="https://arxiv.org/abs/2003.04314">Cheysson and Lang (2020)</a> for background and the <a href="https://cran.r-project.org/web/packages/hawkesbow/vignettes/hawkesbow.pdf">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=LMMELSM">LMMELSM</a> v0.1.0: Implements two-level mixed effects location scale models on multiple observed or latent outcomes, and between-group variance modeling. See <a href="https://econtent.hogrefe.com/doi/10.1027/1015-5759/a000624">Williams et al. (2020)</a> and <a href="https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1541-0420.2007.00924.x">Hedeker et al. (2008)</a> for background and <a href="https://cran.r-project.org/web/packages/LMMELSM/readme/README.html">README</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=mixpoissonreg">mixpoissinreg</a> v1.0.0: Provides functions to fit mixed Poisson regression models (Poisson-Inverse Gaussian or Negative-Binomial) with count data response variables. See <a href="https://link.springer.com/article/10.1007%2Fs11222-015-9601-6"> Barreto-Souza and Simas (2016)</a> for background. There are five vignettes on <a href="https://cran.r-project.org/web/packages/mixpoissonreg/vignettes/influence-mixpoissonreg.html">Global and Local Influence</a>, <a href="https://cran.r-project.org/web/packages/mixpoissonreg/vignettes/intervals-mixpoissonreg.html">Confidence and Prediction Intervals</a>, <a href="https://cran.r-project.org/web/packages/mixpoissonreg/vignettes/ml-mixpoissonreg.html">MLE</a>, <a href="https://cran.r-project.org/web/packages/mixpoissonreg/vignettes/tidyverse-mixpoissonreg.html">Tidy Methods</a>, and <a href="https://cran.r-project.org/web/packages/mixpoissonreg/vignettes/tutorial-mixpoissonreg.html">Overdispersed Count Data</a>.</p>
<p><img src="mixpoissinreg.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=ppdiag">ppdiag</a> v0.1.0: Provides a suite of diagnostic tools for univariate point processes including tools for simulating and fitting both common and more complex temporal point processes and the diagnostic tools described in <a href="https://direct.mit.edu/neco/article/14/2/325/6578/The-Time-Rescaling-Theorem-and-Its-Application-to">Brown et al. (2002)</a> and <a href="https://arxiv.org/abs/2001.09359">Wu et al. (2020)</a>. There is a vignette on <a href="https://cran.r-project.org/web/packages/ppdiag/vignettes/fitting_markov_modulated.html">Markov Modulated Point Processes</a> and another on <a href="https://cran.r-project.org/web/packages/ppdiag/vignettes/ppdiag.html">Diagnostic Tools</a>.</p>
<p><a href="https://cran.r-project.org/package=robustlm">robustlm</a> v0.1.0: Implements a computationally efficient exponential squared loss algorithm for variable selection proposed by <a href="https://www.tandfonline.com/doi/abs/10.1080/01621459.2013.766613">Wang et al.(2013)</a>. See the <a href="https://cran.r-project.org/web/packages/robustlm/vignettes/vignette.html">vignette</a>.</p>
<p><img src="robustlm.png" height = "200" width="300"></p>
<p><a href="https://CRAN.R-project.org/package=smmR">smmR</a> v1.0.2: Provides functions to estimate and simulate multi-state semi-Markov models. The methods implemented are described in <a href="https://www.tandfonline.com/doi/abs/10.1080/10485250701261913">Barbu & Limnios (2008)</a> and <a href="https://www.tandfonline.com/doi/abs/10.1080/10485252.2011.555543">Trevezas & Limnios (2011)</a>. The <a href="https://cran.r-project.org/web/packages/smmR/vignettes/Textile-Factory.html">vignette</a> contains an extended example.</p>
<p><img src="smmR.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=spotoroo">spotoroo</a> v0.1.1: Implements an algorithm to cluster satellite hot spot data spatially and temporally. See the <a href="https://cran.r-project.org/web/packages/spotoroo/vignettes/Clustering-hot-spots.html">vignette</a>.</p>
<p><img src="spotoroo.png" height = "400" width="400"></p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=clock">clock</a> v0.2.0: Provides a comprehensive library for date-time manipulations using a new family of orthogonal date-time classes (duration, time points, zoned-times, and calendars) that partition responsibilities so that the complexities of time zones are only considered when they are really needed. There is a <a href="Getting Started">Getting Started</a> guide, as well as vignettes on <a href="https://cran.r-project.org/web/packages/clock/vignettes/faq.html">FAQ</a>, and <a href="https://cran.r-project.org/web/packages/clock/vignettes/recipes.html">Examples and Recipies</a>.</p>
<p><a href="https://cran.r-project.org/package=crosstable">crosstable</a> v0.2.1: Provides functions to create descriptive tables for continuous and categorical variables, apply summary statistics, and create reports using <code>rmarkdown</code> or <code>officer</code>. There is an <a href="https://cran.r-project.org/web/packages/crosstable/vignettes/crosstable.html">Introduction</a>, and vignettes on <a href="https://cran.r-project.org/web/packages/crosstable/vignettes/crosstable-install.html">Troubleshooting</a>, <a href="https://cran.r-project.org/web/packages/crosstable/vignettes/crosstable-report.html">Making Automatic Reports</a>, and <a href="https://cran.r-project.org/web/packages/crosstable/vignettes/crosstable-selection.html">Selecting Variables</a>.</p>
<p><a href="https://cran.r-project.org/package=pkgdepends">pkgdepends</a> v0.1.0: Provides functions to find recursive dependencies for R packages from various sources including CRAN, Bioconductor, and GitHub enabling users to obtain a consistent set of packages to install. See <a href="https://cran.r-project.org/web/packages/pkgdepends/readme/README.html">README</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=pkglite">pkglite</a> v0.1.1: Implements a tool, grammar, and standard to represent and exchange R package source code as text files. Converts one or more source packages to a text file and restores the package structures from the file. There are vignettes on <a href="https://cran.r-project.org/web/packages/pkglite/vignettes/filespec.html">Generating File Specifications</a>, <a href="https://cran.r-project.org/web/packages/pkglite/vignettes/format.html">Representing Packages</a>, and <a href="https://cran.r-project.org/web/packages/pkglite/index.html">Compact Package Representation</a>.</p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=datplot">datplot</a> v1.0.0: Provides tools to process and prepare data for visualization and employs the concept of <a href="https://www.jratcliffe.net/aoristic-analysis">aoristic analysis</a>. See <a href="https://bit.ly/3svhbdV">aorist</a> and the vignettes <a href="https://cran.r-project.org/web/packages/datplot/vignettes/data_preparation.html">Data Preparation and Visualization</a> and <a href="https://cran.r-project.org/web/packages/datplot/vignettes/how-to.html">Visualizing Chronological Distribution</a>.</p>
<p><img src="datplot.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=ferrn">ferrn</a> v0.0.1: Implements diagnostic plots for optimization, with a focus on projection pursuit which show paths the optimizer takes in the high-dimensional space. See <a href="https://cran.r-project.org/web/packages/ferrn/readme/README.html">README</a> for examples.</p>
<p><img src="ferrn.gif" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=funcharts">funcharts</a> v1.0.0: Provides functional control charts for statistical process monitoring of functional data, using the methods of <a href="https://onlinelibrary.wiley.com/doi/abs/10.1002/asmb.2507">Capezza et al. (2020)</a> and <a href="https://www.tandfonline.com/doi/abs/10.1080/00401706.2020.1753581?journalCode=utch20">Centofanti et al. (2020)</a>. There are vignettes on <a href="https://cran.r-project.org/web/packages/funcharts/vignettes/capezza2020.html">Capezza 2020</a>, <a href="https://cran.r-project.org/web/packages/funcharts/vignettes/centofanti2020.html">Centofanti 2020</a> and on the <a href="https://cran.r-project.org/web/packages/funcharts/vignettes/mfd.html">mfd class</a>.</p>
<p><img src="funcharts.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=gghilbertstrings">gghilbertstrings</a> v0.3.3: Provides functions to plot Hilbert curves which are used to map one dimensional data into the 2D plane. A specific use case maps a character column in a data frame into 2D space allowing visually comparing long lists of URLs, words, genes or other data that has a fixed order and position. See <a href="https://cran.r-project.org/web/packages/gghilbertstrings/readme/README.html">README</a> for examples.</p>
<p><img src="gghilbertstrings.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=mapsf">mapsf</a> v0.1.1: Provides functions to create and integrate thematic maps including functions to design various cartographic representations such as proportional symbols, choropleth or typology maps. Look <a href="https://riatelab.github.io/mapsf">here</a> for examples.</p>
<p><img src="mapsf.png" height = "400" width="400"></p>
<p><sup>1</sup> I have used phrases like <em>By my count</em> and <em>stuck to CRAN</em> in the past, but I do not believe that I have explained what I mean. For some time now, but I believe more frequently in recent months, packages will appear as new on CRAN, only to be removed within a relatively short period of time for failing to resolve check problems. If you happen to know about these packages and search for them by name on CRAN you will receive the message:</p>
<blockquote>
<p>Package XXXX was removed from the CRAN repository.
Formerly available versions can be obtained from the archive.
Archived on 2021-04-17 as check problems remained after update.
A summary of the most recent check results can be obtained from the check results archive.
Please use the canonical form <a href="https://CRAN.R-project.org/package=XXXX">https://CRAN.R-project.org/package=XXXX</a> to link to this page.</p>
</blockquote>
<p>I did not include the ten packages that were identified as being new for March when I created my list of March packages on April 10, 2021, but were removed by the time I finalized my list for this post a week later, in my total count of new CRAN packages. So, there is some instability with the notion of counting new packages in a given month.</p>
<script>window.location.href='https://rviews.rstudio.com/2021/04/22/march-2021-top-40-new-cran-packages/';</script>
An Alternative to the Correlation Coefficient That Works For Numeric and Categorical Variables
https://rviews.rstudio.com/2021/04/15/an-alternative-to-the-correlation-coefficient-that-works-for-numeric-and-categorical-variables/
Thu, 15 Apr 2021 00:00:00 +0000https://rviews.rstudio.com/2021/04/15/an-alternative-to-the-correlation-coefficient-that-works-for-numeric-and-categorical-variables/
<script src="/2021/04/15/an-alternative-to-the-correlation-coefficient-that-works-for-numeric-and-categorical-variables/index_files/header-attrs/header-attrs.js"></script>
<p><em>Dr. Rama Ramakrishnan is Professor of the Practice at MIT Sloan School of Management where he teaches courses in Data Science, Optimization and applied Machine Learning.</em></p>
<p>When starting to work with a new dataset, it is useful to quickly pinpoint which pairs of variables appear to be <em>strongly related</em>. It helps you spot data issues, make better modeling decisions, and ultimately arrive at better answers.</p>
<p>The <a href="https://en.wikipedia.org/wiki/Correlation_coefficient"><em>correlation coefficient</em></a> is used widely for this purpose, but it is well-known that it can’t detect non-linear relationships. Take a look at this scatterplot of two variables <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span>.</p>
<pre class="r"><code>set.seed(42)
x <- seq(-1,1,0.01)
y <- sqrt(1 - x^2) + rnorm(length(x),mean = 0, sd = 0.05)
ggplot(mapping = aes(x, y)) +
geom_point() </code></pre>
<p><img src="/2021/04/15/an-alternative-to-the-correlation-coefficient-that-works-for-numeric-and-categorical-variables/index_files/figure-html/unnamed-chunk-1-1.png" width="672" /></p>
<p>It is obvious to the human eye that <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span> have a strong relationship but the correlation coefficient between <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span> is only -0.01.</p>
<p>Further, if either variable of the pair is <em>categorical</em>, we can’t use the correlation coefficient. We will have to turn to other metrics. If <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span> are <strong>both</strong> categorical, we can try <a href="https://en.wikipedia.org/wiki/Cram%C3%A9r%27s_V">Cramer’s V</a> or <a href="https://en.wikipedia.org/wiki/Phi_coefficient">the phi coefficient</a>. If <span class="math inline">\(x\)</span> is continuous and <span class="math inline">\(y\)</span> is binary, we can use the <a href="https://en.wikipedia.org/wiki/Point-biserial_correlation_coefficient">point-biserial correlation coefficient.</a></p>
<p>But using different metrics is problematic. Since they are derived from different assumptions, we can’t <strong>compare the resulting numbers with one another</strong>. If the correlation coefficient between continuous variables <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span> is 0.6 and the phi coefficient between categorical variables <span class="math inline">\(u\)</span> and <span class="math inline">\(v\)</span> is also 0.6, can we safely conclude that the relationships are equally strong? According to <a href="https://en.wikipedia.org/wiki/Phi_coefficient">Wikipedia</a>,</p>
<blockquote>
<p>The correlation coefficient ranges from −1 to +1, where ±1 indicates perfect agreement or disagreement, and 0 indicates no relationship. The phi coefficient has a maximum value that is determined by the distribution of the two variables if one or both variables can take on more than two values.</p>
</blockquote>
<p>A phi coefficient value of 0.6 between <span class="math inline">\(u\)</span> and <span class="math inline">\(v\)</span> may not mean much if its maximum possible value in this particular situation is much higher. Perhaps we can normalize the phi coefficient to map it to the 0-1 range? But what if that modification introduces biases?</p>
<p>Wouldn’t it be nice if we had <strong>one</strong> uniform approach that was easy to understand, worked for continuous <strong>and</strong> categorical variables alike, and could detect linear <strong>and</strong> nonlinear relationships?</p>
<p>(BTW, when <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span> are continuous, looking at a scatter plot of <span class="math inline">\(x\)</span> vs <span class="math inline">\(y\)</span> can be very effective since the human brain can detect linear and non-linear patterns very quickly. But even if you are lucky and <em>all</em> your variables are continuous, looking at scatterplots of <em>all</em> pairs of variables is hard when you have lots of variables in your dataset; with just 100 predictors (say), you will need to look through 4950 scatterplots and this obviously isn’t practical)</p>
<p><br></p>
<div id="a-potential-solution" class="section level3">
<h3>A Potential Solution</h3>
<p>To devise a metric that satisfies the requirements we listed above, let’s <em>invert</em> the problem: What does it mean to say that <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span> <strong>don’t</strong> have a strong relationship?</p>
<p>Intuitively, if there’s no relationship between <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span>, we would expect to see no patterns in a scatterplot of <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span> - no lines, curves, groups etc. It will be a cloud of points that appears to be randomly scattered, perhaps something like this:</p>
<pre class="r"><code>x <- seq(-1,1,0.01)
y <- runif(length(x),min = -1, max = 1)
ggplot(mapping = aes(x, y)) +
geom_point() </code></pre>
<p><img src="/2021/04/15/an-alternative-to-the-correlation-coefficient-that-works-for-numeric-and-categorical-variables/index_files/figure-html/unnamed-chunk-2-1.png" width="672" /></p>
<p>In this situation, does knowing the value of <span class="math inline">\(x\)</span> give us any information on <span class="math inline">\(y\)</span>?</p>
<p>Clearly not. <span class="math inline">\(y\)</span> seems to be somewhere between -1 and 1 with no particular pattern, regardless of the value of <span class="math inline">\(x\)</span>. Knowing <span class="math inline">\(x\)</span> does not seem to help <em>reduce our uncertainty</em> about the value of <span class="math inline">\(y\)</span>.</p>
<p>In contrast, look at the first picture again.</p>
<p><img src="/2021/04/15/an-alternative-to-the-correlation-coefficient-that-works-for-numeric-and-categorical-variables/index_files/figure-html/unnamed-chunk-3-1.png" width="672" /></p>
<p>Here, knowing the value of <span class="math inline">\(x\)</span> <em>does</em> help. If we know that <span class="math inline">\(x\)</span> is around 0.0, for example, from the graph we will guess that <span class="math inline">\(y\)</span> is likely near 1.0 (the red dots). We can be confident that <span class="math inline">\(y\)</span> is <strong>not</strong> between 0 and 0.8. Knowing <span class="math inline">\(x\)</span> helps us eliminate certain values of <span class="math inline">\(y\)</span>, <strong>reducing our uncertainty</strong> about the values <span class="math inline">\(y\)</span> might take.</p>
<p>This notion - that knowing something reduces our uncertainty about something else - is exactly the idea behind <a href="https://en.wikipedia.org/wiki/Mutual_information">mutual information</a> from <a href="https://en.wikipedia.org/wiki/Information_theory">Information Theory</a>.</p>
<p>According to <a href="https://en.wikipedia.org/wiki/Mutual_information">Wikipedia</a> (emphasis mine),</p>
<blockquote>
<p>Intuitively, mutual information measures the information that <span class="math inline">\(X\)</span> and <span class="math inline">\(Y\)</span> share: It measures <strong>how much knowing one of these variables reduces uncertainty about the other</strong>. For example, if <span class="math inline">\(X\)</span> and <span class="math inline">\(Y\)</span> are independent, then knowing <span class="math inline">\(X\)</span> does not give any information about <span class="math inline">\(Y\)</span> and vice versa, so their mutual information is zero.</p>
</blockquote>
<p>Furthermore,</p>
<blockquote>
<p><strong>Not limited to real-valued random variables and linear dependence like the correlation coefficient</strong>, MI is more general and determines how different the joint distribution of the pair <span class="math inline">\((X,Y)\)</span> is to the product of the marginal distributions of <span class="math inline">\(X\)</span> and <span class="math inline">\(Y\)</span>.</p>
</blockquote>
<p>This is very promising!</p>
<p>As it turns out, however, implementing mutual information is not so simple. We first need to estimate the joint probabilities (i.e., the joint probability density/mass function) of <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span> before we can calculate their Mutual Information. If <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span> are categorical, this is easy but if one or both of them is continuous, it is more involved.</p>
<p>But we can use the basic insight behind mutual information – that knowing <span class="math inline">\(x\)</span> may reduce our uncertainty about <span class="math inline">\(y\)</span> – in a different way.</p>
<p><br></p>
</div>
<div id="the-x2y-metric" class="section level3">
<h3>The X2Y Metric</h3>
<p>Consider three variables <span class="math inline">\(x\)</span>, <span class="math inline">\(y\)</span> and <span class="math inline">\(z\)</span>. If knowing <span class="math inline">\(x\)</span> reduces our uncertainty about <span class="math inline">\(y\)</span> by 70% but knowing <span class="math inline">\(z\)</span> reduces our uncertainty about <span class="math inline">\(y\)</span> by only 40%, we will intuitively expect that the association between <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span> will be stronger than the association between <span class="math inline">\(z\)</span> and <span class="math inline">\(y\)</span>.</p>
<p>So, if we can <em>quantify</em> the reduction in uncertainty, that can be used as a measure of the strength of the association. One way to do so is to measure <span class="math inline">\(x\)</span>’s ability to <em>predict</em> <span class="math inline">\(y\)</span> - after all, <strong>if <span class="math inline">\(x\)</span> reduces our uncertainty about <span class="math inline">\(y\)</span>, knowing <span class="math inline">\(x\)</span> should help us predict <span class="math inline">\(y\)</span> better than if we didn’t know <span class="math inline">\(x\)</span></strong>.</p>
<p>Stated another way, we can think of reduction in prediction error <span class="math inline">\(\approx\)</span> reduction in uncertainty <span class="math inline">\(\approx\)</span> strength of association.</p>
<p>This suggests the following approach:</p>
<ol style="list-style-type: decimal">
<li>Predict <span class="math inline">\(y\)</span> <em>without using</em> <span class="math inline">\(x\)</span>.
<ul>
<li>If <span class="math inline">\(y\)</span> is continuous, we can simply use the average value of <span class="math inline">\(y\)</span>.</li>
<li>If <span class="math inline">\(y\)</span> is categorical, we can use the most frequent value of <span class="math inline">\(y\)</span>.</li>
<li>These are sometimes referred to as a <em>baseline</em> model.</li>
</ul></li>
<li>Predict <span class="math inline">\(y\)</span> <em>using</em> <span class="math inline">\(x\)</span>
<ul>
<li>We can take any of the standard predictive models out there (Linear/Logistic Regression, CART, Random Forests, SVMs, Neural Networks, Gradient Boosting etc.), set <span class="math inline">\(x\)</span> as the independent variable and <span class="math inline">\(y\)</span> as the dependent variable, fit the model to the data, and make predictions. More on this below.</li>
</ul></li>
<li>Calculate the <strong>% decrease in prediction error</strong> when we go from (1) to (2)
<ul>
<li>If <span class="math inline">\(y\)</span> is continuous, we can use any of the familiar error metrics like RMSE, SSE, MAE etc. I prefer mean absolute error (MAE) since it is less susceptible to outliers and is in the same units as <span class="math inline">\(y\)</span> but this is a matter of personal preference.</li>
<li>If <span class="math inline">\(y\)</span> is categorical, we can use Misclassification Error (= 1 - Accuracy) as the error metric.</li>
</ul></li>
</ol>
<blockquote>
<p>In summary, the % reduction in error when we go from a baseline model to a predictive model measures the strength of the relationship between <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span>. We will call this metric <code>x2y</code> since it measures the ability of <span class="math inline">\(x\)</span> to predict <span class="math inline">\(y\)</span>.</p>
</blockquote>
<p>(This definition is similar to <a href="https://en.wikipedia.org/wiki/Coefficient_of_determination"><em>R-Squared</em></a> from Linear Regression. In fact, if <span class="math inline">\(y\)</span> is continuous and we use the Sum of Squared Errors as our error metric, the <code>x2y</code> metric is equal to R-Squared.)</p>
<p>To implement (2) above, we need to pick a predictive model to use. Let’s remind ourselves of what the requirements are:</p>
<ul>
<li>If there’s a non-linear relationship between <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span>, the model should be able to detect it</li>
<li>It should be able to handle all possible <span class="math inline">\(x\)</span>-<span class="math inline">\(y\)</span> variable types: continuous-continuous, continuous-categorical, categorical-continuous and categorical-categorical</li>
<li>We may have hundreds (if not thousands) of pairs of variables we want to analyze so we want this to be quick</li>
</ul>
<p><a href="https://en.wikipedia.org/wiki/Decision_tree_learning">Classification and Regression Trees (CART)</a> satisfies these requirements very nicely and that’s the one I prefer to use. That said, you can certainly use other models if you like.</p>
<p>Let’s try this approach on the ‘semicircle’ dataset from above. We use CART to predict <span class="math inline">\(y\)</span> using <span class="math inline">\(x\)</span> and here’s how the fitted values look:</p>
<pre class="r"><code># Let's generate the data again
set.seed(42)
x <- seq(-1,1,0.01)
d <- data.frame(x = x,
y = sqrt(1 - x^2) + rnorm(length(x),mean = 0, sd = 0.05))
library(rpart)
preds <- predict(rpart(y~x, data = d, method = "anova"), type = "vector")
# Set up a chart
ggplot(data = d, mapping = aes(x = x)) +
geom_point(aes(y = y), size = 0.5) +
geom_line(aes(y=preds, color = '2')) +
scale_color_brewer(name = "", labels='CART', palette="Set1")</code></pre>
<p><img src="/2021/04/15/an-alternative-to-the-correlation-coefficient-that-works-for-numeric-and-categorical-variables/index_files/figure-html/unnamed-chunk-4-1.png" width="672" /></p>
<p>Visually, the CART predictions seem to approximate the semi-circular relationship between <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span>. To confirm, let’s calculate the <code>x2y</code> metric step by step.</p>
<ul>
<li>The MAE from using the average of <span class="math inline">\(y\)</span> to predict <span class="math inline">\(y\)</span> is 0.19.</li>
<li>The MAE from using the CART predictions to predict <span class="math inline">\(y\)</span> is 0.06.</li>
<li>The % reduction in MAE is 68.88%.</li>
</ul>
<p>Excellent!</p>
<p>If you are familiar with CART models, it is straightforward to implement the <code>x2y</code> metric in the Machine Learning environment of your choice. An R implementation is <a href="x2y.R">here</a> and details can be found in the <a href="#appendix">appendix</a> but, for now, I want to highlight two functions from the R script that we will use in the examples below:</p>
<ul>
<li><code>x2y(u, v)</code> calculates the <code>x2y</code> metric between two vectors <span class="math inline">\(u\)</span> and <span class="math inline">\(v\)</span></li>
<li><code>dx2y(d)</code> calculates the <code>x2y</code> metric between all pairs of variables in a dataframe <span class="math inline">\(d\)</span></li>
</ul>
<p><br></p>
</div>
<div id="two-caveats" class="section level3">
<h3>Two Caveats</h3>
<p>Before we demonstrate the <code>x2y</code> metric on a couple of datasets, I want to highlight two aspects of the <code>x2y</code> approach.</p>
<p>Unlike metrics like the correlation coefficient, the <code>x2y</code> metric is <strong>not</strong> symmetric with respect to <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span>. The extent to which <span class="math inline">\(x\)</span> can predict <span class="math inline">\(y\)</span> can be different from the extent to which <span class="math inline">\(y\)</span> can predict <span class="math inline">\(x\)</span>. For the semi-circle dataset, <code>x2y(x,y)</code> is 68.88% but <code>x2y(y,x)</code> is only 10.2%.</p>
<p>This shouldn’t come as a surprise, however. Let’s look at the scatterplot again but with the axes reversed.</p>
<pre class="r"><code>ggplot(data = d, mapping = aes(x = y)) +
geom_point(aes(y = x), size = 0.5) +
geom_point(data = d[abs(d$x) < 0.05,], aes(x = y, y = x), color = "orange" ) +
geom_point(data = d[abs(d$y-0.6) < 0.05,], aes(x = y, y = x), color = "red" )</code></pre>
<p><img src="/2021/04/15/an-alternative-to-the-correlation-coefficient-that-works-for-numeric-and-categorical-variables/index_files/figure-html/unnamed-chunk-5-1.png" width="672" /></p>
<p>When <span class="math inline">\(x\)</span> is around 0.0, for instance, <span class="math inline">\(y\)</span> is near 1.0 (the orange dots). But when <span class="math inline">\(y\)</span> is around 0.6, <span class="math inline">\(x\)</span> can be in the (-0.75, - 1.0) range <em>or</em> in the (0.5, 0.75) range (the red dots). Knowing <span class="math inline">\(x\)</span> reduces the uncertainty about the value of <span class="math inline">\(y\)</span> a lot more than knowing <span class="math inline">\(y\)</span> reduces the uncertainty about the value of <span class="math inline">\(x\)</span>.</p>
<p>But there’s an easy solution if you <em>must</em> have a symmetric metric for your application: just take the average of <code>x2y(x,y)</code> and <code>x2y(y,x)</code>.</p>
<p>The second aspect worth highlighting is about the comparability of the <code>x2y</code> metric across variable pairs. All <code>x2y</code> values where the <span class="math inline">\(y\)</span> variable is continuous will be measuring a % reduction in MAE. All <code>x2y</code> values where the <span class="math inline">\(y\)</span> variable is categorical will be measuring a % reduction in Misclassification Error. Is a 30% reduction in MAE equal to a 30% reduction in Misclassification Error? It is problem dependent, there’s no universal right answer.</p>
<p>On the other hand, since (1) <em>all</em> <code>x2y</code> values are on the same 0-100% scale (2) are conceptually measuring the same thing, i.e., reduction in prediction error and (3) our objective is to quickly scan and identify strongly-related pairs (rather than conduct an in-depth investigation), the <code>x2y</code> approach may be adequate.</p>
<p><br></p>
</div>
<div id="application-to-the-iris-dataset" class="section level3">
<h3>Application to the Iris Dataset</h3>
<p>The <a href="https://en.wikipedia.org/wiki/Iris_flower_data_set">iris flower dataset</a> is iconic in the statistics/ML communities and is widely used to illustrate basic concepts. The dataset consists of 150 observations in total and each observation has four continuous variables - the length and the width of petals and sepals - and a categorical variable indicating the species of iris.</p>
<p>Let’s take a look at 10 randomly chosen rows.</p>
<pre class="r"><code>iris %>% sample_n(10) %>% pander</code></pre>
<table>
<colgroup>
<col width="20%" />
<col width="19%" />
<col width="20%" />
<col width="19%" />
<col width="19%" />
</colgroup>
<thead>
<tr class="header">
<th align="center">Sepal.Length</th>
<th align="center">Sepal.Width</th>
<th align="center">Petal.Length</th>
<th align="center">Petal.Width</th>
<th align="center">Species</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="center">5.9</td>
<td align="center">3</td>
<td align="center">5.1</td>
<td align="center">1.8</td>
<td align="center">virginica</td>
</tr>
<tr class="even">
<td align="center">5.5</td>
<td align="center">2.6</td>
<td align="center">4.4</td>
<td align="center">1.2</td>
<td align="center">versicolor</td>
</tr>
<tr class="odd">
<td align="center">6.1</td>
<td align="center">2.8</td>
<td align="center">4</td>
<td align="center">1.3</td>
<td align="center">versicolor</td>
</tr>
<tr class="even">
<td align="center">5.9</td>
<td align="center">3.2</td>
<td align="center">4.8</td>
<td align="center">1.8</td>
<td align="center">versicolor</td>
</tr>
<tr class="odd">
<td align="center">7.7</td>
<td align="center">2.6</td>
<td align="center">6.9</td>
<td align="center">2.3</td>
<td align="center">virginica</td>
</tr>
<tr class="even">
<td align="center">5.7</td>
<td align="center">4.4</td>
<td align="center">1.5</td>
<td align="center">0.4</td>
<td align="center">setosa</td>
</tr>
<tr class="odd">
<td align="center">6.5</td>
<td align="center">3</td>
<td align="center">5.2</td>
<td align="center">2</td>
<td align="center">virginica</td>
</tr>
<tr class="even">
<td align="center">5.2</td>
<td align="center">2.7</td>
<td align="center">3.9</td>
<td align="center">1.4</td>
<td align="center">versicolor</td>
</tr>
<tr class="odd">
<td align="center">5.6</td>
<td align="center">2.7</td>
<td align="center">4.2</td>
<td align="center">1.3</td>
<td align="center">versicolor</td>
</tr>
<tr class="even">
<td align="center">7.2</td>
<td align="center">3.2</td>
<td align="center">6</td>
<td align="center">1.8</td>
<td align="center">virginica</td>
</tr>
</tbody>
</table>
<p>We can calculate the <code>x2y</code> values for all pairs of variables in <code>iris</code> by running <code>dx2y(iris)</code> in R (details of how to use the <code>dx2y()</code> function are in the <a href="#appendix">appendix</a>).</p>
<pre class="r"><code>dx2y(iris) %>% pander</code></pre>
<table style="width:72%;">
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="19%" />
<col width="11%" />
</colgroup>
<thead>
<tr class="header">
<th align="center">x</th>
<th align="center">y</th>
<th align="center">perc_of_obs</th>
<th align="center">x2y</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="center">Petal.Width</td>
<td align="center">Species</td>
<td align="center">100</td>
<td align="center">94</td>
</tr>
<tr class="even">
<td align="center">Petal.Length</td>
<td align="center">Species</td>
<td align="center">100</td>
<td align="center">93</td>
</tr>
<tr class="odd">
<td align="center">Petal.Width</td>
<td align="center">Petal.Length</td>
<td align="center">100</td>
<td align="center">80.73</td>
</tr>
<tr class="even">
<td align="center">Species</td>
<td align="center">Petal.Length</td>
<td align="center">100</td>
<td align="center">79.72</td>
</tr>
<tr class="odd">
<td align="center">Petal.Length</td>
<td align="center">Petal.Width</td>
<td align="center">100</td>
<td align="center">77.32</td>
</tr>
<tr class="even">
<td align="center">Species</td>
<td align="center">Petal.Width</td>
<td align="center">100</td>
<td align="center">76.31</td>
</tr>
<tr class="odd">
<td align="center">Sepal.Length</td>
<td align="center">Petal.Length</td>
<td align="center">100</td>
<td align="center">66.88</td>
</tr>
<tr class="even">
<td align="center">Sepal.Length</td>
<td align="center">Species</td>
<td align="center">100</td>
<td align="center">62</td>
</tr>
<tr class="odd">
<td align="center">Petal.Length</td>
<td align="center">Sepal.Length</td>
<td align="center">100</td>
<td align="center">60.98</td>
</tr>
<tr class="even">
<td align="center">Sepal.Length</td>
<td align="center">Petal.Width</td>
<td align="center">100</td>
<td align="center">54.36</td>
</tr>
<tr class="odd">
<td align="center">Petal.Width</td>
<td align="center">Sepal.Length</td>
<td align="center">100</td>
<td align="center">48.81</td>
</tr>
<tr class="even">
<td align="center">Species</td>
<td align="center">Sepal.Length</td>
<td align="center">100</td>
<td align="center">42.08</td>
</tr>
<tr class="odd">
<td align="center">Sepal.Width</td>
<td align="center">Species</td>
<td align="center">100</td>
<td align="center">39</td>
</tr>
<tr class="even">
<td align="center">Petal.Width</td>
<td align="center">Sepal.Width</td>
<td align="center">100</td>
<td align="center">31.75</td>
</tr>
<tr class="odd">
<td align="center">Petal.Length</td>
<td align="center">Sepal.Width</td>
<td align="center">100</td>
<td align="center">30</td>
</tr>
<tr class="even">
<td align="center">Sepal.Width</td>
<td align="center">Petal.Length</td>
<td align="center">100</td>
<td align="center">28.16</td>
</tr>
<tr class="odd">
<td align="center">Sepal.Width</td>
<td align="center">Petal.Width</td>
<td align="center">100</td>
<td align="center">23.02</td>
</tr>
<tr class="even">
<td align="center">Species</td>
<td align="center">Sepal.Width</td>
<td align="center">100</td>
<td align="center">22.37</td>
</tr>
<tr class="odd">
<td align="center">Sepal.Length</td>
<td align="center">Sepal.Width</td>
<td align="center">100</td>
<td align="center">18.22</td>
</tr>
<tr class="even">
<td align="center">Sepal.Width</td>
<td align="center">Sepal.Length</td>
<td align="center">100</td>
<td align="center">12.18</td>
</tr>
</tbody>
</table>
<p>The first two columns in the output are self-explanatory. The third column - <code>perc_of_obs</code> - is the % of observations in the dataset that was used to calculate that row’s <code>x2y</code> value. When a dataset has missing values, only observations that have values present for both <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span> will be used to calculate the <code>x2y</code> metrics for that variable pair. The <code>iris</code> dataset has no missing values so this value is 100% for all rows. The fourth column is the value of the <code>x2y</code> metric and the results are sorted in descending order of this value.</p>
<p>Looking at the numbers, both <code>Petal.Length</code> and <code>Petal.Width</code> seem to be highly associated with <code>Species</code> (and with each other). In contrast, it appears that <code>Sepal.Length</code> and <code>Sepal.Width</code> are very weakly associated with each other.</p>
<p>Note that even though <code>Species</code> is categorical and the other four variables are continuous, we could simply “drop” the <code>iris</code> dataframe into the <code>dx2y()</code> function and calculate the associations between all the variables.</p>
<p><br></p>
</div>
<div id="application-to-a-covid-19-dataset" class="section level3">
<h3>Application to a COVID-19 Dataset</h3>
<p>Next, we examine a <a href="https://github.com/rama100/x2y/blob/main/covid19.csv">COVID-19 dataset</a> that was downloaded from the <a href="https://github.com/mdcollab/covidclinicaldata/">COVID-19 Clinical Data Repository</a> in April 2020. This dataset contains clinical characteristics and COVID-19 test outcomes for 352 patients. Since it has a good mix of continuous and categorical variables, having something like the <code>x2y</code> metric that can work for any type of variable pair is convenient.</p>
<p>Let’s read in the data and take a quick look at the columns.</p>
<pre class="r"><code>df <- read.csv("covid19.csv", stringsAsFactors = FALSE)
str(df) </code></pre>
<pre><code>## 'data.frame': 352 obs. of 45 variables:
## $ date_published : chr "2020-04-14" "2020-04-14" "2020-04-14" "2020-04-14" ...
## $ clinic_state : chr "CA" "CA" "CA" "CA" ...
## $ test_name : chr "Rapid COVID-19 Test" "Rapid COVID-19 Test" "Rapid COVID-19 Test" "Rapid COVID-19 Test" ...
## $ swab_type : chr "" "Nasopharyngeal" "Nasal" "" ...
## $ covid_19_test_results : chr "Negative" "Negative" "Negative" "Negative" ...
## $ age : int 30 77 49 42 37 23 71 28 55 51 ...
## $ high_risk_exposure_occupation: logi TRUE NA NA FALSE TRUE FALSE ...
## $ high_risk_interactions : logi FALSE NA NA FALSE TRUE TRUE ...
## $ diabetes : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ chd : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ htn : logi FALSE TRUE FALSE TRUE FALSE FALSE ...
## $ cancer : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ asthma : logi TRUE TRUE FALSE TRUE FALSE FALSE ...
## $ copd : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ autoimmune_dis : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ temperature : num 37.1 36.8 37 36.9 37.3 ...
## $ pulse : int 84 96 79 108 74 110 78 NA 97 66 ...
## $ sys : int 117 128 120 156 126 134 144 NA 160 98 ...
## $ dia : int 69 73 80 89 67 79 85 NA 97 65 ...
## $ rr : int NA 16 18 14 16 16 15 NA 16 16 ...
## $ sats : int 99 97 100 NA 99 98 96 97 99 100 ...
## $ rapid_flu : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ rapid_flu_results : chr "" "" "" "" ...
## $ rapid_strep : logi FALSE TRUE FALSE FALSE FALSE TRUE ...
## $ rapid_strep_results : chr "" "Negative" "" "" ...
## $ ctab : logi TRUE TRUE TRUE TRUE TRUE TRUE ...
## $ labored_respiration : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ rhonchi : logi FALSE FALSE FALSE TRUE FALSE FALSE ...
## $ wheezes : logi FALSE FALSE FALSE TRUE FALSE FALSE ...
## $ cough : logi FALSE NA TRUE TRUE TRUE TRUE ...
## $ cough_severity : chr "" "" "" "Mild" ...
## $ fever : logi NA NA NA FALSE FALSE TRUE ...
## $ sob : logi FALSE NA FALSE FALSE TRUE TRUE ...
## $ sob_severity : chr "" "" "" "" ...
## $ diarrhea : logi NA NA NA TRUE NA NA ...
## $ fatigue : logi NA NA NA NA TRUE TRUE ...
## $ headache : logi NA NA NA NA TRUE TRUE ...
## $ loss_of_smell : logi NA NA NA NA NA NA ...
## $ loss_of_taste : logi NA NA NA NA NA NA ...
## $ runny_nose : logi NA NA NA NA NA TRUE ...
## $ muscle_sore : logi NA NA NA TRUE NA TRUE ...
## $ sore_throat : logi TRUE NA NA NA NA TRUE ...
## $ cxr_findings : chr "" "" "" "" ...
## $ cxr_impression : chr "" "" "" "" ...
## $ cxr_link : chr "" "" "" "" ...</code></pre>
<pre class="r"><code>#%>% pander</code></pre>
<p>There are lots of missing values (denoted by ‘NA’) and lots of blanks as well - for example, see the first few values of the <code>rapid_flu_results</code> field above. We will convert the blanks to NAs so that all the missing values can be treated consistently. Also, the rightmost three columns are free-text fields so we will remove them from the dataframe.</p>
<pre class="r"><code>df <- read.csv("covid19.csv",
stringsAsFactors = FALSE,
na.strings=c("","NA") # read in blanks as NAs
)%>%
select(-starts_with("cxr")) # remove the chest x-ray note fields
str(df) </code></pre>
<pre><code>## 'data.frame': 352 obs. of 42 variables:
## $ date_published : chr "2020-04-14" "2020-04-14" "2020-04-14" "2020-04-14" ...
## $ clinic_state : chr "CA" "CA" "CA" "CA" ...
## $ test_name : chr "Rapid COVID-19 Test" "Rapid COVID-19 Test" "Rapid COVID-19 Test" "Rapid COVID-19 Test" ...
## $ swab_type : chr NA "Nasopharyngeal" "Nasal" NA ...
## $ covid_19_test_results : chr "Negative" "Negative" "Negative" "Negative" ...
## $ age : int 30 77 49 42 37 23 71 28 55 51 ...
## $ high_risk_exposure_occupation: logi TRUE NA NA FALSE TRUE FALSE ...
## $ high_risk_interactions : logi FALSE NA NA FALSE TRUE TRUE ...
## $ diabetes : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ chd : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ htn : logi FALSE TRUE FALSE TRUE FALSE FALSE ...
## $ cancer : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ asthma : logi TRUE TRUE FALSE TRUE FALSE FALSE ...
## $ copd : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ autoimmune_dis : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ temperature : num 37.1 36.8 37 36.9 37.3 ...
## $ pulse : int 84 96 79 108 74 110 78 NA 97 66 ...
## $ sys : int 117 128 120 156 126 134 144 NA 160 98 ...
## $ dia : int 69 73 80 89 67 79 85 NA 97 65 ...
## $ rr : int NA 16 18 14 16 16 15 NA 16 16 ...
## $ sats : int 99 97 100 NA 99 98 96 97 99 100 ...
## $ rapid_flu : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ rapid_flu_results : chr NA NA NA NA ...
## $ rapid_strep : logi FALSE TRUE FALSE FALSE FALSE TRUE ...
## $ rapid_strep_results : chr NA "Negative" NA NA ...
## $ ctab : logi TRUE TRUE TRUE TRUE TRUE TRUE ...
## $ labored_respiration : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ rhonchi : logi FALSE FALSE FALSE TRUE FALSE FALSE ...
## $ wheezes : logi FALSE FALSE FALSE TRUE FALSE FALSE ...
## $ cough : logi FALSE NA TRUE TRUE TRUE TRUE ...
## $ cough_severity : chr NA NA NA "Mild" ...
## $ fever : logi NA NA NA FALSE FALSE TRUE ...
## $ sob : logi FALSE NA FALSE FALSE TRUE TRUE ...
## $ sob_severity : chr NA NA NA NA ...
## $ diarrhea : logi NA NA NA TRUE NA NA ...
## $ fatigue : logi NA NA NA NA TRUE TRUE ...
## $ headache : logi NA NA NA NA TRUE TRUE ...
## $ loss_of_smell : logi NA NA NA NA NA NA ...
## $ loss_of_taste : logi NA NA NA NA NA NA ...
## $ runny_nose : logi NA NA NA NA NA TRUE ...
## $ muscle_sore : logi NA NA NA TRUE NA TRUE ...
## $ sore_throat : logi TRUE NA NA NA NA TRUE ...</code></pre>
<pre class="r"><code>#%>% pander</code></pre>
<p>Now, let’s run it through the <code>x2y</code> approach. We are particularly interested in non-zero associations between the <code>covid_19_test_results</code> field and the other fields so we zero in on those by running <code>dx2y(df, target = "covid_19_test_results")</code> in R (details in the <a href="#appendix">appendix</a>) and filtering out the zero associations.</p>
<pre class="r"><code>dx2y(df, target = "covid_19_test_results") %>%
filter(x2y >0) %>%
pander</code></pre>
<table style="width:86%;">
<colgroup>
<col width="33%" />
<col width="22%" />
<col width="19%" />
<col width="11%" />
</colgroup>
<thead>
<tr class="header">
<th align="center">x</th>
<th align="center">y</th>
<th align="center">perc_of_obs</th>
<th align="center">x2y</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="center">covid_19_test_results</td>
<td align="center">loss_of_smell</td>
<td align="center">21.88</td>
<td align="center">18.18</td>
</tr>
<tr class="even">
<td align="center">covid_19_test_results</td>
<td align="center">loss_of_taste</td>
<td align="center">22.73</td>
<td align="center">12.5</td>
</tr>
<tr class="odd">
<td align="center">covid_19_test_results</td>
<td align="center">sats</td>
<td align="center">92.9</td>
<td align="center">2.24</td>
</tr>
</tbody>
</table>
<p>Only <em>three</em> of the 41 variables have a non-zero association with <code>covid_19_test_results</code>. Disappointingly, the highest <code>x2y</code> value is an unimpressive 18%. It is based on just 22% of the observations (since the other 78% of observations had missing values) and makes one wonder if this modest association is real or if it is just due to chance.</p>
<p>If we were working with the correlation coefficient, we could easily calculate a <em>confidence interval</em> for it and gauge if what we are seeing is real or not. Can we do the same thing for the <code>x2y</code> metric?</p>
<p>We can, by using <a href="https://en.wikipedia.org/wiki/Bootstrapping_(statistics)">bootstrapping</a>. Given <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span>, we can sample with replacement a 1000 times (say) and calculate the <code>x2y</code> metric each time. With these 1000 numbers, we can construct a confidence interval easily (this is available as an optional <code>confidence</code> argument in the R functions we have been using; please see the <a href="#appendix">appendix</a>).</p>
<p>Let’s re-do the earlier calculation with “confidence intervals” turned on by running <code>dx2y(df, target = "covid_19_test_results", confidence = TRUE)</code> in R.</p>
<pre class="r"><code>dx2y(df, target = "covid_19_test_results", confidence = TRUE) %>%
filter(x2y >0) %>%
pander(split.tables = Inf)</code></pre>
<table>
<colgroup>
<col width="26%" />
<col width="17%" />
<col width="15%" />
<col width="8%" />
<col width="15%" />
<col width="15%" />
</colgroup>
<thead>
<tr class="header">
<th align="center">x</th>
<th align="center">y</th>
<th align="center">perc_of_obs</th>
<th align="center">x2y</th>
<th align="center">CI_95_Lower</th>
<th align="center">CI_95_Upper</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="center">covid_19_test_results</td>
<td align="center">loss_of_smell</td>
<td align="center">21.88</td>
<td align="center">18.18</td>
<td align="center">-8.08</td>
<td align="center">36.36</td>
</tr>
<tr class="even">
<td align="center">covid_19_test_results</td>
<td align="center">loss_of_taste</td>
<td align="center">22.73</td>
<td align="center">12.5</td>
<td align="center">-11.67</td>
<td align="center">25</td>
</tr>
<tr class="odd">
<td align="center">covid_19_test_results</td>
<td align="center">sats</td>
<td align="center">92.9</td>
<td align="center">2.24</td>
<td align="center">-1.85</td>
<td align="center">4.48</td>
</tr>
</tbody>
</table>
<p><em>The 95% confidence intervals all contain 0.0</em>, so none of these associations appear to be real.</p>
<p>Let’s see what the top 10 associations are, between <em>any</em> pair of variables.</p>
<pre class="r"><code>dx2y(df) %>%head(10) %>% pander</code></pre>
<table style="width:75%;">
<colgroup>
<col width="22%" />
<col width="22%" />
<col width="19%" />
<col width="11%" />
</colgroup>
<thead>
<tr class="header">
<th align="center">x</th>
<th align="center">y</th>
<th align="center">perc_of_obs</th>
<th align="center">x2y</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="center">loss_of_smell</td>
<td align="center">loss_of_taste</td>
<td align="center">20.17</td>
<td align="center">100</td>
</tr>
<tr class="even">
<td align="center">loss_of_taste</td>
<td align="center">loss_of_smell</td>
<td align="center">20.17</td>
<td align="center">100</td>
</tr>
<tr class="odd">
<td align="center">fatigue</td>
<td align="center">headache</td>
<td align="center">40.06</td>
<td align="center">90.91</td>
</tr>
<tr class="even">
<td align="center">headache</td>
<td align="center">fatigue</td>
<td align="center">40.06</td>
<td align="center">90.91</td>
</tr>
<tr class="odd">
<td align="center">fatigue</td>
<td align="center">sore_throat</td>
<td align="center">27.84</td>
<td align="center">89.58</td>
</tr>
<tr class="even">
<td align="center">headache</td>
<td align="center">sore_throat</td>
<td align="center">30.4</td>
<td align="center">89.36</td>
</tr>
<tr class="odd">
<td align="center">sore_throat</td>
<td align="center">fatigue</td>
<td align="center">27.84</td>
<td align="center">88.89</td>
</tr>
<tr class="even">
<td align="center">sore_throat</td>
<td align="center">headache</td>
<td align="center">30.4</td>
<td align="center">88.64</td>
</tr>
<tr class="odd">
<td align="center">runny_nose</td>
<td align="center">fatigue</td>
<td align="center">25.57</td>
<td align="center">84.44</td>
</tr>
<tr class="even">
<td align="center">runny_nose</td>
<td align="center">headache</td>
<td align="center">25.57</td>
<td align="center">84.09</td>
</tr>
</tbody>
</table>
<p>Interesting. <code>loss_of_smell</code> and <code>loss_of_taste</code> are <em>perfectly</em> associated with each other. Let’s look at the raw data.</p>
<pre class="r"><code>with(df, table(loss_of_smell, loss_of_taste))</code></pre>
<pre><code>## loss_of_taste
## loss_of_smell FALSE TRUE
## FALSE 55 0
## TRUE 0 16</code></pre>
<p>They agree for <em>every</em> observation in the dataset and, as a result, their <code>x2y</code> is 100%.</p>
<p>Moving down the <code>x2y</code> ranking, we see a number of variables - <code>fatigue</code>, <code>headache</code>, <code>sore_throat</code>, and <code>runny_nose</code> - that are <em>all strongly associated with each other</em>, as if they are all connected by a common cause.</p>
<p>When the number of variable combinations is high and there are lots of missing values, it can be helpful to scatterplot <code>x2y</code> vs <code>perc_of_obs</code>.</p>
<pre class="r"><code>ggplot(data = dx2y(df), aes(y=x2y, x = perc_of_obs)) +
geom_point()</code></pre>
<pre><code>## Warning: Removed 364 rows containing missing values (geom_point).</code></pre>
<p><img src="/2021/04/15/an-alternative-to-the-correlation-coefficient-that-works-for-numeric-and-categorical-variables/index_files/figure-html/unnamed-chunk-14-1.png" width="672" /></p>
<p>Unfortunately, the top-right quadrant is empty: there are no strongly-related variable pairs that are based on at least 50% of the observations. There <em>are</em> some variable pairs with <code>x2y</code> values > 75% but none of them are based on more than 40% of the observations.</p>
<p><br></p>
</div>
<div id="conclusion" class="section level3">
<h3>Conclusion</h3>
<p>Using an insight from Information Theory, we devised a new metric - the <code>x2y</code> metric - that quantifies the strength of the association between pairs of variables.</p>
<p>The <code>x2y</code> metric has several advantages:</p>
<ul>
<li>It works for all types of variable pairs (continuous-continuous, continuous-categorical, categorical-continuous and categorical-categorical)</li>
<li>It captures linear and non-linear relationships</li>
<li>Perhaps best of all, it is easy to understand and use.</li>
</ul>
<p>I hope you give it a try in your work.</p>
<p>(If you found this note helpful, you may find <a href="https://rama100.github.io/lecture-notes/">these</a> of interest)</p>
<p><br></p>
</div>
<div id="acknowledgements" class="section level3">
<h3>Acknowledgements</h3>
<p>Thanks to <a href="https://mitsloan.mit.edu/faculty/directory/amr-farahat">Amr Farahat</a> for helpful feedback on an earlier draft.</p>
<p><br></p>
</div>
<div id="appendix" class="section level3">
<h3>Appendix: How to use the R script</h3>
<p>The <a href="https://github.com/rama100/x2y/blob/main/x2y.R">R script</a> depends on two R packages - <code>rpart</code> and <code>dplyr</code> - so please ensure that they are installed in your environment.</p>
<p>The script has two key functions: <code>x2y()</code> and <code>dx2y()</code>.</p>
<p><br></p>
<div id="using-the-x2y-function" class="section level4">
<h4>Using the <code>x2y()</code> function</h4>
<p><em>Usage</em>: <code>x2y(u, v, confidence = FALSE)</code></p>
<p><em>Arguments</em>:</p>
<ul>
<li><code>u</code>, <code>v</code>: two vectors of equal length</li>
<li><code>confidence</code>: (OPTIONAL) a boolean that indicates if a confidence interval is needed. Default is FALSE.</li>
</ul>
<p><em>Value</em>: A list with the following elements:</p>
<ul>
<li><code>perc_of_obs</code>: the % of total observations that were used to calculate <code>x2y</code>. If some observations are missing for either <span class="math inline">\(u\)</span> or <span class="math inline">\(v\)</span>, this will be less than 100%.</li>
<li><code>x2y</code>: the <code>x2y</code> metric for using <span class="math inline">\(u\)</span> to predict <span class="math inline">\(v\)</span></li>
</ul>
<p>Additionally, if <code>x2y()</code> was called with <code>confidence = TRUE</code>:</p>
<ul>
<li><code>CI_95_Lower</code>: the lower end of a 95% confidence interval for the <code>x2y</code> metric estimated by <a href="https://en.wikipedia.org/wiki/Bootstrapping_(statistics)">bootstrapping</a> 1000 samples</li>
<li><code>CI_95_Upper</code>: the upper end of a 95% confidence interval for the <code>x2y</code> metric estimated by bootstrapping 1000 samples</li>
</ul>
<p><br></p>
</div>
<div id="using-the-dx2y-function" class="section level4">
<h4>Using the <code>dx2y()</code> function</h4>
<p><em>Usage</em>: <code>dx2y(d, target = NA, confidence = FALSE)</code></p>
<p><em>Arguments</em>:</p>
<ul>
<li><code>d</code>: a dataframe</li>
<li><code>target</code>: (OPTIONAL) if you are only interested in the <code>x2y</code> values between a <em>particular variable</em> in <code>d</code> and all other variables, set <code>target</code> equal to the name of the variable you are interested in. Default is NA.</li>
<li><code>confidence</code>: (OPTIONAL) a boolean that indicates if a confidence interval is needed. Default is FALSE.</li>
</ul>
<p><em>Value</em>: A dataframe with each row containing the output of running <code>x2y(u, v, confidence)</code> for <code>u</code> and <code>v</code> chosen from the dataframe. Since this is just a standard R dataframe, it can be sliced, sorted, filtered, plotted etc.</p>
<p><strong>Update on April 16, 2021</strong>: I learned from a commenter that a <a href="https://paulvanderlaken.com/2020/05/04/predictive-power-score-finding-patterns-dataset/">similar approach</a> was proposed in April 2020, and that the R package <a href="https://cran.r-project.org/package=ppsr">ppsr</a> which implements that approach is now available on CRAN.</p>
</div>
</div>
<script>window.location.href='https://rviews.rstudio.com/2021/04/15/an-alternative-to-the-correlation-coefficient-that-works-for-numeric-and-categorical-variables/';</script>
What does it take to do a t-test?
https://rviews.rstudio.com/2021/03/29/what-does-it-take-to-do-a-t-test/
Mon, 29 Mar 2021 00:00:00 +0000https://rviews.rstudio.com/2021/03/29/what-does-it-take-to-do-a-t-test/
<script src="/2021/03/29/what-does-it-take-to-do-a-t-test/index_files/header-attrs/header-attrs.js"></script>
<p>In this post, I examine the fundamental assumption of independence underlying the basic <a href="https://en.wikipedia.org/wiki/Student%27s_t-test">Independent two-sample t-test</a> for comparing the means of two random samples. In addition to independence, we assume that both samples are draws from normal distributions where the population means and common variance are unknown. I am going to assume that you are familiar with this kind of test, but even if you are not you are still in the right place. The references at the end of the post all provide rigorous, but gentle explanations that should be very helpful.</p>
<div id="the-two-sample-t-test" class="section level3">
<h3>The two sample t-test</h3>
<p>Typically, we have independent samples for some numeric variable of interest (say the concentration of a drug in the blood stream) from two different groups, and we would like to know whether it is likely that two groups differ with respect to this variable. The formal test of the null hypothesis, <span class="math inline">\(H_0\)</span>, that the means of the underlying populations from which the samples are drawn are equal, proceeds making some assumptions:</p>
<ol style="list-style-type: decimal">
<li><span class="math inline">\(H_0\)</span> is true</li>
<li>The samples are independent</li>
<li>The data are normally distributed</li>
<li>The variances of the two samples are equal (This is the simplest test.)</li>
</ol>
<p>Next, a test statistic that includes the difference between the two sample means is calculated, and a decision is made to establish a “rejection region” for the test statistic. This region depends on the particular circumstances of the test, and is selected to balance the error of rejecting <span class="math inline">\(H_0\)</span> when it is true against the error of not rejecting <span class="math inline">\(H_0\)</span> when it is false. If we compute the test statistic and its value does not fall in the rejection region, then we do not reject <span class="math inline">\(H_0\)</span> and we conclude that we have found nothing. On the other hand, if the test statistic does fall in the rejection region, then we reject the <span class="math inline">\(H_0\)</span> and conclude that our data along with the the bundle of assumptions we made in setting up the test, and the “steel trap” logic of the t-test itself provide some evidence that the population means are different. (Page 6 of the MIT Open Courseware notes <a href="https://ocw.mit.edu/courses/mathematics/18-05-introduction-to-probability-and-statistics-spring-2014/readings/MIT18_05S14_Reading18.pdf">Null Hypothesis Significance Testing II</a> contains an elegantly concise mathematical description of the t-test.)</p>
<p>All of the above assumptions must hold, or be pretty close to holding for the test to give an accurate result. However in my opinion, from the point of view of statistical practice, assumption 2. is fundamental. There are other tests and workarounds for the situations where 4. doesn’t hold. Assumption 3. is very important, but it is relatively easy to check, and the t-test is robust enough to deal with some deviation from normality. Of course, assumption 1. is important. The whole test depends on it, but this assumption is baked into the software that will run the test.</p>
</div>
<div id="independence" class="section level3">
<h3>Independence</h3>
<p>Independence, on the other hand can be a show stopper. Checking for independence is the difference between doing statistics and carrying out a mathematical or maybe just a mechanical exercise. It often involves considerable creative thinking and tedious legwork.</p>
<p>So, what do we mean by independent samples or independent data, and how do we go about verifying it? Independence is a mathematical idea, an abstraction from probability theory. Two events A and B are said to be independent events if the probability of both A and B happening equals the product of the probabilities of A and B happening. That is: P(AB) = P(A)P(B).</p>
<p>A more intuitive way to think about it is in terms of conditionally probability. In general, the probability of A happening given that B happens is defined to be:</p>
<blockquote>
<p>P(A|B) = P(<span class="math inline">\(A\bigcap B\)</span>) / P(B)</p>
</blockquote>
<p>If A and B are independent then P(A|B) = P(A). That is: B has no influence on whether A happens.</p>
<p>“Independent data” or “independent samples” are both shorthand for data sampled or otherwise resulting from independent probability distributions. Relating the mathematical concept to a real world situation requires a clear idea of the population of interest, considerable domain expertise, and a mental slight of hand that is nicely exposed in the short article <a href="https://support.minitab.com/en-us/minitab/19/help-and-how-to/statistics/basic-statistics/supporting-topics/tests-of-means/what-are-independent-samples/">What are independent samples?</a>, by the Minitab® folks. They write:</p>
<blockquote>
<p>Independent samples are samples that are selected randomly so that its observations do not depend on the values other observations.</p>
</blockquote>
<p>Notice what is happening here: what started out as a property of probability distributions has now become a prescription for obtaining data in a way that makes it plausible that we can assume independence for the probability distributions that we imagine govern our data. This is a real magic trick. No procedure for selecting data is ever going to guarantee the mathematical properties of our models. Nevertheless, the statement does show the way to proceed. By systematically tracking down all possibilities for interaction within the sampling process and eliminating the possibilities for one sample to influence another it may be possible to reach confidence that it is plausible to assume that the samples are independent. Because the math says that <a href="http://athenasc.com/Bivariate-Normal.pdf">independent data are not correlated</a> much of the exploratory data analysis involves looking for correlations that would signal dependent data. The Minitab® authors make this clear in the <a href="https://support.minitab.com/en-us/minitab/19/help-and-how-to/statistics/basic-statistics/supporting-topics/tests-of-means/what-are-independent-samples/">example</a> they offer to illustrate their definition.</p>
<blockquote>
<p>For example, suppose quality inspectors want to compare two laboratories to determine whether their blood tests give similar results. They send blood samples drawn from the same 10 children to both labs for analysis. Because both labs tested blood specimens from the same 10 children, the test results are not independent. To compare the average blood test results from the two labs, the inspectors would need to do a paired t-test, which is based on the assumption that samples are dependent.</p>
</blockquote>
<blockquote>
<p>To obtain independent samples, the inspectors would need to randomly select and test 10 children using Lab A and then randomly select and test a different group of 10 different children using Lab B. Then they could compare the average blood test results from the two labs using a 2-sample t-test, which is based on the assumption that samples are independent.</p>
</blockquote>
<p>Nicely said, and to further make their point, I am sure that the authors would agree that if it somehow turned out that the children from lab B happened to be the identical twins of the children in Lab A, they still would not have independent samples.</p>
</div>
<div id="what-happens-when-samples-are-not-independent" class="section level3">
<h3>What happens when samples are not independent</h3>
<p>The following example illustrates the consequences of performing a t-test when the independence assumption does not hold. We adapt a method of <a href="https://blog.revolutionanalytics.com/2016/08/simulating-form-the-bivariate-normal-distribution-in-r-1.html">simulating a bivariate normal distribution</a> with a specified covariance matrix that produces two dependent samples with a specified correlation matrix.</p>
<pre class="r"><code>library(tidyverse)
library(ggfortify)
set.seed(9999)</code></pre>
<p>First, we simulate a two uncorrelated samples with 20 observations each and run a two-sided t-test with equal variances. As you would expect, test output shows that there are 38 degrees of freedom and the p-value is large.</p>
<pre class="r"><code>rbvn_t<-function (n=20, mu1=1, s1=4, mu2=1, s2=4, rho=0)
{
X <- rnorm(n, mu1, s1)
Y <- rnorm(n, mu2 + (s2/s1) * rho *
(X - mu1), sqrt((1 - rho^2)*s2^2))
t.test(X,Y, mu=0, alternative = "two.sided", var.equal = TRUE)
}
rbvn_t()</code></pre>
<pre><code>##
## Two Sample t-test
##
## data: X and Y
## t = 2.1, df = 38, p-value = 0.04
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.06266 5.06516
## sample estimates:
## mean of x mean of y
## 2.9333 0.3694</code></pre>
<p>Now we simulate 10,000 two-sided t-tests with independent samples having 20 observations in each sample.</p>
<pre class="r"><code>ts <- replicate(10000,rbvn_t(n=20, mu1=1, s1=4, mu2=1, s2=4, rho=0)$statistic)</code></pre>
<p>Plotting the simulated samples shows that the empirical density curve nicely overlays the theoretical density for the t-distribution.</p>
<pre class="r"><code>p <- ggdistribution(dt, df = 38, seq(-4, 4, 0.1))
autoplot(density(ts), colour = 'blue', p = p, fill = 'blue') +
ggtitle("When variables are independent")</code></pre>
<p><img src="/2021/03/29/what-does-it-take-to-do-a-t-test/index_files/figure-html/unnamed-chunk-4-1.png" width="672" /></p>
<p>Moreover, the 0.975 quantile, the value that would indicate the upper boundary for the acceptance region for an <span class="math inline">\(\alpha\)</span> value of 0.05 is very close to the theoretical value of 2.024.</p>
<pre class="r"><code>quantile(ts,.975)</code></pre>
<pre><code>## 97.5%
## 1.996</code></pre>
<pre class="r"><code>qt(.975,38)</code></pre>
<pre><code>## [1] 2.024</code></pre>
<p>Next, we simulate 10,000 small samples of 20 with a correlation of 0.3.</p>
<pre class="r"><code>ts_d <- replicate(10000,rbvn_t(n=20, mu1=1, s1=4, mu2=1, s2=4, rho=.3)$statistic)</code></pre>
<p>We see that now the fit is not so good. There simulated distribution has noticeably less probability in the tails.</p>
<pre class="r"><code>pd <- ggdistribution(dt, df = 38, seq(-4, 4, 0.1))
autoplot(density(ts_d), colour = 'blue', p = pd, fill = 'blue') +
ggtitle("When variables are NOT independent")</code></pre>
<p><img src="/2021/03/29/what-does-it-take-to-do-a-t-test/index_files/figure-html/unnamed-chunk-7-1.png" width="672" />
The .975 quantile is much lower than the theoretical value of 2.024 showing that dependent data would lead to very misleading p-values.</p>
<pre class="r"><code>quantile(ts_d,.975)</code></pre>
<pre><code>## 97.5%
## 1.73</code></pre>
</div>
<div id="summary" class="section level3">
<h3>Summary</h3>
<p>Properly performing a t-test on data obtained from an experiment could mean doing a whole lot of up front work to design the experiment in a way that will make the assumptions plausible. One could argue that the real practice of statistics begins even before making exploratory plots. Doing statistics with found data is much more problematic. At a minimum, doing a simple t-test means acquiring more that a superficial understanding of how the data were generated.</p>
<p>Finally, when all is said and done, and you have a well constructed t-test that results in a sufficiently small p-value to reject the null hypothesis, you will have attained what most people call a statistically significant result. However, I think this language misleadingly emphasizes the mechanical grinding of the “steel trap” logic of the test that I mentioned above. Maybe instead we should emphasize the work that went into checking assumptions, and think about hypothesis tests as producing “plausibly significant” results.</p>
</div>
<div id="some-resources-for-doing-t-tests-in-r" class="section level3">
<h3>Some resources for doing t-tests in R</h3>
<ul>
<li><p>Holmes and Huber (2019) <a href="https://web.stanford.edu/class/bios221/book/">Modern Statistics for Modern Biology</a>, Chapter 6,</p></li>
<li><p>Orloff and Bloom (2014) <a href="https://ocw.mit.edu/courses/mathematics/18-05-introduction-to-probability-and-statistics-spring-2014/readings/MIT18_05S14_Reading18.pdf">Null Hypothesis Significance Testing II</a></p></li>
<li><p>Poldrack (2018) <a href="https://web.stanford.edu/group/poldracklab/statsthinking21/">Statistical Thinking for the 21st century</a>, Chapter 9</p></li>
<li><p>Spector <a href="https://statistics.berkeley.edu/computing/r-t-tests">Using t-tests in R</a></p></li>
<li><p>Wetherill (2015) <a href="https://datascienceplus.com/t-tests/">How to Perform T-tests in R</a></p></li>
</ul>
</div>
<script>window.location.href='https://rviews.rstudio.com/2021/03/29/what-does-it-take-to-do-a-t-test/';</script>
February 2021: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2021/03/19/february-2021-top-40-new-cran-packages/
Fri, 19 Mar 2021 00:00:00 +0000https://rviews.rstudio.com/2021/03/19/february-2021-top-40-new-cran-packages/
<p>In February, two hundred forty-three new packages made it to CRAN, many of them very interesting and at least one entertaining. It was exceptionally difficult to pick the “Top 40”, but here they are, more or less, in eleven categories: Computational Methods, Data, Finance, Games, Genomics, Machine Learning, Mathematics, Medicine, Networks and Graphs, Statistics, Utilities, and Visualization. <code>iconr</code> in the Networks and Graphs section is a package for doing computational archaeology, a relatively new field that I hope will dig R. I also hope that <code>sassy</code> in the Statistics sections helps some statisticians find their way to R.</p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=blaster">blaster</a> v1.0.3: Implements an efficient BLAST-like sequence comparison algorithm, written in C++11 and using native R data types. See <a href="https://www.biorxiv.org/content/10.1101/399782v1">Schmid et al. (2018)</a> for background and <a href="https://cran.r-project.org/web/packages/blaster/readme/README.html">README</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=rando">rando</a> v0.2.0: Provides random number generating functions that are much more context aware than the built-in functions. The functions are also safer, as they check for incompatible values, and reproducible.</p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=AWAPer">AWAPer</a> 0.1.46: Provides catchment area weighted climate data NetCDF files from the Bureau of Meteorology <a href="http://www.bom.gov.au/jsp/awap/">Australian Water Availability Project</a> for all of Australia. There is a vignette on <a href="https://cran.r-project.org/web/packages/AWAPer/vignettes/Catchment_avg_ET_rainfall.html">Daily Area Weighted PET and Precipitation</a> and another on <a href="https://cran.r-project.org/web/packages/AWAPer/vignettes/Point_rainfall.html">Daily Point Precipitation</a></p>
<p><img src="AWAPer.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=caRecall">caRecall</a> v0.1.0: Provides API access to the Government of Canada <a href="https://tc.api.canada.ca/en/detail?api=VRDB">Vehicle Recalls Database</a> used by the Defect Investigations and Recalls Division for vehicles, tires, and child car seats. See the <a href="https://cran.r-project.org/web/packages/caRecall/vignettes/vrd_vignette.html">vignette</a>.</p>
<p><img src="caRecall.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=geofi">geofi</a> v1.0.0: Provides tools for reading Finnish open geospatial data in R. There are vignettes on <a href="https://cran.r-project.org/web/packages/geofi/vignettes/geofi_datasets.html">Datasets</a>, <a href="https://cran.r-project.org/web/packages/geofi/vignettes/geofi_joining_attribute_data.html">Joining Attributes</a>, <a href="https://cran.r-project.org/web/packages/geofi/vignettes/geofi_making_maps.html">Making Maps</a>, <a href="https://cran.r-project.org/web/packages/geofi/vignettes/geofi_spatial_analysis.html">Data Manipulation</a>, and <a href="https://cran.r-project.org/web/packages/geofi/vignettes/tricolore_tutorial.html">Color-coded Maps</a>.</p>
<p><img src="geofi.png" height = "400" width="200"></p>
<p><a href="https://cran.r-project.org/package=hockeystick">hockeystick</a> v0.4.0: Provides easy access to essential climate change data sets for non-climate experts. Users can download the latest raw data from authoritative sources and view it via pre-defined <code>ggplot2</code> charts. Data sets include atmospheric CO2, instrumental and proxy temperature records, sea levels, Arctic/Antarctic sea-ice, and Paleoclimate data. Sources include: <a href="https://www.esrl.noaa.gov/gmd/ccgg/trends/data.html">NOAA Mauna Loa Laboratory</a>, <a href="https://data.giss.nasa.gov/gistemp/">NASA GISTEMP</a>, <a href="https://nsidc.org/data/seaice_index/archives">National Snow and Sea Ice Data Center</a>, <a href="http://www.cmar.csiro.au/sealevel/sl_data_cmar.htm">CSIRO</a>, <a href="https://www.star.nesdis.noaa.gov/socd/lsa/SeaLevelRise/">NOAA Laboratory for Satellite Altimetry</a>, and <a href="https://cdiac.ess-dive.lbl.gov/trends/co2/vostok.html">Vostok Paleo</a> carbon dioxide and temperature data. See <a href="https://cran.r-project.org/web/packages/hockeystick/readme/README.html">README</a> for examples.</p>
<p><img src="hockeystick.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=votesmart">votesmart</a> v0.1.0: Implements a wrapper to the <a href="https://justfacts.votesmart.org/">Project VoteSmart</a> API. See the <a href="https://cran.r-project.org/web/packages/votesmart/vignettes/votesmart.html">vignette</a>.</p>
<h3 id="finance">Finance</h3>
<p><a href="https://cran.r-project.org/package=PriceIndices">PriceIndices</a> v0.0.3: Provides functions to compute bilateral and multilateral indexes. For details, see: <a href="https://onlinelibrary.wiley.com/doi/abs/10.1111/roiw.12304">de Haan and Krsinich (2017)</a> and <a href="https://www.tandfonline.com/doi/abs/10.1080/07350015.2020.1816176?journalCode=ubes20">Diewert and Fox (2020)</a>. The <a href="https://cran.r-project.org/web/packages/PriceIndices/vignettes/PriceIndices.html">vignette</a> offers examples.</p>
<p><a href="https://cran.r-project.org/package=treasuryTR">treasuryTR</a> v0.1.1: Generates Total Returns (TR) from bond yield data with fixed maturity (e.g. reported treasury yields) which may provide an alternative to commercial products. See <a href="https://www.mdpi.com/2306-5729/4/3/91">Swinkels (2019)</a> for background and the <a href="https://cran.r-project.org/web/packages/treasuryTR/vignettes/treasuryTR.html">vignette</a> for examples.</p>
<p><img src="treasuryTR.png" height = "200" width="400"></p>
<h3 id="games">Games</h3>
<p><a href="https://cran.r-project.org/package=pixelpuzzle">pixelpuzzle</a> v1.0.0: Implements a puzzle game that can be played in the R console. Restore the pixel art by shifting rows. Learn how to play <a href="https://github.com/rolkra/pixelpuzzle">here</a>.</p>
<p><img src="pixelpuzzle.png" height = "200" width="400"></p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=CDSeq">CDSeq</a> v1.0.8: Provides functions to estimate cell-type-specific gene expression profiles and sample-specific cell-type proportions simultaneously using bulk sequencing data. See <a href="https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1007510">Kang et al. (2019)</a> for the theory and the <a href="https://cran.r-project.org/web/packages/CDSeq/vignettes/CDSeq-vignette.html">vignette</a> for examples.</p>
<p><img src="CDSeq.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=ClusTorus">ClusTorus</a> v0.0.1: Provides various tools for clustering multivariate angular data on the torus including angular adaptations of usual clustering methods such as the k-means clustering, pairwise angular distances. See the <a href="https://cran.r-project.org/web/packages/ClusTorus/vignettes/ClusTorus.html">vignette</a> for examples.</p>
<p><img src="ClusTorus.png" height = "200" width="400"></p>
<p><a href="https://CRAN.R-project.org/package=dsb">dsb</a> v0.1.0: Provides a method for normalizing and denoising protein expression data from droplet based single cell experiments. See the <a href="https://cran.r-project.org/web/packages/dsb/vignettes/dsb_normalizing_CITEseq_data.html">vignette</a> for tutorials on how to integrate <code>dsb</code> with Seurat, Bioconductor and the AnnData class in Python. The preprint <a href="https://www.biorxiv.org/content/10.1101/2020.02.24.963603v1">Mulè et al. (2020)</a> describes the details.</p>
<p><img src="dsb.png" height = "200" width="400"></p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=bestridge">besridge</a> v1.0.4: Provides functions to perform ridge regression in complex situations on high dimensional data using the primal dual active set algorithm proposed in <a href="https://www.jstatsoft.org/article/view/v094i04">Wen et al. (2020)</a>. Functions support regression, classification, count regression and censored regression, group variable selection and nuisance variable selection. See the <a href="https://cran.r-project.org/web/packages/bestridge/vignettes/An-introduction-to-bestridge.html">vignette</a> for examples.</p>
<p><img src="bestridge.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=ROCket">ROCket</a> v1.0.1: Provides functions for estimating receiver operating characteristic (ROC) curves and area under the curve (AUC) calculation which distinguish two types of ROC curve representations: 1) parametric curves - the true positive rate (TPR) and the false positive rate (FPR) are functions of a score parameter and 2) function curves - TPR is a function of FPR. See <a href="https://www.ine.pt/revstat/pdf/rs140101.pdf">Gonçalves et al. (2014)</a> and <a href="https://onlinelibrary.wiley.com/doi/abs/10.1111/j.0006-341X.2004.00200.x">Cai & Pepe (2004)</a> for background and <a href="https://cran.r-project.org/web/packages/ROCket/readme/README.html">README</a> to get started.</p>
<p><img src="ROCket.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=wordpiece">wordpiece</a> v1.0.2: Provides functions to apply <a href="https://arxiv.org/abs/1609.08144">Wordpiece</a> tokenization to input text, given an appropriate vocabulary. The <a href="https://arxiv.org/abs/1810.04805">BERT</a> tokenization conventions are used by default. See the <a href="https://cran.r-project.org/web/packages/wordpiece/vignettes/basic_usage.html">vignette</a> for an example.</p>
<h3 id="mathematics">Mathematics</h3>
<p><a href="https://cran.r-project.org/package=fractD">fractD</a> v0.1.0: Estimates the of fractal dimension of a black area in 2D and 3D (slices) images using the box-counting method. See <a href="https://link.springer.com/article/10.1007%2FBF02065874">Klinkenberg (1994)</a> for background and the <a href="https://cran.r-project.org/web/packages/fractD/vignettes/Calculates_the_fractal_dimension_of_2D_and_3D_images.html">vignette</a> for examples.</p>
<p><img src="fractD.svg" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=spacefillr">spacefillr</a> v0.2.0: Generates random and quasi-random space-filling sequences including <a href="https://en.wikipedia.org/wiki/Halton_sequence">Halton</a>, <a href="https://en.wikipedia.org/wiki/Sobol_sequence">Sobol</a> and other sequences with errors distributed as various types of jittered blue noise. See <a href="https://epubs.siam.org/doi/10.1137/070709359">Joe and Kuo (2018)</a>, <a href="https://graphics.pixar.com/library/ProgressiveMultiJitteredSampling/paper.pdf">Christensen et al. (2018)</a> and <a href="https://dl.acm.org/doi/10.1145/3306307.3328191">Heitz et al. (2019)</a> for background and look <a href="https://github.com/tylermorganwall/spacefillr">here</a> for examples.</p>
<p><img src="spacefillr.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=tensorsign">tensorsign</a> v0.1.0: Provides an efficient algorithm for nonparametric tensor completion via sign series. The algorithm which employs the alternating optimization approach to solve the weighted classification problem is described in <a href="https://arxiv.org/abs/2102.00384">Lee and Wang (2021)</a></p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=bhmbasket">bhmbasket</a> v0.9.1: Provides functions to evaluate basket trial designs with binary endpoints using Bayesian hierarchical models and Bayesian decision rules. See <a href="https://journals.sagepub.com/doi/10.1177/1740774513497539">Berry et al. (2013)</a>, <a href="https://onlinelibrary.wiley.com/doi/abs/10.1002/pst.1730">Neuenschwander et al. (2016)</a> and <a href="https://link.springer.com/article/10.1177%2F2168479014533970">Fisch et al. (2015)</a> for background and the <a href="https://cran.r-project.org/web/packages/bhmbasket/vignettes/reproduceExNex.html">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=bp">bp</a> v1.0.1: Provides functions to aid in the analysis of blood pressure data of all forms by providing both descriptive and visualization tools for researchers. There is a <a href="https://cran.r-project.org/web/packages/bp/vignettes/bp.html">vignette</a>.</p>
<p><img src="blood.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=CHOIRBM">CHOIRBM</a> v0.0.2: Provides functions for visualizing body map data collected with the Collaborative Health Outcomes Information Registry <a href="https://choir.stanford.edu/">CHOIR)</a>. See the <a href="https://cran.r-project.org/web/packages/CHOIRBM/vignettes/plot-one-patient.html">vignette</a>.</p>
<p><img src="CHOIRBM.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=QDiabetes">QDiabetes</a> v1.0-2: Calculates the risk of developing type 2 diabetes using risk prediction algorithms derived by <a href="https://clinrisk.co.uk/ClinRisk/Welcome.html">ClinRisk</a>. Look <a href="https://github.com/Feakster/qdiabetes">here</a> for information and examples.</p>
<p><a href="https://cran.r-project.org/package=SteppedPower">SteppedPower</a> v0.1.0: Provides tools for power and sample size calculations and design diagnostics for longitudinal mixed models with a focus on stepped wedge designs using methods introduced in <a href="https://www.sciencedirect.com/science/article/pii/S1551714406000632?via%3Dihub">Hussey and Hughes (2007)</a> and extensions discussed in <a href="https://journals.sagepub.com/doi/10.1177/0962280220932962">Li et al. (2020)</a>. See the <a href="https://cran.r-project.org/web/packages/SteppedPower/vignettes/Getting_Started.html">vignette</a> to get started.</p>
<p><img src="SteppedPower.png" height = "200" width="400"></p>
<h3 id="networks-and-graphs">Networks and Graphs</h3>
<p><a href="https://cran.r-project.org/package=bnmonitor">bnmonitor</a> v0.1.0. Implements sensitivity and robustness methods for Bayesian networks including methods to perform parameter variations via a variety of co-variation schemes, to compute sensitivity functions and to quantify the dissimilarity of two Bayesian networks via distances and divergences. See <a href="https://www.jair.org/index.php/jair/article/view/10307">Chan and Darwiche (2002)</a>, <a href="https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1539-6975.2007.00235.x">Cowell et al. (2007)</a>, and <a href="https://arxiv.org/abs/1809.10794">Goergen and Leonell (2020)</a> for background and <a href="https://cran.r-project.org/web/packages/bnmonitor/readme/README.html">README</a> for examples.</p>
<p><img src="bnmonitor.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=iconr">iconr</a> v0.1.0: Provides formal methods for studying archaeological iconographic data sets (rock-art, pottery decoration, stelae, etc.) using network and spatial analysis See <a href="http://archiv.ub.uni-heidelberg.de/propylaeumdok/512/">Alexander (2008)</a> and <a href="https://hal.archives-ouvertes.fr/hal-02913656">Huet (2018)</a> for background and the <a href="https://cran.r-project.org/web/packages/iconr/vignettes/index.html">vignette</a> for examples.</p>
<p><img src="iconr.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=MLVSBM">MLVSBM</a> 0.2.1: Provides functions for simulation, inference and clustering of multilevel networks using a stochastic block model framework as described in <a href="https://www.sciencedirect.com/science/article/abs/pii/S016794732100013X?via%3Dihub">Chabert-Liddell et al. (2021)</a>. There is a <a href="https://cran.r-project.org/web/packages/MLVSBM/vignettes/vignette.html">tutorial</a>.</p>
<p><img src="MLVSBM.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=motifr">motifr</a> v1.0.0: Provides tools to analyze motifs(small configurations of nodes and edges) in multi-level networks (networks which combine multiple networks in one, e.g. social-ecological networks.) See <a href="https://cran.r-project.org/web/packages/motifr/vignettes/motif_zoo.html">The motif zoo</a> and <a href="https://cran.r-project.org/web/packages/motifr/vignettes/random_baselines.html">Baseline model comparisons</a>.</p>
<p><img src="motifr.svg" height = "200" width="400"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=cfda">cfda</a> v0.9.9: Provides functions to encode categorical data as functional data and perform basis statistical analysis. See <a href="https://hal.inria.fr/hal-02973094/document">Preda et al. (2020)</a> for background and the <a href="https://cran.r-project.org/web/packages/cfda/vignettes/cfda.html">vignette</a> to get started.</p>
<p><img src="cfda.png" height = "350" width="350"></p>
<p><a href="https://cran.r-project.org/package=cvCovEst">cvCovEst</a> v0.3.4: Implements an efficient cross-validated approach for covariance matrix estimation, particularly useful in high-dimensional settings. See the <a href="https://cran.r-project.org/web/packages/cvCovEst/vignettes/using_cvCovEst.html">vignette</a> for background and examples.</p>
<p><img src="cvCovEst.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=flipr">flipr</a> v0.2.1: Implements a permutation framework point estimation, confidence intervals or hypothesis testing for multiple data types. There is a <a href="https://cran.r-project.org/web/packages/flipr/vignettes/flipr.html">Tour of Permutation Inference</a>, and vignettes on <a href="https://cran.r-project.org/web/packages/flipr/vignettes/alternative.html">Alternative Hypothesis Testing</a>, the <a href="https://cran.r-project.org/web/packages/flipr/vignettes/exactness.html">Exactness of Permutation Tests</a>, and <a href="https://cran.r-project.org/web/packages/flipr/vignettes/pvalue-function.html">Calculating p-value Functions</a>.</p>
<p><img src="flipr.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=ipmr">ipmr</a> v0.0.1: implements integral projection models using an expression based framework that handles density dependence and environmental stochasticity and provides tools for diagnostics, plotting, simulations, and analysis. See <a href="https://esajournals.onlinelibrary.wiley.com/doi/abs/10.1890/0012-9658%282000%29081%5B0694%3ASSSAAN%5D2.0.CO%3B2">Easterling et al. (2000)</a>
for an in depth description of integral projection models. There is an <a href="https://cran.r-project.org/web/packages/ipmr/vignettes/ipmr-introduction.html">Introduction</a> and vignettes on <a href="https://cran.r-project.org/web/packages/ipmr/vignettes/age_x_size.html">Age-Size IPMS</a>, <a href="https://cran.r-project.org/web/packages/ipmr/vignettes/density-dependence.html">Density Dependent IPMS</a>, <a href="https://cran.r-project.org/web/packages/ipmr/vignettes/hierarchical-notation.html">Hierarchical Notation</a>, and <a href="https://cran.r-project.org/web/packages/ipmr/vignettes/proto-ipms.html">Data Structures</a>.</p>
<p><a href="https://cran.r-project.org/package=metapack">metapack</a> v0.1.1: Provides functions performing Bayesian inference for meta-analytic and network meta-analytic models through Markov chain Monte Carlo algorithm. See <a href="https://www.tandfonline.com/doi/full/10.1080/01621459.2015.1006065">Yao et al. (2015)</a> for the theory, the <a href="https://cran.r-project.org/web/packages/metapack/vignettes/intro-to-metapack.html">vignette</a> for an introduction and the <a href="http://merlot.stat.uconn.edu/packages/metapack/">online documentation</a>.</p>
<p><a href="https://cran.r-project.org/package=sassy">sassy</a> v1.0.4: Loads a collection of packages that collectively aim to make R easier for SAS® programmers. Functions bring many familiar SAS® concepts to R, including data libraries, data dictionaries, formats and format catalogs, a data step, and a traceable log. There is an <a href="https://cran.r-project.org/web/packages/sassy/vignettes/sassy.html">Introduction</a>, and vignettes with example <a href="https://cran.r-project.org/web/packages/sassy/vignettes/sassy-figure.html">Figures</a>, <a href="https://cran.r-project.org/web/packages/sassy/vignettes/sassy-listing.html">Listings</a>, and <a href="https://cran.r-project.org/web/packages/sassy/vignettes/sassy-table.html">Tables</a>, as well as a few <a href="https://cran.r-project.org/web/packages/sassy/vignettes/sassy-disclaimers.html">Disclaimers</a> which include a statement indicating that the packages were developed in the context of the pharmaceutical industry but should be generally helpful.</p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=gargoyle">gargoyle</a> v0.0.1: Implements an event-Based framework for building <code>Shiny</code> apps. Instead of relying on standard <code>Shiny</code> reactive objects, this package allow to relying on a lighter set of triggers, so that reactive contexts can be invalidated with more control. See the <a href="https://cran.r-project.org/web/packages/gargoyle/vignettes/gargoyle.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=multidplyr">multidplyr</a> Provides simple multicore parallelism through functions that partition a data frame across multiple worker processes. See the <a href="https://cran.r-project.org/web/packages/multidplyr/vignettes/multidplyr.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=quarto">quarto</a> v0.1: Provides an interface to the <a href="https://github.com/avdi/quarto">Quarto</a> markdown publishing system and allows converting R Markdown documents and <a href="https://jupyter.org/">Jupyter Notebooks</a> to a variety of output formats.</p>
<p><a href="https://cran.r-project.org/package=vmr">var</a> v0.0.2: Provides functions to manage, provision and use virtual machines pre-configured for R, and develop, test and build package in a clean environment. <a href="https://www.vagrantup.com/intro">Vagrant</a> and a provider such as <a href="https://www.virtualbox.org/">Virtualbox</a> must be installed.</p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=ggh4x">ggh4x</a> v0.1.2.1: Extends <code>ggplot2</code> facets by setting individual scales per panel, resizing panels, providing nested facets, and allowing multiple colour and fill scales per plot. See the <a href="https://cran.r-project.org/web/packages/ggh4x/vignettes/ggh4x.html">Introduction</a>, and the vignettes <a href="https://cran.r-project.org/web/packages/ggh4x/vignettes/Facets.html">Facets</a>, <a href="https://cran.r-project.org/web/packages/ggh4x/vignettes/Miscellaneous.html">Misc</a>, <a href="https://cran.r-project.org/web/packages/ggh4x/vignettes/PositionGuides.html">Position Guides</a>, and <a href="https://cran.r-project.org/web/packages/ggh4x/vignettes/Statistics.html">Statistics</a>.</p>
<p><img src="ggh4x.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=tastypie">tastypie</a> v0.0.3: Provides functions and templates for making pie charts even though you probably shouldn’t. See the vignettes <a href="https://cran.r-project.org/web/packages/tastypie/vignettes/available_templates.html">available templates</a> and <a href="https://cran.r-project.org/web/packages/tastypie/vignettes/your_favourite_template.html">Your favorite template</a>, and look <a href="https://paolodalena.github.io/tastypie/">here</a> for examples.</p>
<p><img src="tastypie.png" height = "350" width="350"></p>
<p><a href="https://cran.r-project.org/package=terrainr">terrainr</a> v0.3.1: Provides functions to retrieve, manipulate, and visualize geospatial data, with an aim towards producing ‘3D’ landscape visualizations in the <a href="https://unity.com/">Unity 3D</a> rendering engine. Functions are also provided for retrieving elevation data and base map tiles from the <a href="https://apps.nationalmap.gov/services/">USGS National Map</a>. There is an <a href="https://cran.r-project.org/web/packages/terrainr/vignettes/overview.html">Introduction</a> and a <a href="https://cran.r-project.org/web/packages/terrainr/vignettes/unity_instructions.html">vignette</a> on importing terrain tiles.</p>
<p><img src="terrainr.jpeg" height = "300" width="300"></p>
<script>window.location.href='https://rviews.rstudio.com/2021/03/19/february-2021-top-40-new-cran-packages/';</script>
Cheat Sheets
https://rviews.rstudio.com/2021/03/10/rstudio-open-source-resorurces/
Wed, 10 Mar 2021 00:00:00 +0000https://rviews.rstudio.com/2021/03/10/rstudio-open-source-resorurces/
<p>In a <a href="https://rviews.rstudio.com/2020/12/02/learn-and-teach-r/">previous post</a>, I described how I was captivated by the virtual landscape imagined by the RStudio education team while looking for resources on the <a href="https://rstudio.com/">RStudio</a> website. In this post, I’ll take a look at
<a href="https://rstudio.com/resources/cheatsheets/"><em>Cheatsheets</em></a> another amazing resource hiding in plain sight.</p>
<p><img src="cs.png" height = "400" width="100%"></p>
<p>Apparently, some time ago when I wasn’t paying much attention, cheat sheets evolved from the home made study notes of students with highly refined visual cognitive skills, but a relatively poor grasp of algebra or history or whatever to an essential software learning tool. I don’t know how this happened in general, but master cheat sheet artist Garrett Grolemund has passed along some of the lore of the cheat sheet at RStudio. Garrett writes:</p>
<blockquote>
<p>One day I put two and two together and realized that our Winston Chang, who I had known for a couple of years, was the same “W Chang” that made the LaTex cheatsheet that I’d used throughout grad school. It inspired me to do something similarly useful, so I tried my hand at making a cheatsheet for Winston and Joe’s Shiny package. The Shiny cheatsheet ended up being the first of many. A funny thing about the first cheatsheet is that I was working next to Hadley at a co-working space when I made it. In the time it took me to put together the cheatsheet, he wrote the entire first version of the tidyr package from scratch.</p>
</blockquote>
<p>It is now hard to imagine getting by without cheat sheets. It seems as if they are becoming expected adjunct to the documentation. But, as Garret explains in the <a href="https://github.com/rstudio/cheatsheets">README</a> for the cheat sheets GitHub repository, <strong>they are not documentation!</strong></p>
<blockquote>
<p>RStudio cheat sheets are not meant to be text or documentation! They are scannable visual aids that use layout and visual mnemonics to help people zoom to the functions they need. … Cheat sheets fall squarely on the human-facing side of software design.</p>
</blockquote>
<p>Cheat sheets live in the space where <a href="https://psnet.ahrq.gov/primer/human-factors-engineering">human factors</a> engineering gets a boost from artistic design. If R packages were airplanes then pilots would want cheat sheets to help them master the controls.</p>
<p>The RStudio site contains sixteen RStudio produced cheat sheets and nearly forty contributed efforts, some of which are displayed in the graphic above. The <a href="https://github.com/rstudio/cheatsheets/raw/master/data-transformation.pdf"><em>Data Transformation cheat sheet</em></a> is a classic example of a straightforward mnemonic tool.
It is likely that even someone who just beginning to work with <code>dplyr</code> will immediately grok that it organizes functions that manipulate tidy data. The cognitive load then is to remember how functions are grouped by task. The cheat sheet offers a canonical set of classes: “manipulate cases”, “manipulate variables” etc. to facilitate the process. Users that work with <code>dplyr</code> on a regular basis will probably just need to glance at the cheat sheet after a relatively short time.</p>
<p>The <a href="https://github.com/rstudio/cheatsheets/raw/master/shiny.pdf"><em>Shiny cheat sheet</em></a> is little more ambitious. It works on multiple levels and goes beyond categories to also suggest process and workflow.</p>
<p><img src="shiny.png" height = "400" width="100%"></p>
<p>The <a href="https://github.com/rstudio/cheatsheets/raw/master/purrr.pdf"><em>Apply functions cheat sheet</em></a> takes on an even more difficult task. For most of us, internally visualizing multi-level data structures is difficult enough, imaging how data elements flow under transformations is a serious cognitive load. I for one, really appreciate the help.</p>
<p><img src="purrr.png" height = "400" width="100%"></p>
<p>Cheat sheets are immensely popular. And even in this ebook age where nearly everything you can look at is online, and conference attending digital natives travel light, the cheat sheets as artifacts retain considerable appeal. Not only are they useful tools and geek art (Take a look at <a href="https://github.com/rstudio/cheatsheets/raw/master/cartography.pdf"><em>cartography</em></a>) for decorating a workplace, my guess is that they are perceived as <em>runes of power</em> enabling the cognoscenti to grasp essential knowledge and project it in the world.</p>
<p>When in-person conferences resume again, I fully expect the heavy paper copies to disappear soon after we put them out at the RStudio booth.</p>
<script>window.location.href='https://rviews.rstudio.com/2021/03/10/rstudio-open-source-resorurces/';</script>
2021 R Conferences
https://rviews.rstudio.com/2021/03/03/2021-r-conferences/
Wed, 03 Mar 2021 00:00:00 +0000https://rviews.rstudio.com/2021/03/03/2021-r-conferences/
<p><img src="conf2021.png" height = "400" width="100%"></p>
<p>It is not yet clear what lasting impact the Covid-19 pandemic will ultimately have on R conferences. We are still adapting to our inability to attend large events, and trying to make the best of the “silver lining” of virtual events which permit worldwide participation. The following is an attempt to list 2021 conferences that are likely to have interesting R content. I suspect that it is incomplete. If you know of an R Conference that is not mentioned, please add it to the comments section for this post.</p>
<h3 id="upcoming-events">Upcoming Events</h3>
<p><a href="https://www.ire.org/training/conferences/nicar-2021/">NICAR 2021</a> (March 3 - 5), the Investigative Reporters & Editors Conference on data journalism should be well attended by data journalists using R for their everyday reporting.</p>
<p><a href="https://cascadiarconf.com/">CascadiaRConf 2021</a> (June 4 - 5), a jewel of a regional R conference for its first three years, was canceled in 2020. It is back this year as a virtual event. The <a href="https://cascadiarconf.com/speakers/">Call for Presentations</a> is open.</p>
<p><a href="https://www.phuse-events.org/attend/frontend/reg/thome.csp?pageID=2283&eventID=6&traceRedir=2">PHUSE US Connect 2021</a> (June 14 - 18) - PHUSE is a non-profit organization with the mission: “Sharing ideas, tools and standards around data, statistical and reporting technologies to advance the future of life sciences.” The conference which is focused on clinical data science is likely to have some interesting R content this year. The <a href="https://mail.google.com/mail/u/0/#inbox/FMfcgxwLsmclTmvczLGxMrVptgJlVrhW">Call for Papers</a> is open.</p>
<p><a href="https://psiweb.org/conferences/about-the-conference">PSI 2021 Online</a> (June 21 - 23) usually attracts six hundred or so statisticians from the pharmaceutical industry when the conference is held in person. <a href="https://www.psiweb.org/">PSI</a> statisticians bring you <a href="https://rviews.rstudio.com/2021/01/11/wonderful-wednesdays/">Wonderful Wednesdays</a>.</p>
<p><a href="https://user2021.r-project.org/">useR! 2021</a> (July 5 - 9) has an outstanding lineup of <a href="https://user2021.r-project.org/program/keynotes/">keynote speakers</a>. The <a href="https://user2021.r-project.org/program/overview/">program</a> is very likely to make US based attendees night-owls.</p>
<p><a href="https://bioc2021.bioconductor.org/">BioC 2021</a> (August 4 - 6) is the must attend event for anyone doing computational biology. Peruse the <a href="https://bioc2021.bioconductor.org/conferences/">slides</a> of past events to get a “rear view preview” of what to expect.</p>
<p><a href="https://ww2.amstat.org/meetings/jsm/2021/">JSM 2021</a> Seattle (August 7 - 12), the mother of all statistics conferences, usually draws between 4,000 and 6,000 statisticians to in-person events. This organizers appear to be following some pretty optimistic Covid-19 vaccination rate models.</p>
<p><a href="https://events.linuxfoundation.org/r-medicine/">R/Medicine 2021</a> (August 27 - 29) has the dates, but no website yet. Don’t worry, the clinicians are big come from behind organizers. <a href="https://rviews.rstudio.com/2020/09/16/some-thoughts-on-r-medicine-2020/">Last year’s</a> conference was outstanding, and I expect an amazing event again this year.</p>
<p><a href="https://rinpharma.com/">R/Pharma 2021</a> organizers like to give R / Medicine organizers a head start, but a well placed source tells me that the conference will take place in Q3 or Q4. For the past three years, <a href="https://rviews.rstudio.com/2018/10/03/some-thoughts-on-r-pharma-2018/">R/Pharma</a> has been a bright star among R conferences where some of the best Shiny developers in the world meet and discuss their work.</p>
<p><a href="https://info.mango-solutions.com/earl-2021#:~:text=EARL%202021%206%2D10th%20September,of%20the%20world%27s%20leading%20practitioners">EARL Conference 2021</a> (September 6 - 10), the premier R in industry event, will be online this year. The call for abstracts is already open.</p>
<p><a href="https://rstats.ai/">NY R Conference 2021</a> is usually the perfect way to spend a couple of Manhattan Spring days. This year, the organizers are hoping for and in-person event in August or September if things go really well, but planning to surpass their spectacular 2020 virtual event if things don’t.</p>
<p><a href="https://ww2.amstat.org/meetings/biop/2021/workshopinfo.cfm">BIOP 2021</a> Rockville, MD (September 21 - 23) may be an in-person event. This workshop was originally an event for FDA statisticians but is now open to all statisticians interested in statistical practices for all areas regulated by the FDA.</p>
<p><a href="https://rnorthconference.github.io/">noRth 2021</a> (September 29 30) is a regional conference out of the “Twin Cities” that is looking to virtually expand their reach within the R Community. Gabriela de Queiroz heads the list of confirmed speakers which includes new faces from IBM, Google, and the Federal Reserve.</p>
<p><a href="https://2021.foss4g.org/">Foss4g for OSGEO</a> Buenos Aires (September 27 - October 2) is the annual conference of <a href="https://www.osgeo.org/">OSGeo</a>, the Open Source Geospatial Foundation. Given the prominence of R in geospatial analysis this is sure to be an R heavy event. The conference will be online.</p>
<p><a href="https://www.linkedin.com/in/gabrieladequeiroz/">PHUSE EU Connect 21</a> (November 15 - 19) See above.</p>
<p><a href="https://rstats.ai/">R Government</a> has a reasonable chance of pulling off an in-person event (at least for people in the DC area) sometime in December if the region gets a break from Covid.</p>
<h3 id="earlier-events">Earlier Events</h3>
<p><a href="https://rstudio.com/resources/rstudioglobal-2021/">rstudio::global</a> (January 21) - The <a href="https://rviews.rstudio.com/2021/02/04/some-thoughts-on-rstudio-global/">talks</a> from this unique 24 hour, worldwide event are on line.</p>
<p><a href="https://www.eshackathon.org/events/2021-01-ESMAR.html">Evidence Synthesis and Meta-Analysis in R</a> - The talks from this conference and hackathon which attracted 514 participants from 26 countries are online <a href="https://www.youtube.com/channel/UCqoKd8CCBInvyDMqeqGs0YQ">here</a>.</p>
<script>window.location.href='https://rviews.rstudio.com/2021/03/03/2021-r-conferences/';</script>
January 2020: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2021/02/24/january-2020-top-40-new-cran-packages/
Wed, 24 Feb 2021 00:00:00 +0000https://rviews.rstudio.com/2021/02/24/january-2020-top-40-new-cran-packages/
<p>Two hundred thirty new packages made it to CRAN in January. Here are my “Top 40” selections in ten categories: Data, Finance, Genomics, Machine Learning, Medicine, Science, Statistics, Time Series, Utilities, and Visualization.</p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=igoR">igoR</a> v0.1.1: Provides tools to extract information from the Intergovernmental Organizations (‘IGO’) Database , version 3, provided by the <a href="https://correlatesofwar.org/">Correlates of War Project</a>. See <a href="https://correlatesofwar.org/">Pevehouse et al. (2020)</a> for information from 1815 to 2014, and get started with the <a href="https://cran.r-project.org/web/packages/igoR/vignettes/igoR.html">vignette</a>.</p>
<p><img src="igoR.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=OTrecod">OTrecord</a> v0.1.0: Uses optimal transportation theory as described in <a href="https://www.degruyter.com/document/doi/10.1515/ijb-2018-0106/html">Gares, Guernec & Savy (2019)</a> and <a href="https://www.tandfonline.com/doi/abs/10.1080/01621459.2020.1775615?journalCode=uasa20">Gares & Omer (2020)</a> to solve recoding problems. Given two databases that share a subset of variables, package functions assist users in obtaining a unique synthetic database with complete information. See the <a href="https://cran.r-project.org/web/packages/OTrecod/vignettes/an-application-of-the-OTrecod-package.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=pwt10">pwt10</a> v10.0-0: Interfaces to the <a href="http://www.ggdc.net/pwt/">Penn World Table 10.x</a> which provides information on relative levels of income, output, input, and productivity for 183 countries between 1950 and 2019.</p>
<p><a href="https://cran.r-project.org/package=trainR">trainR</a> v0.0.1: Interfaces to the the <a href="https://www.nationalrail.co.uk/46391.aspx">National Rail Enquiries</a> systems, including Darwin which provides real-time arrival and departure predictions, platform numbers, delay estimates, schedule changes and cancellations. Look <a href="https://villegar.github.io/trainR/">here</a> for examples.</p>
<h3 id="finance">Finance</h3>
<p><a href="https://cran.r-project.org/package=LSMRealOptions">LSMRealOptions</a> v0.1.0: Provides an implementation of the <a href="https://academic.oup.com/rfs/article-abstract/14/1/113/1587472?redirectedFrom=fulltext">least-squares Monte Carlo</a> simulation method to value American option products and capital investment projects through real options analysis. Cash flows are modeled as being dependent upon underlying state variables that evolve stochastically. See the <a href="https://cran.r-project.org/web/packages/LSMRealOptions/vignettes/LSMRealOptions.html">vignette</a> for examples.</p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=AlleleShift">AlleleShift</a> v0.9-2: Provides methods for calibrating and predicting shifts in allele frequencies through redundancy analysis (<code>vegan::rda()</code>) and generalized additive models (<code>mgcv::gam()</code>) and functions to visualize the predicted changes in frequencies. See <a href="https://cran.r-project.org/web/packages/AlleleShift/readme/README.html">README</a> for examples.</p>
<p><img src="AlleleShift.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=GenomeAdmixR">GenomeAdmixR</a> v1.1.3: Provides tools to simulate how patterns in ancestry along the genome change after admixture. Se <a href="https://www.biorxiv.org/content/10.1101/2020.10.19.343491v1">Janzen (2020)</a> for the details and the vignettes <a href="https://cran.r-project.org/web/packages/GenomeAdmixR/vignettes/Demonstrate_isofemales.html">Isofemales</a>, <a href="https://cran.r-project.org/web/packages/GenomeAdmixR/vignettes/Joyplots.html">Joyplot</a>, <a href="https://cran.r-project.org/web/packages/GenomeAdmixR/vignettes/Visualization.html">Visualization</a>, and <a href="https://cran.r-project.org/web/packages/GenomeAdmixR/vignettes/Walkthrough.html">Walkthrough</a>.</p>
<p><img src="GenomeAdmixR.svg" height = "400" width="300"></p>
<p><a href="https://cran.r-project.org/package=MOSS">MOSS</a> v0.1.0: Implements an omics integration method based on sparse singular value decomposition to deal with the challenges of high dimensionality, noise and heterogeneity among samples and features in omics data. See <a href="https://www.nature.com/articles/s41598-020-65119-5">(Gonzalez-Reymundez & Vazquez, 2020)</a> for background and the <a href="https://cran.r-project.org/web/packages/MOSS/vignettes/MOSS_working_example.pdf">vignette</a> for examples.</p>
<p><img src="MOSS.png" height = "300" width="300"></p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=autoMrP">autoMrP</a> v0.98: Implements a tool that improves the prediction performance of multilevel regression with post-stratification (MrP) by combining a number of machine learning methods. For information on the method, refer to <a href="https://lucasleemann.files.wordpress.com/2020/07/automrp-r2pa.pdf">Broniecki, Wüest, Leemann (2020)</a> and the <a href="https://cran.r-project.org/web/packages/autoMrP/vignettes/autoMrP_vignette.pdf">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=aweSOM">aweSOM</a> v1.1: Implements Self-organizing maps, a method for dimensionality reduction and clustering of continuous data, as well as interactive graphics to assist analysis. See <a href="https://link.springer.com/book/10.1007%2F978-3-642-56927-2">Kohonen (2001)</a> for background and the <a href="https://cran.r-project.org/web/packages/aweSOM/vignettes/aweSOM.html">vignette</a> for an overview of the package.</p>
<p><img src="aweSOM.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=RandomForestsGLS">RandomForestsGLS</a> v0.1.2: Fits non-linear generalized least square regression models with Random Forests as described in <a href="https://arxiv.org/abs/2007.15421">Saha, Basu & Datta (2020)</a>.</p>
<p><img src="rf.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=torchaudio">torchaudio</a> v0.1.1.0: Provides access to datasets, models and preprocessing facilities for deep learning in audio. See the <a href="https://cran.r-project.org/web/packages/torchaudio/vignettes/audio_preprocessing_tutorial.html">vignette</a>.</p>
<p><img src="torchaudio.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=vimpclust">vimpclust</a> v0.1.0: Implements functions to perform sparse k-means clustering with a group penalty and variable selection on mixed categorical and numeric data. See <a href="https://www.esann.org/sites/default/files/proceedings/2020/ES2020-103.pdf">Chavet et al. (2020)</a> for background. There are vignettes on <a href="https://cran.r-project.org/web/packages/vimpclust/vignettes/groupsparsewkm.html">numeric</a> and <a href="https://cran.r-project.org/web/packages/vimpclust/vignettes/sparsewkm.html">mixed data</a> sparse k-means clustering.</p>
<p><img src="vimpclust.png" height = "200" width="400"></p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=cmprskcoxmsm">cmprskcoxmsm</a> v0.2.0: Provides functions to estimate treatment effect a under marginal structure model for the cause-specific hazard of competing risk events. Functions also estimate the risk of the potential outcomes, risk difference and risk ratio. See <a href="https://www.tandfonline.com/doi/abs/10.1198/016214501753168154">Hernan et al. (2001)</a> for the theory and the <a href="https://cran.r-project.org/web/packages/cmprskcoxmsm/vignettes/weight_cause_cox.pdf">vignette</a> for examples.</p>
<p><img src="cmprskcoxmsm.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=coder">coder</a> v0.13.5: Provides functions to classify individuals or items based on external code data identified by regular expressions. A typical use case considers patients with medically coded data, such as codes from the International Classification of Diseases. There is an <a href="https://cran.r-project.org/web/packages/coder/vignettes/coder.html">overview</a> and vignettes on <a href="https://cran.r-project.org/web/packages/coder/vignettes/classcodes.html">class codes</a>, <a href="https://cran.r-project.org/web/packages/coder/vignettes/Interpret_regular_expressions.html">interpreting regular expressions</a>, and <a href="https://cran.r-project.org/web/packages/coder/vignettes/ex_data.html">example data</a>.</p>
<p><img src="coder.png" height = "150" width="350"></p>
<p><a href="https://cran.r-project.org/package=dataquieR">dataQuieR</a> v1.0.4: Provides functions to assess data quality issues in studies. See the <a href="https://www.tmf-ev.de/EnglishSite/Home.aspx">TMF Guideline</a> and the <a href="https://dfg-qa.ship-med.uni-greifswald.de">DFG Project</a> for background, and the <a href="https://cran.r-project.org/web/packages/dataquieR/vignettes/DQ-report-example.html">vignette</a> for examples.</p>
<p><img src="dataQuieR.png" height = "250" width="450"></p>
<p><a href="https://cran.r-project.org/package=NHSDataDictionaRy">NHSDataDictionaRy</a> v1.2.1: Provides a common set of simplified web scraping tools for working with the <a href="https://datadictionary.nhs.uk/data_elements_overview.html">NHS Data Dictionary</a>.This package was commissioned by the <a href="https://nhsrcommunity.com/">NHS-R community</a> to provide this consistency of lookups. See the <a href="https://cran.r-project.org/web/packages/NHSDataDictionaRy/vignettes/introduction.html">vignette</a> to get started.</p>
<h3 id="science">Science</h3>
<p><a href="https://cran.r-project.org/package=LPDynR">LPDynR</a> v1.0.1: Implements methods that use phenological and productivity-related variables derived from time series of vegetation indexes to assess ecosystem dynamics. Functions compute an indicator with five classes of land productivity dynamics. Look <a href="https://github.com/xavi-rp/LPD/blob/master/ATBD/LPD_ATBD.pdf">here</a> for background. See the <a href="https://cran.r-project.org/web/packages/LPDynR/vignettes/LPD_PartialTimeSeries_example.html">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=rgee">rgee</a> v1.0.8: Provides an <a href="https://earthengine.google.com/">Earth Engine</a> client library for R that includes all <code>Earth Engine</code> API classes, modules, and functions, as well as additional functions for importing spatial objects, extracting time series, and displaying metadata and interactive maps. Look <a href="https://r-spatial.github.io/rgee/">here</a> for further details. Read the <a href="https://cran.r-project.org/web/packages/rgee/vignettes/rgee01.html">Introduction</a> and the vignette on <a href="https://cran.r-project.org/web/packages/rgee/vignettes/rgee03.html">Best Practices</a> to get started.</p>
<p><img src="rgee.png" height = "250" width="450"></p>
<p><a href="https://cran.r-project.org/package=SAMtool">SAMtool</a> v1.1.1: Provides tools for simulating the <code>MSEtool</code> operating model to inform data-rich fisheries. It includes a conditioning model, tools for assessing models of varying complexity and comparing models, and diagnostic tools for evaluating assessments inside closed-loop simulations. There is a <a href="https://cran.r-project.org/web/packages/SAMtool/vignettes/SAMtool.html">User Guide</a> and a series of seven more vignettes including an <a href="https://cran.r-project.org/web/packages/SAMtool/vignettes/RCM.html">overview</a> of the Rapid Conditioning Model (RCM) for conditioning <code>MSEtool</code> operating models, and a <a href="https://cran.r-project.org/web/packages/SAMtool/vignettes/RCM_eq.html">mathematical description</a> of RCM.</p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=circularEV">circularEV</a> v0.1.0: Provides functions for performing extreme value analysis on a circular domain. See the <a href="https://cran.r-project.org/web/packages/circularEV/vignettes/localMethods.html">local methods example</a> and the <a href="https://cran.r-project.org/web/packages/circularEV/vignettes/splineML.html">spline example</a>.</p>
<p><img src="circularEV.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=ghcm">ghcm</a> v1.0.0: Implements a statistical hypothesis test for conditional independence which can be applied to both discretely observed functional data and multivariate data. See <a href="https://arxiv.org/abs/2101.07108">Lundborg et al. (2020)</a> for details and the <a href="https://cran.r-project.org/web/packages/ghcm/vignettes/ghcm.html">vignette</a> for an overview of the generalized Hilbert Covariance measure with examples.</p>
<p><img src="ghcm.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=gplite">gplite</a> v0.11.1: Implements the most common Gaussian process models using Laplace and expectation propagation approximations, maximum marginal likelihood inference for the hyperparameters, and sparse approximations for larger datasets. See the <a href="https://cran.r-project.org/web/packages/gplite/vignettes/quickstart.html">vignette</a> for a quick start.</p>
<p><img src="gplite.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=multibridge">multibridge</a> v1.0.0: Implements functions to evaluate hypotheses concerning the distribution of multinomial proportions using bridge sampling. Functions are able to compute Bayes factors for hypotheses that entail inequality constraints, equality constraints, free parameters, and mixtures of all three. See <a href="https://psyarxiv.com/bux7p/">Sarafoglou et al. (2020)</a> for background and the examples: <a href="https://cran.r-project.org/web/packages/multibridge/vignettes/MemoryOfLifestresses.html">Memory of Lifestresses</a>, <a href="https://cran.r-project.org/web/packages/multibridge/vignettes/MendelianLawsOfInheritance.html">Mendelian Laws of Inheritance</a>, and <a href="https://cran.r-project.org/web/packages/multibridge/vignettes/PrevalenceOfStatisticalReportingErrors.html">Prevalence of Statistical Reporting Errors</a>.</p>
<p><a href="https://cran.r-project.org/package=partR2">partR2</a> v0.9.1: Provides functions to to partition the variance explained in generalized linear mixed models (GLMMs) into variation unique to predicators and variation shared among predictors. This can be done using semi-partial <em>R<sup>2</sup></em> and inclusive <em>R<sup>2</sup></em>. See <a href="https://besjournals.onlinelibrary.wiley.com/doi/full/10.1111/j.2041-210x.2012.00261.x">Nakagawa & Schielzeth (2013)</a> and <a href="https://royalsocietypublishing.org/doi/10.1098/rsif.2017.0213">Nakagawa, Johnson & Schielzeth (2017)</a> for the theory and the <a href="https://cran.r-project.org/web/packages/partR2/vignettes/Using_partR2.html">vignette</a> for examples.</p>
<p><img src="partR2.jpeg" height = "350" width="500"></p>
<p><a href="https://cran.r-project.org/package=spNetwork">spNetwork</a> v0.1.1: Provides tools to perform spatial analysis on network including estimating network kernel density, building spatial matrices. See <a href="https://www.tandfonline.com/doi/abs/10.1080/13658810802475491?journalCode=tgis20">Okabe et al. (2019)</a> for background and the vignettes: <a href="https://cran.r-project.org/web/packages/spNetwork/vignettes/KNetworkFunctions.html">Network k Functions</a>, <a href="https://cran.r-project.org/web/packages/spNetwork/vignettes/NKDE.html">Network Kernel Density Estimate</a>,
<a href="https://cran.r-project.org/web/packages/spNetwork/vignettes/NKDEdetailed.html">Details about NKDE</a>, and <a href="https://cran.r-project.org/web/packages/spNetwork/vignettes/SpatialWeightMatrices.html">Spatial Weight Matrices</a>.</p>
<p><img src="spNetwork.png" height = "300" width="350"></p>
<p><a href="https://cran.r-project.org/package=ubms">ubms</a> v1.0.2: Provides functions to fit Bayesian hierarchical models, including single-season occupancy, dynamic occupancy, and N-mixture abundance models, of animal abundance and occurrence with the <code>rstan</code> package. See <a href="https://www.jstatsoft.org/article/view/v076i01">Carpenter et al. (2017)</a> and <a href="https://www.jstatsoft.org/article/view/v043i10">Fiske and Chandler (2011)</a> for background. There is a package <a href="https://cran.r-project.org/web/packages/ubms/vignettes/ubms.html">Overview</a>, a vignette on <a href="https://cran.r-project.org/web/packages/ubms/vignettes/random-effects.html">Random Effects</a>, and another on <a href="https://cran.r-project.org/web/packages/ubms/vignettes/JAGS-comparison.html">Comparing ubms with JAGS</a>.</p>
<p><img src="ubms.png" height = "200" width="400"></p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=autostsm">autostsm</a> v1.2: Provides functions to automate the decomposition of structural time series into trend, cycle, and seasonal components using the Kalman filter. See <a href="https://www.oxfordhandbooks.com/view/10.1093/oxfordhb/9780195398649.001.0001/oxfordhb-9780195398649-e-6">Koopman et al. (2012)</a> for the theory and the <a href="https://cran.r-project.org/web/packages/autostsm/vignettes/autostsm_vignette.html">vignette</a> for an overview with examples.</p>
<p><a href="https://cran.r-project.org/package=bayesforecast">bayesforecast</a> v0.0.1: Provides functions to fit Bayesian time series models using <code>Stan</code> for full Bayesian inference. It includes seasonal ARIMA, ARIMAX, dynamic harmonic regression, GARCH, t-student innovation GARCH models, asymmetric GARCH, random walks, stochastic volatility models for univariate time series. See <a href="https://www.jstatsoft.org/article/view/v027i03">Hyndman (2017)</a> and <a href="https://www.jstatsoft.org/article/view/v076i01">Carpenter et al. (2017)</a> for background and <a href="https://cran.r-project.org/web/packages/bayesforecast/readme/README.html">README</a> for examples.</p>
<p><img src="bayesforecast.png" height = "450" width="500"></p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=autoharp">autoharp</a> v0.0.5: Implements customizable tools for assessing and grading R or R-markdown scripts from students which allow for checking correctness of code output, runtime statistics and static code analysis. There is a <a href="https://cran.r-project.org/web/packages/autoharp/vignettes/user-manual.html">User Manual</a> and a vignettes on the S4 class <a href="https://cran.r-project.org/web/packages/autoharp/vignettes/treeharp.html">treeharp</a>.</p>
<p><img src="autoharp.png" height = "200" width="400"></p>
<p><a href="https://cran.r-project.org/package=cachem">cachem</a> v1.0.4: Provides functions to cache R objects with automated pruning. Caches can limit either their total size or the age of the oldest object (or both), automatically pruning objects to maintain the constraints. See <a href="https://cran.r-project.org/web/packages/cachem/readme/README.html">README</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=eList">eList</a> v0.2.0: Provides list compression functions to convert for loops into vectorized <code>lapply()</code> functions which support loops with multiple variables, parallelization, and loops across non-standard objects. See the <a href="https://cran.r-project.org/web/packages/eList/vignettes/VectorComprehension.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=Microsoft365R">Microsoft365R</a> v1.0.0: Builds on <code>AzureGraph</code> to implement and interface to <a href="https://www.microsoft.com/en-us/microsoft-365">Microsoft365</a> and enables access to data stored in SharePoint Online and OneDrive. See the <a href="https://cran.r-project.org/web/packages/Microsoft365R/vignettes/Microsoft365R.html">vignette</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=rtables">rtables</a> v0.3.6: Provides a framework for declaring complex multi-level tabulations and then applying them to data. Tables are modeled as hierarchical, tree-like objects which support sibling sub-tables, arbitrary splitting or grouping of data in row and column dimensions, cells containing multiple values, and the concept of contextual summary computations. There is a <a href="https://cran.r-project.org/web/packages/rtables/vignettes/introduction.html">Introduction</a> and a series of vignettes on <a href="https://cran.r-project.org/web/packages/rtables/vignettes/baseline.html">comparing</a> against baseline or control, a clinical trials <a href="https://cran.r-project.org/web/packages/rtables/vignettes/clinical_trials.html">example</a>, constructing tables <a href="https://cran.r-project.org/web/packages/rtables/vignettes/manual_table_construction.html">manually</a>, <a href="https://cran.r-project.org/web/packages/rtables/vignettes/sorting_pruning.html">pruning and sorting</a>
tables, <a href="https://cran.r-project.org/web/packages/rtables/vignettes/subsetting_tables.html">subsetting</a> tables, <a href="https://cran.r-project.org/web/packages/rtables/vignettes/tabulation_concepts.html">Tabulation concepts</a>, and a <a href="https://cran.r-project.org/web/packages/rtables/vignettes/tabulation_dplyr.html">comparison with dplyr</a> tabulation.</p>
<p><img src="rtables.png" height = "250" width="450"></p>
<p><a href="https://CRAN.R-project.org/package=targets">targets</a> v0.1.0: Brings together function-oriented programming and <code>make</code>- like declarative workflows in toolkit for building statistics and data science pipelines in R. The methodology borrows from <a href="https://www.gnu.org/software/make/manual/make.html">GNU make</a> and <a href="https://joss.theoj.org/papers/10.21105/joss.00550">drake</a>. See the <a href="https://cran.r-project.org/web/packages/targets/vignettes/overview.html">vignette</a> and the <a href="https://docs.ropensci.org/targets/">reference website</a>.</p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=ggmulti">ggmulti</a> v0.1.0: Provides tools such as serial axes objects, Andrew’s plot, various scatter plot glyphs to visualize high dimensional data. There are vignettes on visualizing <a href="https://cran.r-project.org/web/packages/ggmulti/vignettes/highDim.html">high dimensional data</a>, <a href="https://cran.r-project.org/web/packages/ggmulti/vignettes/glyph.html">adding glyphs to scatter plots</a>, and creating <a href="https://cran.r-project.org/web/packages/ggmulti/vignettes/histogram-density-.html">histograms with density</a>.</p>
<p><img src="ggmulti.png" height = "500" width="500"></p>
<p><a href="https://cran.r-project.org/package=ggOceanMaps">ggOceanMaps</a> v1.0.9: Allows plotting data on bathymetric maps using <code>ggplot2</code> using data that contain geographic information from anywhere around the globe. There is a <a href="https://cran.r-project.org/web/packages/ggOceanMaps/vignettes/ggOceanMaps.html">User Manual</a> and a <a href="https://cran.r-project.org/web/packages/ggOceanMaps/vignettes/premade-shapefiles.html">vignette</a> on pre-made shape files.</p>
<p><img src="ggOceanMaps.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=pacviz">pacviz</a> v1.0.0.5: Provides functions to map data onto a radial coordinate system and visualize the residual values of linear regression and Cartesian data in the defined radial scheme. See the <a href="https://spencerriley.me/pacviz/book/">pacviz documentation</a> for more information.</p>
<p><img src="pacviz.png" height = "400" width="400"></p>
<p><a href="https://cran.r-project.org/package=parallelPlot">parallelPlot</a> v0.1.0: Provides functions to create parallel coordinates plots using the <code>htmlwidgets</code> package and <code>d3.js</code>. The <a href="https://cran.r-project.org/web/packages/parallelPlot/vignettes/introduction-to-parallelplot.html">vignette</a> provides multiple examples.</p>
<p><img src="parallelPlot.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=thematic">thematic</a> v0.1.1: Provides tools to “theme” <code>ggplot2</code>, <code>lattice</code>, and <code>base</code> graphics using a small set of choices that include foreground color, background color, accent color, and font family. See <a href="https://cran.r-project.org/web/packages/thematic/readme/README.html">README</a> for examples.</p>
<p><img src="theme.png" height = "200" width="400"></p>
<script>window.location.href='https://rviews.rstudio.com/2021/02/24/january-2020-top-40-new-cran-packages/';</script>
R Interface for MiniZinc
https://rviews.rstudio.com/2021/02/15/r-interface-for-minizinc/
Mon, 15 Feb 2021 00:00:00 +0000https://rviews.rstudio.com/2021/02/15/r-interface-for-minizinc/
<script src="/2021/02/15/r-interface-for-minizinc/index_files/header-attrs/header-attrs.js"></script>
<p><em>Akshit Achara is a medical device engineer and computer science enthusiast based in Bengaluru, Karnataka, India. You can connect with Akshit on <a href="https://in.linkedin.com/in/akshit-achara-737589163">LinkedIn</a>.</em></p>
<div id="introduction" class="section level2">
<h2>Introduction</h2>
<p><a href="https://en.wikipedia.org/wiki/Constraint_programming">Constraint programming</a> is a paradigm for solving combinatorial problems that draws on a wide range of techniques from artificial intelligence, computer science, and operations research. <a href="https://www.minizinc.org/">MiniZinc</a> is a free and open-source constraint modeling language. <a href="https://en.wikipedia.org/wiki/Constraint_satisfaction">Constraint satisfaction</a> and <a href="https://en.wikipedia.org/wiki/Discrete_optimization">discrete optimization</a> problems can be formulated in a high-level modeling language. Models are compiled into an intermediate representation that is understood by a <a href="https://www.minizinc.org/software.html#flatzinc">wide range of solvers</a>. MiniZinc itself provides several solvers, for instance GeCode. The existing packages in R are not powerful enough to solve even mid-sized problems in combinatorial optimization.</p>
<p>Until recently, there were implementations of an Interface to MiniZinc in Python like MiniZinc Python and pymzn and JMiniZinc for Java but none for R.</p>
</div>
<div id="rminizinc-as-a-gsoc-project" class="section level2">
<h2>rminizinc as a GSOC project</h2>
<p><a href="https://cran.r-project.org/web/packages/rminizinc/index.html">rminizinc</a> started as a <a href="https://summerofcode.withgoogle.com/archive/2020/projects/6235019934171136/">Google Summer of Code Project</a> in 2020. Initially, the goal was to provide infrastructure/support for creating 15-20 commonly used MiniZinc problems by creating classes and functions for providing the basic syntax/constructs used in those MiniZinc models. However, it was decided that the libminizinc (MiniZinc C++ API) library can be leveraged using Rcpp for parsing various MiniZinc models and a mirror API can be created to construct the MiniZinc models. Using the library helped me in understanding MiniZinc more which in turn also helped to to provide more features and test the package on larger problems. The following objectives were achieved at the end of the GSOC period:</p>
<ul>
<li>Parse a MiniZinc model into R.</li>
<li>Find the model parameters which have not been assigned a value yet.</li>
<li>Set the values of unassigned parameters. (Scope needs to be extended)</li>
<li>Solve a model and get parsed solutions as a named list in R.</li>
<li>Create a MiniZinc model in R using the R6 classes from MiniZinc API mirror.</li>
<li>Manipulate a model.</li>
</ul>
<p>The development continued till the end of GSOC but the package was not yet submitted to CRAN.</p>
</div>
<div id="post-gsoc" class="section level2">
<h2>Post GSOC</h2>
<p>The package submission to CRAN was very challenging. <a href="https://github.com/MiniZinc/libminizinc">Libminizinc</a> and solver binaries were required in order to use the package because the Rcpp functions were using them to parse and solve the models. To tackle this, we leveraged the <a href="https://opensource.com/article/19/7/introduction-gnu-autotools">autotools</a> to create a configure script for letting the users provide custom paths and configure the package during the installation, used #ifdef macros to provide alternative definitions in case libminizinc and/or solvers are not present on the system.</p>
</div>
<div id="examples" class="section level2">
<h2>Examples</h2>
<p>There are a lot of features provided by the package but let’s start with something simple say solving a knapsack problem. Knapsack problem is known by everyone who has interest in constraint programming. The knapsack problem is a problem in combinatorial optimization: Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. It derives its name from the problem faced by someone who is constrained by a fixed-size knapsack and must fill it with the most valuable items. The problem often arises in resource allocation where the decision makers have to choose from a set of non-divisible projects or tasks under a fixed budget or time constraint, respectively.</p>
<p>The <code>knapsack()</code> function can be used to directly solve the knapsack problem. Here, <code>n</code> is the number of items, <code>capacity</code> is the total capacity of carrying weight, <code>profit</code> is the profit corresponding to each item and <code>weight</code> is the weight/size of each item. The goal is to maximize the total profit. The solution is returned in the form of a named list with all the solutions along with the optimal solution if found.</p>
<p>Please find the installation instructions in the <a href="https://cran.r-project.org/web/packages/rminizinc/vignettes/R_MiniZinc.html">vignette</a> or the <a href="https://github.com/acharaakshit/RMiniZinc">github readme</a>.</p>
<pre class="r"><code>library(rminizinc)
# knapsack problem
print(knapsack(n = 3, capacity = 9, profit = c(15,10,7), size = c(4,3,2)))</code></pre>
<pre><code>$SOLUTION0
$SOLUTION0$x
[1] 0 0 0
$SOLUTION1
$SOLUTION1$x
[1] 0 0 1
$SOLUTION2
$SOLUTION2$x
[1] 0 0 2
$SOLUTION3
$SOLUTION3$x
[1] 0 0 3
$SOLUTION4
$SOLUTION4$x
[1] 0 0 4
$SOLUTION5
$SOLUTION5$x
[1] 0 1 3
$OPTIMAL_SOLUTION
$OPTIMAL_SOLUTION$x
[1] 1 1 1
</code></pre>
<p>A function to solve the assignment problem has also been provided. More common examples will be provided in the next package releases based on the user feedback. This will especially be useful for the users who don’t have any knowledge of MiniZinc.</p>
<p>Basic knowledge of MiniZinc is required in order to understand the next examples. <a href="https://www.minizinc.org/doc-2.5.3/en/part_2_tutorial.html">MiniZinc tutorial</a> would be a good place to start.</p>
<p>The users can also create a MiniZinc model using the API. Let’s compute the base of a right angled triangle given the height and hypotenuse. The Pythagoras theorem says that In a right-angled triangle, the square of the hypotenuse side is equal to the sum of squares of the other two sides i.e <span class="math inline">\(a² + b² = c²\)</span>. The theorem give us three functions, <span class="math inline">\(c = \sqrt{(a² + b²)}\)</span>, <span class="math inline">\(a = \sqrt(c² - b²)\)</span> and <span class="math inline">\(b = \sqrt(c² - a²)\)</span>.</p>
<p>MiniZinc Representation of the model:</p>
<pre><code>int: a = 4;
int: c = 5;
var int: b;
constraint b>0;
constraint a² + b² = c²;
solve satisfy;</code></pre>
<p>Let’s create and solve the model using rminizinc.</p>
<pre class="r"><code>a = IntDecl(name = "a", kind = "par", value = 4)
c = IntDecl(name = "c", kind = "par", value = 5)
b = IntDecl(name = "b", kind = "var")
# declaration items
a_item = VarDeclItem$new(decl = a)
b_item = VarDeclItem$new(decl = b)
c_item = VarDeclItem$new(decl = c)
# b > 0 is a binary operation
b_0 = BinOp$new(lhs = b$getId(), binop = ">", rhs = Int$new(0))
constraint1 = ConstraintItem$new(e = b_0)
# a ^ 2 is a binary operation
# a$getId() gives the variable identifier
a_2 = BinOp$new(lhs = a$getId(), binop = "^", Int$new(2))
b_2 = BinOp$new(lhs = b$getId(), binop = "^", Int$new(2))
a2_b2 = BinOp$new(lhs = a_2, binop = "+", rhs = b_2)
c_2 = BinOp$new(lhs = c$getId(), binop = "^", Int$new(2))
a2_b2_c2 = BinOp$new(lhs = a2_b2, binop = "=", rhs = c_2)
constraint2 = ConstraintItem$new(e = a2_b2_c2)
solve = SolveItem$new(solve_type = "satisfy")
model = Model$new(items = c(a_item, b_item, c_item, constraint1, constraint2, solve))
cat(model$mzn_string())</code></pre>
<pre><code>int: a;
var int: b;
int: c;
constraint (b > 0);
constraint (((a ^ 2) + (b ^ 2)) = (c ^ 2));
solve satisfy;
</code></pre>
<p>Creating the model required a lot of code which is more cumbersome that writing the model in MiniZinc itself. However, that was to give the users a taste of various classes that can be used to create items and expressions. This will especially be useful in modifying an existing model.</p>
<p>The items can directly be provided as strings.</p>
<pre class="r"><code>a = VarDeclItem$new(mzn_str = "int: a = 4;")
c = VarDeclItem$new(mzn_str = "int: c = 5;")
b = VarDeclItem$new(mzn_str = "var int: b;")
constraint1 = ConstraintItem$new(mzn_str = "constraint b > 0;")
constraint2 = ConstraintItem$new(mzn_str = "constraint a^2 + b^2 = c^2;")
solve = SolveItem$new(mzn_str = "solve satisfy;")
model = Model$new(items = c(a, b, c, constraint1, constraint2, solve))
cat(model$mzn_string())</code></pre>
<pre><code>int: a = 4;
var int: b;
int: c = 5;
constraint (b > 0);
constraint (((a ^ 2) + (b ^ 2)) = (c ^ 2));
solve satisfy;</code></pre>
<p>The model can directly be parsed by providing the string representation as the argument to <code>mzn_parse()</code>. This method uses libminizinc to parse the model. The included mzn files are appearing because the parsed model is serialized back by libminizinc.</p>
<pre class="r"><code>pythagoras_string =
" int: a = 4;
int: c = 5;
var int: b;
constraint b > 0;
constraint a^2 + b^2 = c^2;
solve satisfy;
"
model = mzn_parse(model_string = pythagoras_string)
cat(model$mzn_string())</code></pre>
<pre><code>int: a = 4;
int: c = 5;
var int: b;
constraint (b > 0);
constraint (((a ^ 2) + (b ^ 2)) = (c ^ 2));
solve satisfy;
include "solver_redefinitions.mzn";
include "stdlib.mzn";</code></pre>
<p>Let’s solve the model now.</p>
<pre class="r"><code>solution = mzn_eval(r_model = model)
print(solution)</code></pre>
<pre><code>$SOLUTION_STRING
[1] "{\n \"b\" : 3\n}\n----------\n==========\n"
$SOLUTIONS
$SOLUTIONS$OPTIMAL_SOLUTION
$SOLUTIONS$OPTIMAL_SOLUTION$b
[1] 3</code></pre>
<p>In the next post, we will try another problem and/or use some other features of rminizinc. Please <a href="acharaakshit@gmail.com">let me know</a> what you think.</p>
</div>
<script>window.location.href='https://rviews.rstudio.com/2021/02/15/r-interface-for-minizinc/';</script>
Some thoughts on rstudio::global talks
https://rviews.rstudio.com/2021/02/04/some-thoughts-on-rstudio-global/
Thu, 04 Feb 2021 00:00:00 +0000https://rviews.rstudio.com/2021/02/04/some-thoughts-on-rstudio-global/
<p><img src="global.png" height = "400" width="100%"></p>
<p>The fifty-five <a href="https://rstudio.com/resources/rstudioglobal-2021/">videos</a> from last month’s rstudio::global conference are now available online. You will find them at the link above arranged in ten categories (Keynotes, Data for Good, Language Interop, Learning, Modeling, Organizational Tooling, Package Dev, Programming, Teaching, and Visualization) that reflect fundamental areas of technical and community infrastructure and R applications. Theses talks were selected from hundreds of submissions, many of which were really very good. I participated in the first selection round and found it impossible to make some choices, so I am certain that it must have been agonizingly difficult for the program committee to pare down to the final selections.</p>
<p>I believe that you will find the content of most of these talks to be nothing less than compelling. The themes and moods of the talks range from informative and deeply technical R issues to data science, journalism, art, education and public service. A few talks transcend the parochial concerns of the R community and address issues that are important to society at large. It is gratifying to see that in the hands of committed people R is helping to make the world just a little bit better. The videos themselves are high quality and a pleasure to watch. Unlike typical conference videos recorded in real time, all of these were produced with excellent lighting, good audio, and were rehearsed, pre-recorded, and edited. Except for the keynotes, the talks are shorter than twenty minutes.</p>
<p>In the remainder of this post, I will highlight just five talks that I personally found compelling. I have arranged them in an order that I think makes sense to view them. But, you might do just as well to sample talks from the categories listed above that organize the talks on the conference page. My selections do not cover the whole range of topics submitted, and they certainly do not include all of the good stuff. I do think, however, that they reflect the quality of the talks, and I hope that if you watch these five you will be motivated to watch the rest too.</p>
<p><img src="global2.png" height = "400" width="600"></p>
<p>My first three selections are by data journalists who are out to make the world a better place. <a href="https://rstudio.com/resources/rstudioglobal-2021/the-opioid-files-turning-big-pharmacy-data-over-to-the-public/">The Opioid Files: Turning big pharmacy data over to the public</a> by Washington Post data journalist <a href="https://www.washingtonpost.com/people/andrew-ba-tran/">Andrew Ba Tran</a> demonstrates the scale of the opiod scandal. I had the opportunity to meet Andrew at the <a href="https://www.ire.org/training/conferences/nicar-2021/">NICAR conference</a> for Investigative Reporters and Editors in 2019 where he was speaking and teaching R. NICAR opened my eyes to the discipline and tradition of <a href="https://gijn.org/2015/11/12/fifty-years-of-journalism-and-data-a-brief-history/#:~:text=As%20of%202015%2C%20and%20after,a%20driving%20force%20for%20stories.&text=The%20use%20of%20computers%20for,data%20analysis%20to%20societal%20issues.">Data Journalism</a> and the efforts of data journalists to harness technology for the public good. Andrew’s conference talk represents this tradition and illustrates the data crunching skills, persistence, and unvarnished storytelling necessary to illuminate a dark topic.</p>
<p>Next, I recommend watching <a href="https://rstudio.com/resources/rstudioglobal-2021/trial-and-error-in-data-viz-at-the-aclu/">Trial and Error in Data Viz at the ACLU</a>. <a href="http://sophiebeiers.com/about/">Sophie Beiers</a> is a data journalist whose work for the ACLU involves discovering and visualizing data with sufficient rigor and clarity to support arguments that will hold up in court. Sophie describes the messy work of iterating through visualizations in a process built around candid feedback from colleagues and stakeholders. Driving the process is a determination to make charts that effectively communicate key points to the intended audience. Sophie’s talk hints at the emotional toll caused by striving to see the people behind the data, and the satisfaction that comes from making a difference. The ACLU analytics team coined a word for expressing the excitement at being able to prove terrible news with quantitative evidence.</p>
<p><img src="terr.png" height = "350" width="600"></p>
<p>The third talk on my list by
<a href="https://www.ft.com/stream/e191658e-c66a-45bc-9bad-343bdc4210b3">John Burn Murdoch</a> on
<a href="https://rstudio.com/resources/rstudioglobal-2021/reporting-on-and-visualising-the-pandemic/">Reporting on and visualizing the pandemic</a> continues the theme of polishing visualizations until they work for the target audience. John is a data journalist with the Financial Times who has garnered quite a following for producing data visualizations that command attention. John’s talk dives deeply into his process of evolving a visualization until it not only illustrates what he wants to show but also shows that it is resonating with his mass audience.</p>
<p>In thinking about Sophie and John’s work, the Japanese word <a href="https://kbjanderson.com/the-real-meaning-of-kaizen/">kaizen</a> (making something good for the good of other people) comes to mind. There are many R visualization experts who can lay down the basic principles of making a good data visualization, but few I think, that have Sophie and John’s empathy and capacity to listen and process criticism.</p>
<p>The final two talks on my list are by R developers who are concerned with the big picture of sustaining the R package ecosystem. Hadley Wickham’s Keynote
<a href="https://rstudio.com/resources/rstudioglobal-2021/reporting-on-and-visualising-the-pandemic/">Maintaining the house the tidyverse built</a> addresses a fundamental challenge encountered by all complex software projects that develop over time. How do you maintain functional stability while coping with growth and change? Hadley’s solution for the tidyverse encapsulated in the following figure:</p>
<p><img src="tidy.png" height = "400" width="600"></p>
<p>may not be the right solution for all subsystems within the R ecosystem, but surely something like it must evolve to reach into all of the corners of the R Universe. For example, consider the <a href="https://cran.r-project.org/web/views/">CRAN Task Views</a>. When they were assembled, each of these curated lists of R packages represented the cutting edge of software for a particular functional area. The Task View maintainers do a mostly unacknowledged, essential service in keeping these up to date. Nevertheless, it is not difficult to discover Task View packages that have not changed significantly in five or ten years or more. To my knowledge, there are no standards for retiring packages and integrating new work. The future of R depends on systems thinking and the development of new ideas and tools for open source development.</p>
<p>These considerations lead to Jeroen Ooms’ talk:
<a href="https://rstudio.com/resources/rstudioglobal-2021/monitoring-health-and-impact-of-open-source-projects/">Monitoring health and impact of open-source projects</a> which describes how <a href="https://ropensci.org/">ROpenSci</a> is taking on the immense challenge of measuring the quality of R packages according to technical, social and scientific indicators, while building out the infrastructure to improve the entire R package ecosystem. Some of the tools for monitoring the status and “health” of open source software are already in place. ROpenSci is offering <a href="https://r-universe.dev/organizations/">R-universe</a>, a platform based in git for managing personal R repositories. Once a “universe” of packages is registered with R-universe every time an author pushes an update the platform will automatically build binaries and documentation.</p>
<p>Enjoy the videos!!</p>
<script>window.location.href='https://rviews.rstudio.com/2021/02/04/some-thoughts-on-rstudio-global/';</script>
Dec 2020: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2021/01/29/dec-2020-top-40-new-cran-packages/
Fri, 29 Jan 2021 00:00:00 +0000https://rviews.rstudio.com/2021/01/29/dec-2020-top-40-new-cran-packages/
<p>One hundred twenty-three new packages made it to CRAN in December. Here are my “Top 40” selections in nine categories: Computational Methods, Data, Genomics, Machine Learning, Medicine, Science, Statistics, Utilities, and Visualization.</p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=FKF.SP">FKF.SP</a> v0.1.0: Provides a fast and flexible Kalman filtering implementation utilizing sequential processing, designed for efficient parameter estimation through maximum likelihood estimation. See the <a href="https://cran.r-project.org/web/packages/FKF.SP/vignettes/FKFSP.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=rminizinc">rminizinc</a> v0.0.4: Implements an interface to <a href="https://www.minizinc.org/">MiniZinc</a>, a free and open-source constraint modeling language which is used to identify feasible solutions out of a very large set of candidates when the problem can be modeled in terms of arbitrary constraints. See the <a href="https://cran.r-project.org/web/packages/rminizinc/vignettes/R_MiniZinc.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=noisySBM">nosiySBM</a> v0.1.4: Implements the variational expectation-maximization algorithm to fit a noisy stochastic block model to an observed dense graph and to perform node clustering. See <a href="https://arxiv.org/abs/1907.10176">Rebafka & Villers (2020)</a> for background and the <a href="https://cran.r-project.org/web/packages/noisySBM/vignettes/UserGuide.html">vignette</a> to get started.</p>
<p><img src="noisySBM.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=qsimulatR">qsimulatR</a> v1.0: Implements a quantum computer simulator with up to 24 qubits which provides many common gates and allows users to define general single qubit gates and general controlled single qubit gates. The package supports plotting circuits and exporting circuits to <a href="https://qiskit.org/"><code>Qiskit</code></a>, a Python package which can be used to run on <a href="https://quantum-computing.ibm.com/">IBM’s Quantum hardware</a>. There is an <a href="https://cran.r-project.org/web/packages/qsimulatR/vignettes/qsimulatR.html">Introduction</a>, and vignettes on <a href="https://cran.r-project.org/web/packages/qsimulatR/vignettes/ExponentiateModN.pdf">Exponentiation modulo n</a>, <a href="https://cran.r-project.org/web/packages/qsimulatR/vignettes/addbyqft.pdf">Addition by Fourier transform</a>, the <a href="https://cran.r-project.org/web/packages/qsimulatR/vignettes/deutsch-jozsa.pdf">Deutsch-Sozsa Algorithm</a>, the <a href="https://cran.r-project.org/web/packages/qsimulatR/vignettes/phase_estimation.pdf">Phase Estimation Algorithm</a> and <a href="https://cran.r-project.org/web/packages/qsimulatR/vignettes/qft.pdf">Quantum Fourier Trafo</a>.</p>
<p><img src="quantum.png" height = "250" width="450"></p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=eyedata">eyedata</a> v0.1.0: Contains anonymized real life, open source data sets from patients treated in <a href="https://en.wikipedia.org/wiki/Moorfields_Eye_Hospital">Moorfields Eye Hospital</a>, London and includes data about people who received intravitreal injections with anti-vascular endothelial growth factor due to age-related macular degeneration or diabetic macular edema. See <a href="https://cran.r-project.org/web/packages/eyedata/readme/README.html#ref-fu2">README</a> for the list of medical publications associated with the data sets.</p>
<p><a href="https://cran.r-project.org/package=rgugik">rgugik</a> v0.2.1: Automates open data acquisition including raster and vector data from the <a href="www.gugik.gov.pl">Polish Head Office of Geodesy and Cartography</a>. See the vignettes <a href="https://cran.r-project.org/web/packages/rgugik/vignettes/DEM.html">Digital Eelvation Model</a>, <a href="https://cran.r-project.org/web/packages/rgugik/vignettes/orthophotomap.html">Orthophotomap</a>, and <a href="https://cran.r-project.org/web/packages/rgugik/vignettes/topodb.html">Topographic Database</a>.</p>
<p><img src="rgugik.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=readrba">readrba</a> v0.1.0: Provides tools to download current and historical <a href="https://www.rba.gov.au/statistics/tables/">statistical tables</a> and <a href="https://www.rba.gov.au/publications/smp/forecasts-archive.html">forecasts</a> from the Reserve Bank of Australia Data which comprise a broad range of Australian macroeconomic and financial time series. See the <a href="https://cran.r-project.org/web/packages/readrba/vignettes/readrba.html">vignette</a> to get started.</p>
<p><img src="readrba.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=threesixtygiving">threesixtygiving</a> v0.2.2: Provides access to open data from <a href="https://www.threesixtygiving.org">360Giving</a>, a database of charitable grant giving in the UK. See the <a href="https://cran.r-project.org/web/packages/threesixtygiving/threesixtygiving.pdf">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=USgas">USgas</a> Links to the <a href="https://www.eia.gov/">US Energy Information Administration</a> to provide and overview of natural gas demand at the county level. See the <a href="https://cran.r-project.org/web/packages/USgas/vignettes/introduction.html">vignette</a>.</p>
<p><img src="USgas.png" height = "300" width="500"></p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=polyqtlR">polyqtlR</a> v0.0.4: Provides functions for quantitative trait loci (QTL) analysis in polyploid bi-parental F1 populations. See the <a href="https://cran.r-project.org/web/packages/polyqtlR/vignettes/polyqtlR_vignette.html">vignette</a> for background and examples.</p>
<p><img src="polyqtlR.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=RPPASPACE">RPPASPACE</a> v1.0.7: Provides tools for the analysis of reverse-phase protein arrays (RPPAs), which are also known as <em>tissue lysate arrays</em> or simply <em>lysate arrays</em>. See <a href="https://academic.oup.com/bioinformatics/article/23/15/1986/205819">Hu (2007)</a> for background and the <a href="https://cran.r-project.org/web/packages/RPPASPACE/vignettes/Guide_to_RPPASPACE.pdf">Guide</a> to for examples.</p>
<p><a href="https://cran.r-project.org/package=RVA">RVA</a> v0.0.3: Provides functions to automate downstream visualization & pathway analysis in RNAseq analysis. See the <a href="https://cran.r-project.org/web/packages/RVA/vignettes/RVA.html">vignette</a>.</p>
<p><img src="RVA.png" height = "300" width="500"></p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=comparator">comparator</a> v0.0.1: Implements functions for comparing strings, sequences and numeric vectors for clustering and record linkage applications. It includes generalized edit distances for comparing sequences/strings, Monge-Elkan similarity for fuzzy comparison of token sets, and L-p distances for comparing numeric vectors. See <a href="https://cran.r-project.org/web/packages/comparator/readme/README.html">README</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=DoubleML">DoubleML</a> v0.1.1: Implements the double/debiased machine learning framework of <a href="https://academic.oup.com/ectj/article/21/1/C1/5056401">Chernozhukov et al. (2018)</a> for partially linear regression models, partially linear instrumental variable regression models, interactive regression models and interactive instrumental variable regression models. There are guides on <a href="https://cran.r-project.org/web/packages/DoubleML/vignettes/install.html">Installation</a> and <a href="https://cran.r-project.org/web/packages/DoubleML/vignettes/DoubleML.html">Getting Started</a>.</p>
<p><a href="https://cran.r-project.org/package=functClust">functClust</a> v0.1.6: Provides functions to cluster the components that make up an interactive system on the basis of their functional redundancy for one or more collective, systemic performances. There are six vignettes including and <a href="https://cran.r-project.org/web/packages/functClust/vignettes/a.Overview.html">Overview</a>, a simple <a href="https://cran.r-project.org/web/packages/functClust/vignettes/b.Simplest_use.html">Use Case</a>, and <a href="https://cran.r-project.org/web/packages/functClust/vignettes/e.Multi_functionality.html">Multi Fuctionality</a>.</p>
<p><img src="functClust.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=mlpack">mlpack</a> v3.4.2.1: Implements bindings to the mlpack C++ machine learning library. See <a href="https://joss.theoj.org/papers/10.21105/joss.00726">Curtin et al (2018)</a> for background and look <a href="https://www.mlpack.org/doc/mlpack-3.4.2/r_documentation.html">here</a> for documentation.</p>
<p><a href="https://cran.r-project.org/package=RFCCA">RFCCA</a> v1.0.3: Implements Random Forest with Canonical Correlation Analysis, a method for estimating the canonical correlations between two sets of variables depending on the subject-related covariates. The method is described in <a href="https://arxiv.org/abs/2011.11555">Alakus et al. (2020)</a>. See the <a href="https://cran.r-project.org/web/packages/RFCCA/vignettes/RFCCA.html">vignette</a> for examples.</p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=babsim.hospital">babsim.hospital</a> v11.5.14: Implements a discrete-event simulation model for a hospital resource planning. Motivated by the challenges faced by health care institutions in the current COVID-19 pandemic, it can be used by health departments to forecast demand for intensive care beds, ventilators, and staff resources. See <a href="https://www.jstatsoft.org/article/view/v090i02">Ucar, Smeets & Azcorra (2019)</a>, <a href="https://www.rcpjournals.org/content/futurehosp/6/1/17">Lawton & McCooe (2019)</a> and the <a href="https://www.th-koeln.de/informatik-und-ingenieurwissenschaften/babsimhospital_78996.php">website</a> for background, and the <a href="https://cran.r-project.org/web/packages/babsim.hospital/vignettes/babsim-vignette-introduction.pdf">vignette</a> to get started.</p>
<p><img src="sim.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=healthyR">healthyR</a> v0.1.1: Implements hospital data analysis workflow tools including modeling tools, and tools to review common administrative hospital data such as average length of stay, readmission rates, average net pay amounts by service lines, and more. See the <a href="https://cran.r-project.org/web/packages/healthyR/vignettes/getting-started.html">vignette</a>.</p>
<p><img src="healthyR.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=metaSurvival">metaSurvival</a> v0.1.0: Provides a function to assess information from a summary survival curve and test the between-strata heterogeneity. See the <a href="https://github.com/shubhrampandey/metaSurvival">GitHub repo</a> for an example.</p>
<p><img src="metaSurvival.png" height = "300" width="500"></p>
<h3 id="science">Science</h3>
<p><a href="https://cran.r-project.org/package=cmcR">cmcR</a> v0.1.3: Implements the congruent matching cells method for cartridge case identification as proposed by <a href="https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=911193">Song (2013)</a> as well as an extension of the method proposed by <a href="https://nvlpubs.nist.gov/nistpubs/jres/120/jres.120.008.pdf">Tong et al. (2015)</a>. There is a vignette on <a href="https://cran.r-project.org/web/packages/cmcR/vignettes/decisionRuleDescription.html">Decision Rules</a> and <a href="https://cran.r-project.org/web/packages/cmcR/vignettes/cmcR_plotReproduction.html">another vignette</a> reproducing the study by Song et al.</p>
<p><img src="cmcR.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=envi">envi</a> v0.1.6: Provides tools for environmental interpolation using occurrence data, covariates, kernel density-based estimation, and spatial relative risk. See <a href="https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.7577">Davies et al. (2018)</a> for details on spatial relative risk, <a href="https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.4780090616">Bithell (1990)</a> for kernel density estimation and <a href="https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.4780101112">Bithell (1991)</a> for estimating relative risk. The <a href="https://cran.r-project.org/web/packages/envi/vignettes/vignette.html">vignette</a> provides background and examples.</p>
<p><img src="envi.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=PAMpal">PAMpal</a> v0.9.14: Provides tools for loading and processing passive acoustic data, including functions to read <a href="https://www.pamguard.org/">Pamguard</a> data, process, and export data. See <a href="https://asa.scitation.org/doi/10.1121/1.2743157">Oswald et al (2007)</a>, <a href="https://asa.scitation.org/doi/10.1121/10.0001229">Griffiths et al (2020)</a>, and <a href="https://asa.scitation.org/doi/full/10.1121/1.3479549">Baumann-Pickering et al (2010)</a> for background. Look <a href="https://taikisan21.github.io/PAMpal/">here</a> for the installation guide and tutorial.</p>
<p><img src="PAMpal.png" height = "300" width="500"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=bpcs">bpcs</a> v1.0.0: Implements models for the analysis of paired comparison data using <code>Stan</code> including random effects, generalized model for predictors and order effect Bayesian versions of the Bradley-Terry model. See <a href="https://www.jstor.org/stable/2334029?origin=crossref&seq=1">Bradley & Terry (1952)</a>, <a href="https://www.tandfonline.com/doi/abs/10.1080/01621459.1970.10481082">Davidson (1970)</a>, and <a href="https://www.jstatsoft.org/article/view/v076i01">Carpenter et al. (2017)</a> for background and the <a href="https://cran.r-project.org/web/packages/bpcs/vignettes/a_get_started.html">vignette</a> for an overview.</p>
<p><a href="https://cran.r-project.org/package=brolgar">brolgar</a> v0.1.0: Provides a framework of tools to summarise, visualise, and explore longitudinal data and includes methods for calculating features and summary statistics and sampling individual series. See <a href="https://arxiv.org/abs/2012.01619">Tierney, Cook & Prvan</a> and the <a href="https://cran.r-project.org/web/packages/brolgar/vignettes/getting-started.html">Getting Started Guide</a> to get going. There are also vignettes <a href="https://cran.r-project.org/web/packages/brolgar/vignettes/exploratory-modelling.html">exploratory modelling</a>, finding <a href="https://cran.r-project.org/web/packages/brolgar/vignettes/finding-features.html">features</a>, identifying <a href="https://cran.r-project.org/web/packages/brolgar/vignettes/id-interesting-obs.html">interesting observations</a>, <a href="https://cran.r-project.org/web/packages/brolgar/vignettes/longitudinal-data-structures.html">data structures</a>, <a href="https://cran.r-project.org/web/packages/brolgar/vignettes/mixed-effects-models.html">mixed effects models</a>, and
<a href="https://cran.r-project.org/web/packages/brolgar/vignettes/visualisation-gallery.html">visualisation</a>.</p>
<p><img src="brolgar.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=MASSExtra">MASSExtra</a> v1.0.2: Provides enhancements, extensions and additions (such as Gramm-Schmidt orthogonalisation and generalised eigenvalue problems) to the <code>MASS</code> package with convenient default settings and user interfaces. See the <a href="https://cran.r-project.org/web/packages/MASSExtra/vignettes/rationale.pdf">vignette</a>.</p>
<p><img src="MASSExtra.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=motifr">motifr</a> v1.0.0: Provides tools for motif analysis in multi-level networks to visualize multi-level networks, count multi-level network motifs and compare motif occurrences to baseline models. See the <a href="https://cran.r-project.org/web/packages/motifr/vignettes/motif_zoo.html">motif zoo</a> and <a href="https://cran.r-project.org/web/packages/motifr/vignettes/random_baselines.html">Baseline model comparisons</a> to get started.</p>
<p><img src="motifr.svg" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=OptCirClust">OptCirClust</a> v0.0.3: Provides fast (runtime = O(K N log^2 N), optimal, reproducible clustering algorithms for circular, periodic, or framed data based on a core algorithm for optimal framed clustering. There are vignettes on <a href="https://cran.r-project.org/web/packages/OptCirClust/vignettes/CircularGenomes.html">Circular genome clustering</a>, <a href="https://cran.r-project.org/web/packages/OptCirClust/vignettes/Performance.html">Performance</a>, <a href="https://cran.r-project.org/web/packages/OptCirClust/vignettes/Tutorial_CirClust.html">Circular Clustering</a>, and <a href="https://cran.r-project.org/web/packages/OptCirClust/vignettes/Tutorial_FramedClust.html">Framed Clusterine</a>.</p>
<p><img src="OptCirClust.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=pflamelet">pflamelet</a> v0.1.1: Provides functions to compute the persistence flamelets, a statistical tool for exploring the Topological Invariants of Scale-Space families introduced in <a href="https://arxiv.org/abs/1709.07097">Padellini and Brutti (2017)</a>.</p>
<p><a href="https://cran.r-project.org/package=PRDA">PRDA</a> v1.0.0: Implements the <em>Design Analysis</em> proposed by <a href="https://journals.sagepub.com/doi/10.1177/1745691614551642">Gelman & Carlin (2014)</a> which combines the evaluation of Power-Analysis with other inferential-risks. See also <a href="https://www.frontiersin.org/articles/10.3389/fpsyg.2019.02893/full">Altoè et al. (2020)</a> and <a href="https://psyarxiv.com/q9f86/">Bertoldo et al. (2020)</a> for background and the vignettes <a href="https://cran.r-project.org/web/packages/PRDA/vignettes/PRDA.html">PRDA</a>, <a href="https://cran.r-project.org/web/packages/PRDA/vignettes/prospective.html">Prospective</a> and <a href="https://cran.r-project.org/web/packages/PRDA/vignettes/retrospective.html">Retrospective</a>.</p>
<p><img src="PRDA.png" height = "300" width="300"></p>
<p><a href="https://cran.r-project.org/package=puls">puls</a> v0.1.1: Supplements the <code>fda</code> and <code>fda.use</code> packages by providing a method for clustering functional data using subregion information of the curves. See the <a href="https://cran.r-project.org/package=puls">vignette</a> for an example and references.</p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=coro">coro</a> v1.0.1: Provides <em>coroutines</em>, a family of functions that can be suspended and resumed later on. This includes async functions (which await) and generators (which yield). See the <a href="https://cran.r-project.org/web/packages/coro/vignettes/generator.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=dataReporter">dataReporter</a> v1.0.0: Provides functions to auto generate a customizable data report showing potential errors in a data set. See <a href="https://www.jstatsoft.org/article/view/v090i06">Petersen & Ekstrøm (2019)</a> for background, and the <a href="https://cran.r-project.org/web/packages/dataReporter/vignettes/extending_dataReporter.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=DescrTab2">DescrTab2</a> v2.0.3: Provides functions to create descriptive statistics tables for continuous and categorical variables. There are vignettes on <a href="https://cran.r-project.org/web/packages/DescrTab2/vignettes/maintenance_guide.html">Maintenance</a>, <a href="https://cran.r-project.org/web/packages/DescrTab2/vignettes/usage_guide.html">Usage</a>, and <a href="https://cran.r-project.org/web/packages/DescrTab2/vignettes/validation_report.html">Validation</a>.</p>
<p><a href="https://cran.r-project.org/package=libr">libr</a> v1.1.1: Provides functions to create data libraries, generate data dictionaries, and simulate a data step. There is an <a href="https://cran.r-project.org/web/packages/libr/vignettes/libr.html">Introduction</a>, and vignettes on library <a href="https://cran.r-project.org/web/packages/libr/vignettes/libr-basics.html">operations</a> and <a href="https://cran.r-project.org/web/packages/libr/vignettes/libr-management.html">management</a>, and <a href="https://cran.r-project.org/web/packages/libr/vignettes/libr-datastep.html">Data Step</a> operations and the <a href="https://cran.r-project.org/web/packages/libr/vignettes/libr-management.html">enhanced equality</a> operator.</p>
<p><a href="https://cran.r-project.org/package=outsider">outsider</a> v0.1.1: Allows users to install and run external command-line programs in R through use of <a href="https://www.docker.com/">Docker</a> and online repositories. Look <a href="https://docs.ropensci.org/outsider/">here</a> for package information.</p>
<p><img src="outsider.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=srcr">srcr</a> v1.0.0: Provides a simple tool to abstract connection details, including secret credentials, out of your source code and manage configurations for frequently-used database connections. See the <a href="https://cran.r-project.org/web/packages/srcr/vignettes/Managing_data_sources.html">vignette</a>.</p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=ComplexUpset">ComplexUpset</a> v1.0.3: Provides functions to create Upset plots which offer improvements over Venn Diagrams for set overlap visualizations.</p>
<p><img src="upset.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=nmaplateplot">nmaplateplot</a> v1.0.0: Provides a graphical display of results from network meta-analysis (NMA) which is suitable for outcomes like odds ratios, risk ratios, risk differences, and standardized mean differences. See the <a href="https://cran.r-project.org/web/packages/ComplexUpset/vignettes/Examples_R.html">vignette</a> for examples. <a href="https://cran.r-project.org/web/packages/nmaplateplot/vignettes/nmaplateplot-intro.html">vignette</a> for examples.</p>
<p><img src="nmaplateplot.svg" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=PantaRhei">PantaRhei</a> v0.1.2: Provides functions to produce <a href="https://en.wikipedia.org/wiki/Sankey_diagram#:~:text=Sankey%20diagrams%20are%20a%20type,proportional%20to%20the%20flow%20rate.&text=Sankey%20diagrams%20emphasize%20the%20major,quantities%20within%20defined%20system%20boundaries.">Sankey diagrams</a> which are used to visualize the flow of conservative substances through a system. See the <a href="https://cran.r-project.org/web/packages/PantaRhei/vignettes/panta-rhei.html">vignette</a>.</p>
<p><img src="PantaRhei.png" height = "300" width="500"></p>
<script>window.location.href='https://rviews.rstudio.com/2021/01/29/dec-2020-top-40-new-cran-packages/';</script>
SEM Time Series Modeling
https://rviews.rstudio.com/2021/01/22/sem-time-series-modeling/
Fri, 22 Jan 2021 00:00:00 +0000https://rviews.rstudio.com/2021/01/22/sem-time-series-modeling/
<script src="/2021/01/22/sem-time-series-modeling/index_files/header-attrs/header-attrs.js"></script>
<!--
tested on Win10: R-4.0.3, rstudio-1.3.911, bimets-1.5.2
tested on Redhat7: R-3.5.3, rstudio-1.1.463, bimets-1.5.2
-->
<p><em>Andrea Luciani is a Technical Advisor for the Directorate General for Economics, Statistics and Research at the Bank of Italy, and co-author of the bimets package.</em></p>
<p>Structural Equation Models <a href="https://en.wikipedia.org/wiki/Structural_equation_modeling">(SEM)</a>, which are common in many economic modeling efforts, require fitting and simulating whole system of equations where each equation may depend on the results of other equations. Moreover, they often require combining time series and regression equations in ways that are well beyond what the <code>ts()</code> and <code>lm()</code> functions were designed to do. For example, one might want to account for an error auto-correlation of some degree in the regression, or force linear restrictions modeling coefficients.</p>
<p>In this post, we will show how to do structural equation modeling in R by working through the <a href="http://www.ipe.ro/rjef/rjef1_14/rjef1_2014p5-14.pdf">Klein Model</a> of the United States economy, one of the oldest and most elementary models of its kind.</p>
<p>These equations define the model:</p>
<p><span class="math inline">\(CN_t = \alpha_1 + \alpha_2 * P_t + \alpha_3 * P_{t-1} + \alpha_4 * ( WP_t + WG_t )\)</span></p>
<p><span class="math inline">\(I_t = \beta_1 + \beta_2 * P_t + \beta_3 * P_{t-1} - \beta_4 * K_{t-1}\)</span></p>
<p><span class="math inline">\(WP_t = \gamma_1 + \gamma_2 * ( Y_t + T_t - WG_t ) + \gamma_3 * ( Y_{t-1} + T_{t-1} - WG_{t-1} ) + \gamma_4 * Time\)</span></p>
<p><span class="math inline">\(P_t = Y_t - ( WP_t + WG_t )\)</span></p>
<p><span class="math inline">\(K_t = K_{t-1} + I_t\)</span></p>
<p><span class="math inline">\(Y_t = CN_t + I_t + G_t - T_t\)</span></p>
<p>Given:</p>
<p><span class="math inline">\(CN\)</span> as private consumption expenditure;<br />
<span class="math inline">\(I\)</span> as investment;<br />
<span class="math inline">\(WP\)</span> as wage bill of the private sector (demand for labor);<br />
<span class="math inline">\(P\)</span> as profits;<br />
<span class="math inline">\(K\)</span> as stock of capital goods;<br />
<span class="math inline">\(Y\)</span> as gross national product;<br />
<span class="math inline">\(WG\)</span> as wage bill of the government sector;<br />
<span class="math inline">\(Time\)</span> as an index of the passage of time, e.g. 1931 = zero;<br />
<span class="math inline">\(G\)</span> as government expenditure plus net exports;<br />
<span class="math inline">\(T\)</span> as business taxes.</p>
<p><span class="math inline">\(\alpha_i, \beta_j, \gamma_k\)</span> are coefficient to be estimated.</p>
<p>This system has only 6 equations, three of which must be fitted in order to assess the coefficients. It may not seem so difficult to solve this system, but the real complexity emerges if you look at the incidence graph in the following figure, wherein endogenous variables are plotted in blue and exogenous variables are plotted in pink.</p>
<p><img src="/2021/01/22/sem-time-series-modeling/index_files/figure-html/incidence_graph-1.png" width="672" /></p>
<p>Each edge states a simultaneous dependence from a variable to another, e.g. the <code>WP</code> equation depends on the current value of the <code>TIME</code> time series; complexity arises because in this model there are several circular dependencies, one of which is plotted in dark blue.</p>
<p>A circular dependency in the incidence graph of a model implies that the model is a “simultaneous” equations model and that it must be estimated by using ad-hoc procedures; moreover it can be simulated, i.e. performing a forecast, only by using an iterative algorithm.</p>
<p>If we search for “simultaneous equations” inside the <a href="https://cran.r-project.org/web/views/Econometrics.html">Econometrics Task View</a> web page we can find two results: the <a href="https://cran.r-project.org/web/packages/systemfit/index.html">systemfit</a> and the <a href="https://cran.r-project.org/web/packages/bimets/index.html">bimets</a> packages.</p>
<p>The <a href="https://cran.r-project.org/web/packages/systemfit/index.html">systemfit</a> package is a powerful tool for econometric estimation of simultaneous systems of linear and nonlinear equations, but it only provides fitting procedures, thus it cannot be used in our example in order to work out a forecast.</p>
<p>On the other hand, the <a href="https://cran.r-project.org/web/packages/bimets/index.html">bimets</a> package implements, among others, simulation and forecasting procedures; as stated into the <a href="https://cran.r-project.org/web/packages/bimets/vignettes/bimets.pdf">vignette</a> it allows users to write down the model in a natural way, to test several strategies and to focus on the econometric analysis, without overly dealing with coding.</p>
<p>Time series projection, linear restrictions and error auto-correlation can be triggered directly in the model definition, so let us try to define a similar but more complex Klein model by using a <a href="https://cran.r-project.org/web/packages/bimets/index.html">bimets</a> compliant syntax:</p>
<pre class="r"><code>#load library
library(bimets)
#define the Klein model
kleinModelDef <- "
MODEL
COMMENT> Modified Klein Model 1 of the U.S. Economy with PDL,
COMMENT> autocorrelation on errors, restrictions and conditional equation evaluations
COMMENT> Consumption with autocorrelation on errors
BEHAVIORAL> cn
TSRANGE 1923 1 1940 1
EQ> cn = a1 + a2*p + a3*TSLAG(p,1) + a4*(wp+wg)
COEFF> a1 a2 a3 a4
ERROR> AUTO(2)
COMMENT> Investment with restrictions
BEHAVIORAL> i
TSRANGE 1923 1 1940 1
EQ> i = b1 + b2*p + b3*TSLAG(p,1) + b4*TSLAG(k,1)
COEFF> b1 b2 b3 b4
RESTRICT> b2 + b3 = 1
COMMENT> Demand for Labor with PDL
BEHAVIORAL> wp
TSRANGE 1923 1 1940 1
EQ> wp = c1 + c2*(y+t-wg) + c3*TSLAG(y+t-wg,1) + c4*time
COEFF> c1 c2 c3 c4
PDL> c3 1 2
COMMENT> Gross National Product
IDENTITY> y
EQ> y = cn + i + g - t
COMMENT> Profits
IDENTITY> p
EQ> p = y - (wp+wg)
COMMENT> Capital Stock with IF switches
IDENTITY> k
EQ> k = TSLAG(k,1) + i
IF> i > 0
IDENTITY> k
EQ> k = TSLAG(k,1)
IF> i <= 0
END
"
#load the model
kleinModel <- LOAD_MODEL(modelText = kleinModelDef)</code></pre>
<pre><code>## Analyzing behaviorals...
## Analyzing identities...
## Optimizing...
## Loaded model "kleinModelDef":
## 3 behaviorals
## 3 identities
## 12 coefficients
## ...LOAD MODEL OK</code></pre>
<p>The code is quite intuitive and uses explicit keywords in order to define equations, coefficients, parameters, etc. Users can easily:</p>
<ul>
<li><p>change the <code>TSRANGE</code> in order to fit the model in a custom time range per equation;</p></li>
<li><p>modify an equation <code>EQ</code> without changing any user procedure or code;</p></li>
<li><p>add or remove one or more linear restriction on the coefficients by using the keyword <code>RESTRICT</code>, e.g.<br />
<code>RESTRICT> -1.23*b2 + 8.9*b3 = 0.34</code><br />
<code>RESRTICT> b4 – 1.2*b1 = 5</code></p></li>
<li><p>add or remove an error auto-correlation structure with an arbitrary order by using the keyword:<br />
<code>ERROR></code></p></li>
</ul>
<p>Equations can contain advanced expressions, e.g.:</p>
<p><code>EQ> TSDELTA(i) = b1 + b2*EXP(p/1000) + b3*TSDELTALOG(TSLAG(p,1)) + b4*MOVAVG(TSLAG(k,1),5)</code></p>
<div id="model-estimation" class="section level3">
<h3>Model estimation</h3>
<p>Now, we define time series to be used in our example, and then we perform an estimation of the whole <code>kleinModel</code> by using the command <code>ESTIMATE()</code>:</p>
<pre class="r"><code>#define data
kleinModelData <- list(
cn =TIMESERIES(39.8,41.9,45,49.2,50.6,52.6,55.1,56.2,57.3,57.8,
55,50.9,45.6,46.5,48.7,51.3,57.7,58.7,57.5,61.6,65,69.7,
START=c(1920,1),FREQ=1),
g =TIMESERIES(4.6,6.6,6.1,5.7,6.6,6.5,6.6,7.6,7.9,8.1,9.4,10.7,
10.2,9.3,10,10.5,10.3,11,13,14.4,15.4,22.3,
START=c(1920,1),FREQ=1),
i =TIMESERIES(2.7,-.2,1.9,5.2,3,5.1,5.6,4.2,3,5.1,1,-3.4,-6.2,
-5.1,-3,-1.3,2.1,2,-1.9,1.3,3.3,4.9,
START=c(1920,1),FREQ=1),
k =TIMESERIES(182.8,182.6,184.5,189.7,192.7,197.8,203.4,207.6,
210.6,215.7,216.7,213.3,207.1,202,199,197.7,199.8,
201.8,199.9,201.2,204.5,209.4,
START=c(1920,1),FREQ=1),
p =TIMESERIES(12.7,12.4,16.9,18.4,19.4,20.1,19.6,19.8,21.1,21.7,
15.6,11.4,7,11.2,12.3,14,17.6,17.3,15.3,19,21.1,23.5,
START=c(1920,1),FREQ=1),
wp =TIMESERIES(28.8,25.5,29.3,34.1,33.9,35.4,37.4,37.9,39.2,41.3,
37.9,34.5,29,28.5,30.6,33.2,36.8,41,38.2,41.6,45,53.3,
START=c(1920,1),FREQ=1),
y =TIMESERIES(43.7,40.6,49.1,55.4,56.4,58.7,60.3,61.3,64,67,57.7,
50.7,41.3,45.3,48.9,53.3,61.8,65,61.2,68.4,74.1,85.3,
START=c(1920,1),FREQ=1),
t =TIMESERIES(3.4,7.7,3.9,4.7,3.8,5.5,7,6.7,4.2,4,7.7,7.5,8.3,5.4,
6.8,7.2,8.3,6.7,7.4,8.9,9.6,11.6,
START=c(1920,1),FREQ=1),
time=TIMESERIES(NA,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,
1,2,3,4,5,6,7,8,9,10,
START=c(1920,1),FREQ=1),
wg =TIMESERIES(2.2,2.7,2.9,2.9,3.1,3.2,3.3,3.6,3.7,4,4.2,4.8,
5.3,5.6,6,6.1,7.4,6.7,7.7,7.8,8,8.5,
START=c(1920,1),FREQ=1)
);
#load time series into the model object
kleinModel <- LOAD_MODEL_DATA(kleinModel,kleinModelData)</code></pre>
<pre><code>## Load model data "kleinModelData" into model "kleinModelDef"...
## ...LOAD MODEL DATA OK</code></pre>
<pre class="r"><code>#estimate the model
kleinModel <- ESTIMATE(kleinModel, quietly=TRUE)</code></pre>
<p>In order to reduce this blog post length we only show the output for a single estimation; anyhow, for each estimated equation the output is similar to the following:</p>
<pre class="r"><code>kleinModel <- ESTIMATE(kleinModel, eqList='cn')</code></pre>
<pre><code>##
## Estimate the Model kleinModelDef:
## the number of behavioral equations to be estimated is 1.
## The total number of coefficients is 4.
##
## _________________________________________
##
## BEHAVIORAL EQUATION: cn
## Estimation Technique: OLS
## Autoregression of Order 2 (Cochrane-Orcutt procedure)
##
## Convergence was reached in 6 / 20 iterations.
##
##
## cn = 14.83
## T-stat. 7.608 ***
##
## + 0.2589 p
## T-stat. 2.96 *
##
## + 0.01424 TSLAG(p,1)
## T-stat. 0.1735
##
## + 0.839 (wp+wg)
## T-stat. 14.68 ***
##
## ERROR STRUCTURE: AUTO(2)
##
## AUTOREGRESSIVE PARAMETERS:
## Rho Std. Error T-stat.
## 0.2542 0.2589 0.9817
## -0.05251 0.2594 -0.2024
##
##
## STATs:
## R-Squared : 0.9827
## Adjusted R-Squared : 0.9755
## Durbin-Watson Statistic : 2.256
## Sum of squares of residuals : 8.072
## Standard Error of Regression : 0.8201
## Log of the Likelihood Function : -18.32
## F-statistic : 136.2
## F-probability : 3.874e-10
## Akaike's IC : 50.65
## Schwarz's IC : 56.88
## Mean of Dependent Variable : 54.29
## Number of Observations : 18
## Number of Degrees of Freedom : 12
## Current Sample (year-period) : 1923-1 / 1940-1
##
##
## Signif. codes: *** 0.001 ** 0.01 * 0.05
##
##
## ...ESTIMATE OK</code></pre>
<p>The <code>ESTIMATE()</code> function can fit also non-simultaneous system and a single equation. Several predefined time series transformations are available in <a href="https://cran.r-project.org/web/packages/bimets/index.html">bimets</a>:</p>
<p>– Time series extension <code>TSEXTEND()</code><br />
– Time series merging <code>TSMERGE()</code><br />
– Time series projection <code>TSPROJECT()</code><br />
– Lag <code>TSLAG()</code><br />
– Lag differences: standard, percentage and logarithmic, i.e. <code>TSDELTA()</code>, <code>TSDELTAP()</code>, <code>TSDELTALOG()</code><br />
– Cumulative product <code>CUMPROD()</code><br />
– Cumulative sum <code>CUMSUM()</code><br />
– Moving average <code>MOVAVG()</code><br />
– Moving sum <code>MOVSUM()</code><br />
– Parametric (Dis)Aggregation <code>YEARLY()</code>, <code>QUARTERLY()</code>, <code>MONTHLY()</code>, <code>DAILY()</code><br />
– Time series data presentation <code>TABIT()</code></p>
</div>
<div id="forecasting" class="section level3">
<h3>Forecasting</h3>
<p>The <code>predict()</code> function of the <code>lm()</code> or <code>dyn$lm</code> linear model framework produces predicted values, obtained by evaluating the regression function with new data: it is a popular function among the R users.</p>
<p>Unfortunately, it does not help in our example: as we said before, in order to forecast a simultaneous model that presents circular dependencies in the incidence graph, we cannot merely assess the right-hand side of the equations, as the <code>predict.lm</code> function does; in our case we need an iterative algorithm.</p>
<p>The <code>predict.lm</code> equivalent function that allows to forecast our simultaneous model is the <code>SIMULATE()</code> function. On the other hand the <code>SIMULATE()</code> function can also solve non-simultaneous models and gives the same results as the <code>predict.lm</code> function.</p>
<p>In addition, as in the Capital Stock <code>k</code> equation in our example, the <code>SIMULATE()</code> function can conditionally evaluate an identity during a simulation, depending on the value of a logical expression (e.g. for each simulation period the <code>k</code> equation changes depending on the <code>i</code> current value). Thus, it is possible to have a model alternating between two or more equation specifications for each simulation period, depending upon results from other equations.</p>
<p>Structural stability, multiplier analysis and endogenous targeting are additional capabilities coded in <a href="https://cran.r-project.org/web/packages/bimets/index.html">bimets</a> but not described in this post.</p>
<p>In order to forecast the model up to 1944, we need to extend exogenous time series by using the <code>TSEXTEND()</code> function. In this example, we perform simple extensions:</p>
<pre class="r"><code>#we need to extend exogenous variables up to 1944
kleinModel$modelData <- within(kleinModel$modelData,{
wg = TSEXTEND(wg, UPTO=c(1944,1),EXTMODE='CONSTANT')
t = TSEXTEND(t, UPTO=c(1944,1),EXTMODE='LINEAR')
g = TSEXTEND(g, UPTO=c(1944,1),EXTMODE='CONSTANT')
k = TSEXTEND(k, UPTO=c(1944,1),EXTMODE='LINEAR')
time = TSEXTEND(time,UPTO=c(1944,1),EXTMODE='LINEAR')
})</code></pre>
<p>A call to the <code>SIMULATE()</code> function will solve our simultaneous system of equations:</p>
<pre class="r"><code>#forecast model
kleinModel <- SIMULATE(kleinModel
,simType='FORECAST'
,TSRANGE=c(1941,1,1944,1)
,simConvergence=0.00001
,simIterLimit=100
,quietly=TRUE
)</code></pre>
<p>The historical GNP (original referred as “Net national income, measured in billions of 1934 dollars” , pg. 141 in “<a href="https://cowles.yale.edu/sites/default/files/files/pub/mon/m11-all.pdf">Economic Fluctuations in the United States 1921-1941</a>” by L. R. Klein, Wiley and Sons Inc., New York, 1950) is shown in figure, along with the simulation and the forecast.</p>
<pre class="r"><code>#get forecasted GNP
TABIT(kleinModel$simulation$y)</code></pre>
<pre><code>##
## DATE, PER, kleinModel$simulation$y
##
## 1941, 1 , 125.3
## 1942, 1 , 172.5
## 1943, 1 , 185.6
## 1944, 1 , 141.1</code></pre>
<p><img src="/2021/01/22/sem-time-series-modeling/index_files/figure-html/plot_ts-1.png" width="672" /></p>
<p>Disclaimer: <em>The views and opinions expressed in this page are those of the author and do not necessarily reflect the official policy or position of the Bank of Italy. Examples of analysis performed within these pages are only examples. They should not be utilized in real-world analytic products as they are based only on very limited and dated open source information. Assumptions made within the analysis are not reflective of the position of the Bank of Italy.</em></p>
</div>
<script>window.location.href='https://rviews.rstudio.com/2021/01/22/sem-time-series-modeling/';</script>
A Custom Forest Plot from Wonderful Wednesdays
https://rviews.rstudio.com/2021/01/15/wonderful-wednesdays-forest-plot/
Fri, 15 Jan 2021 00:00:00 +0000https://rviews.rstudio.com/2021/01/15/wonderful-wednesdays-forest-plot/
<p><em>Waseem Medhat is a Statistical Programmer and Computational Experimentalist who resides in Alexandria, Egypt</em></p>
<p>This post takes a closer look at the forest plot that was mentioned in a <a href="https://rviews.rstudio.com/2021/01/11/wonderful-wednesdays/">previous post</a> introducing PSI’s Wonderful Wednesdays events. It describes a custom version of a forest plot with additional bands to visualize heterogeneity between studies in a meta-analysis that was part of a project submitted to the Wonderful Wednesdays challenge hosted by PSI and reviewed by statisticians in the organization. Find more information
<a href="https://vis-sig.github.io/blog/posts/2020-12-03-wonderful-wednesdays-december-2020/">here</a>. The plot is built with JavaScript using the
<a href="https://d3js.org/">D3.js</a> library and wrapped in a
<a href="https://shiny.rstudio.com/">Shiny</a> app with the help of the
<a href="https://rstudio.github.io/r2d3/">R2D3</a> package.</p>
<h2 id="background-problem">Background problem</h2>
<p>The problem around this visualization is specific to meta-analysis, which is the statistical pooling of the results of multiple studies (e.g. a multi-center clinical trial) to obtain a single, more powerful estimate. The choice of pooling model (fixed effect vs. random effects) depends on the heterogeneity of effect size between studies. So, the main question that I wanted to answer with this visualization is:</p>
<p><em>“What graphical tools can be used to assess heterogeneity?”</em></p>
<p>Like any statistical graphic, the purpose of the visualization is to complement the statistical measures of heterogeneity, like I^2^, to give a more complete picture.</p>
<h2 id="plot-description">Plot description</h2>
<p><img src="https://waseem-medhat.netlify.app/post/forest-plot-with-heterogeneity-bands_files/forest_plot_with_bands.png" alt="" /></p>
<p>A lot of the plot components are directly comparable to the typical <a href="https://en.wikipedia.org/wiki/Forest_plot">forest
plot</a>, which is very popular in the medical field as visualization tool in meta-analyses. Its main features are:</p>
<ul>
<li>A square for each point estimate for a study. The square size is proportional
to the sample size (i.e. weight) of that study.</li>
<li>A line for each confidence interval of the effect size in a study.</li>
<li>Diamonds that represent the pooled estimate using either fixed-effect or random-effects model. The diamond width represents the confidence interval around the pooled estimate.</li>
<li>The plot is usually combined with a tabular display of the numbers represented by the plot.</li>
</ul>
<p>My own additions are:</p>
<ul>
<li>Colored bands to give a better visualization of the heterogeneity between studies. There is a band for each study, with a width equal to its confidence interval. All the bands are semi-transparent and overlayed over each other so that more overlapping produces darker areas.</li>
<li>More attention to annotations than the typical plots, providing a title and a subtitle with the interventions and the outcome, respectively. Another label is also added to show which direction represents the “positive” effect.</li>
</ul>
<h2 id="shiny-app-description">Shiny app description</h2>
<p><img src="https://waseem-medhat.netlify.app/post/forest-plot-with-heterogeneity-bands_files/forest_plot_with_bands_shiny.png" alt="" /></p>
<p>As a proof of concept for a viable product, I wrapped the plot in a Shiny app which provides additional interactive features:</p>
<ul>
<li>Selection of summary measure, which can be expanded to include more than the
odds ratio and risk ratio.</li>
<li>Control over the plot dimensions. Giving this control to the user allows the plot to be conveniently visible in different screen sizes and deliverable forms (e.g. a report or a dashboard).</li>
<li>Help button that shows a guide for interpretation. This makes the information available on-demand instead having it a separate tab.</li>
</ul>
<h2 id="technologies-and-packages">Technologies and packages</h2>
<h3 id="d3-js-javascript">D3.js (JavaScript)</h3>
<p>The plot itself (and associated tabular display) was built using D3. Being a JavaScript library, D3 works with web technologies: HTML, CSS, and especially SVG. It has a lot of low-level tools that bind data to SVG shapes and change the shape properties accordingly. One particular advantage of using web technologies in this visualization is that CSS allows semi-transparent elements to “blend” colors in multiple ways, which allowed me to choose a blend mode that emphasizes the overlap.</p>
<h3 id="r2d3">R2D3</h3>
<p>R2D3 was the main wrapper around the D3 visualization. Beside the obvious
advantage of introducing an interface between R and D3 and allowing its
rendering in Shiny, it makes some steps easier like giving the data to the plot and making the plot take as much space as possible inside its container. Because of this, initial variables like <code>data</code>, <code>width</code>, <code>height</code>, and (the container) <code>svg</code> are provided by R2D3 and are not declared in the JavaScript code.</p>
<h3 id="shiny">Shiny</h3>
<p>It does not need an introduction at this point: Shiny is the de facto standard for R-based web applications. With the R2D3 package, I have available <code>d3Output()</code> and <code>renderD3()</code> to render the D3 plot just like any typical output in Shiny. Other Shiny packages I used are
<a href="https://github.com/cwthom/shinyhelper">shinyhelper</a>, which provides a help button and rich modal dialogs for help content, and <a href="http://rstudio.github.io/shinythemes/">shinythemes</a> to change the appearance of the app.</p>
<p>By wrapping the visualization in a Shiny app, this project became a prototype that can be taken in a lot of different directions to include more effect sizes and other meta-analysis techniques, or maybe even add another module that imports the data, performs the meta-analysis, and send the results to this module to be visualized.</p>
<h2 id="links">Links</h2>
<ul>
<li>Live version of the Shiny app: <a href="https://waseem-medhat.shinyapps.io/forest_plot_with_bands/">https://waseem-medhat.shinyapps.io/forest_plot_with_bands/</a></li>
<li>GitHub: <a href="https://github.com/waseem-medhat/forest_plot_with_bands">https://github.com/waseem-medhat/forest_plot_with_bands</a></li>
<li>Wonderful Wednesdays December submissions: <a href="https://vis-sig.github.io/blog/posts/2020-12-03-wonderful-wednesdays-december-2020/">https://vis-sig.github.io/blog/posts/2020-12-03-wonderful-wednesdays-december-2020/</a></li>
</ul>
<script>window.location.href='https://rviews.rstudio.com/2021/01/15/wonderful-wednesdays-forest-plot/';</script>
Wonderful Wednesdays
https://rviews.rstudio.com/2021/01/11/wonderful-wednesdays/
Mon, 11 Jan 2021 00:00:00 +0000https://rviews.rstudio.com/2021/01/11/wonderful-wednesdays/
<p>For almost a year now, the PSI Visualization Special Interest Group <a href="https://www.psiweb.org/sigs-special-interest-groups/visualisation">(VIS SIG)</a> has been conducting a monthly graduate-level seminar on creating effective statistical visualizations that is open to everyone. <a href="https://www.psiweb.org/sigs-special-interest-groups/visualisation/welcome-to-wonderful-wednesdays">Wonderful Wednesdays</a> is a unique collegial event. Every month the SIG publishes a link to a new data set and issues a challenge to produce visualizations that effectively illustrate some specific aspects of the data. Anyone can submit an entry coded in the language of their choice. Submissions that are received by the deadline are then critiqued in free webinar that takes place roughly thirty days later. You don’t have to make a submission to attend the webinar.</p>
<p>The process is well organized and straightforward. The figure below illustrates the process and time liness for the for the webinar that will happen this week on Wednesday, January 13th.</p>
<p><img src="ww1.png" height = "300" width="500"></p>
<p>Click <a href="https://attendee.gotowebinar.com/register/3242063276946783247">here</a> to register for the webinar.</p>
<p>Here is the <a href="https://www.psiweb.org/vod/item/psi-vissig-wonderful-wednesday-10-meta-analysis#video_490750250">link</a> to the December webinar where the challenge was to visualize the heterogeneity among the data used for a meta-analysis of seven studies undertaken to show a reduction in hypertension.</p>
<p>The following image is a traditional forest plot showing a comparison of the odds ratios for the seven studies. (If you are not familiar with this plot type look <a href="https://s4be.cochrane.org/blog/2016/07/11/tutorial-read-forest-plot/">here</a> for some tips on how to interpret it.)</p>
<p><img src="forest.png" height = "300" width="500"></p>
<p>This image comes from a shiny app that is critiqued at the by the VIS-SIG statisticians towards the beginning of the webinar. The experts liked the clean look and labeling on the plot, but had mixed feelings about the colored bands which are meant to show regions where the studies overlap. (Darker color indicates more overlap.) Here are the links to the <a href="https://waseem-medhat.shinyapps.io/forest_plot_with_bands/">Shiny App</a> and the <a href="https://vis-sig.github.io/blog/posts/2020-12-03-wonderful-wednesdays-december-2020/#example1%20code">code</a> and also to the <a href="https://vis-sig.github.io/blog/posts/2020-12-03-wonderful-wednesdays-december-2020/">blog post</a> that reviews all of the submissions for the December challenge.</p>
<p>Visit the <a href="https://vis-sig.github.io/blog/">VIS-SIG Blog</a> to finds posts and code for the submissions for all of Wonderful Wednesday events so far.</p>
<script>window.location.href='https://rviews.rstudio.com/2021/01/11/wonderful-wednesdays/';</script>
COVID-19 Data: The Long Run
https://rviews.rstudio.com/2021/01/06/covid-19-data-the-long-run/
Wed, 06 Jan 2021 00:00:00 +0000https://rviews.rstudio.com/2021/01/06/covid-19-data-the-long-run/
<p>The world seems to have moved to a new phase of paying attention to COVID-19. We have gone from pondering daily plots of case counts, to puzzling through models and forecasts, and are now moving on to the vaccines and the science behind them. For data scientists, however, the focus needs to remain on the data and the myriad issues and challenges that efforts to collect and curate COVID data have uncovered. My intuition is that not only will COVID-19 data continue to be important for quite some time in the future, but that efforts to improve the quality of this data will be crucial for successfully dealing with the next pandemic.</p>
<p>An incredible amount of work has been done by epidemiologists, universities, government agencies and data journalists to collect, organize, and reconcile data from thousands of sources. Nevertheless, the experts caution that there is much yet to be done.</p>
<p>Roni Rosenfeld, head of the Machine Learning Department of the School of Computer Science at Carnegie Mellon University and project lead for the <a href="https://delphi.cmu.edu/about/">Delphi Group</a> put it this way in a recent <a href="https://www.niss.org/news/copss-niss-webinar-delphi%E2%80%99s-covidcast-project-featured">COPSS-NISS webinar</a>:</p>
<blockquote>
<p>Data is a big problem in this pandemic. Availability of high quality, comprehensive, geographically detailed data is very far from where it should be.</p>
</blockquote>
<p>There are over <a href="https://www.aha.org/statistics/fast-facts-us-hospitals">6,000</a> hospitals in the United States, and over <a href="https://en.wikipedia.org/wiki/Lists_of_hospitals#:~:text=These%20are%20links%20to%20lists,164%2C500%20hospitals%20worldwide%20in%202015">160,000</a> hospitals worldwide. Many of these are collecting COVID-19 data yet there few standards for recording cases, dealing with missing data, updating case count data, and coping with the time lag between recording and reporting cases. <a href="https://journals.lww.com/epidem/Fulltext/2019/09000/Nowcasting_the_Number_of_New_Symptomatic_Cases.16.aspx">Nowcasting</a> epidemiological and heath care data has become a vital field of statistical research.</p>
<p>The following <a href="https://cmu-delphi.github.io/covidcast/talks/copss-niss/talk.html#(4)">slide</a> from the COPSS-NISS webinar shows a hierarchy of relevant COVID data organized on the Severity Pyramid that epidemiologists use to study disease progression.</p>
<p><img src="pyramid.svg" height = "400" width="600"></p>
<p>The Delphi Group is making fundamental contributions to the long term improvement of COVID data by archiving the data shown in such a way that versions can be retrieved by date, and also by collecting <a href="https://rviews.rstudio.com/2020/10/13/delphi-s-covidcast-project/">massive data sets</a> of leading indicators.</p>
<p>The webinar is well worth watching, and I highly recommend listening through the Q&A session at the end. The speakers explain the importance of nowcasting and Professor Rosenfeld presents a vision of making epidemic forecasting comparable to weather forecasting. It seems to me that this would be a worthwhile project to help advance.</p>
<p>Note that the Delphi’s <a href="https://cmu-delphi.github.io/delphi-epidata/api/covidcast_signals.html">COVID-19 indicators</a>, probably the nation’s largest public repository of diverse, geographically-detailed, real-time indicators of COVID activity in the US, are freely available through the <a href="https://cmu-delphi.github.io/delphi-epidata/api/covidcast.html">public API</a> which is easily accessible to R and Python users.</p>
<p>Also note that R users can contribute to <a href="https://www.r-consortium.org/">R Consortium</a> sponsored COVID related projects that include the <a href="https://cmu-delphi.github.io/delphi-epidata/api/covidcast.html">COVID-19 Data Hub</a> an organized archive of global COVID-19 case count data, and the <a href="https://tasks.repidemicsconsortium.org/#/">RECON COVID-19 Challenge</a>, an open source project to improve epidemiological tools.</p>
<script>window.location.href='https://rviews.rstudio.com/2021/01/06/covid-19-data-the-long-run/';</script>
November: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2020/12/22/november-top-40-new-cran-packages/
Tue, 22 Dec 2020 00:00:00 +0000https://rviews.rstudio.com/2020/12/22/november-top-40-new-cran-packages/
<p>Two hundred ninety-two new packages made it to CRAN in November. Picking forty was unusually difficult. Nevertheless, here are my “Top 40” selections in twelve categories: Archaeology, Computational Methods, Data, Epidemiology, Games, Machine Learning, Mathematics, Medicine, Statistics, Time Series, Utilities, and Visualization. R developers continue to extend the reach of R. November featured a new package on Archaeology, one of only seventeen I could find on CRAN <code>pkgsearch::pkg_search(query="Archaeology ",size=200)</code>, as well as a package that wraps Python’s <code>chess</code> package.</p>
<p>Looking back over the last twelve months my impression is that R continues to grow in the life sciences. Packages that I have classified as belonging to the categories Epidemiology, Genomics, or Medicine have comprised between ten and fourteen percent of the packages I have reviewed each month.</p>
<h3 id="archaeology">Archaeology</h3>
<p><a href="https://cran.r-project.org/package=archeofrag">archeofrag</a> v0.6.0: Implements methods based on graphs and graph theory for the stratigraphic analysis of fragmented objects in archaeology using “refitting” relationships between fragments scattered in stratigraphic layers. See the <a href="https://cran.r-project.org/web/packages/archeofrag/vignettes/archeofrag-vignette.html">vignette</a>.</p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=ADtools">ADtools</a> v0.5.4: Implements the forward-mode automatic differentiation for multivariate functions using the matrix-calculus notation from <a href="https://onlinelibrary.wiley.com/doi/book/10.1002/9781119541219">Magnus and Neudecker (2019)</a>. See the <a href="https://cran.r-project.org/web/packages/ADtools/vignettes/introduction-to-ADtools.html">vignette</a> for an introduction.</p>
<p><a href="https://cran.r-project.org/package=ML2Pvae">ML2Pvae</a> v1.0.0: Provides functions to create a variational autoencoder (VAE) for parameter estimation in Item Response Theory (IRT) which allows straight-forward construction, training, and evaluation. Only minimal knowledge of <code>tensorflow</code> or <code>keras</code> is required. See <a href="https://ieeexplore.ieee.org/document/8852333">Curi et al. (2019)</a> for background and the <a href="https://cran.r-project.org/web/packages/ML2Pvae/vignettes/ml2p_vae_vignette.pdf">vignette</a> for an overview.</p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=campfin">campfin</a> v1.0.4: Provides tools to explore and normalize American campaign finance data. This package was created by the Investigative Reporting Workshop to facilitate work on <a href="https://publicaccountability.org/">The Accountability Project</a>. See the <a href="https://cran.r-project.org/web/packages/campfin/vignettes/normalize-geography.html">vignette</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=cpsvote">cpsvote</a> v0.1.0: Provides automated methods for downloading, recoding, and merging selected years of the Current Population Survey’s Voting and Registration Supplement, a large national survey about registration, voting, and non-voting in <a href="http://www.electproject.org/home/voter-turnout/voter-turnout-data">United States federal elections</a>. There are vignettes on <a href="https://cran.r-project.org/web/packages/cpsvote/vignettes/basics.html">basics</a>, <a href="https://cran.r-project.org/web/packages/cpsvote/vignettes/background.html">background</a>, <a href="https://cran.r-project.org/web/packages/cpsvote/vignettes/voting.html">voting</a>, and <a href="https://cran.r-project.org/web/packages/cpsvote/vignettes/add-variables.html">adding variables</a>.</p>
<p><a href="https://cran.r-project.org/package=geogenr">geogenr</a> v1.0.0: Allows users to access geodatabasees and obtain information from the American Community Survey <a href="https://www.census.gov/programs-surveys/acs">(ACS)</a>. See the <a href="https://cran.r-project.org/web/packages/geogenr/vignettes/geogenr.html">vignette</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=openSkies">openSkies</a> v0.99.8: Provides a client interface to the <a href="https://opensky-network.org">OpenSky</a> API that allows retrieval of flight information, as well as aircraft state vectors. See the <a href="https://cran.r-project.org/web/packages/openSkies/vignettes/openSkies.html">vignette</a>.</p>
<p><img src="openSkies.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=salem">salem</a> v0.2.0: Access data on all 152 accused witches from the 1692 <a href="https://www.tulane.edu/~salem/index.html">Salem Witch Trials</a>. There is an <a href="https://cran.r-project.org/web/packages/salem/vignettes/introduction.html">Introduction</a> and a <a href="https://cran.r-project.org/web/packages/salem/vignettes/recreating_analyses.html">vignette</a> reproducing an analysis.</p>
<p><img src="salem.png" height = "400" width="600"></p>
<h3 id="epidemiology">Epidemiology</h3>
<p><a href="https://cran.r-project.org/package=oxcgrt">oxcgrt</a> v0.1.0: Implements an interface to the Oxford COVID-19 Government Response Tracker <a href="https://covidtracker.bsg.ox.ac.uk/">(OxCGRT)</a>. There are vignettes on <a href="https://cran.r-project.org/web/packages/oxcgrt/vignettes/calculate.html">calculating incices</a> and <a href="https://cran.r-project.org/web/packages/oxcgrt/vignettes/retrieve.html">retrieving data</a>.</p>
<p><a href="https://cran.r-project.org/package=PandemicLP">PandemicLP</a> v0.2.0: Implements the <a href="http://est.ufmg.br/covidlp/home/pt/">CovidL</a> methodology for long-term epidemic and pandemic prediction. There is an <a href="https://cran.r-project.org/web/packages/PandemicLP/vignettes/PandemicLP.html">Introduction</a> and a <a href="https://cran.r-project.org/web/packages/PandemicLP/vignettes/PandemicLP_SumRegions.html">case study</a>.</p>
<p><a href="https://cran.r-project.org/package=SEIRfansy">SEIRfansy</a> v1.1.0: Implements the Extended Susceptible-Exposed-Infected-Recovery Model for handling high false negative rate and symptom based administration of diagnostic tests. See <a href="https://www.medrxiv.org/content/10.1101/2020.09.24.20200238v1">Bhaduri et al. (2020)</a> and the <a href="https://github.com/umich-biostatistics/SEIRfans">GitHub site</a> for examples.</p>
<p><img src="SEIRfansy.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=trendeval">trendeval</a> v0.0.1: Provides a coherent interface for evaluating models fit with the <a href="https://www.repidemicsconsortium.org/">RECON</a> <a href="https://CRAN.R-project.org/package=trending"><code>trending</code></a> package. See <a href="https://cran.r-project.org/web/packages/trendeval/readme/README.html">README</a> to get started.</p>
<p><img src="trendeval.png" height = "300" width="500"></p>
<h3 id="games">Games</h3>
<p><a href="https://cran.r-project.org/package=chess">chess</a> v1.0.1: Implements an “opinionated” wrapper around the <code>python-chess</code> library allowing users to read and write PGN files as well as create and explore game trees such as the ones seen in chess books. See the vignettes <a href="https://cran.r-project.org/web/packages/chess/vignettes/chess.html">chess</a>, <a href="https://cran.r-project.org/web/packages/chess/vignettes/games.html">games</a>, and <a href="https://cran.r-project.org/web/packages/chess/vignettes/advanced.html">advanced</a>.</p>
<p><a href="https://cran.r-project.org/package=codebreaker">codebreaker</a> v0.0.2: Inspired by <a href="https://www.archimedes-lab.org/mastermind.html">Mastermind</a>, the package implements a logic game in the style of the early 1980s home computers that can be played in the R console. Can you break the code? See <a href="https://cran.r-project.org/web/packages/codebreaker/readme/README.html">README</a> to start playing.</p>
<p><img src="codebreaker.png" height = "200" width="400"></p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=fastai">fastai</a> v2.0.2: Implements functions to simplify training neural networks based on best practices developed at <a href="https://www.fast.ai/">fast.ai</a>. See the <a href="https://github.com/henry090/fastai">website</a> to get started and the twenty-three vignettes which include <a href="https://cran.r-project.org/web/packages/fastai/vignettes/audio.html">Audio Classification</a>, <a href="https://cran.r-project.org/web/packages/fastai/vignettes/multilabel.html">Multilabel Classification</a> and <a href="https://cran.r-project.org/web/packages/fastai/vignettes/medical_dcm.html">Medical Images</a>.</p>
<p><img src="fastai.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=mikropml">mikropml</a> v0.0.2: Implements the ML pipeline described in <a href="https://mbio.asm.org/content/11/3/e00434-20">Topçuoğlu et al. (2020)</a> For building machine learning models for classification and regression problems. There is an <a href="https://cran.r-project.org/web/packages/mikropml/vignettes/introduction.html">Introduction</a> and an <a href="https://cran.r-project.org/web/packages/mikropml/vignettes/paper.html">Overview</a>.</p>
<p><img src="mikropml.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=stacks">stacks</a> v0.1.0: Implements a grammar of model stacking for <code>tidymodels</code>. There is a <a href="https://cran.r-project.org/web/packages/stacks/vignettes/basics.html">Getting Started Guide</a> and a <a href="https://cran.r-project.org/web/packages/stacks/vignettes/classification.html">vignette</a> on classification.</p>
<p><img src="stacks.png" height = "400" width="600"></p>
<h3 id="mathematics">Mathematics</h3>
<p><a href="https://cran.r-project.org/package=BaseSet">BaseSet</a> v0.0.14: Implements a class and methods to work with sets, doing intersection, union, complementary sets, power sets, cartesian product and other set operations in a “tidy” way. See the <a href="https://cran.r-project.org/web/packages/BaseSet/vignettes/basic.html">Introduction</a>, and the vignettes <a href="https://cran.r-project.org/web/packages/BaseSet/vignettes/advanced.html">Advanced Examples</a> and <a href="https://cran.r-project.org/web/packages/BaseSet/vignettes/fuzzy.html">Fuzzy Sets</a>.</p>
<p><a href="https://cran.r-project.org/src/contrib/Archive/viscomplexr">viscomplexr</a> v1.1.0: Provides functions to create phase portraits of functions in the complex number plane. See the <a href="https://cran.r-project.org/web/packages/viscomplexr/vignettes/viscomplexr-vignette.html">vignette</a> to get started.</p>
<p><img src="viscomplexr.png" height = "400" width="600"></p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=causalCmprsk">causalCmprisk</a> v1.0.0: Provides functions to estimate average treatment effects of two static treatment regimes on time-to-event outcomes with competing events. The method uses propensity scores weighting for emulation of baseline randomization. See the <a href="https://cran.r-project.org/web/packages/causalCmprsk/vignettes/cmp_rsk_RHC.html">vignette</a>.</p>
<p><img src="causalCmprisk.png" height = "250" width="450"></p>
<p><a href="https://cran.r-project.org/package=eventglm">eventglm</a> v1.0.2 Implements methods for doing event history regression for marginal estimands, including cumulative incidence the restricted mean survival, as described in the methodology reviewed in <a href="https://journals.sagepub.com/doi/10.1177/0962280209105020">Andersen & Perme (2010)</a>. See the <a href="https://cran.r-project.org/web/packages/eventglm/vignettes/example-analysis.html">vignette</a> for examples.</p>
<p><img src="eventglm.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=IPDfromKM">IPDfromKM</a> v0.1.10: Implements a method to reconstruct individual patient data from Kaplan-Meier (KM) survival curves, visualize and assess the accuracy of the reconstruction, and perform secondary analysis on the reconstructed data. The package also implements iterative KM estimation algorithm proposed in <a href="https://bmcmedresmethodol.biomedcentral.com/articles/10.1186/1471-2288-12-9">Guyot (2012)</a>.</p>
<p><a href="https://cran.r-project.org/package=packDAMipd">packDAMipd</a> v0.1.2: Provides functions to construct both time-homogenous and time-dependent Markov models for cost-effectiveness analyses, perform decision analyses, and conduct deterministic and probabilistic sensitivity analyses. There are vignettes on <a href="https://cran.r-project.org/web/packages/packDAMipd/vignettes/Deterministic_sensitivity_analysis.html">deterministic</a> and <a href="https://cran.r-project.org/web/packages/packDAMipd/vignettes/Probabilstic_sensitivity_analysis.html">probabilistic</a> sensitivity analyses, <a href="https://cran.r-project.org/web/packages/packDAMipd/vignettes/Simple_sick_sicker.html">simple</a> “sick-sicker” models, <a href="https://cran.r-project.org/web/packages/packDAMipd/vignettes/Sick_sicker_age_dependent.html">age-dependent</a> “sick-sicker” models, and <a href="https://cran.r-project.org/web/packages/packDAMipd/vignettes/cycle_dependent.html">cycle dependent</a> models.</p>
<p><img src="packDAMipd.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=reconstructKM">reconstructKM</a> v0.3.0: Provides functions for reconstructing individual-level data (time, status, arm) from Kaplan-MEIER curves published in academic journals. See <a href="https://www.nejm.org/doi/10.1056/NEJMc1808567">Sun et al. (2018)</a> for background and the <a href="https://cran.r-project.org/web/packages/reconstructKM/vignettes/introduction.html">vignette</a> for the reconstruction procedure.</p>
<p><img src="reconstructKM.png" height = "400" width="600"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=ceser">ceser</a> v1.0.0: Implements the Cluster Estimated Standard Errors method proposed in <a href="https://www.cambridge.org/core/journals/political-analysis/article/abs/corrected-standard-errors-with-clustered-data/F2332E494290725256181955B9BC7428">Jackson (2020)</a> to compute clustered standard errors of linear coefficients in regression models with grouped data. See the <a href="https://cran.r-project.org/web/packages/ceser/vignettes/ceser.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=gfilmm">gfilmm</a> v2.0.2: Implements generalized Fiducial inference for normal linear mixed models. Fiducial inference is similar to Bayesian inference in the sense that it represents the uncertainty about the parameters with a probability distribution. However, it does not require a prior. See <a href="https://projecteuclid.org/euclid.aos/1351602538">Cisewski and Hannig (2012)</a> for background and the <a href="https://cran.r-project.org/web/packages/gfilmm/vignettes/the-gfilmm-package.html">vignette</a> for examples.</p>
<p><img src="gfilmm.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=hdpGLM">hdpGLM</a> v1.0.0: Implements MCMC algorithms to estimate the Hierarchical Dirichlet Process Generalized Linear Model presented in paper <a href="https://www.cambridge.org/core/journals/political-analysis/article/abs/modeling-contextdependent-latent-effect-heterogeneity/B7B0AF067DF97A1A8F0B50646EF64F24">Ferrari (2020)</a>. See the <a href="https://cran.r-project.org/web/packages/hdpGLM/vignettes/hdpGLM.html">vignette</a> for examples.</p>
<p><img src="hdpGLM.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=latrend">latrend</a> v1.0.1: Implements a framework for clustering longitudinal datasets in a standardized way. There is a <a href="https://cran.r-project.org/web/packages/latrend/vignettes/demo.html">Demo</a> vignette and vignettes on implementing <a href="https://cran.r-project.org/web/packages/latrend/vignettes/custom.html">new models</a> and <a href="https://cran.r-project.org/web/packages/latrend/vignettes/validation.html">validating</a> cluster models.</p>
<p><img src="latrend.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=mixComp">mixComp</a> v0.1-1: Implements methods to estimate the order of mixture distributions. See the <a href="https://cran.r-project.org/web/packages/mixComp/vignettes/mixComp.html">vignette</a> for an introduction to mixture models and and extended list of references.</p>
<p><img src="mixComp.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=monoClust">monoClust</a> v1.2.0:
Implements the monothetic clustering algorithm for continuous data described in <a href="https://www.sciencedirect.com/science/article/abs/pii/S0167865598000877?via%3Dihub">Chavent (1998)</a>. See the <a href="https://cran.r-project.org/web/packages/monoClust/vignettes/monoclust.html">vignette</a>.</p>
<p><img src="monoClust.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=potential">potential</a> v0.1.0: Implements the potential model for measuring social influences described in <a href="https://science.sciencemag.org/content/93/2404/89">Stewart (1941)</a>. See the <a href="https://cran.r-project.org/web/packages/potential/vignettes/potential.html">vignette</a> for an introduction.</p>
<p><img src="potential.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=sftrack">sftrack</a> v0.5.2: Implements classes for tracking and movement data, building on <code>sf</code> spatial infrastructure, and early theoretical work from <a href="https://www.amazon.com/Quantitative-Analysis-Movement-Population-Redistribution/dp/0996139508">Turchin (1998)</a>, and <a href="https://www.sciencedirect.com/science/article/abs/pii/S1574954108000654?via%3Dihub">Calenge et al. (2009)</a>. There is an <a href="https://cran.r-project.org/web/packages/sftrack/vignettes/sftrack1_overview.html">Overview</a> along with the vignettes <a href="https://cran.r-project.org/web/packages/sftrack/index.html">Reading in an sftrack</a>, <a href="https://cran.r-project.org/web/packages/sftrack/vignettes/sftrack3_workingwith.html">Structure</a>, <a href="https://cran.r-project.org/web/packages/sftrack/vignettes/sftrack4_groups.html">Fantastic Groups</a>, and <a href="https://cran.r-project.org/web/packages/sftrack/vignettes/sftrack5_spatial.html">Getting Spatial</a>.</p>
<p><img src="sftrack.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=simrec">simrec</a> v1.0.0: Provides functions to simulate recurrent event data with a non-constant baseline hazard and possibly risk-free intervals and competing events. See <a href="https://bmcmedresmethodol.biomedcentral.com/articles/10.1186/s12874-015-0005-2">Jahn-Eimermacher et al. (2015)</a> for background and the <a href="https://cran.r-project.org/web/packages/simrec/vignettes/simrec-vignette.html">vignette</a> for an introduction.</p>
<p><img src="simrec.png" height = "400" width="600"></p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=modeltime.resample">modeltime.resample</a> v0.1.0: A <code>modeltime</code> extension which implements forecast resampling tools to asses time-based model performance and stability for time series, panel data, and cross-sectional time series. There is a <a href="https://cran.r-project.org/web/packages/modeltime.resample/vignettes/getting-started.html">Getting Started</a> guide and a vignette on <a href="https://cran.r-project.org/web/packages/modeltime.resample/vignettes/panel-data.html">Resampling</a>.</p>
<p><img src="resample.png" height = "400" width="600"></p>
<p><a href="https://cran.r-project.org/package=tfarima">tfarima</a> v0.1.1: Provides tools to build customized transfer functions and ARIMA models with multiple operators and parameter restrictions. see <a href="https://www.tandfonline.com/doi/abs/10.1080/01621459.1983.10478005">Bell & Hilmer (1983)</a> and <a href="https://www.tandfonline.com/doi/abs/10.1080/01621459.1975.10480264">Box & Tiao (1973)</a> for background and the <a href="https://cran.r-project.org/web/packages/tfarima/vignettes/tfarima.pdf">vignette</a> for some theory and examples.</p>
<p><img src="tfarima.png" height = "300" width="500"></p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=getDTeval">getDTeval</a> v0.0.1: Provides functions to translate statements that use <code>get()</code> or <code>eval()</code> to improve run-time efficiency. See the <a href="https://cran.r-project.org/web/packages/getDTeval/vignettes/Introduction_to_getDTeval.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=lineup2">lineup2</a> v0.2-5: Provides tools for detecting and correcting sample mix-ups between two sets of measurements, such as between gene expression data on two tissues. There is a <a href="https://cran.r-project.org/web/packages/lineup2/vignettes/lineup2.html">vignette</a>.</p>
<p><img src="lineup2.png" height = "300" width="500"></p>
<p><a href="https://cran.r-project.org/package=sdcLog">sdcLog</a> v0.1.0: Tools for researchers to explicitly show that their results comply to rules for statistical disclosure control imposed by research data centers. The methods used are described in <a href="https://ec.europa.eu/eurostat/cros/system/files/dwb_standalone-document_output-checking-guidelines.pdf">Bond et al. (2015)</a>. There is an <a href="https://cran.r-project.org/web/packages/sdcLog/vignettes/sdcLog.html">Introduction</a> and a vignette on <a href="https://cran.r-project.org/web/packages/sdcLog/vignettes/options.html">options</a>.</p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=leaflet.multiopacity">leaflet.multiopacity</a> v0.1.1: Extends <code>leaflet</code> by adding a widget to control the opacity of multiple layers. There are vignettes for using the package with <a href="https://cran.r-project.org/web/packages/leaflet.multiopacity/vignettes/usage-leaflet.html">leaflet</a> and <a href="https://cran.r-project.org/web/packages/leaflet.multiopacity/vignettes/usage-leafletProxy.html">leafletProxy</a>.</p>
<p><a href="https://cran.r-project.org/package=mapboxer">mapboxer</a> v0.4.0: Provides access to <a href="https://docs.mapbox.com/mapbox-gl-js/api/">Mapbox GL JS</a>, an open source JavaScript library that uses <a href="https://get.webgl.org/">WebGL</a> to render interactive maps via the <code>htmlwidgets</code> package. Visualizations can be used from the R console, in R Markdown documents and in Shiny apps. See the <a href="https://cran.r-project.org/web/packages/mapboxer/vignettes/mapboxer.html">vignette</a> to get started.</p>
<p><img src="mapboxer.png" height = "400" width="600"></p>
<script>window.location.href='https://rviews.rstudio.com/2020/12/22/november-top-40-new-cran-packages/';</script>
Plotting Surfaces with R
https://rviews.rstudio.com/2020/12/14/plotting-surfaces-with-r/
Mon, 14 Dec 2020 00:00:00 +0000https://rviews.rstudio.com/2020/12/14/plotting-surfaces-with-r/
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/header-attrs/header-attrs.js"></script>
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/htmlwidgets/htmlwidgets.js"></script>
<link href="/2020/12/14/plotting-surfaces-with-r/index_files/rglwidgetClass/rgl.css" rel="stylesheet" />
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/rglwidgetClass/rglClass.src.js"></script>
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/CanvasMatrix4/CanvasMatrix.src.js"></script>
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/rglWebGL-binding/rglWebGL.js"></script>
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/jquery/jquery.min.js"></script>
<link href="/2020/12/14/plotting-surfaces-with-r/index_files/crosstalk/css/crosstalk.css" rel="stylesheet" />
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/crosstalk/js/crosstalk.min.js"></script>
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/threejs/three.min.js"></script>
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/threejs/Detector.js"></script>
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/threejs/Projector.js"></script>
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/threejs/CanvasRenderer.js"></script>
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/threejs/TrackballControls.js"></script>
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/threejs/StateOrbitControls.js"></script>
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/scatterplotThree-binding/scatterplotThree.js"></script>
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/plotly-binding/plotly.js"></script>
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/typedarray/typedarray.min.js"></script>
<link href="/2020/12/14/plotting-surfaces-with-r/index_files/plotly-htmlwidgets-css/plotly-htmlwidgets.css" rel="stylesheet" />
<script src="/2020/12/14/plotting-surfaces-with-r/index_files/plotly-main/plotly-latest.min.js"></script>
<p>In this post, I’d like to review some basic options for plotting three dimensional surfaces in R. In addition to producing some eye catching visualizations, plotting surfaces can also help develop one’s geometric intuition for the mathematics describing the surfaces.</p>
<p>The first plot below shows a <a href="https://en.wikipedia.org/wiki/Helicoid">Helicoid</a> surface which is the path a propeller moving at uniform speed along the z-axis would sweep out. You might be familiar with this shape from working with a hand turned steel auger or a <a href="https://www.tandfonline.com/doi/pdf/10.1080/00046973.1973.9648356">helocoid anemometer</a>. The surface is built up from first principles as follows: we consider two open intervals U = {u: <span class="math inline">\(\in\)</span> (0 , 2<span class="math inline">\(\pi\)</span>)} and V = {v: <span class="math inline">\(\in\)</span> (0 , <span class="math inline">\(\pi\)</span>)}, lay down a mesh or grid over the two dimensional open set U x V, compute the parametric representation of the surface in <span class="math inline">\(R^{3}\)</span>, and use the
<code>surf3D()</code> function from the <a href="https://cran.r-project.org/package=plot3D">plot3D</a> package to render the surface.</p>
<pre class="r"><code>library(plot3D)
M <- mesh(seq(0, 6*pi, length.out = 50),seq(pi/3, pi, length.out = 50))
u <- M$x ; v <- M$y
x <- v * cos(u)
y <- v * sin(u)
z <- 10 * u
surf3D(x, y, z, colvar = z, colkey = TRUE,
box = TRUE, bty = "b", phi = 20, theta = 120)</code></pre>
<p><img src="/2020/12/14/plotting-surfaces-with-r/index_files/figure-html/unnamed-chunk-1-1.png" width="672" />
The next code block uses the same approach and functions to render half of a torus.</p>
<pre class="r"><code>R <- 3; r <- 2
M <- mesh(seq(0, 2*pi,length.out=50), seq(0, pi,length.out=50))
alpha <- M$x; beta <- M$y
x <- (R + r*cos(alpha)) * cos(beta)
y <- (R + r*cos(alpha)) * sin(beta)
z <- r * sin(alpha)
surf3D(x = x, y = y, z = z, colkey=TRUE, bty="b2",
phi = 40, theta = 30, main="Half of a Torus")</code></pre>
<p><img src="/2020/12/14/plotting-surfaces-with-r/index_files/figure-html/unnamed-chunk-2-1.png" width="672" /></p>
<p>You might test your intuition about the how changing the ratio of R and r alters the look of the torus.</p>
<p>I think <code>surf3D()</code>, which is built on base R graphics, produces high quality visualizations. I really like the crisp, metallic look of the torus. However, although <code>surf3D()</code> allows you to set the viewing angle, it is limited to producing static plots. A first remedy for this might be to consider the <code>plot3d()</code> function in the <a href="https://cran.r-project.org/package=rgl">rgl package</a> which contains functions built on base graphics and the <a href="https://www.opengl.org/">OpenGL</a> standard for high performance graphics. You can use the same code as above, but just swap out <code>surf3D()</code> and replace it with <code>plot3d()</code>.</p>
<p>Here is a wireframe version of the half torus that you can rotate with your mouse.</p>
<pre class="r"><code>library(rgl)
torus <- plot3d(x, y, z, type = "l", col = "blue",
cex = .3, pch = 1, main = "Half Torus", pch = 20)
rglwidget(elementId = "plot3drgl")</code></pre>
<div id="plot3drgl" style="width:672px;height:480px;" class="rglWebGL html-widget"></div>
<script type="application/json" data-for="plot3drgl">{"x":{"material":{"color":"#000000","alpha":1,"lit":true,"ambient":"#000000","specular":"#FFFFFF","emission":"#000000","shininess":50,"smooth":true,"front":"filled","back":"filled","size":3,"lwd":1,"fog":false,"point_antialias":false,"line_antialias":false,"texture":null,"textype":"rgb","texmipmap":false,"texminfilter":"linear","texmagfilter":"linear","texenvmap":false,"depth_mask":true,"depth_test":"less","isTransparent":false,"polygon_offset":[0,0]},"rootSubscene":6,"objects":{"12":{"id":12,"type":"linestrip","material":{"lit":false},"vertices":[[5,0,0],[4.98358011245728,0,0.255754321813583],[4.93458986282349,0,0.507309138774872],[4.85383367538452,0,0.750533998012543],[4.74263763427734,0,0.981435120105743],[4.60282707214355,0,1.19622111320496],[4.43669891357422,0,1.39136505126953],[4.24697971343994,0,1.56366300582886],[4.03678512573242,0,1.71028554439545],[3.80956673622131,0,1.82882523536682],[3.56905508041382,0,1.91733574867249],[3.31919980049133,0,1.97436356544495],[3.06410312652588,0,1.99897241592407],[2.80795383453369,0,1.99075818061829],[2.55495810508728,0,1.94985580444336],[2.30926990509033,0,1.87693679332733],[2.07492351531982,0,1.77319860458374],[1.85576665401459,0,1.64034450054169],[1.65539824962616,0,1.48055601119995],[1.47710812091827,0,1.29645681381226],[1.32382380962372,0,1.09106981754303],[1.19806230068207,0,0.867767453193665],[1.10188853740692,0,0.630216419696808],[1.03688168525696,0,0.382317245006561],[1.0041092634201,0,0.128140434622765],[1.0041092634201,0,-0.128140434622765],[1.03688168525696,0,-0.382317245006561],[1.10188853740692,0,-0.630216419696808],[1.19806230068207,0,-0.867767453193665],[1.32382380962372,0,-1.09106981754303],[1.47710812091827,0,-1.29645681381226],[1.65539824962616,0,-1.48055601119995],[1.85576665401459,0,-1.64034450054169],[2.07492351531982,0,-1.77319860458374],[2.30926990509033,0,-1.87693679332733],[2.55495810508728,0,-1.94985580444336],[2.80795383453369,0,-1.99075818061829],[3.06410312652588,0,-1.99897241592407],[3.31919980049133,0,-1.97436356544495],[3.56905508041382,0,-1.91733574867249],[3.80956673622131,0,-1.82882523536682],[4.03678512573242,0,-1.71028554439545],[4.24697971343994,0,-1.56366300582886],[4.43669891357422,0,-1.39136505126953],[4.60282707214355,0,-1.19622111320496],[4.74263763427734,0,-0.981435120105743],[4.85383367538452,0,-0.750533998012543],[4.93458986282349,0,-0.507309138774872],[4.98358011245728,0,-0.255754321813583],[5,0,-4.89858741034067e-16],[4.98972702026367,0.320351094007492,0],[4.97334051132202,0.319299072027206,0.255754321813583],[4.92445087432861,0.316160261631012,0.507309138774872],[4.8438606262207,0.310986191034317,0.750533998012543],[4.7328929901123,0.303861826658249,0.981435120105743],[4.59337043762207,0.294904142618179,1.19622111320496],[4.42758321762085,0.284260272979736,1.39136505126953],[4.23825359344482,0.272104918956757,1.56366300582886],[4.02849102020264,0.258637726306915,1.71028554439545],[3.80173945426941,0.244079768657684,1.82882523536682],[3.56172227859497,0.22867015004158,1.91733574867249],[3.31238007545471,0.212661862373352,1.97436356544495],[3.0578076839447,0.196317762136459,1.99897241592407],[2.80218482017517,0.179906234145164,1.99075818061829],[2.54970860481262,0.163696736097336,1.94985580444336],[2.30452513694763,0.147955432534218,1.87693679332733],[2.07066035270691,0.132940798997879,1.77319860458374],[1.8519538640976,0.118899382650852,1.64034450054169],[1.6519969701767,0.106061726808548,1.48055601119995],[1.4740731716156,0.0946386381983757,1.29645681381226],[1.32110381126404,0.0848176777362823,1.09106981754303],[1.19560074806213,0.0767601132392883,0.867767453193665],[1.09962451457977,0.0705982372164726,0.630216419696808],[1.0347512960434,0.0664332360029221,0.382317245006561],[1.00204610824585,0.0643334984779358,0.128140434622765],[1.00204610824585,0.0643334984779358,-0.128140434622765],[1.0347512960434,0.0664332360029221,-0.382317245006561],[1.09962451457977,0.0705982372164726,-0.630216419696808],[1.19560074806213,0.0767601132392883,-0.867767453193665],[1.32110381126404,0.0848176777362823,-1.09106981754303],[1.4740731716156,0.0946386381983757,-1.29645681381226],[1.6519969701767,0.106061726808548,-1.48055601119995],[1.8519538640976,0.118899382650852,-1.64034450054169],[2.07066035270691,0.132940798997879,-1.77319860458374],[2.30452513694763,0.147955432534218,-1.87693679332733],[2.54970860481262,0.163696736097336,-1.94985580444336],[2.80218482017517,0.179906234145164,-1.99075818061829],[3.0578076839447,0.196317762136459,-1.99897241592407],[3.31238007545471,0.212661862373352,-1.97436356544495],[3.56172227859497,0.22867015004158,-1.91733574867249],[3.80173945426941,0.244079768657684,-1.82882523536682],[4.02849102020264,0.258637726306915,-1.71028554439545],[4.23825359344482,0.272104918956757,-1.56366300582886],[4.42758321762085,0.284260272979736,-1.39136505126953],[4.59337043762207,0.294904142618179,-1.19622111320496],[4.7328929901123,0.303861826658249,-0.981435120105743],[4.8438606262207,0.310986191034317,-0.750533998012543],[4.92445087432861,0.316160261631012,-0.507309138774872],[4.97334051132202,0.319299072027206,-0.255754321813583],[4.98972702026367,0.320351094007492,-4.89858741034067e-16],[4.95895004272461,0.63938581943512,0],[4.94266510009766,0.637286067008972,0.255754321813583],[4.89407682418823,0.631021320819855,0.507309138774872],[4.81398344039917,0.62069445848465,0.750533998012543],[4.70370054244995,0.606474995613098,0.981435120105743],[4.56503820419312,0.58859646320343,1.19622111320496],[4.40027332305908,0.567352414131165,1.39136505126953],[4.21211194992065,0.543091714382172,1.56366300582886],[4.00364303588867,0.516212642192841,1.71028554439545],[3.77829027175903,0.487156569957733,1.82882523536682],[3.53975319862366,0.456400632858276,1.91733574867249],[3.29194927215576,0.424449861049652,1.97436356544495],[3.03894686698914,0.391828805208206,1.99897241592407],[2.7849006652832,0.35907319188118,1.99075818061829],[2.53398203849792,0.326720803976059,1.94985580444336],[2.29031085968018,0.295302867889404,1.87693679332733],[2.05788826942444,0.265335321426392,1.77319860458374],[1.84053087234497,0.237310171127319,1.64034450054169],[1.64180743694305,0.211687624454498,1.48055601119995],[1.46498107910156,0.188888385891914,1.29645681381226],[1.31295526027679,0.169286832213402,1.09106981754303],[1.18822622299194,0.153204798698425,0.867767453193665],[1.09284198284149,0.140906378626823,0.630216419696808],[1.02836894989014,0.132593482732773,0.382317245006561],[0.99586546421051,0.128402635455132,0.128140434622765],[0.99586546421051,0.128402635455132,-0.128140434622765],[1.02836894989014,0.132593482732773,-0.382317245006561],[1.09284198284149,0.140906378626823,-0.630216419696808],[1.18822622299194,0.153204798698425,-0.867767453193665],[1.31295526027679,0.169286832213402,-1.09106981754303],[1.46498107910156,0.188888385891914,-1.29645681381226],[1.64180743694305,0.211687624454498,-1.48055601119995],[1.84053087234497,0.237310171127319,-1.64034450054169],[2.05788826942444,0.265335321426392,-1.77319860458374],[2.29031085968018,0.295302867889404,-1.87693679332733],[2.53398203849792,0.326720803976059,-1.94985580444336],[2.7849006652832,0.35907319188118,-1.99075818061829],[3.03894686698914,0.391828805208206,-1.99897241592407],[3.29194927215576,0.424449861049652,-1.97436356544495],[3.53975319862366,0.456400632858276,-1.91733574867249],[3.77829027175903,0.487156569957733,-1.82882523536682],[4.00364303588867,0.516212642192841,-1.71028554439545],[4.21211194992065,0.543091714382172,-1.56366300582886],[4.40027332305908,0.567352414131165,-1.39136505126953],[4.56503820419312,0.58859646320343,-1.19622111320496],[4.70370054244995,0.606474995613098,-0.981435120105743],[4.81398344039917,0.62069445848465,-0.750533998012543],[4.89407682418823,0.631021320819855,-0.507309138774872],[4.94266510009766,0.637286067008972,-0.255754321813583],[4.95895004272461,0.63938581943512,-4.89858741034067e-16],[4.90779590606689,0.955793142318726,0],[4.89167881011963,0.952654302120209,0.255754321813583],[4.84359169006348,0.943289399147034,0.507309138774872],[4.76432466506958,0.927852153778076,0.750533998012543],[4.65517902374268,0.906596064567566,0.981435120105743],[4.51794719696045,0.879870116710663,1.19622111320496],[4.35488224029541,0.848113238811493,1.39136505126953],[4.16866159439087,0.811846792697906,1.56366300582886],[3.96234345436096,0.771666288375854,1.71028554439545],[3.73931503295898,0.728231549263,1.82882523536682],[3.50323867797852,0.682255685329437,1.91733574867249],[3.25799083709717,0.634493708610535,1.97436356544495],[3.00759840011597,0.585729777812958,1.99897241592407],[2.75617289543152,0.536764621734619,1.99075818061829],[2.50784254074097,0.488402307033539,1.94985580444336],[2.26668500900269,0.441436856985092,1.87693679332733],[2.03666019439697,0.39663952589035,1.77319860458374],[1.82154476642609,0.354745805263519,1.64034450054169],[1.62487125396729,0.316443651914597,1.48055601119995],[1.44986891746521,0.282361954450607,1.29645681381226],[1.29941141605377,0.253060340881348,1.09106981754303],[1.17596900463104,0.229019939899445,0.867767453193665],[1.08156871795654,0.210635498166084,0.630216419696808],[1.01776075363159,0.198208883404732,0.382317245006561],[0.985592603683472,0.191944137215614,0.128140434622765],[0.985592603683472,0.191944137215614,-0.128140434622765],[1.01776075363159,0.198208883404732,-0.382317245006561],[1.08156871795654,0.210635498166084,-0.630216419696808],[1.17596900463104,0.229019939899445,-0.867767453193665],[1.29941141605377,0.253060340881348,-1.09106981754303],[1.44986891746521,0.282361954450607,-1.29645681381226],[1.62487125396729,0.316443651914597,-1.48055601119995],[1.82154476642609,0.354745805263519,-1.64034450054169],[2.03666019439697,0.39663952589035,-1.77319860458374],[2.26668500900269,0.441436856985092,-1.87693679332733],[2.50784254074097,0.488402307033539,-1.94985580444336],[2.75617289543152,0.536764621734619,-1.99075818061829],[3.00759840011597,0.585729777812958,-1.99897241592407],[3.25799083709717,0.634493708610535,-1.97436356544495],[3.50323867797852,0.682255685329437,-1.91733574867249],[3.73931503295898,0.728231549263,-1.82882523536682],[3.96234345436096,0.771666288375854,-1.71028554439545],[4.16866159439087,0.811846792697906,-1.56366300582886],[4.35488224029541,0.848113238811493,-1.39136505126953],[4.51794719696045,0.879870116710663,-1.19622111320496],[4.65517902374268,0.906596064567566,-0.981435120105743],[4.76432466506958,0.927852153778076,-0.750533998012543],[4.84359169006348,0.943289399147034,-0.507309138774872],[4.89167881011963,0.952654302120209,-0.255754321813583],[4.90779590606689,0.955793142318726,-4.89858741034067e-16],[4.83647441864014,1.2682728767395,0],[4.82059144973755,1.26410794258118,0.255754321813583],[4.77320337295532,1.25168132781982,0.507309138774872],[4.69508838653564,1.23119711875916,0.750533998012543],[4.58752870559692,1.20299172401428,0.981435120105743],[4.4522910118103,1.16752827167511,1.19622111320496],[4.29159593582153,1.1253889799118,1.39136505126953],[4.10808134078979,1.07726585865021,1.56366300582886],[3.90476155281067,1.02394902706146,1.71028554439545],[3.684974193573,0.966314077377319,1.82882523536682],[3.4523286819458,0.905307233333588,1.91733574867249],[3.21064496040344,0.841930270195007,1.97436356544495],[2.96389126777649,0.777223825454712,1.99897241592407],[2.71611952781677,0.712250411510468,1.99075818061829],[2.4713978767395,0.648076832294464,1.94985580444336],[2.23374485969543,0.585756897926331,1.87693679332733],[2.00706267356873,0.526313841342926,1.77319860458374],[1.7950736284256,0.47072371840477,1.64034450054169],[1.60125815868378,0.419899344444275,1.48055601119995],[1.42879903316498,0.374675244092941,1.29645681381226],[1.28052794933319,0.335793972015381,1.09106981754303],[1.15887951850891,0.303893983364105,0.867767453193665],[1.06585109233856,0.279499083757401,0.630216419696808],[1.00297033786774,0.263009786605835,0.382317245006561],[0.97126966714859,0.254696905612946,0.128140434622765],[0.97126966714859,0.254696905612946,-0.128140434622765],[1.00297033786774,0.263009786605835,-0.382317245006561],[1.06585109233856,0.279499083757401,-0.630216419696808],[1.15887951850891,0.303893983364105,-0.867767453193665],[1.28052794933319,0.335793972015381,-1.09106981754303],[1.42879903316498,0.374675244092941,-1.29645681381226],[1.60125815868378,0.419899344444275,-1.48055601119995],[1.7950736284256,0.47072371840477,-1.64034450054169],[2.00706267356873,0.526313841342926,-1.77319860458374],[2.23374485969543,0.585756897926331,-1.87693679332733],[2.4713978767395,0.648076832294464,-1.94985580444336],[2.71611952781677,0.712250411510468,-1.99075818061829],[2.96389126777649,0.777223825454712,-1.99897241592407],[3.21064496040344,0.841930270195007,-1.97436356544495],[3.4523286819458,0.905307233333588,-1.91733574867249],[3.684974193573,0.966314077377319,-1.82882523536682],[3.90476155281067,1.02394902706146,-1.71028554439545],[4.10808134078979,1.07726585865021,-1.56366300582886],[4.29159593582153,1.1253889799118,-1.39136505126953],[4.4522910118103,1.16752827167511,-1.19622111320496],[4.58752870559692,1.20299172401428,-0.981435120105743],[4.69508838653564,1.23119711875916,-0.750533998012543],[4.77320337295532,1.25168132781982,-0.507309138774872],[4.82059144973755,1.26410794258118,-0.255754321813583],[4.83647441864014,1.2682728767395,-4.89858741034067e-16],[4.74527883529663,1.57554113864899,0],[4.72969532012939,1.57036697864532,0.255754321813583],[4.68320083618164,1.55492973327637,0.507309138774872],[4.60655879974365,1.5294828414917,0.750533998012543],[4.50102710723877,1.49444401264191,0.981435120105743],[4.36833953857422,1.45038866996765,1.19622111320496],[4.21067428588867,1.39804017543793,1.39136505126953],[4.03062057495117,1.33825814723969,1.56366300582886],[3.83113408088684,1.27202415466309,1.71028554439545],[3.61549115180969,1.2004257440567,1.82882523536682],[3.38723230361938,1.12463855743408,1.91733574867249],[3.15010571479797,1.04590713977814,1.97436356544495],[2.90800476074219,0.965524077415466,1.99897241592407],[2.66490483283997,0.884809374809265,1.99075818061829],[2.42479777336121,0.80508828163147,1.94985580444336],[2.19162583351135,0.727669894695282,1.87693679332733],[1.96921801567078,0.653825402259827,1.77319860458374],[1.76122605800629,0.58476734161377,1.64034450054169],[1.57106518745422,0.521629571914673,1.48055601119995],[1.40185797214508,0.465448886156082,1.29645681381226],[1.25638258457184,0.417147755622864,1.09106981754303],[1.13702785968781,0.377519279718399,0.867767453193665],[1.0457535982132,0.347214132547379,0.630216419696808],[0.984058499336243,0.326729953289032,0.382317245006561],[0.952955603599548,0.316403061151505,0.128140434622765],[0.952955603599548,0.316403061151505,-0.128140434622765],[0.984058499336243,0.326729953289032,-0.382317245006561],[1.0457535982132,0.347214132547379,-0.630216419696808],[1.13702785968781,0.377519279718399,-0.867767453193665],[1.25638258457184,0.417147755622864,-1.09106981754303],[1.40185797214508,0.465448886156082,-1.29645681381226],[1.57106518745422,0.521629571914673,-1.48055601119995],[1.76122605800629,0.58476734161377,-1.64034450054169],[1.96921801567078,0.653825402259827,-1.77319860458374],[2.19162583351135,0.727669894695282,-1.87693679332733],[2.42479777336121,0.80508828163147,-1.94985580444336],[2.66490483283997,0.884809374809265,-1.99075818061829],[2.90800476074219,0.965524077415466,-1.99897241592407],[3.15010571479797,1.04590713977814,-1.97436356544495],[3.38723230361938,1.12463855743408,-1.91733574867249],[3.61549115180969,1.2004257440567,-1.82882523536682],[3.83113408088684,1.27202415466309,-1.71028554439545],[4.03062057495117,1.33825814723969,-1.56366300582886],[4.21067428588867,1.39804017543793,-1.39136505126953],[4.36833953857422,1.45038866996765,-1.19622111320496],[4.50102710723877,1.49444401264191,-0.981435120105743],[4.60655879974365,1.5294828414917,-0.750533998012543],[4.68320083618164,1.55492973327637,-0.507309138774872],[4.72969532012939,1.57036697864532,-0.255754321813583],[4.74527883529663,1.57554113864899,-4.89858741034067e-16],[4.63458395004272,1.87633502483368,0],[4.61936378479004,1.8701730966568,0.255754321813583],[4.5739541053772,1.85178875923157,0.507309138774872],[4.49909973144531,1.82148361206055,0.750533998012543],[4.39602994918823,1.77975535392761,0.981435120105743],[4.26643753051758,1.7272891998291,1.19622111320496],[4.11245059967041,1.6649466753006,1.39136505126953],[3.93659663200378,1.59375131130219,1.56366300582886],[3.74176383018494,1.51487231254578,1.71028554439545],[3.53115129470825,1.42960464954376,1.82882523536682],[3.30821704864502,1.3393486738205,1.91733574867249],[3.07662200927734,1.24558615684509,1.97436356544495],[2.84016847610474,1.14985680580139,1.99897241592407],[2.60273957252502,1.05373251438141,1.99075818061829],[2.36823344230652,0.958791494369507,1.94985580444336],[2.14050102233887,0.866592824459076,1.87693679332733],[1.92328131198883,0.778650283813477,1.77319860458374],[1.72014129161835,0.696408033370972,1.64034450054169],[1.53441631793976,0.621216356754303,1.48055601119995],[1.36915624141693,0.554309904575348,1.29645681381226],[1.22707450389862,0.496787399053574,1.09106981754303],[1.11050403118134,0.449593245983124,0.867767453193665],[1.02135896682739,0.413502395153046,0.630216419696808],[0.961103022098541,0.389107495546341,0.382317245006561],[0.930725634098053,0.376809060573578,0.128140434622765],[0.930725634098053,0.376809060573578,-0.128140434622765],[0.961103022098541,0.389107495546341,-0.382317245006561],[1.02135896682739,0.413502395153046,-0.630216419696808],[1.11050403118134,0.449593245983124,-0.867767453193665],[1.22707450389862,0.496787399053574,-1.09106981754303],[1.36915624141693,0.554309904575348,-1.29645681381226],[1.53441631793976,0.621216356754303,-1.48055601119995],[1.72014129161835,0.696408033370972,-1.64034450054169],[1.92328131198883,0.778650283813477,-1.77319860458374],[2.14050102233887,0.866592824459076,-1.87693679332733],[2.36823344230652,0.958791494369507,-1.94985580444336],[2.60273957252502,1.05373251438141,-1.99075818061829],[2.84016847610474,1.14985680580139,-1.99897241592407],[3.07662200927734,1.24558615684509,-1.97436356544495],[3.30821704864502,1.3393486738205,-1.91733574867249],[3.53115129470825,1.42960464954376,-1.82882523536682],[3.74176383018494,1.51487231254578,-1.71028554439545],[3.93659663200378,1.59375131130219,-1.56366300582886],[4.11245059967041,1.6649466753006,-1.39136505126953],[4.26643753051758,1.7272891998291,-1.19622111320496],[4.39602994918823,1.77975535392761,-0.981435120105743],[4.49909973144531,1.82148361206055,-0.750533998012543],[4.5739541053772,1.85178875923157,-0.507309138774872],[4.61936378479004,1.8701730966568,-0.255754321813583],[4.63458395004272,1.87633502483368,-4.89858741034067e-16],[4.50484418869019,2.1694188117981,0],[4.49005031585693,2.16229438781738,0.255754321813583],[4.44591188430786,2.14103817939758,0.507309138774872],[4.37315273284912,2.10599946975708,0.750533998012543],[4.27296876907349,2.05775332450867,0.981435120105743],[4.14700412750244,1.99709188938141,1.19622111320496],[3.99732732772827,1.92501139640808,1.39136505126953],[3.82639646530151,1.84269535541534,1.56366300582886],[3.63701772689819,1.75149548053741,1.71028554439545],[3.43230104446411,1.65290904045105,1.82882523536682],[3.21560764312744,1.54855501651764,1.91733574867249],[2.9904956817627,1.4401468038559,1.97436356544495],[2.76066160202026,1.32946455478668,1.99897241592407],[2.52987909317017,1.2183256149292,1.99075818061829],[2.30193781852722,1.10855484008789,1.94985580444336],[2.08058023452759,1.00195467472076,1.87693679332733],[1.86944139003754,0.900275528430939,1.77319860458374],[1.67198801040649,0.805186986923218,1.64034450054169],[1.49146223068237,0.718250393867493,1.48055601119995],[1.33082842826843,0.640893161296844,1.29645681381226],[1.19272398948669,0.574385643005371,1.09106981754303],[1.07941675186157,0.519819736480713,0.867767453193665],[0.992767214775085,0.478091508150101,0.630216419696808],[0.934198141098022,0.449886113405228,0.382317245006561],[0.904671132564545,0.435666650533676,0.128140434622765],[0.904671132564545,0.435666650533676,-0.128140434622765],[0.934198141098022,0.449886113405228,-0.382317245006561],[0.992767214775085,0.478091508150101,-0.630216419696808],[1.07941675186157,0.519819736480713,-0.867767453193665],[1.19272398948669,0.574385643005371,-1.09106981754303],[1.33082842826843,0.640893161296844,-1.29645681381226],[1.49146223068237,0.718250393867493,-1.48055601119995],[1.67198801040649,0.805186986923218,-1.64034450054169],[1.86944139003754,0.900275528430939,-1.77319860458374],[2.08058023452759,1.00195467472076,-1.87693679332733],[2.30193781852722,1.10855484008789,-1.94985580444336],[2.52987909317017,1.2183256149292,-1.99075818061829],[2.76066160202026,1.32946455478668,-1.99897241592407],[2.9904956817627,1.4401468038559,-1.97436356544495],[3.21560764312744,1.54855501651764,-1.91733574867249],[3.43230104446411,1.65290904045105,-1.82882523536682],[3.63701772689819,1.75149548053741,-1.71028554439545],[3.82639646530151,1.84269535541534,-1.56366300582886],[3.99732732772827,1.92501139640808,-1.39136505126953],[4.14700412750244,1.99709188938141,-1.19622111320496],[4.27296876907349,2.05775332450867,-0.981435120105743],[4.37315273284912,2.10599946975708,-0.750533998012543],[4.44591188430786,2.14103817939758,-0.507309138774872],[4.49005031585693,2.16229438781738,-0.255754321813583],[4.50484418869019,2.1694188117981,-4.89858741034067e-16],[4.3565936088562,2.45358777046204,0],[4.34228658676147,2.44553017616272,0.255754321813583],[4.29960012435913,2.42148971557617,0.507309138774872],[4.22923612594604,2.38186120986938,0.750533998012543],[4.13234853744507,2.32729530334473,0.981435120105743],[4.01052951812744,2.25868821144104,1.19622111320496],[3.86577844619751,2.17716598510742,1.39136505126953],[3.70047283172607,2.08406734466553,1.56366300582886],[3.51732635498047,1.98092126846313,1.71028554439545],[3.31934666633606,1.8694212436676,1.82882523536682],[3.1097846031189,1.75139796733856,1.91733574867249],[2.89208078384399,1.62878954410553,1.97436356544495],[2.66981029510498,1.50360918045044,1.99897241592407],[2.44662284851074,1.37791228294373,1.99075818061829],[2.22618269920349,1.25376284122467,1.94985580444336],[2.01210999488831,1.1331992149353,1.87693679332733],[1.80791962146759,1.01820135116577,1.77319860458374],[1.61696422100067,0.910657286643982,1.64034450054169],[1.44237947463989,0.812332987785339,1.48055601119995],[1.28703188896179,0.724842846393585,1.29645681381226],[1.15347242355347,0.649623572826385,1.09106981754303],[1.04389405250549,0.587910175323486,0.867767453193665],[0.960096061229706,0.540716052055359,0.630216419696808],[0.903454422950745,0.508816063404083,0.382317245006561],[0.87489914894104,0.492734014987946,0.128140434622765],[0.87489914894104,0.492734014987946,-0.128140434622765],[0.903454422950745,0.508816063404083,-0.382317245006561],[0.960096061229706,0.540716052055359,-0.630216419696808],[1.04389405250549,0.587910175323486,-0.867767453193665],[1.15347242355347,0.649623572826385,-1.09106981754303],[1.28703188896179,0.724842846393585,-1.29645681381226],[1.44237947463989,0.812332987785339,-1.48055601119995],[1.61696422100067,0.910657286643982,-1.64034450054169],[1.80791962146759,1.01820135116577,-1.77319860458374],[2.01210999488831,1.1331992149353,-1.87693679332733],[2.22618269920349,1.25376284122467,-1.94985580444336],[2.44662284851074,1.37791228294373,-1.99075818061829],[2.66981029510498,1.50360918045044,-1.99897241592407],[2.89208078384399,1.62878954410553,-1.97436356544495],[3.1097846031189,1.75139796733856,-1.91733574867249],[3.31934666633606,1.8694212436676,-1.82882523536682],[3.51732635498047,1.98092126846313,-1.71028554439545],[3.70047283172607,2.08406734466553,-1.56366300582886],[3.86577844619751,2.17716598510742,-1.39136505126953],[4.01052951812744,2.25868821144104,-1.19622111320496],[4.13234853744507,2.32729530334473,-0.981435120105743],[4.22923612594604,2.38186120986938,-0.750533998012543],[4.29960012435913,2.42148971557617,-0.507309138774872],[4.34228658676147,2.44553017616272,-0.255754321813583],[4.3565936088562,2.45358777046204,-4.89858741034067e-16],[4.19044065475464,2.72767448425293,0],[4.1766791343689,2.7187168598175,0.255754321813583],[4.13562107086182,2.69199085235596,0.507309138774872],[4.06794023513794,2.64793562889099,0.750533998012543],[3.97474789619446,2.58727431297302,0.981435120105743],[3.8575747013092,2.51100301742554,1.19622111320496],[3.71834444999695,2.42037391662598,1.39136505126953],[3.55934309959412,2.31687569618225,1.56366300582886],[3.38318157196045,2.20220708847046,1.71028554439545],[3.19275259971619,2.0782516002655,1.82882523536682],[2.99118280410767,1.94704413414001,1.91733574867249],[2.78178191184998,1.81073927879333,1.97436356544495],[2.56798839569092,1.67157518863678,1.99897241592407],[2.35331273078918,1.53183686733246,1.99075818061829],[2.14127993583679,1.39381885528564,1.94985580444336],[1.93537163734436,1.2597873210907,1.87693679332733],[1.73896861076355,1.13194310665131,1.77319860458374],[1.55529594421387,1.01238548755646,1.64034450054169],[1.38736951351166,0.903077483177185,1.48055601119995],[1.23794674873352,0.805814027786255,1.29645681381226],[1.10948097705841,0.722192108631134,1.09106981754303],[1.00408172607422,0.653584778308868,0.867767453193665],[0.923479676246643,0.601118624210358,0.630216419696808],[0.868998229503632,0.565655171871185,0.382317245006561],[0.841531991958618,0.547776639461517,0.128140434622765],[0.841531991958618,0.547776639461517,-0.128140434622765],[0.868998229503632,0.565655171871185,-0.382317245006561],[0.923479676246643,0.601118624210358,-0.630216419696808],[1.00408172607422,0.653584778308868,-0.867767453193665],[1.10948097705841,0.722192108631134,-1.09106981754303],[1.23794674873352,0.805814027786255,-1.29645681381226],[1.38736951351166,0.903077483177185,-1.48055601119995],[1.55529594421387,1.01238548755646,-1.64034450054169],[1.73896861076355,1.13194310665131,-1.77319860458374],[1.93537163734436,1.2597873210907,-1.87693679332733],[2.14127993583679,1.39381885528564,-1.94985580444336],[2.35331273078918,1.53183686733246,-1.99075818061829],[2.56798839569092,1.67157518863678,-1.99897241592407],[2.78178191184998,1.81073927879333,-1.97436356544495],[2.99118280410767,1.94704413414001,-1.91733574867249],[3.19275259971619,2.0782516002655,-1.82882523536682],[3.38318157196045,2.20220708847046,-1.71028554439545],[3.55934309959412,2.31687569618225,-1.56366300582886],[3.71834444999695,2.42037391662598,-1.39136505126953],[3.8575747013092,2.51100301742554,-1.19622111320496],[3.97474789619446,2.58727431297302,-0.981435120105743],[4.06794023513794,2.64793562889099,-0.750533998012543],[4.13562107086182,2.69199085235596,-0.507309138774872],[4.1766791343689,2.7187168598175,-0.255754321813583],[4.19044065475464,2.72767448425293,-4.89858741034067e-16],[4.00706815719604,2.9905526638031,0],[3.99390888214111,2.98073172569275,0.255754321813583],[3.95464754104614,2.95143008232117,0.507309138774872],[3.88992834091187,2.90312886238098,0.750533998012543],[3.80081415176392,2.83662128448486,0.981435120105743],[3.68876838684082,2.75299954414368,1.19622111320496],[3.55563068389893,2.65363621711731,1.39136505126953],[3.40358734130859,2.54016327857971,1.56366300582886],[3.23513460159302,2.41444373130798,1.71028554439545],[3.05303859710693,2.27854204177856,1.82882523536682],[2.86028933525085,2.13468956947327,1.91733574867249],[2.66005182266235,1.98524832725525,1.97436356544495],[2.45561408996582,1.8326723575592,1.99897241592407],[2.25033259391785,1.67946684360504,1.99075818061829],[2.04757833480835,1.52814733982086,1.94985580444336],[1.85068035125732,1.38119864463806,1.87693679332733],[1.66287183761597,1.24103355407715,1.77319860458374],[1.48723673820496,1.10995364189148,1.64034450054169],[1.32665872573853,0.990111112594604,1.48055601119995],[1.18377459049225,0.883473873138428,1.29645681381226],[1.06093037128448,0.791792929172516,1.09106981754303],[0.960143446922302,0.716573655605316,0.867767453193665],[0.883068442344666,0.659051120281219,0.630216419696808],[0.830971121788025,0.620169878005981,0.382317245006561],[0.804706811904907,0.600568294525146,0.128140434622765],[0.804706811904907,0.600568294525146,-0.128140434622765],[0.830971121788025,0.620169878005981,-0.382317245006561],[0.883068442344666,0.659051120281219,-0.630216419696808],[0.960143446922302,0.716573655605316,-0.867767453193665],[1.06093037128448,0.791792929172516,-1.09106981754303],[1.18377459049225,0.883473873138428,-1.29645681381226],[1.32665872573853,0.990111112594604,-1.48055601119995],[1.48723673820496,1.10995364189148,-1.64034450054169],[1.66287183761597,1.24103355407715,-1.77319860458374],[1.85068035125732,1.38119864463806,-1.87693679332733],[2.04757833480835,1.52814733982086,-1.94985580444336],[2.25033259391785,1.67946684360504,-1.99075818061829],[2.45561408996582,1.8326723575592,-1.99897241592407],[2.66005182266235,1.98524832725525,-1.97436356544495],[2.86028933525085,2.13468956947327,-1.91733574867249],[3.05303859710693,2.27854204177856,-1.82882523536682],[3.23513460159302,2.41444373130798,-1.71028554439545],[3.40358734130859,2.54016327857971,-1.56366300582886],[3.55563068389893,2.65363621711731,-1.39136505126953],[3.68876838684082,2.75299954414368,-1.19622111320496],[3.80081415176392,2.83662128448486,-0.981435120105743],[3.88992834091187,2.90312886238098,-0.750533998012543],[3.95464754104614,2.95143008232117,-0.507309138774872],[3.99390888214111,2.98073172569275,-0.255754321813583],[4.00706815719604,2.9905526638031,-4.89858741034067e-16],[3.80722975730896,3.24114203453064,0],[3.79472684860229,3.23049807548523,0.255754321813583],[3.75742340087891,3.19874119758606,0.507309138774872],[3.69593191146851,3.14639282226562,0.750533998012543],[3.61126208305359,3.07431221008301,0.981435120105743],[3.5048041343689,2.98368334770203,1.19622111320496],[3.37830638885498,2.87599396705627,1.39136505126953],[3.23384547233582,2.75301265716553,1.56366300582886],[3.07379364967346,2.61675882339478,1.71028554439545],[2.90077924728394,2.46946930885315,1.82882523536682],[2.71764254570007,2.31356287002563,1.91733574867249],[2.52739119529724,2.15159964561462,1.97436356544495],[2.33314895629883,1.98623871803284,1.99897241592407],[2.13810515403748,1.82019543647766,1.99075818061829],[1.94546258449554,1.6561963558197,1.94985580444336],[1.75838422775269,1.49693429470062,1.87693679332733],[1.57994210720062,1.34502422809601,1.77319860458374],[1.41306602954865,1.20296061038971,1.64034450054169],[1.26049625873566,1.07307612895966,1.48055601119995],[1.12473797798157,0.957503378391266,1.29645681381226],[1.00802028179169,0.858140170574188,1.09106981754303],[0.912259697914124,0.776618003845215,0.867767453193665],[0.839028537273407,0.714275419712067,0.630216419696808],[0.789529383182526,0.672136127948761,0.382317245006561],[0.764574885368347,0.650892078876495,0.128140434622765],[0.764574885368347,0.650892078876495,-0.128140434622765],[0.789529383182526,0.672136127948761,-0.382317245006561],[0.839028537273407,0.714275419712067,-0.630216419696808],[0.912259697914124,0.776618003845215,-0.867767453193665],[1.00802028179169,0.858140170574188,-1.09106981754303],[1.12473797798157,0.957503378391266,-1.29645681381226],[1.26049625873566,1.07307612895966,-1.48055601119995],[1.41306602954865,1.20296061038971,-1.64034450054169],[1.57994210720062,1.34502422809601,-1.77319860458374],[1.75838422775269,1.49693429470062,-1.87693679332733],[1.94546258449554,1.6561963558197,-1.94985580444336],[2.13810515403748,1.82019543647766,-1.99075818061829],[2.33314895629883,1.98623871803284,-1.99897241592407],[2.52739119529724,2.15159964561462,-1.97436356544495],[2.71764254570007,2.31356287002563,-1.91733574867249],[2.90077924728394,2.46946930885315,-1.82882523536682],[3.07379364967346,2.61675882339478,-1.71028554439545],[3.23384547233582,2.75301265716553,-1.56366300582886],[3.37830638885498,2.87599396705627,-1.39136505126953],[3.5048041343689,2.98368334770203,-1.19622111320496],[3.61126208305359,3.07431221008301,-0.981435120105743],[3.69593191146851,3.14639282226562,-0.750533998012543],[3.75742340087891,3.19874119758606,-0.507309138774872],[3.79472684860229,3.23049807548523,-0.255754321813583],[3.80722975730896,3.24114203453064,-4.89858741034067e-16],[3.59174680709839,3.47841286659241,0],[3.5799515247345,3.46698975563049,0.255754321813583],[3.54475927352905,3.4329080581665,0.507309138774872],[3.48674821853638,3.37672734260559,0.750533998012543],[3.4068706035614,3.2993700504303,0.981435120105743],[3.30643796920776,3.20210671424866,1.19622111320496],[3.18709969520569,3.08653378486633,1.39136505126953],[3.05081510543823,2.95454955101013,1.56366300582886],[2.89982199668884,2.80832099914551,1.71028554439545],[2.7365996837616,2.65024900436401,1.82882523536682],[2.56382846832275,2.48292946815491,1.91733574867249],[2.38434505462646,2.3091094493866,1.97436356544495],[2.201096534729,2.13164305686951,1.99897241592407],[2.01709198951721,1.95344460010529,1.99075818061829],[1.83535254001617,1.77743983268738,1.94985580444336],[1.65886247158051,1.60651874542236,1.87693679332733],[1.49051988124847,1.44348800182343,1.77319860458374],[1.3330887556076,1.29102444648743,1.64034450054169],[1.1891542673111,1.15163171291351,1.48055601119995],[1.061079621315,1.02759826183319,1.29645681381226],[0.950967967510223,0.920961081981659,1.09106981754303],[0.860627233982086,0.83347100019455,0.867767453193665],[0.791540920734406,0.766564607620239,0.630216419696808],[0.744843304157257,0.721340477466583,0.382317245006561],[0.721301198005676,0.698541283607483,0.128140434622765],[0.721301198005676,0.698541283607483,-0.128140434622765],[0.744843304157257,0.721340477466583,-0.382317245006561],[0.791540920734406,0.766564607620239,-0.630216419696808],[0.860627233982086,0.83347100019455,-0.867767453193665],[0.950967967510223,0.920961081981659,-1.09106981754303],[1.061079621315,1.02759826183319,-1.29645681381226],[1.1891542673111,1.15163171291351,-1.48055601119995],[1.3330887556076,1.29102444648743,-1.64034450054169],[1.49051988124847,1.44348800182343,-1.77319860458374],[1.65886247158051,1.60651874542236,-1.87693679332733],[1.83535254001617,1.77743983268738,-1.94985580444336],[2.01709198951721,1.95344460010529,-1.99075818061829],[2.201096534729,2.13164305686951,-1.99897241592407],[2.38434505462646,2.3091094493866,-1.97436356544495],[2.56382846832275,2.48292946815491,-1.91733574867249],[2.7365996837616,2.65024900436401,-1.82882523536682],[2.89982199668884,2.80832099914551,-1.71028554439545],[3.05081510543823,2.95454955101013,-1.56366300582886],[3.18709969520569,3.08653378486633,-1.39136505126953],[3.30643796920776,3.20210671424866,-1.19622111320496],[3.4068706035614,3.2993700504303,-0.981435120105743],[3.48674821853638,3.37672734260559,-0.750533998012543],[3.54475927352905,3.4329080581665,-0.507309138774872],[3.5799515247345,3.46698975563049,-0.255754321813583],[3.59174680709839,3.47841286659241,-4.89858741034067e-16],[3.36150455474854,3.70139002799988,0],[3.35046529769897,3.68923473358154,0.255754321813583],[3.31752896308899,3.65296816825867,0.507309138774872],[3.26323652267456,3.59318614006042,0.750533998012543],[3.18847942352295,3.51087021827698,0.981435120105743],[3.09448480606079,3.40737175941467,1.19622111320496],[2.98279643058777,3.28439044952393,1.39136505126953],[2.85524821281433,3.14394545555115,1.56366300582886],[2.71393418312073,2.98834323883057,1.71028554439545],[2.56117510795593,2.82013845443726,1.82882523536682],[2.39947891235352,2.64209294319153,1.91733574867249],[2.23150086402893,2.45713067054749,1.97436356544495],[2.0599992275238,2.26828813552856,1.99897241592407],[1.8877899646759,2.07866644859314,1.99075818061829],[1.71770060062408,1.89137923717499,1.94985580444336],[1.55252420902252,1.70950174331665,1.87693679332733],[1.39497292041779,1.53602015972137,1.77319860458374],[1.24763357639313,1.37378323078156,1.64034450054169],[1.11292564868927,1.22545492649078,1.48055601119995],[0.993061065673828,1.09347057342529,1.29645681381226],[0.89000791311264,0.979997634887695,1.09106981754303],[0.805458307266235,0.88689911365509,0.867767453193665],[0.740800619125366,0.815703809261322,0.630216419696808],[0.697096467018127,0.767580687999725,0.382317245006561],[0.675063490867615,0.743319928646088,0.128140434622765],[0.675063490867615,0.743319928646088,-0.128140434622765],[0.697096467018127,0.767580687999725,-0.382317245006561],[0.740800619125366,0.815703809261322,-0.630216419696808],[0.805458307266235,0.88689911365509,-0.867767453193665],[0.89000791311264,0.979997634887695,-1.09106981754303],[0.993061065673828,1.09347057342529,-1.29645681381226],[1.11292564868927,1.22545492649078,-1.48055601119995],[1.24763357639313,1.37378323078156,-1.64034450054169],[1.39497292041779,1.53602015972137,-1.77319860458374],[1.55252420902252,1.70950174331665,-1.87693679332733],[1.71770060062408,1.89137923717499,-1.94985580444336],[1.8877899646759,2.07866644859314,-1.99075818061829],[2.0599992275238,2.26828813552856,-1.99897241592407],[2.23150086402893,2.45713067054749,-1.97436356544495],[2.39947891235352,2.64209294319153,-1.91733574867249],[2.56117510795593,2.82013845443726,-1.82882523536682],[2.71393418312073,2.98834323883057,-1.71028554439545],[2.85524821281433,3.14394545555115,-1.56366300582886],[2.98279643058777,3.28439044952393,-1.39136505126953],[3.09448480606079,3.40737175941467,-1.19622111320496],[3.18847942352295,3.51087021827698,-0.981435120105743],[3.26323652267456,3.59318614006042,-0.750533998012543],[3.31752896308899,3.65296816825867,-0.507309138774872],[3.35046529769897,3.68923473358154,-0.255754321813583],[3.36150455474854,3.70139002799988,-4.89858741034067e-16],[3.11744904518127,3.90915751457214,0],[3.10721135139465,3.89631986618042,0.255754321813583],[3.07666635513306,3.85801768302917,0.507309138774872],[3.02631568908691,3.79487991333008,0.750533998012543],[2.95698595046997,3.70794320106506,0.981435120105743],[2.86981582641602,3.59863519668579,1.19622111320496],[2.76623630523682,3.46875071525574,1.39136505126953],[2.64794850349426,3.32042241096497,1.56366300582886],[2.51689434051514,3.156085729599,1.71028554439545],[2.37522602081299,2.97843909263611,1.82882523536682],[2.22526955604553,2.79039978981018,1.91733574867249],[2.06948733329773,2.59505486488342,1.97436356544495],[1.91043710708618,2.39561223983765,1.99897241592407],[1.75073063373566,2.19534683227539,1.99075818061829],[1.59299039840698,1.99754667282104,1.94985580444336],[1.43980622291565,1.805459856987,1.87693679332733],[1.29369354248047,1.62224042415619,1.77319860458374],[1.15705156326294,1.45089685916901,1.64034450054169],[1.0321239233017,1.29424250125885,1.48055601119995],[0.920961797237396,1.15484964847565,1.29645681381226],[0.825390636920929,1.03500711917877,1.09106981754303],[0.746979594230652,0.936682820320129,0.867767453193665],[0.687016248703003,0.861491143703461,0.630216419696808],[0.646485149860382,0.810666739940643,0.382317245006561],[0.626051843166351,0.785044193267822,0.128140434622765],[0.626051843166351,0.785044193267822,-0.128140434622765],[0.646485149860382,0.810666739940643,-0.382317245006561],[0.687016248703003,0.861491143703461,-0.630216419696808],[0.746979594230652,0.936682820320129,-0.867767453193665],[0.825390636920929,1.03500711917877,-1.09106981754303],[0.920961797237396,1.15484964847565,-1.29645681381226],[1.0321239233017,1.29424250125885,-1.48055601119995],[1.15705156326294,1.45089685916901,-1.64034450054169],[1.29369354248047,1.62224042415619,-1.77319860458374],[1.43980622291565,1.805459856987,-1.87693679332733],[1.59299039840698,1.99754667282104,-1.94985580444336],[1.75073063373566,2.19534683227539,-1.99075818061829],[1.91043710708618,2.39561223983765,-1.99897241592407],[2.06948733329773,2.59505486488342,-1.97436356544495],[2.22526955604553,2.79039978981018,-1.91733574867249],[2.37522602081299,2.97843909263611,-1.82882523536682],[2.51689434051514,3.156085729599,-1.71028554439545],[2.64794850349426,3.32042241096497,-1.56366300582886],[2.76623630523682,3.46875071525574,-1.39136505126953],[2.86981582641602,3.59863519668579,-1.19622111320496],[2.95698595046997,3.70794320106506,-0.981435120105743],[3.02631568908691,3.79487991333008,-0.750533998012543],[3.07666635513306,3.85801768302917,-0.507309138774872],[3.10721135139465,3.89631986618042,-0.255754321813583],[3.11744904518127,3.90915751457214,-4.89858741034067e-16],[2.86058330535889,4.10086107254028,0],[2.85118913650513,4.08739423751831,0.255754321813583],[2.82316088676453,4.04721355438232,0.507309138774872],[2.77695894241333,3.98097968101501,0.750533998012543],[2.71334195137024,3.88977956771851,0.981435120105743],[2.63335418701172,3.77511119842529,1.19622111320496],[2.53830933570862,3.63885712623596,1.39136505126953],[2.42976784706116,3.48325490951538,1.56366300582886],[2.3095121383667,3.31085920333862,1.71028554439545],[2.17951655387878,3.12450098991394,1.82882523536682],[2.04191589355469,2.92724013328552,1.91733574867249],[1.89896953105927,2.72231554985046,1.97436356544495],[1.75302445888519,2.5130922794342,1.99897241592407],[1.6064772605896,2.3030059337616,1.99075818061829],[1.46173405647278,2.0955057144165,1.94985580444336],[1.32117176055908,1.89399909973145,1.87693679332733],[1.18709826469421,1.70179462432861,1.77319860458374],[1.06171500682831,1.52204835414886,1.64034450054169],[0.947080910205841,1.3577116727829,1.48055601119995],[0.84507817029953,1.21148312091827,1.29645681381226],[0.757381618022919,1.08576357364655,1.09106981754303],[0.685431361198425,0.982617437839508,0.867767453193665],[0.630408763885498,0.903738379478455,0.630216419696808],[0.593217313289642,0.850421607494354,0.382317245006561],[0.574467599391937,0.823542535305023,0.128140434622765],[0.574467599391937,0.823542535305023,-0.128140434622765],[0.593217313289642,0.850421607494354,-0.382317245006561],[0.630408763885498,0.903738379478455,-0.630216419696808],[0.685431361198425,0.982617437839508,-0.867767453193665],[0.757381618022919,1.08576357364655,-1.09106981754303],[0.84507817029953,1.21148312091827,-1.29645681381226],[0.947080910205841,1.3577116727829,-1.48055601119995],[1.06171500682831,1.52204835414886,-1.64034450054169],[1.18709826469421,1.70179462432861,-1.77319860458374],[1.32117176055908,1.89399909973145,-1.87693679332733],[1.46173405647278,2.0955057144165,-1.94985580444336],[1.6064772605896,2.3030059337616,-1.99075818061829],[1.75302445888519,2.5130922794342,-1.99897241592407],[1.89896953105927,2.72231554985046,-1.97436356544495],[2.04191589355469,2.92724013328552,-1.91733574867249],[2.17951655387878,3.12450098991394,-1.82882523536682],[2.3095121383667,3.31085920333862,-1.71028554439545],[2.42976784706116,3.48325490951538,-1.56366300582886],[2.53830933570862,3.63885712623596,-1.39136505126953],[2.63335418701172,3.77511119842529,-1.19622111320496],[2.71334195137024,3.88977956771851,-0.981435120105743],[2.77695894241333,3.98097968101501,-0.750533998012543],[2.82316088676453,4.04721355438232,-0.507309138774872],[2.85118913650513,4.08739423751831,-0.255754321813583],[2.86058330535889,4.10086107254028,-4.89858741034067e-16],[2.59196281433105,4.27571392059326,0],[2.58345079421997,4.26167249679565,0.255754321813583],[2.55805468559265,4.21977853775024,0.507309138774872],[2.51619124412537,4.15072059631348,0.750533998012543],[2.45854806900024,4.0556321144104,0.981435120105743],[2.38607144355774,3.93607449531555,1.19622111320496],[2.29995155334473,3.79401087760925,1.39136505126953],[2.20160269737244,3.63177394866943,1.56366300582886],[2.09263944625854,3.4520275592804,1.71028554439545],[1.97485101222992,3.25772333145142,1.82882523536682],[1.85017168521881,3.05205178260803,1.91733574867249],[1.72064852714539,2.83838963508606,1.97436356544495],[1.58840835094452,2.62024569511414,1.99897241592407],[1.45562243461609,2.40120148658752,1.99075818061829],[1.32447135448456,2.18485403060913,1.94985580444336],[1.19710838794708,1.9747554063797,1.87693679332733],[1.07562482357025,1.77435576915741,1.77319860458374],[0.962015628814697,1.58694541454315,1.64034450054169],[0.858146131038666,1.41560184955597,1.48055601119995],[0.76572185754776,1.26313829421997,1.29645681381226],[0.686260402202606,1.1320583820343,1.09106981754303],[0.621066570281982,1.02451431751251,0.867767453193665],[0.57121080160141,0.942272007465363,0.630216419696808],[0.537511765956879,0.886681854724884,0.382317245006561],[0.520522773265839,0.858656704425812,0.128140434622765],[0.520522773265839,0.858656704425812,-0.128140434622765],[0.537511765956879,0.886681854724884,-0.382317245006561],[0.57121080160141,0.942272007465363,-0.630216419696808],[0.621066570281982,1.02451431751251,-0.867767453193665],[0.686260402202606,1.1320583820343,-1.09106981754303],[0.76572185754776,1.26313829421997,-1.29645681381226],[0.858146131038666,1.41560184955597,-1.48055601119995],[0.962015628814697,1.58694541454315,-1.64034450054169],[1.07562482357025,1.77435576915741,-1.77319860458374],[1.19710838794708,1.9747554063797,-1.87693679332733],[1.32447135448456,2.18485403060913,-1.94985580444336],[1.45562243461609,2.40120148658752,-1.99075818061829],[1.58840835094452,2.62024569511414,-1.99897241592407],[1.72064852714539,2.83838963508606,-1.97436356544495],[1.85017168521881,3.05205178260803,-1.91733574867249],[1.97485101222992,3.25772333145142,-1.82882523536682],[2.09263944625854,3.4520275592804,-1.71028554439545],[2.20160269737244,3.63177394866943,-1.56366300582886],[2.29995155334473,3.79401087760925,-1.39136505126953],[2.38607144355774,3.93607449531555,-1.19622111320496],[2.45854806900024,4.0556321144104,-0.981435120105743],[2.51619124412537,4.15072059631348,-0.750533998012543],[2.55805468559265,4.21977853775024,-0.507309138774872],[2.58345079421997,4.26167249679565,-0.255754321813583],[2.59196281433105,4.27571392059326,-4.89858741034067e-16],[2.31269145011902,4.43299674987793,0],[2.30509662628174,4.41843843460083,0.255754321813583],[2.28243660926819,4.37500381469727,0.507309138774872],[2.24508380889893,4.30340528488159,0.750533998012543],[2.1936514377594,4.2048192024231,0.981435120105743],[2.12898373603821,4.08086347579956,1.19622111320496],[2.05214309692383,3.93357396125793,1.39136505126953],[1.96439063549042,3.76536917686462,1.56366300582886],[1.86716771125793,3.57901096343994,1.71028554439545],[1.76207041740417,3.37755918502808,1.82882523536682],[1.65082466602325,3.16432189941406,1.91733574867249],[1.53525698184967,2.94280028343201,1.97436356544495],[1.41726505756378,2.71663165092468,1.99897241592407],[1.29878616333008,2.48953008651733,1.99075818061829],[1.18176591396332,2.26522421836853,1.94985580444336],[1.06812572479248,2.04739713668823,1.87693679332733],[0.95973151922226,1.83962571620941,1.77319860458374],[0.858363151550293,1.64532148838043,1.64034450054169],[0.765685081481934,1.46767497062683,1.48055601119995],[0.683219075202942,1.30960297584534,1.29645681381226],[0.61231917142868,1.17370128631592,1.09106981754303],[0.554149687290192,1.0622011423111,0.867767453193665],[0.509665608406067,0.976933598518372,0.630216419696808],[0.479597479104996,0.919298589229584,0.382317245006561],[0.464438945055008,0.890242516994476,0.128140434622765],[0.464438945055008,0.890242516994476,-0.128140434622765],[0.479597479104996,0.919298589229584,-0.382317245006561],[0.509665608406067,0.976933598518372,-0.630216419696808],[0.554149687290192,1.0622011423111,-0.867767453193665],[0.61231917142868,1.17370128631592,-1.09106981754303],[0.683219075202942,1.30960297584534,-1.29645681381226],[0.765685081481934,1.46767497062683,-1.48055601119995],[0.858363151550293,1.64532148838043,-1.64034450054169],[0.95973151922226,1.83962571620941,-1.77319860458374],[1.06812572479248,2.04739713668823,-1.87693679332733],[1.18176591396332,2.26522421836853,-1.94985580444336],[1.29878616333008,2.48953008651733,-1.99075818061829],[1.41726505756378,2.71663165092468,-1.99897241592407],[1.53525698184967,2.94280028343201,-1.97436356544495],[1.65082466602325,3.16432189941406,-1.91733574867249],[1.76207041740417,3.37755918502808,-1.82882523536682],[1.86716771125793,3.57901096343994,-1.71028554439545],[1.96439063549042,3.76536917686462,-1.56366300582886],[2.05214309692383,3.93357396125793,-1.39136505126953],[2.12898373603821,4.08086347579956,-1.19622111320496],[2.1936514377594,4.2048192024231,-0.981435120105743],[2.24508380889893,4.30340528488159,-0.750533998012543],[2.28243660926819,4.37500381469727,-0.507309138774872],[2.30509662628174,4.41843843460083,-0.255754321813583],[2.31269145011902,4.43299674987793,-4.89858741034067e-16],[2.02391672134399,4.57206296920776,0],[2.0172700881958,4.55704832077026,0.255754321813583],[1.99743974208832,4.51225090026855,0.507309138774872],[1.96475100517273,4.43840646743774,0.750533998012543],[1.91974067687988,4.33672761917114,0.981435120105743],[1.86314785480499,4.20888328552246,1.19622111320496],[1.79590177536011,4.05697345733643,1.39136505126953],[1.71910655498505,3.88349175453186,1.56366300582886],[1.63402342796326,3.69128727912903,1.71028554439545],[1.54204916954041,3.4835159778595,1.82882523536682],[1.44469404220581,3.26358914375305,1.91733574867249],[1.34355676174164,3.03511810302734,1.97436356544495],[1.24029791355133,2.80185461044312,1.99897241592407],[1.13661301136017,2.56762862205505,1.99075818061829],[1.03420448303223,2.33628606796265,1.94985580444336],[0.934754014015198,2.11162543296814,1.87693679332733],[0.839894413948059,1.89733612537384,1.77319860458374],[0.751183450222015,1.69693648815155,1.64034450054169],[0.670077621936798,1.51371705532074,1.48055601119995],[0.597908735275269,1.3506863117218,1.29645681381226],[0.535861790180206,1.21052122116089,1.09106981754303],[0.484955638647079,1.09552323818207,0.867767453193665],[0.446026116609573,1.00758075714111,0.630216419696808],[0.419712424278259,0.948137700557709,0.382317245006561],[0.406446695327759,0.918170154094696,0.128140434622765],[0.406446695327759,0.918170154094696,-0.128140434622765],[0.419712424278259,0.948137700557709,-0.382317245006561],[0.446026116609573,1.00758075714111,-0.630216419696808],[0.484955638647079,1.09552323818207,-0.867767453193665],[0.535861790180206,1.21052122116089,-1.09106981754303],[0.597908735275269,1.3506863117218,-1.29645681381226],[0.670077621936798,1.51371705532074,-1.48055601119995],[0.751183450222015,1.69693648815155,-1.64034450054169],[0.839894413948059,1.89733612537384,-1.77319860458374],[0.934754014015198,2.11162543296814,-1.87693679332733],[1.03420448303223,2.33628606796265,-1.94985580444336],[1.13661301136017,2.56762862205505,-1.99075818061829],[1.24029791355133,2.80185461044312,-1.99897241592407],[1.34355676174164,3.03511810302734,-1.97436356544495],[1.44469404220581,3.26358914375305,-1.91733574867249],[1.54204916954041,3.4835159778595,-1.82882523536682],[1.63402342796326,3.69128727912903,-1.71028554439545],[1.71910655498505,3.88349175453186,-1.56366300582886],[1.79590177536011,4.05697345733643,-1.39136505126953],[1.86314785480499,4.20888328552246,-1.19622111320496],[1.91974067687988,4.33672761917114,-0.981435120105743],[1.96475100517273,4.43840646743774,-0.750533998012543],[1.99743974208832,4.51225090026855,-0.507309138774872],[2.0172700881958,4.55704832077026,-0.255754321813583],[2.02391672134399,4.57206296920776,-4.89858741034067e-16],[1.72682523727417,4.69234228134155,0],[1.72115433216095,4.6769323348999,0.255754321813583],[1.70423483848572,4.63095664978027,0.507309138774872],[1.67634451389313,4.55516958236694,0.750533998012543],[1.63794124126434,4.45081567764282,0.981435120105743],[1.58965563774109,4.31960821151733,1.19622111320496],[1.53228068351746,4.16370153427124,1.39136505126953],[1.46675837039948,3.98565626144409,1.56366300582886],[1.39416456222534,3.78839540481567,1.71028554439545],[1.31569123268127,3.57515811920166,1.82882523536682],[1.23262691497803,3.34944558143616,1.91733574867249],[1.14633560180664,3.11496424674988,1.97436356544495],[1.05823409557343,2.87556409835815,1.99897241592407],[0.969769179821014,2.63517618179321,1.99075818061829],[0.88239324092865,2.39774751663208,1.94985580444336],[0.79754114151001,2.1671769618988,1.87693679332733],[0.716606020927429,1.94725012779236,1.77319860458374],[0.64091694355011,1.74157845973969,1.64034450054169],[0.571716725826263,1.55353891849518,1.48055601119995],[0.510141491889954,1.38621926307678,1.29645681381226],[0.457202464342117,1.24236679077148,1.09106981754303],[0.413768827915192,1.12434363365173,0.867767453193665],[0.380553781986237,1.03408753871918,0.630216419696808],[0.358102709054947,0.973080694675446,0.382317245006561],[0.346784234046936,0.942324817180634,0.128140434622765],[0.346784234046936,0.942324817180634,-0.128140434622765],[0.358102709054947,0.973080694675446,-0.382317245006561],[0.380553781986237,1.03408753871918,-0.630216419696808],[0.413768827915192,1.12434363365173,-0.867767453193665],[0.457202464342117,1.24236679077148,-1.09106981754303],[0.510141491889954,1.38621926307678,-1.29645681381226],[0.571716725826263,1.55353891849518,-1.48055601119995],[0.64091694355011,1.74157845973969,-1.64034450054169],[0.716606020927429,1.94725012779236,-1.77319860458374],[0.79754114151001,2.1671769618988,-1.87693679332733],[0.88239324092865,2.39774751663208,-1.94985580444336],[0.969769179821014,2.63517618179321,-1.99075818061829],[1.05823409557343,2.87556409835815,-1.99897241592407],[1.14633560180664,3.11496424674988,-1.97436356544495],[1.23262691497803,3.34944558143616,-1.91733574867249],[1.31569123268127,3.57515811920166,-1.82882523536682],[1.39416456222534,3.78839540481567,-1.71028554439545],[1.46675837039948,3.98565626144409,-1.56366300582886],[1.53228068351746,4.16370153427124,-1.39136505126953],[1.58965563774109,4.31960821151733,-1.19622111320496],[1.63794124126434,4.45081567764282,-0.981435120105743],[1.67634451389313,4.55516958236694,-0.750533998012543],[1.70423483848572,4.63095664978027,-0.507309138774872],[1.72115433216095,4.6769323348999,-0.255754321813583],[1.72682523727417,4.69234228134155,-4.89858741034067e-16],[1.42263793945312,4.79333925247192,0],[1.41796600818634,4.77759790420532,0.255754321813583],[1.40402686595917,4.73063230514526,0.507309138774872],[1.38104951381683,4.65321397781372,0.750533998012543],[1.34941112995148,4.54661417007446,0.981435120105743],[1.30963134765625,4.41258239746094,1.19622111320496],[1.26236319541931,4.25332021713257,1.39136505126953],[1.20838284492493,4.07144260406494,1.56366300582886],[1.1485767364502,3.86993622779846,1.71028554439545],[1.08392679691315,3.65210914611816,1.82882523536682],[1.01549470424652,3.42153835296631,1.91733574867249],[0.944403886795044,3.18201017379761,1.97436356544495],[0.871821880340576,2.93745708465576,1.99897241592407],[0.798940360546112,2.69189524650574,1.99075818061829],[0.726956069469452,2.44935631752014,1.94985580444336],[0.657050967216492,2.21382284164429,1.87693679332733],[0.590372979640961,1.98916232585907,1.77319860458374],[0.528016805648804,1.77906382083893,1.64034450054169],[0.471006453037262,1.58697700500488,1.48055601119995],[0.420278012752533,1.41605603694916,1.29645681381226],[0.376664400100708,1.26910734176636,1.09106981754303],[0.340881764888763,1.14854383468628,0.867767453193665],[0.313517689704895,1.0563451051712,0.630216419696808],[0.295021444559097,0.994025111198425,0.382317245006561],[0.285696774721146,0.962607204914093,0.128140434622765],[0.285696774721146,0.962607204914093,-0.128140434622765],[0.295021444559097,0.994025111198425,-0.382317245006561],[0.313517689704895,1.0563451051712,-0.630216419696808],[0.340881764888763,1.14854383468628,-0.867767453193665],[0.376664400100708,1.26910734176636,-1.09106981754303],[0.420278012752533,1.41605603694916,-1.29645681381226],[0.471006453037262,1.58697700500488,-1.48055601119995],[0.528016805648804,1.77906382083893,-1.64034450054169],[0.590372979640961,1.98916232585907,-1.77319860458374],[0.657050967216492,2.21382284164429,-1.87693679332733],[0.726956069469452,2.44935631752014,-1.94985580444336],[0.798940360546112,2.69189524650574,-1.99075818061829],[0.871821880340576,2.93745708465576,-1.99897241592407],[0.944403886795044,3.18201017379761,-1.97436356544495],[1.01549470424652,3.42153835296631,-1.91733574867249],[1.08392679691315,3.65210914611816,-1.82882523536682],[1.1485767364502,3.86993622779846,-1.71028554439545],[1.20838284492493,4.07144260406494,-1.56366300582886],[1.26236319541931,4.25332021713257,-1.39136505126953],[1.30963134765625,4.41258239746094,-1.19622111320496],[1.34941112995148,4.54661417007446,-0.981435120105743],[1.38104951381683,4.65321397781372,-0.750533998012543],[1.40402686595917,4.73063230514526,-0.507309138774872],[1.41796600818634,4.77759790420532,-0.255754321813583],[1.42263793945312,4.79333925247192,-4.89858741034067e-16],[1.11260461807251,4.8746395111084,0],[1.10895085334778,4.8586311340332,0.255754321813583],[1.09804952144623,4.81086921691895,0.507309138774872],[1.08007955551147,4.73213768005371,0.750533998012543],[1.05533611774445,4.62372970581055,0.981435120105743],[1.02422547340393,4.48742485046387,1.19622111320496],[0.987258315086365,4.32546138763428,1.39136505126953],[0.94504189491272,4.14049911499023,1.56366300582886],[0.898269176483154,3.93557453155518,1.71028554439545],[0.847708344459534,3.71405291557312,1.82882523536682],[0.794189512729645,3.47957158088684,1.91733574867249],[0.738591432571411,3.23598051071167,1.97436356544495],[0.681827068328857,2.98727965354919,1.99897241592407],[0.624828517436981,2.73755264282227,1.99075818061829],[0.568531692028046,2.49090003967285,1.94985580444336],[0.513860881328583,2.25137162208557,1.87693679332733],[0.461713910102844,2.02290081977844,1.77319860458374],[0.412946939468384,1.80923879146576,1.64034450054169],[0.368360757827759,1.61389398574829,1.48055601119995],[0.328687459230423,1.44007384777069,1.29645681381226],[0.294578492641449,1.29063272476196,1.09106981754303],[0.266593933105469,1.16802430152893,0.867767453193665],[0.245193257927895,1.07426190376282,0.630216419696808],[0.230727881193161,1.01088488101959,0.382317245006561],[0.223435327410698,0.978934109210968,0.128140434622765],[0.223435327410698,0.978934109210968,-0.128140434622765],[0.230727881193161,1.01088488101959,-0.382317245006561],[0.245193257927895,1.07426190376282,-0.630216419696808],[0.266593933105469,1.16802430152893,-0.867767453193665],[0.294578492641449,1.29063272476196,-1.09106981754303],[0.328687459230423,1.44007384777069,-1.29645681381226],[0.368360757827759,1.61389398574829,-1.48055601119995],[0.412946939468384,1.80923879146576,-1.64034450054169],[0.461713910102844,2.02290081977844,-1.77319860458374],[0.513860881328583,2.25137162208557,-1.87693679332733],[0.568531692028046,2.49090003967285,-1.94985580444336],[0.624828517436981,2.73755264282227,-1.99075818061829],[0.681827068328857,2.98727965354919,-1.99897241592407],[0.738591432571411,3.23598051071167,-1.97436356544495],[0.794189512729645,3.47957158088684,-1.91733574867249],[0.847708344459534,3.71405291557312,-1.82882523536682],[0.898269176483154,3.93557453155518,-1.71028554439545],[0.94504189491272,4.14049911499023,-1.56366300582886],[0.987258315086365,4.32546138763428,-1.39136505126953],[1.02422547340393,4.48742485046387,-1.19622111320496],[1.05533611774445,4.62372970581055,-0.981435120105743],[1.08007955551147,4.73213768005371,-0.750533998012543],[1.09804952144623,4.81086921691895,-0.507309138774872],[1.10895085334778,4.8586311340332,-0.255754321813583],[1.11260461807251,4.8746395111084,-4.89858741034067e-16],[0.797999501228333,4.93590879440308,0],[0.795378863811493,4.91969919204712,0.255754321813583],[0.787559986114502,4.87133693695068,0.507309138774872],[0.774671316146851,4.79161596298218,0.750533998012543],[0.756924450397491,4.68184518814087,0.981435120105743],[0.734610736370087,4.54382705688477,1.19622111320496],[0.708096623420715,4.37982797622681,1.39136505126953],[0.677817523479462,4.19254112243652,1.56366300582886],[0.644270479679108,3.98504066467285,1.71028554439545],[0.608006417751312,3.76073479652405,1.82882523536682],[0.569620847702026,3.52330636978149,1.91733574867249],[0.529743909835815,3.2766535282135,1.97436356544495],[0.489030539989471,3.02482676506042,1.99897241592407],[0.448149144649506,2.77196097373962,1.99075818061829],[0.407771050930023,2.52220821380615,1.94985580444336],[0.368559241294861,2.27966928482056,1.87693679332733],[0.331157565116882,2.04832649230957,1.77319860458374],[0.296180158853531,1.83197903633118,1.64034450054169],[0.264201372861862,1.63417899608612,1.48055601119995],[0.235746294260025,1.45817422866821,1.29645681381226],[0.211282134056091,1.30685472488403,1.09106981754303],[0.191210612654686,1.18270528316498,0.867767453193665],[0.175861284136772,1.08776426315308,0.630216419696808],[0.165486201643944,1.02359068393707,0.382317245006561],[0.16025573015213,0.991238296031952,0.128140434622765],[0.16025573015213,0.991238296031952,-0.128140434622765],[0.165486201643944,1.02359068393707,-0.382317245006561],[0.175861284136772,1.08776426315308,-0.630216419696808],[0.191210612654686,1.18270528316498,-0.867767453193665],[0.211282134056091,1.30685472488403,-1.09106981754303],[0.235746294260025,1.45817422866821,-1.29645681381226],[0.264201372861862,1.63417899608612,-1.48055601119995],[0.296180158853531,1.83197903633118,-1.64034450054169],[0.331157565116882,2.04832649230957,-1.77319860458374],[0.368559241294861,2.27966928482056,-1.87693679332733],[0.407771050930023,2.52220821380615,-1.94985580444336],[0.448149144649506,2.77196097373962,-1.99075818061829],[0.489030539989471,3.02482676506042,-1.99897241592407],[0.529743909835815,3.2766535282135,-1.97436356544495],[0.569620847702026,3.52330636978149,-1.91733574867249],[0.608006417751312,3.76073479652405,-1.82882523536682],[0.644270479679108,3.98504066467285,-1.71028554439545],[0.677817523479462,4.19254112243652,-1.56366300582886],[0.708096623420715,4.37982797622681,-1.39136505126953],[0.734610736370087,4.54382705688477,-1.19622111320496],[0.756924450397491,4.68184518814087,-0.981435120105743],[0.774671316146851,4.79161596298218,-0.750533998012543],[0.787559986114502,4.87133693695068,-0.507309138774872],[0.795378863811493,4.91969919204712,-0.255754321813583],[0.797999501228333,4.93590879440308,-4.89858741034067e-16],[0.480115115642548,4.97689533233643,0],[0.478538423776627,4.96055126190186,0.255754321813583],[0.473834246397018,4.91178750991821,0.507309138774872],[0.466079771518707,4.83140468597412,0.750533998012543],[0.455402404069901,4.72072219848633,0.981435120105743],[0.44197741150856,4.58155822753906,1.19622111320496],[0.426025241613388,4.41619729995728,1.39136505126953],[0.40780782699585,4.22735500335693,1.56366300582886],[0.387624323368073,4.01813173294067,1.71028554439545],[0.365806132555008,3.79196310043335,1.82882523536682],[0.342711478471756,3.55256295204163,1.91733574867249],[0.3187195956707,3.30386209487915,1.97436356544495],[0.294224470853806,3.04994416236877,1.99897241592407],[0.26962822675705,2.79497861862183,1.99075818061829],[0.245334804058075,2.54315185546875,1.94985580444336],[0.221743077039719,2.29859900474548,1.87693679332733],[0.199240431189537,2.06533551216125,1.77319860458374],[0.17819632589817,1.84719133377075,1.64034450054169],[0.158956348896027,1.64774882793427,1.48055601119995],[0.141836389899254,1.47028255462646,1.29645681381226],[0.127117559313774,1.31770658493042,1.09106981754303],[0.115041561424732,1.19252610206604,0.867767453193665],[0.105806671082973,1.09679675102234,0.630216419696808],[0.0995645150542259,1.03209042549133,0.382317245006561],[0.0964176058769226,0.999469339847565,0.128140434622765],[0.0964176058769226,0.999469339847565,-0.128140434622765],[0.0995645150542259,1.03209042549133,-0.382317245006561],[0.105806671082973,1.09679675102234,-0.630216419696808],[0.115041561424732,1.19252610206604,-0.867767453193665],[0.127117559313774,1.31770658493042,-1.09106981754303],[0.141836389899254,1.47028255462646,-1.29645681381226],[0.158956348896027,1.64774882793427,-1.48055601119995],[0.17819632589817,1.84719133377075,-1.64034450054169],[0.199240431189537,2.06533551216125,-1.77319860458374],[0.221743077039719,2.29859900474548,-1.87693679332733],[0.245334804058075,2.54315185546875,-1.94985580444336],[0.26962822675705,2.79497861862183,-1.99075818061829],[0.294224470853806,3.04994416236877,-1.99897241592407],[0.3187195956707,3.30386209487915,-1.97436356544495],[0.342711478471756,3.55256295204163,-1.91733574867249],[0.365806132555008,3.79196310043335,-1.82882523536682],[0.387624323368073,4.01813173294067,-1.71028554439545],[0.40780782699585,4.22735500335693,-1.56366300582886],[0.426025241613388,4.41619729995728,-1.39136505126953],[0.44197741150856,4.58155822753906,-1.19622111320496],[0.455402404069901,4.72072219848633,-0.981435120105743],[0.466079771518707,4.83140468597412,-0.750533998012543],[0.473834246397018,4.91178750991821,-0.507309138774872],[0.478538423776627,4.96055126190186,-0.255754321813583],[0.480115115642548,4.97689533233643,-4.89858741034067e-16],[0.160257890820503,4.99743127822876,0],[0.159731596708298,4.98101949691772,0.255754321813583],[0.158161386847496,4.93205451965332,0.507309138774872],[0.155573025345802,4.85133981704712,0.750533998012543],[0.152009010314941,4.74020051956177,0.981435120105743],[0.147527873516083,4.60046243667603,1.19622111320496],[0.142203196883202,4.43441915512085,1.39136505126953],[0.136122390627861,4.244797706604,1.56366300582886],[0.129385337233543,4.03471088409424,1.71028554439545],[0.122102625668049,3.80760931968689,1.82882523536682],[0.114393845200539,3.56722140312195,1.91733574867249],[0.106385588645935,3.31749439239502,1.97436356544495],[0.098209336400032,3.06252884864807,1.99897241592407],[0.0899993553757668,2.80651116371155,1.99075818061829],[0.0818904414772987,2.55364537239075,1.94985580444336],[0.0740157440304756,2.30808353424072,1.87693679332733],[0.066504567861557,2.07385730743408,1.77319860458374],[0.0594802498817444,1.85481321811676,1.64034450054169],[0.0530581250786781,1.65454769134521,1.48055601119995],[0.0473436452448368,1.4763491153717,1.29645681381226],[0.0424306392669678,1.32314360141754,1.09106981754303],[0.0383997857570648,1.19744670391083,0.867767453193665],[0.0353172644972801,1.10132241249084,0.630216419696808],[0.0332336947321892,1.03634893894196,0.382317245006561],[0.0321832858026028,1.00359332561493,0.128140434622765],[0.0321832858026028,1.00359332561493,-0.128140434622765],[0.0332336947321892,1.03634893894196,-0.382317245006561],[0.0353172644972801,1.10132241249084,-0.630216419696808],[0.0383997857570648,1.19744670391083,-0.867767453193665],[0.0424306392669678,1.32314360141754,-1.09106981754303],[0.0473436452448368,1.4763491153717,-1.29645681381226],[0.0530581250786781,1.65454769134521,-1.48055601119995],[0.0594802498817444,1.85481321811676,-1.64034450054169],[0.066504567861557,2.07385730743408,-1.77319860458374],[0.0740157440304756,2.30808353424072,-1.87693679332733],[0.0818904414772987,2.55364537239075,-1.94985580444336],[0.0899993553757668,2.80651116371155,-1.99075818061829],[0.098209336400032,3.06252884864807,-1.99897241592407],[0.106385588645935,3.31749439239502,-1.97436356544495],[0.114393845200539,3.56722140312195,-1.91733574867249],[0.122102625668049,3.80760931968689,-1.82882523536682],[0.129385337233543,4.03471088409424,-1.71028554439545],[0.136122390627861,4.244797706604,-1.56366300582886],[0.142203196883202,4.43441915512085,-1.39136505126953],[0.147527873516083,4.60046243667603,-1.19622111320496],[0.152009010314941,4.74020051956177,-0.981435120105743],[0.155573025345802,4.85133981704712,-0.750533998012543],[0.158161386847496,4.93205451965332,-0.507309138774872],[0.159731596708298,4.98101949691772,-0.255754321813583],[0.160257890820503,4.99743127822876,-4.89858741034067e-16],[-0.160257890820503,4.99743127822876,0],[-0.159731596708298,4.98101949691772,0.255754321813583],[-0.158161386847496,4.93205451965332,0.507309138774872],[-0.155573025345802,4.85133981704712,0.750533998012543],[-0.152009010314941,4.74020051956177,0.981435120105743],[-0.147527873516083,4.60046243667603,1.19622111320496],[-0.142203196883202,4.43441915512085,1.39136505126953],[-0.136122390627861,4.244797706604,1.56366300582886],[-0.129385337233543,4.03471088409424,1.71028554439545],[-0.122102625668049,3.80760931968689,1.82882523536682],[-0.114393845200539,3.56722140312195,1.91733574867249],[-0.106385588645935,3.31749439239502,1.97436356544495],[-0.098209336400032,3.06252884864807,1.99897241592407],[-0.0899993553757668,2.80651116371155,1.99075818061829],[-0.0818904414772987,2.55364537239075,1.94985580444336],[-0.0740157440304756,2.30808353424072,1.87693679332733],[-0.066504567861557,2.07385730743408,1.77319860458374],[-0.0594802498817444,1.85481321811676,1.64034450054169],[-0.0530581250786781,1.65454769134521,1.48055601119995],[-0.0473436452448368,1.4763491153717,1.29645681381226],[-0.0424306392669678,1.32314360141754,1.09106981754303],[-0.0383997857570648,1.19744670391083,0.867767453193665],[-0.0353172644972801,1.10132241249084,0.630216419696808],[-0.0332336947321892,1.03634893894196,0.382317245006561],[-0.0321832858026028,1.00359332561493,0.128140434622765],[-0.0321832858026028,1.00359332561493,-0.128140434622765],[-0.0332336947321892,1.03634893894196,-0.382317245006561],[-0.0353172644972801,1.10132241249084,-0.630216419696808],[-0.0383997857570648,1.19744670391083,-0.867767453193665],[-0.0424306392669678,1.32314360141754,-1.09106981754303],[-0.0473436452448368,1.4763491153717,-1.29645681381226],[-0.0530581250786781,1.65454769134521,-1.48055601119995],[-0.0594802498817444,1.85481321811676,-1.64034450054169],[-0.066504567861557,2.07385730743408,-1.77319860458374],[-0.0740157440304756,2.30808353424072,-1.87693679332733],[-0.0818904414772987,2.55364537239075,-1.94985580444336],[-0.0899993553757668,2.80651116371155,-1.99075818061829],[-0.098209336400032,3.06252884864807,-1.99897241592407],[-0.106385588645935,3.31749439239502,-1.97436356544495],[-0.114393845200539,3.56722140312195,-1.91733574867249],[-0.122102625668049,3.80760931968689,-1.82882523536682],[-0.129385337233543,4.03471088409424,-1.71028554439545],[-0.136122390627861,4.244797706604,-1.56366300582886],[-0.142203196883202,4.43441915512085,-1.39136505126953],[-0.147527873516083,4.60046243667603,-1.19622111320496],[-0.152009010314941,4.74020051956177,-0.981435120105743],[-0.155573025345802,4.85133981704712,-0.750533998012543],[-0.158161386847496,4.93205451965332,-0.507309138774872],[-0.159731596708298,4.98101949691772,-0.255754321813583],[-0.160257890820503,4.99743127822876,-4.89858741034067e-16],[-0.480115115642548,4.97689533233643,0],[-0.478538423776627,4.96055126190186,0.255754321813583],[-0.473834246397018,4.91178750991821,0.507309138774872],[-0.466079771518707,4.83140468597412,0.750533998012543],[-0.455402404069901,4.72072219848633,0.981435120105743],[-0.44197741150856,4.58155822753906,1.19622111320496],[-0.426025241613388,4.41619729995728,1.39136505126953],[-0.40780782699585,4.22735500335693,1.56366300582886],[-0.387624323368073,4.01813173294067,1.71028554439545],[-0.365806132555008,3.79196310043335,1.82882523536682],[-0.342711478471756,3.55256295204163,1.91733574867249],[-0.3187195956707,3.30386209487915,1.97436356544495],[-0.294224470853806,3.04994416236877,1.99897241592407],[-0.26962822675705,2.79497861862183,1.99075818061829],[-0.245334804058075,2.54315185546875,1.94985580444336],[-0.221743077039719,2.29859900474548,1.87693679332733],[-0.199240431189537,2.06533551216125,1.77319860458374],[-0.17819632589817,1.84719133377075,1.64034450054169],[-0.158956348896027,1.64774882793427,1.48055601119995],[-0.141836389899254,1.47028255462646,1.29645681381226],[-0.127117559313774,1.31770658493042,1.09106981754303],[-0.115041561424732,1.19252610206604,0.867767453193665],[-0.105806671082973,1.09679675102234,0.630216419696808],[-0.0995645150542259,1.03209042549133,0.382317245006561],[-0.0964176058769226,0.999469339847565,0.128140434622765],[-0.0964176058769226,0.999469339847565,-0.128140434622765],[-0.0995645150542259,1.03209042549133,-0.382317245006561],[-0.105806671082973,1.09679675102234,-0.630216419696808],[-0.115041561424732,1.19252610206604,-0.867767453193665],[-0.127117559313774,1.31770658493042,-1.09106981754303],[-0.141836389899254,1.47028255462646,-1.29645681381226],[-0.158956348896027,1.64774882793427,-1.48055601119995],[-0.17819632589817,1.84719133377075,-1.64034450054169],[-0.199240431189537,2.06533551216125,-1.77319860458374],[-0.221743077039719,2.29859900474548,-1.87693679332733],[-0.245334804058075,2.54315185546875,-1.94985580444336],[-0.26962822675705,2.79497861862183,-1.99075818061829],[-0.294224470853806,3.04994416236877,-1.99897241592407],[-0.3187195956707,3.30386209487915,-1.97436356544495],[-0.342711478471756,3.55256295204163,-1.91733574867249],[-0.365806132555008,3.79196310043335,-1.82882523536682],[-0.387624323368073,4.01813173294067,-1.71028554439545],[-0.40780782699585,4.22735500335693,-1.56366300582886],[-0.426025241613388,4.41619729995728,-1.39136505126953],[-0.44197741150856,4.58155822753906,-1.19622111320496],[-0.455402404069901,4.72072219848633,-0.981435120105743],[-0.466079771518707,4.83140468597412,-0.750533998012543],[-0.473834246397018,4.91178750991821,-0.507309138774872],[-0.478538423776627,4.96055126190186,-0.255754321813583],[-0.480115115642548,4.97689533233643,-4.89858741034067e-16],[-0.797999501228333,4.93590879440308,0],[-0.795378863811493,4.91969919204712,0.255754321813583],[-0.787559986114502,4.87133693695068,0.507309138774872],[-0.774671316146851,4.79161596298218,0.750533998012543],[-0.756924450397491,4.68184518814087,0.981435120105743],[-0.734610736370087,4.54382705688477,1.19622111320496],[-0.708096623420715,4.37982797622681,1.39136505126953],[-0.677817523479462,4.19254112243652,1.56366300582886],[-0.644270479679108,3.98504066467285,1.71028554439545],[-0.608006417751312,3.76073479652405,1.82882523536682],[-0.569620847702026,3.52330636978149,1.91733574867249],[-0.529743909835815,3.2766535282135,1.97436356544495],[-0.489030539989471,3.02482676506042,1.99897241592407],[-0.448149144649506,2.77196097373962,1.99075818061829],[-0.407771050930023,2.52220821380615,1.94985580444336],[-0.368559241294861,2.27966928482056,1.87693679332733],[-0.331157565116882,2.04832649230957,1.77319860458374],[-0.296180158853531,1.83197903633118,1.64034450054169],[-0.264201372861862,1.63417899608612,1.48055601119995],[-0.235746294260025,1.45817422866821,1.29645681381226],[-0.211282134056091,1.30685472488403,1.09106981754303],[-0.191210612654686,1.18270528316498,0.867767453193665],[-0.175861284136772,1.08776426315308,0.630216419696808],[-0.165486201643944,1.02359068393707,0.382317245006561],[-0.16025573015213,0.991238296031952,0.128140434622765],[-0.16025573015213,0.991238296031952,-0.128140434622765],[-0.165486201643944,1.02359068393707,-0.382317245006561],[-0.175861284136772,1.08776426315308,-0.630216419696808],[-0.191210612654686,1.18270528316498,-0.867767453193665],[-0.211282134056091,1.30685472488403,-1.09106981754303],[-0.235746294260025,1.45817422866821,-1.29645681381226],[-0.264201372861862,1.63417899608612,-1.48055601119995],[-0.296180158853531,1.83197903633118,-1.64034450054169],[-0.331157565116882,2.04832649230957,-1.77319860458374],[-0.368559241294861,2.27966928482056,-1.87693679332733],[-0.407771050930023,2.52220821380615,-1.94985580444336],[-0.448149144649506,2.77196097373962,-1.99075818061829],[-0.489030539989471,3.02482676506042,-1.99897241592407],[-0.529743909835815,3.2766535282135,-1.97436356544495],[-0.569620847702026,3.52330636978149,-1.91733574867249],[-0.608006417751312,3.76073479652405,-1.82882523536682],[-0.644270479679108,3.98504066467285,-1.71028554439545],[-0.677817523479462,4.19254112243652,-1.56366300582886],[-0.708096623420715,4.37982797622681,-1.39136505126953],[-0.734610736370087,4.54382705688477,-1.19622111320496],[-0.756924450397491,4.68184518814087,-0.981435120105743],[-0.774671316146851,4.79161596298218,-0.750533998012543],[-0.787559986114502,4.87133693695068,-0.507309138774872],[-0.795378863811493,4.91969919204712,-0.255754321813583],[-0.797999501228333,4.93590879440308,-4.89858741034067e-16],[-1.11260461807251,4.8746395111084,0],[-1.10895085334778,4.8586311340332,0.255754321813583],[-1.09804952144623,4.81086921691895,0.507309138774872],[-1.08007955551147,4.73213768005371,0.750533998012543],[-1.05533611774445,4.62372970581055,0.981435120105743],[-1.02422547340393,4.48742485046387,1.19622111320496],[-0.987258315086365,4.32546138763428,1.39136505126953],[-0.94504189491272,4.14049911499023,1.56366300582886],[-0.898269176483154,3.93557453155518,1.71028554439545],[-0.847708344459534,3.71405291557312,1.82882523536682],[-0.794189512729645,3.47957158088684,1.91733574867249],[-0.738591432571411,3.23598051071167,1.97436356544495],[-0.681827068328857,2.98727965354919,1.99897241592407],[-0.624828517436981,2.73755264282227,1.99075818061829],[-0.568531692028046,2.49090003967285,1.94985580444336],[-0.513860881328583,2.25137162208557,1.87693679332733],[-0.461713910102844,2.02290081977844,1.77319860458374],[-0.412946939468384,1.80923879146576,1.64034450054169],[-0.368360757827759,1.61389398574829,1.48055601119995],[-0.328687459230423,1.44007384777069,1.29645681381226],[-0.294578492641449,1.29063272476196,1.09106981754303],[-0.266593933105469,1.16802430152893,0.867767453193665],[-0.245193257927895,1.07426190376282,0.630216419696808],[-0.230727881193161,1.01088488101959,0.382317245006561],[-0.223435327410698,0.978934109210968,0.128140434622765],[-0.223435327410698,0.978934109210968,-0.128140434622765],[-0.230727881193161,1.01088488101959,-0.382317245006561],[-0.245193257927895,1.07426190376282,-0.630216419696808],[-0.266593933105469,1.16802430152893,-0.867767453193665],[-0.294578492641449,1.29063272476196,-1.09106981754303],[-0.328687459230423,1.44007384777069,-1.29645681381226],[-0.368360757827759,1.61389398574829,-1.48055601119995],[-0.412946939468384,1.80923879146576,-1.64034450054169],[-0.461713910102844,2.02290081977844,-1.77319860458374],[-0.513860881328583,2.25137162208557,-1.87693679332733],[-0.568531692028046,2.49090003967285,-1.94985580444336],[-0.624828517436981,2.73755264282227,-1.99075818061829],[-0.681827068328857,2.98727965354919,-1.99897241592407],[-0.738591432571411,3.23598051071167,-1.97436356544495],[-0.794189512729645,3.47957158088684,-1.91733574867249],[-0.847708344459534,3.71405291557312,-1.82882523536682],[-0.898269176483154,3.93557453155518,-1.71028554439545],[-0.94504189491272,4.14049911499023,-1.56366300582886],[-0.987258315086365,4.32546138763428,-1.39136505126953],[-1.02422547340393,4.48742485046387,-1.19622111320496],[-1.05533611774445,4.62372970581055,-0.981435120105743],[-1.08007955551147,4.73213768005371,-0.750533998012543],[-1.09804952144623,4.81086921691895,-0.507309138774872],[-1.10895085334778,4.8586311340332,-0.255754321813583],[-1.11260461807251,4.8746395111084,-4.89858741034067e-16],[-1.42263793945312,4.79333925247192,0],[-1.41796600818634,4.77759790420532,0.255754321813583],[-1.40402686595917,4.73063230514526,0.507309138774872],[-1.38104951381683,4.65321397781372,0.750533998012543],[-1.34941112995148,4.54661417007446,0.981435120105743],[-1.30963134765625,4.41258239746094,1.19622111320496],[-1.26236319541931,4.25332021713257,1.39136505126953],[-1.20838284492493,4.07144260406494,1.56366300582886],[-1.1485767364502,3.86993622779846,1.71028554439545],[-1.08392679691315,3.65210914611816,1.82882523536682],[-1.01549470424652,3.42153835296631,1.91733574867249],[-0.944403886795044,3.18201017379761,1.97436356544495],[-0.871821880340576,2.93745708465576,1.99897241592407],[-0.798940360546112,2.69189524650574,1.99075818061829],[-0.726956069469452,2.44935631752014,1.94985580444336],[-0.657050967216492,2.21382284164429,1.87693679332733],[-0.590372979640961,1.98916232585907,1.77319860458374],[-0.528016805648804,1.77906382083893,1.64034450054169],[-0.471006453037262,1.58697700500488,1.48055601119995],[-0.420278012752533,1.41605603694916,1.29645681381226],[-0.376664400100708,1.26910734176636,1.09106981754303],[-0.340881764888763,1.14854383468628,0.867767453193665],[-0.313517689704895,1.0563451051712,0.630216419696808],[-0.295021444559097,0.994025111198425,0.382317245006561],[-0.285696774721146,0.962607204914093,0.128140434622765],[-0.285696774721146,0.962607204914093,-0.128140434622765],[-0.295021444559097,0.994025111198425,-0.382317245006561],[-0.313517689704895,1.0563451051712,-0.630216419696808],[-0.340881764888763,1.14854383468628,-0.867767453193665],[-0.376664400100708,1.26910734176636,-1.09106981754303],[-0.420278012752533,1.41605603694916,-1.29645681381226],[-0.471006453037262,1.58697700500488,-1.48055601119995],[-0.528016805648804,1.77906382083893,-1.64034450054169],[-0.590372979640961,1.98916232585907,-1.77319860458374],[-0.657050967216492,2.21382284164429,-1.87693679332733],[-0.726956069469452,2.44935631752014,-1.94985580444336],[-0.798940360546112,2.69189524650574,-1.99075818061829],[-0.871821880340576,2.93745708465576,-1.99897241592407],[-0.944403886795044,3.18201017379761,-1.97436356544495],[-1.01549470424652,3.42153835296631,-1.91733574867249],[-1.08392679691315,3.65210914611816,-1.82882523536682],[-1.1485767364502,3.86993622779846,-1.71028554439545],[-1.20838284492493,4.07144260406494,-1.56366300582886],[-1.26236319541931,4.25332021713257,-1.39136505126953],[-1.30963134765625,4.41258239746094,-1.19622111320496],[-1.34941112995148,4.54661417007446,-0.981435120105743],[-1.38104951381683,4.65321397781372,-0.750533998012543],[-1.40402686595917,4.73063230514526,-0.507309138774872],[-1.41796600818634,4.77759790420532,-0.255754321813583],[-1.42263793945312,4.79333925247192,-4.89858741034067e-16],[-1.72682523727417,4.69234228134155,0],[-1.72115433216095,4.6769323348999,0.255754321813583],[-1.70423483848572,4.63095664978027,0.507309138774872],[-1.67634451389313,4.55516958236694,0.750533998012543],[-1.63794124126434,4.45081567764282,0.981435120105743],[-1.58965563774109,4.31960821151733,1.19622111320496],[-1.53228068351746,4.16370153427124,1.39136505126953],[-1.46675837039948,3.98565626144409,1.56366300582886],[-1.39416456222534,3.78839540481567,1.71028554439545],[-1.31569123268127,3.57515811920166,1.82882523536682],[-1.23262691497803,3.34944558143616,1.91733574867249],[-1.14633560180664,3.11496424674988,1.97436356544495],[-1.05823409557343,2.87556409835815,1.99897241592407],[-0.969769179821014,2.63517618179321,1.99075818061829],[-0.88239324092865,2.39774751663208,1.94985580444336],[-0.79754114151001,2.1671769618988,1.87693679332733],[-0.716606020927429,1.94725012779236,1.77319860458374],[-0.64091694355011,1.74157845973969,1.64034450054169],[-0.571716725826263,1.55353891849518,1.48055601119995],[-0.510141491889954,1.38621926307678,1.29645681381226],[-0.457202464342117,1.24236679077148,1.09106981754303],[-0.413768827915192,1.12434363365173,0.867767453193665],[-0.380553781986237,1.03408753871918,0.630216419696808],[-0.358102709054947,0.973080694675446,0.382317245006561],[-0.346784234046936,0.942324817180634,0.128140434622765],[-0.346784234046936,0.942324817180634,-0.128140434622765],[-0.358102709054947,0.973080694675446,-0.382317245006561],[-0.380553781986237,1.03408753871918,-0.630216419696808],[-0.413768827915192,1.12434363365173,-0.867767453193665],[-0.457202464342117,1.24236679077148,-1.09106981754303],[-0.510141491889954,1.38621926307678,-1.29645681381226],[-0.571716725826263,1.55353891849518,-1.48055601119995],[-0.64091694355011,1.74157845973969,-1.64034450054169],[-0.716606020927429,1.94725012779236,-1.77319860458374],[-0.79754114151001,2.1671769618988,-1.87693679332733],[-0.88239324092865,2.39774751663208,-1.94985580444336],[-0.969769179821014,2.63517618179321,-1.99075818061829],[-1.05823409557343,2.87556409835815,-1.99897241592407],[-1.14633560180664,3.11496424674988,-1.97436356544495],[-1.23262691497803,3.34944558143616,-1.91733574867249],[-1.31569123268127,3.57515811920166,-1.82882523536682],[-1.39416456222534,3.78839540481567,-1.71028554439545],[-1.46675837039948,3.98565626144409,-1.56366300582886],[-1.53228068351746,4.16370153427124,-1.39136505126953],[-1.58965563774109,4.31960821151733,-1.19622111320496],[-1.63794124126434,4.45081567764282,-0.981435120105743],[-1.67634451389313,4.55516958236694,-0.750533998012543],[-1.70423483848572,4.63095664978027,-0.507309138774872],[-1.72115433216095,4.6769323348999,-0.255754321813583],[-1.72682523727417,4.69234228134155,-4.89858741034067e-16],[-2.02391672134399,4.57206296920776,0],[-2.0172700881958,4.55704832077026,0.255754321813583],[-1.99743974208832,4.51225090026855,0.507309138774872],[-1.96475100517273,4.43840646743774,0.750533998012543],[-1.91974067687988,4.33672761917114,0.981435120105743],[-1.86314785480499,4.20888328552246,1.19622111320496],[-1.79590177536011,4.05697345733643,1.39136505126953],[-1.71910655498505,3.88349175453186,1.56366300582886],[-1.63402342796326,3.69128727912903,1.71028554439545],[-1.54204916954041,3.4835159778595,1.82882523536682],[-1.44469404220581,3.26358914375305,1.91733574867249],[-1.34355676174164,3.03511810302734,1.97436356544495],[-1.24029791355133,2.80185461044312,1.99897241592407],[-1.13661301136017,2.56762862205505,1.99075818061829],[-1.03420448303223,2.33628606796265,1.94985580444336],[-0.934754014015198,2.11162543296814,1.87693679332733],[-0.839894413948059,1.89733612537384,1.77319860458374],[-0.751183450222015,1.69693648815155,1.64034450054169],[-0.670077621936798,1.51371705532074,1.48055601119995],[-0.597908735275269,1.3506863117218,1.29645681381226],[-0.535861790180206,1.21052122116089,1.09106981754303],[-0.484955638647079,1.09552323818207,0.867767453193665],[-0.446026116609573,1.00758075714111,0.630216419696808],[-0.419712424278259,0.948137700557709,0.382317245006561],[-0.406446695327759,0.918170154094696,0.128140434622765],[-0.406446695327759,0.918170154094696,-0.128140434622765],[-0.419712424278259,0.948137700557709,-0.382317245006561],[-0.446026116609573,1.00758075714111,-0.630216419696808],[-0.484955638647079,1.09552323818207,-0.867767453193665],[-0.535861790180206,1.21052122116089,-1.09106981754303],[-0.597908735275269,1.3506863117218,-1.29645681381226],[-0.670077621936798,1.51371705532074,-1.48055601119995],[-0.751183450222015,1.69693648815155,-1.64034450054169],[-0.839894413948059,1.89733612537384,-1.77319860458374],[-0.934754014015198,2.11162543296814,-1.87693679332733],[-1.03420448303223,2.33628606796265,-1.94985580444336],[-1.13661301136017,2.56762862205505,-1.99075818061829],[-1.24029791355133,2.80185461044312,-1.99897241592407],[-1.34355676174164,3.03511810302734,-1.97436356544495],[-1.44469404220581,3.26358914375305,-1.91733574867249],[-1.54204916954041,3.4835159778595,-1.82882523536682],[-1.63402342796326,3.69128727912903,-1.71028554439545],[-1.71910655498505,3.88349175453186,-1.56366300582886],[-1.79590177536011,4.05697345733643,-1.39136505126953],[-1.86314785480499,4.20888328552246,-1.19622111320496],[-1.91974067687988,4.33672761917114,-0.981435120105743],[-1.96475100517273,4.43840646743774,-0.750533998012543],[-1.99743974208832,4.51225090026855,-0.507309138774872],[-2.0172700881958,4.55704832077026,-0.255754321813583],[-2.02391672134399,4.57206296920776,-4.89858741034067e-16],[-2.31269145011902,4.43299674987793,0],[-2.30509662628174,4.41843843460083,0.255754321813583],[-2.28243660926819,4.37500381469727,0.507309138774872],[-2.24508380889893,4.30340528488159,0.750533998012543],[-2.1936514377594,4.2048192024231,0.981435120105743],[-2.12898373603821,4.08086347579956,1.19622111320496],[-2.05214309692383,3.93357396125793,1.39136505126953],[-1.96439063549042,3.76536917686462,1.56366300582886],[-1.86716771125793,3.57901096343994,1.71028554439545],[-1.76207041740417,3.37755918502808,1.82882523536682],[-1.65082466602325,3.16432189941406,1.91733574867249],[-1.53525698184967,2.94280028343201,1.97436356544495],[-1.41726505756378,2.71663165092468,1.99897241592407],[-1.29878616333008,2.48953008651733,1.99075818061829],[-1.18176591396332,2.26522421836853,1.94985580444336],[-1.06812572479248,2.04739713668823,1.87693679332733],[-0.95973151922226,1.83962571620941,1.77319860458374],[-0.858363151550293,1.64532148838043,1.64034450054169],[-0.765685081481934,1.46767497062683,1.48055601119995],[-0.683219075202942,1.30960297584534,1.29645681381226],[-0.61231917142868,1.17370128631592,1.09106981754303],[-0.554149687290192,1.0622011423111,0.867767453193665],[-0.509665608406067,0.976933598518372,0.630216419696808],[-0.479597479104996,0.919298589229584,0.382317245006561],[-0.464438945055008,0.890242516994476,0.128140434622765],[-0.464438945055008,0.890242516994476,-0.128140434622765],[-0.479597479104996,0.919298589229584,-0.382317245006561],[-0.509665608406067,0.976933598518372,-0.630216419696808],[-0.554149687290192,1.0622011423111,-0.867767453193665],[-0.61231917142868,1.17370128631592,-1.09106981754303],[-0.683219075202942,1.30960297584534,-1.29645681381226],[-0.765685081481934,1.46767497062683,-1.48055601119995],[-0.858363151550293,1.64532148838043,-1.64034450054169],[-0.95973151922226,1.83962571620941,-1.77319860458374],[-1.06812572479248,2.04739713668823,-1.87693679332733],[-1.18176591396332,2.26522421836853,-1.94985580444336],[-1.29878616333008,2.48953008651733,-1.99075818061829],[-1.41726505756378,2.71663165092468,-1.99897241592407],[-1.53525698184967,2.94280028343201,-1.97436356544495],[-1.65082466602325,3.16432189941406,-1.91733574867249],[-1.76207041740417,3.37755918502808,-1.82882523536682],[-1.86716771125793,3.57901096343994,-1.71028554439545],[-1.96439063549042,3.76536917686462,-1.56366300582886],[-2.05214309692383,3.93357396125793,-1.39136505126953],[-2.12898373603821,4.08086347579956,-1.19622111320496],[-2.1936514377594,4.2048192024231,-0.981435120105743],[-2.24508380889893,4.30340528488159,-0.750533998012543],[-2.28243660926819,4.37500381469727,-0.507309138774872],[-2.30509662628174,4.41843843460083,-0.255754321813583],[-2.31269145011902,4.43299674987793,-4.89858741034067e-16],[-2.59196281433105,4.27571392059326,0],[-2.58345079421997,4.26167249679565,0.255754321813583],[-2.55805468559265,4.21977853775024,0.507309138774872],[-2.51619124412537,4.15072059631348,0.750533998012543],[-2.45854806900024,4.0556321144104,0.981435120105743],[-2.38607144355774,3.93607449531555,1.19622111320496],[-2.29995155334473,3.79401087760925,1.39136505126953],[-2.20160269737244,3.63177394866943,1.56366300582886],[-2.09263944625854,3.4520275592804,1.71028554439545],[-1.97485101222992,3.25772333145142,1.82882523536682],[-1.85017168521881,3.05205178260803,1.91733574867249],[-1.72064852714539,2.83838963508606,1.97436356544495],[-1.58840835094452,2.62024569511414,1.99897241592407],[-1.45562243461609,2.40120148658752,1.99075818061829],[-1.32447135448456,2.18485403060913,1.94985580444336],[-1.19710838794708,1.9747554063797,1.87693679332733],[-1.07562482357025,1.77435576915741,1.77319860458374],[-0.962015628814697,1.58694541454315,1.64034450054169],[-0.858146131038666,1.41560184955597,1.48055601119995],[-0.76572185754776,1.26313829421997,1.29645681381226],[-0.686260402202606,1.1320583820343,1.09106981754303],[-0.621066570281982,1.02451431751251,0.867767453193665],[-0.57121080160141,0.942272007465363,0.630216419696808],[-0.537511765956879,0.886681854724884,0.382317245006561],[-0.520522773265839,0.858656704425812,0.128140434622765],[-0.520522773265839,0.858656704425812,-0.128140434622765],[-0.537511765956879,0.886681854724884,-0.382317245006561],[-0.57121080160141,0.942272007465363,-0.630216419696808],[-0.621066570281982,1.02451431751251,-0.867767453193665],[-0.686260402202606,1.1320583820343,-1.09106981754303],[-0.76572185754776,1.26313829421997,-1.29645681381226],[-0.858146131038666,1.41560184955597,-1.48055601119995],[-0.962015628814697,1.58694541454315,-1.64034450054169],[-1.07562482357025,1.77435576915741,-1.77319860458374],[-1.19710838794708,1.9747554063797,-1.87693679332733],[-1.32447135448456,2.18485403060913,-1.94985580444336],[-1.45562243461609,2.40120148658752,-1.99075818061829],[-1.58840835094452,2.62024569511414,-1.99897241592407],[-1.72064852714539,2.83838963508606,-1.97436356544495],[-1.85017168521881,3.05205178260803,-1.91733574867249],[-1.97485101222992,3.25772333145142,-1.82882523536682],[-2.09263944625854,3.4520275592804,-1.71028554439545],[-2.20160269737244,3.63177394866943,-1.56366300582886],[-2.29995155334473,3.79401087760925,-1.39136505126953],[-2.38607144355774,3.93607449531555,-1.19622111320496],[-2.45854806900024,4.0556321144104,-0.981435120105743],[-2.51619124412537,4.15072059631348,-0.750533998012543],[-2.55805468559265,4.21977853775024,-0.507309138774872],[-2.58345079421997,4.26167249679565,-0.255754321813583],[-2.59196281433105,4.27571392059326,-4.89858741034067e-16],[-2.86058330535889,4.10086107254028,0],[-2.85118913650513,4.08739423751831,0.255754321813583],[-2.82316088676453,4.04721355438232,0.507309138774872],[-2.77695894241333,3.98097968101501,0.750533998012543],[-2.71334195137024,3.88977956771851,0.981435120105743],[-2.63335418701172,3.77511119842529,1.19622111320496],[-2.53830933570862,3.63885712623596,1.39136505126953],[-2.42976784706116,3.48325490951538,1.56366300582886],[-2.3095121383667,3.31085920333862,1.71028554439545],[-2.17951655387878,3.12450098991394,1.82882523536682],[-2.04191589355469,2.92724013328552,1.91733574867249],[-1.89896953105927,2.72231554985046,1.97436356544495],[-1.75302445888519,2.5130922794342,1.99897241592407],[-1.6064772605896,2.3030059337616,1.99075818061829],[-1.46173405647278,2.0955057144165,1.94985580444336],[-1.32117176055908,1.89399909973145,1.87693679332733],[-1.18709826469421,1.70179462432861,1.77319860458374],[-1.06171500682831,1.52204835414886,1.64034450054169],[-0.947080910205841,1.3577116727829,1.48055601119995],[-0.84507817029953,1.21148312091827,1.29645681381226],[-0.757381618022919,1.08576357364655,1.09106981754303],[-0.685431361198425,0.982617437839508,0.867767453193665],[-0.630408763885498,0.903738379478455,0.630216419696808],[-0.593217313289642,0.850421607494354,0.382317245006561],[-0.574467599391937,0.823542535305023,0.128140434622765],[-0.574467599391937,0.823542535305023,-0.128140434622765],[-0.593217313289642,0.850421607494354,-0.382317245006561],[-0.630408763885498,0.903738379478455,-0.630216419696808],[-0.685431361198425,0.982617437839508,-0.867767453193665],[-0.757381618022919,1.08576357364655,-1.09106981754303],[-0.84507817029953,1.21148312091827,-1.29645681381226],[-0.947080910205841,1.3577116727829,-1.48055601119995],[-1.06171500682831,1.52204835414886,-1.64034450054169],[-1.18709826469421,1.70179462432861,-1.77319860458374],[-1.32117176055908,1.89399909973145,-1.87693679332733],[-1.46173405647278,2.0955057144165,-1.94985580444336],[-1.6064772605896,2.3030059337616,-1.99075818061829],[-1.75302445888519,2.5130922794342,-1.99897241592407],[-1.89896953105927,2.72231554985046,-1.97436356544495],[-2.04191589355469,2.92724013328552,-1.91733574867249],[-2.17951655387878,3.12450098991394,-1.82882523536682],[-2.3095121383667,3.31085920333862,-1.71028554439545],[-2.42976784706116,3.48325490951538,-1.56366300582886],[-2.53830933570862,3.63885712623596,-1.39136505126953],[-2.63335418701172,3.77511119842529,-1.19622111320496],[-2.71334195137024,3.88977956771851,-0.981435120105743],[-2.77695894241333,3.98097968101501,-0.750533998012543],[-2.82316088676453,4.04721355438232,-0.507309138774872],[-2.85118913650513,4.08739423751831,-0.255754321813583],[-2.86058330535889,4.10086107254028,-4.89858741034067e-16],[-3.11744904518127,3.90915751457214,0],[-3.10721135139465,3.89631986618042,0.255754321813583],[-3.07666635513306,3.85801768302917,0.507309138774872],[-3.02631568908691,3.79487991333008,0.750533998012543],[-2.95698595046997,3.70794320106506,0.981435120105743],[-2.86981582641602,3.59863519668579,1.19622111320496],[-2.76623630523682,3.46875071525574,1.39136505126953],[-2.64794850349426,3.32042241096497,1.56366300582886],[-2.51689434051514,3.156085729599,1.71028554439545],[-2.37522602081299,2.97843909263611,1.82882523536682],[-2.22526955604553,2.79039978981018,1.91733574867249],[-2.06948733329773,2.59505486488342,1.97436356544495],[-1.91043710708618,2.39561223983765,1.99897241592407],[-1.75073063373566,2.19534683227539,1.99075818061829],[-1.59299039840698,1.99754667282104,1.94985580444336],[-1.43980622291565,1.805459856987,1.87693679332733],[-1.29369354248047,1.62224042415619,1.77319860458374],[-1.15705156326294,1.45089685916901,1.64034450054169],[-1.0321239233017,1.29424250125885,1.48055601119995],[-0.920961797237396,1.15484964847565,1.29645681381226],[-0.825390636920929,1.03500711917877,1.09106981754303],[-0.746979594230652,0.936682820320129,0.867767453193665],[-0.687016248703003,0.861491143703461,0.630216419696808],[-0.646485149860382,0.810666739940643,0.382317245006561],[-0.626051843166351,0.785044193267822,0.128140434622765],[-0.626051843166351,0.785044193267822,-0.128140434622765],[-0.646485149860382,0.810666739940643,-0.382317245006561],[-0.687016248703003,0.861491143703461,-0.630216419696808],[-0.746979594230652,0.936682820320129,-0.867767453193665],[-0.825390636920929,1.03500711917877,-1.09106981754303],[-0.920961797237396,1.15484964847565,-1.29645681381226],[-1.0321239233017,1.29424250125885,-1.48055601119995],[-1.15705156326294,1.45089685916901,-1.64034450054169],[-1.29369354248047,1.62224042415619,-1.77319860458374],[-1.43980622291565,1.805459856987,-1.87693679332733],[-1.59299039840698,1.99754667282104,-1.94985580444336],[-1.75073063373566,2.19534683227539,-1.99075818061829],[-1.91043710708618,2.39561223983765,-1.99897241592407],[-2.06948733329773,2.59505486488342,-1.97436356544495],[-2.22526955604553,2.79039978981018,-1.91733574867249],[-2.37522602081299,2.97843909263611,-1.82882523536682],[-2.51689434051514,3.156085729599,-1.71028554439545],[-2.64794850349426,3.32042241096497,-1.56366300582886],[-2.76623630523682,3.46875071525574,-1.39136505126953],[-2.86981582641602,3.59863519668579,-1.19622111320496],[-2.95698595046997,3.70794320106506,-0.981435120105743],[-3.02631568908691,3.79487991333008,-0.750533998012543],[-3.07666635513306,3.85801768302917,-0.507309138774872],[-3.10721135139465,3.89631986618042,-0.255754321813583],[-3.11744904518127,3.90915751457214,-4.89858741034067e-16],[-3.36150455474854,3.70139002799988,0],[-3.35046529769897,3.68923473358154,0.255754321813583],[-3.31752896308899,3.65296816825867,0.507309138774872],[-3.26323652267456,3.59318614006042,0.750533998012543],[-3.18847942352295,3.51087021827698,0.981435120105743],[-3.09448480606079,3.40737175941467,1.19622111320496],[-2.98279643058777,3.28439044952393,1.39136505126953],[-2.85524821281433,3.14394545555115,1.56366300582886],[-2.71393418312073,2.98834323883057,1.71028554439545],[-2.56117510795593,2.82013845443726,1.82882523536682],[-2.39947891235352,2.64209294319153,1.91733574867249],[-2.23150086402893,2.45713067054749,1.97436356544495],[-2.0599992275238,2.26828813552856,1.99897241592407],[-1.8877899646759,2.07866644859314,1.99075818061829],[-1.71770060062408,1.89137923717499,1.94985580444336],[-1.55252420902252,1.70950174331665,1.87693679332733],[-1.39497292041779,1.53602015972137,1.77319860458374],[-1.24763357639313,1.37378323078156,1.64034450054169],[-1.11292564868927,1.22545492649078,1.48055601119995],[-0.993061065673828,1.09347057342529,1.29645681381226],[-0.89000791311264,0.979997634887695,1.09106981754303],[-0.805458307266235,0.88689911365509,0.867767453193665],[-0.740800619125366,0.815703809261322,0.630216419696808],[-0.697096467018127,0.767580687999725,0.382317245006561],[-0.675063490867615,0.743319928646088,0.128140434622765],[-0.675063490867615,0.743319928646088,-0.128140434622765],[-0.697096467018127,0.767580687999725,-0.382317245006561],[-0.740800619125366,0.815703809261322,-0.630216419696808],[-0.805458307266235,0.88689911365509,-0.867767453193665],[-0.89000791311264,0.979997634887695,-1.09106981754303],[-0.993061065673828,1.09347057342529,-1.29645681381226],[-1.11292564868927,1.22545492649078,-1.48055601119995],[-1.24763357639313,1.37378323078156,-1.64034450054169],[-1.39497292041779,1.53602015972137,-1.77319860458374],[-1.55252420902252,1.70950174331665,-1.87693679332733],[-1.71770060062408,1.89137923717499,-1.94985580444336],[-1.8877899646759,2.07866644859314,-1.99075818061829],[-2.0599992275238,2.26828813552856,-1.99897241592407],[-2.23150086402893,2.45713067054749,-1.97436356544495],[-2.39947891235352,2.64209294319153,-1.91733574867249],[-2.56117510795593,2.82013845443726,-1.82882523536682],[-2.71393418312073,2.98834323883057,-1.71028554439545],[-2.85524821281433,3.14394545555115,-1.56366300582886],[-2.98279643058777,3.28439044952393,-1.39136505126953],[-3.09448480606079,3.40737175941467,-1.19622111320496],[-3.18847942352295,3.51087021827698,-0.981435120105743],[-3.26323652267456,3.59318614006042,-0.750533998012543],[-3.31752896308899,3.65296816825867,-0.507309138774872],[-3.35046529769897,3.68923473358154,-0.255754321813583],[-3.36150455474854,3.70139002799988,-4.89858741034067e-16],[-3.59174680709839,3.47841286659241,0],[-3.5799515247345,3.46698975563049,0.255754321813583],[-3.54475927352905,3.4329080581665,0.507309138774872],[-3.48674821853638,3.37672734260559,0.750533998012543],[-3.4068706035614,3.2993700504303,0.981435120105743],[-3.30643796920776,3.20210671424866,1.19622111320496],[-3.18709969520569,3.08653378486633,1.39136505126953],[-3.05081510543823,2.95454955101013,1.56366300582886],[-2.89982199668884,2.80832099914551,1.71028554439545],[-2.7365996837616,2.65024900436401,1.82882523536682],[-2.56382846832275,2.48292946815491,1.91733574867249],[-2.38434505462646,2.3091094493866,1.97436356544495],[-2.201096534729,2.13164305686951,1.99897241592407],[-2.01709198951721,1.95344460010529,1.99075818061829],[-1.83535254001617,1.77743983268738,1.94985580444336],[-1.65886247158051,1.60651874542236,1.87693679332733],[-1.49051988124847,1.44348800182343,1.77319860458374],[-1.3330887556076,1.29102444648743,1.64034450054169],[-1.1891542673111,1.15163171291351,1.48055601119995],[-1.061079621315,1.02759826183319,1.29645681381226],[-0.950967967510223,0.920961081981659,1.09106981754303],[-0.860627233982086,0.83347100019455,0.867767453193665],[-0.791540920734406,0.766564607620239,0.630216419696808],[-0.744843304157257,0.721340477466583,0.382317245006561],[-0.721301198005676,0.698541283607483,0.128140434622765],[-0.721301198005676,0.698541283607483,-0.128140434622765],[-0.744843304157257,0.721340477466583,-0.382317245006561],[-0.791540920734406,0.766564607620239,-0.630216419696808],[-0.860627233982086,0.83347100019455,-0.867767453193665],[-0.950967967510223,0.920961081981659,-1.09106981754303],[-1.061079621315,1.02759826183319,-1.29645681381226],[-1.1891542673111,1.15163171291351,-1.48055601119995],[-1.3330887556076,1.29102444648743,-1.64034450054169],[-1.49051988124847,1.44348800182343,-1.77319860458374],[-1.65886247158051,1.60651874542236,-1.87693679332733],[-1.83535254001617,1.77743983268738,-1.94985580444336],[-2.01709198951721,1.95344460010529,-1.99075818061829],[-2.201096534729,2.13164305686951,-1.99897241592407],[-2.38434505462646,2.3091094493866,-1.97436356544495],[-2.56382846832275,2.48292946815491,-1.91733574867249],[-2.7365996837616,2.65024900436401,-1.82882523536682],[-2.89982199668884,2.80832099914551,-1.71028554439545],[-3.05081510543823,2.95454955101013,-1.56366300582886],[-3.18709969520569,3.08653378486633,-1.39136505126953],[-3.30643796920776,3.20210671424866,-1.19622111320496],[-3.4068706035614,3.2993700504303,-0.981435120105743],[-3.48674821853638,3.37672734260559,-0.750533998012543],[-3.54475927352905,3.4329080581665,-0.507309138774872],[-3.5799515247345,3.46698975563049,-0.255754321813583],[-3.59174680709839,3.47841286659241,-4.89858741034067e-16],[-3.80722975730896,3.24114203453064,0],[-3.79472684860229,3.23049807548523,0.255754321813583],[-3.75742340087891,3.19874119758606,0.507309138774872],[-3.69593191146851,3.14639282226562,0.750533998012543],[-3.61126208305359,3.07431221008301,0.981435120105743],[-3.5048041343689,2.98368334770203,1.19622111320496],[-3.37830638885498,2.87599396705627,1.39136505126953],[-3.23384547233582,2.75301265716553,1.56366300582886],[-3.07379364967346,2.61675882339478,1.71028554439545],[-2.90077924728394,2.46946930885315,1.82882523536682],[-2.71764254570007,2.31356287002563,1.91733574867249],[-2.52739119529724,2.15159964561462,1.97436356544495],[-2.33314895629883,1.98623871803284,1.99897241592407],[-2.13810515403748,1.82019543647766,1.99075818061829],[-1.94546258449554,1.6561963558197,1.94985580444336],[-1.75838422775269,1.49693429470062,1.87693679332733],[-1.57994210720062,1.34502422809601,1.77319860458374],[-1.41306602954865,1.20296061038971,1.64034450054169],[-1.26049625873566,1.07307612895966,1.48055601119995],[-1.12473797798157,0.957503378391266,1.29645681381226],[-1.00802028179169,0.858140170574188,1.09106981754303],[-0.912259697914124,0.776618003845215,0.867767453193665],[-0.839028537273407,0.714275419712067,0.630216419696808],[-0.789529383182526,0.672136127948761,0.382317245006561],[-0.764574885368347,0.650892078876495,0.128140434622765],[-0.764574885368347,0.650892078876495,-0.128140434622765],[-0.789529383182526,0.672136127948761,-0.382317245006561],[-0.839028537273407,0.714275419712067,-0.630216419696808],[-0.912259697914124,0.776618003845215,-0.867767453193665],[-1.00802028179169,0.858140170574188,-1.09106981754303],[-1.12473797798157,0.957503378391266,-1.29645681381226],[-1.26049625873566,1.07307612895966,-1.48055601119995],[-1.41306602954865,1.20296061038971,-1.64034450054169],[-1.57994210720062,1.34502422809601,-1.77319860458374],[-1.75838422775269,1.49693429470062,-1.87693679332733],[-1.94546258449554,1.6561963558197,-1.94985580444336],[-2.13810515403748,1.82019543647766,-1.99075818061829],[-2.33314895629883,1.98623871803284,-1.99897241592407],[-2.52739119529724,2.15159964561462,-1.97436356544495],[-2.71764254570007,2.31356287002563,-1.91733574867249],[-2.90077924728394,2.46946930885315,-1.82882523536682],[-3.07379364967346,2.61675882339478,-1.71028554439545],[-3.23384547233582,2.75301265716553,-1.56366300582886],[-3.37830638885498,2.87599396705627,-1.39136505126953],[-3.5048041343689,2.98368334770203,-1.19622111320496],[-3.61126208305359,3.07431221008301,