Blog Archives

Compute with combinations: Maximize a function over combinations of variables

March 19, 2018
By

About once a month I see a question on the SAS Support Communities that involves what I like to call "computations with combinations." A typical question asks how to find k values (from a set of p values) that maximize or minimize some function, such as "I have 5 variables, [...] The post Compute with combinations: Maximize a function over combinations of variables appeared first on The DO Loop.

Visualize repetition in song lyrics

March 14, 2018
By

One of my favorite magazines, Significance, printed an intriguing image of a symmetric matrix that shows repetition in a song's lyrics. The image was created by Colin Morris, who has created many similar images. When I saw these images, I knew that I wanted to duplicate the analysis in SAS! [...] The post Visualize repetition in song lyrics appeared first on The DO Loop.

Pi, special functions, and distributions

March 12, 2018
By

Welcome to my annual Pi Day post. Every year on March 14th (written 3/14 in the US), geeky mathematicians and their friends celebrate "all things pi-related" because 3.14 is the three-decimal approximation to pi. Pi is a mathematical constant that never changes. Pi is the same value today as it [...] The post Pi, special functions, and distributions appeared first on The DO Loop.

Fit a distribution from quantiles

March 7, 2018
By

Data analysts often fit a probability distribution to data. When you have access to the data, a common technique is to use maximum likelihood estimation (MLE) to compute the parameters of a distribution that are "most likely" to have produced the observed data. However, how can you fit a distribution [...] The post Fit a distribution from quantiles appeared first on The DO Loop.

The probability of a saddle point in a matrix

March 5, 2018
By

Many people know that a surface can contain a saddle point, but did you know that you can define the saddle point of a matrix? Saddle points in matrices are somewhat rare, which means that if you choose a random matrix you are unlikely to choose one that has a [...] The post The probability of a saddle point in a matrix appeared first on The DO Loop.

Solve a system of nonlinear equations with SAS

February 28, 2018
By

This article shows how to use SAS to solve a system of nonlinear equations. When there are n unknowns and n equations, this problem is equivalent to finding a multivariate root of a vector-valued function F(x) = 0 because you can always write the system as f1(x1, x2, ..., xn) [...] The post Solve a system of nonlinear equations with SAS appeared first on The DO Loop.

How to use FIRST.variable and LAST.variable in a BY-group analysis in SAS

February 26, 2018
By

My article about the difference between CLASS variables and BY variables in SAS focused on SAS analytical procedures. However, the BY statement is also useful in the SAS DATA step where it is used to merge data sets and to analyze data at the group level. When you use the [...] The post How to use FIRST.variable and LAST.variable in a BY-group analysis in SAS appeared first on The DO…

A Monte Carlo algorithm to estimate a median

February 21, 2018
By

This article describes and implements a fast algorithm that estimates a median for very large samples. The traditional median estimate sorts a sample of size N and returns the middle value (when N is odd). The algorithm in this article uses Monte Carlo techniques to estimate the median much faster. [...] The post A Monte Carlo algorithm to estimate a median appeared first on The DO Loop.

Compute the quantiles of any distribution

February 19, 2018
By

Your statistical software probably provides a function that computes quantiles of common probability distributions such as the normal, exponential, and beta distributions. Because there are infinitely many probability distributions, you might encounter a distribution for which a built-in quantile function is not implemented. No problem! This article shows how to [...] The post Compute the quantiles of any distribution appeared first on The DO Loop.

The difference between CLASS statements and BY statements in SAS

February 14, 2018
By

When I first learned to program in SAS, I remember being confused about the difference between CLASS statements and BY statements. A novice SAS programmer recently asked when to use one instead of the other, so this article explains the difference between the CLASS statement and BY variables in SAS [...] The post The difference between CLASS statements and BY statements in SAS appeared first on The DO Loop.