R

quickNmix: Asymptotic N-mixture Models

Estimating population abundance for replicated counts data is a computationally intensive problem. N-mixture models are used extensively in ecology to estimate population sizes, and to ascertain under-detection rates. Here I will discuss my new R package: quickNmix, which implements asymptotic solutions to the N-mixture likelihood function. The asymptotic solutions admit faster computation of the likelihood function, and the addition of parallel computing to the package can further increase computing speeds.

Functional Data Analysis: Discrete Observations to Functional Representations

Functional data can come from many different areas of study. Some of the most common examples come from finance (for example stock prices over time), or from health research (such as fMRI time series). Analyzing data of this form has been done traditionally using time series analysis techniques. However, viewing the data as functional, rather than individual observed points, can lead to more natural interpretations and analysis. Here we will be looking at a single example data set, and learning how to represent discrete data as functional data objects.

Rcpp: Using C++ to improve performance in R

Rcpp is an R library allowing for easy integration of C++ code in your R workflow. It allows you to create optimized functions for when R just isn’t fast enough. It can also be used as a bridge between R and C++ giving you the ability to access the existing C++ libraries. Why use Rcpp? There are many use cases for Rcpp, and of course many of them assume that you are interested in primarily working in R.

Bootstrap Tutorial in R

Bootstrapping is a statistical technique for analyzing the distributional properties of sample data (such as variability and bias). It has many uses, and is generally quite easy to implement. Continue reading to learn how you can perform a bootstrap procedure in R! What is bootstrapping? The bootstrap essentially uses re-sampling of a set of sample data in order to observe properties of the distribution of the data. For each re-sampling of the data (each “bootstrap sample”), you sample with replacement from the sample data, and compute the statistic of interest on the bootstrap sample (the bootstrap statistic).

optimizeAPA Tutorial (Arbitrary Precision Optimization)

optimizeAPA is an R package which allows for multi-parameter optimization. That means you can use it to find the maximum (or the minimum) value of a function with many input values. What makes optimizeAPA unique? It works with arbitrary precision arithmetic. Why use optimizeAPA? 1) works with both APA and NAPA optimization 2) works with both single parameter and multi-parameter functions 3) save an output file at each iteration 4) allows you to keep every value and input visited 5) easily plot the convergence path with a single function call Note: APA stands for “arbitrary precision arithmetic”, while NAPA stands for “non arbitrary precision arithmetic”

Manifold Regression (part 2)

Welcome to the world of manifold regression! In part 2 we will apply manifold regression to a case study involving fMRI brain imaging data. See part 1 for an introduction to these models. If you want to skip past the data preparation steps, and go right into the manifold regression, click here Getting Data First, we need a set of data to work from. There are many great fMRI imaging datasets available on the OpenNeuro website.

Manifold Regression (part 1)

Welcome to the world of manifold regression! In part 1 we will introduce the basic concepts, overview the theory behind regression on manifolds, develop an intuition for these models, and discuss their applications. See part 2 for a step by step statistical analysis applying these models. What is regression? We will consider regular linear regression (RLR) as an analogy to help understand manifold regression. In RLR, we consider pairs of observations \((x,y)\), with \(x\) the independent variable, and \(y\) the dependent variable.

An RMPFR Tutorial (Arbitrary Precision Probability Densities)

Working on a likelihood function that relies on the Poisson distribution with large mean \(\lambda\), I ran into the problem of underflow! Underflow occurs when a number is too small to be stored in memory, and so it is truncated to be equal to zero. In my case, the probabilities are so small in the tails of the distribution, that the probabilities return as 0 (although there is a non-zero probability in those tails).

Easy Latex Titles and Labels for ggplot

Summary Ever wanted to add \(\LaTeX\) to your R plots? Well now you can, with tikz, and it will allow you to use \(\LaTeX\) code within your plot titles, labels, and annotations. We’re going to look at how to use \(\LaTeX\) (text formating, formulas, fractions, greek letters, etc) with your ggplot data visualizations. We will be using the tikzDevice package for R (and to use your plots in \(\LaTeX\), you will use the package tikz).

Introduction to ggplot2 (part 2)

Getting bored with the plots you can make using the base R plot? Probably time to spice things up with ggplot! You can read through this article, or you can watch the tutorial video below (or both!). Let’s get started. First load the ggplot2 library, since thats what we’re here to learn! library(ggplot2) We’re going to be looking at the msleep dataset (same one we were looking at in the last tutorial )