R on Statistics @ Home
http://statsathome.com/tags/r/
Recent content in R on Statistics @ HomeHugo -- gohugo.ioen-ENstats.at.home@gmail.com (Justin and Rachel Silverman)stats.at.home@gmail.com (Justin and Rachel Silverman)(c) 2017 Justin and Rachel SilvermanSat, 27 Oct 2018 00:00:00 +0000Sampling from the Singular Normal
http://statsathome.com/2018/10/27/sampling-from-the-singular-normal/
Sat, 27 Oct 2018 00:00:00 +0000stats.at.home@gmail.com (Justin and Rachel Silverman)http://statsathome.com/2018/10/27/sampling-from-the-singular-normal/Following up the previous post on sampling from the multivariate normal, I decided to describe in more detail the situation where the covariance matrix or precision matrix is singular (e.g., it is not positive definite). A normal distribution with such a singular covariance/precision matrix is referred to as a singular normal distribution. Here is 100 samples from a two dimensional example:
Notice that a singular normal essentially has less dimensions (in this case 1 dimension) than the dimension of the random variable (in this case 2 dimensions).Sampling from Multivariate Normal (precision and covariance parameterizations)
http://statsathome.com/2018/10/19/sampling-from-multivariate-normal-precision-and-covariance-parameterizations/
Fri, 19 Oct 2018 00:00:00 +0000stats.at.home@gmail.com (Justin and Rachel Silverman)http://statsathome.com/2018/10/19/sampling-from-multivariate-normal-precision-and-covariance-parameterizations/Two things are motivating this quick post. First, I have seen a lot of R code that is slower than it should be due to unoptimized sampling from a multivariate normal. Second, yesterday I spend a frustrating few hours tracking down a bug that ultimately was due to a slight subtlety in sampling from the multivariate normal parameterized by a precision matrix (the inverse of a covariance matrix).
Key Idea: It is easy to draw univariate standard (e.Bayesian Decision Theory Made Ridiculously Simple
http://statsathome.com/2017/10/12/bayesian-decision-theory-made-ridiculously-simple/
Thu, 12 Oct 2017 00:00:00 +0000stats.at.home@gmail.com (Justin and Rachel Silverman)http://statsathome.com/2017/10/12/bayesian-decision-theory-made-ridiculously-simple/Framing the decision space Examples: Part 1 The other information that helps us make a decision Examples: Part 2 The Loss Function Examples: Part 3 Uncertainty Fully Worked Example: What price should I sell my used phone for? Next steps Bayesian Decision Theory is a wonderfully useful tool that provides a formalism for decision making under uncertainty. It is used in a diverse range of applications including but definitely not limited to finance for guiding investment strategies or in engineering for designing control systems.Plotting a Sequential Binary Partition on a Tree in R
http://statsathome.com/2017/09/20/plotting-a-sequential-binary-partition-on-a-tree-in-r/
Wed, 20 Sep 2017 00:00:00 +0000stats.at.home@gmail.com (Justin and Rachel Silverman)http://statsathome.com/2017/09/20/plotting-a-sequential-binary-partition-on-a-tree-in-r/For users of PhILR (Paper, R Package), and also for users of the ILR transform that wan to make use of the awesome plotting functions in R. I wanted to share a function for plotting a sequential binary partition on a tree using the ggtree package. I recently wrote this for a manuscript but figured it might be of more general use to others as well.
In its simplest form a sequential binary partition can be represented as a binary tree.Visualizing the Multinomial in the Simplex
http://statsathome.com/2017/09/14/visualizing-the-multinomial-in-the-simplex/
Thu, 14 Sep 2017 00:00:00 +0000stats.at.home@gmail.com (Justin and Rachel Silverman)http://statsathome.com/2017/09/14/visualizing-the-multinomial-in-the-simplex/Lately I have been working on figures for a manuscript. In this process I created a few visualizations that I thought might help others visualize the Multinomial distribution. I will focus on describing how counting processes introduce uncertainty into estimates of relative abundances and I will end with a discussion of how understanding the Multinomial has impacted my view of analyses of sequence count data (e.g., data from 16s studies of the microbiome, RNA-seq, and more).Does Gauss Love Me More in the Kitchen?
http://statsathome.com/2017/08/27/does-gauss-love-me-more-in-the-kitchen/
Sun, 27 Aug 2017 00:00:00 +0000stats.at.home@gmail.com (Justin and Rachel Silverman)http://statsathome.com/2017/08/27/does-gauss-love-me-more-in-the-kitchen/The Idea First things first, Gauss is our dog.
Since I am able to work from home, my dog Gauss and I spend a lot of time together. As a result, I like to think I know why he does what he does. But of course I will never really know - though, it’s nice to think that I do. Both of us being a creatures of habit, we have fallen into a nice routine during the day - one where he sleeps the day away and comes to get me around 4pm for some outdoor training/playing.A New(?) Regression Clustering Algorithm
http://statsathome.com/2017/08/13/a-new-functional-clustering-algorithm/
Sun, 13 Aug 2017 00:00:00 +0000stats.at.home@gmail.com (Justin and Rachel Silverman)http://statsathome.com/2017/08/13/a-new-functional-clustering-algorithm/Motivation My Solution - Hybrid K-Means/Linear-Regression with Transformation Starting on Boring Simulated Data Now a more interesting simulated dataset More realistic, presense of observational noise Conclusions and future directions Motivation I am a fan of the Stack Exchange forums. In particular, I like Cross Validated and Stack Overflow. An interesting question regarding clustering was posted recently. Essentially someone had the following dataset.
plot(Retirees) Essentially the poster wanted a way of clustering the observations into the “lines” that are fairly easy to observe in the data.Stochastic Loading of Microfluidic Droplets
http://statsathome.com/2017/07/08/stochastic-loading-of-microfluidic-droplets/
Sat, 08 Jul 2017 00:00:00 +0000stats.at.home@gmail.com (Justin and Rachel Silverman)http://statsathome.com/2017/07/08/stochastic-loading-of-microfluidic-droplets/The Basic Model The First Step - Multinomial Focusing on our Question - Binomial Approximating the Binomial - Poisson When is the Poisson approximation to the Binomial valid? Looking at Real Parameters Values Calculating the distribution of quantities in light of uncertainty in lab measurements Bivariate Distributions Droplet-based microfluidics are emerging as a useful technology in various fields of biomedicine. Both droplet digital PCR and droplet based culture methods require that droplets are created with either a single DNA molecule or a single cell per droplet.Fitting Non-Linear Growth Curves in R
http://statsathome.com/2017/06/07/fitting-non-linear-groth-curves-in-r/
Wed, 07 Jun 2017 00:00:00 +0000stats.at.home@gmail.com (Justin and Rachel Silverman)http://statsathome.com/2017/06/07/fitting-non-linear-groth-curves-in-r/A few months ago I offered to help a friend fit a bunch of microbial growth curves using R. When I was looking over possible solutions I was quite supprised by how little information was available online. Apart from the R package grofit (which after playing around with I decided seemed a little over-designed for my uses) I found very limited recources or code available. As a result of this I wanted to share a few functions I wrote to quickly fit non-linear growth models.