# Posts Tagged ‘ Matrix Computations ’

## The sweep operator: A fundamental operation in regression

April 18, 2018
By

The sweep operator performs elementary row operations on a system of linear equations. The sweep operator enables you to build regression models by "sweeping in" or "sweeping out" particular rows of the X`X matrix. As you do so, the estimates for the regression coefficients, the error sum of squares, and [...] The post The sweep operator: A fundamental operation in regression appeared first on The DO Loop.

## Find the unique rows of a numeric matrix

April 11, 2018
By

Sometimes it is important to ensure that a matrix has unique rows. When the data are all numeric, there is an easy way to detect (and delete!) duplicate rows in a matrix. The main idea is to subtract one row from another. Start with the first row and subtract it [...] The post Find the unique rows of a numeric matrix appeared first on The DO Loop.

March 21, 2018
By

I often claim that the "natural syntax" of the SAS/IML language makes it easy to implement an algorithm or statistical formula as it appears in a textbook or journal. The other day I had an opportunity to test the truth of that statement. A SAS programmer wanted to implement the [...] The post The conjugate gradient method 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.

## A self-similar Christmas tree

December 11, 2017
By

Happy holidays to all my readers! My greeting-card to you is an image of a self-similar Christmas tree. The image (click to enlarge) was created in SAS by using two features that I blog about regularly: matrix computations and ODS statistical graphics. Self-similarity in Kronecker products I have previously shown [...] The post A self-similar Christmas tree appeared first on The DO Loop.

## The singular value decomposition and low-rank approximations

August 30, 2017
By

A previous article discussed the mathematical properties of the singular value decomposition (SVD) and showed how to use the SVD subroutine in SAS/IML software. This article uses the SVD to construct a low-rank approximation to an image. Applications include image compression and denoising an image. Construct a grayscale image The [...] The post The singular value decomposition and low-rank approximations appeared first on The DO Loop.

## Flip it. Flip it good.

July 31, 2017
By

A SAS user needed to convert a program from MATLAB into the SAS/IML matrix language and asked whether there is a SAS/IML equivalent to the fliplr and flipud functions in MATLAB. These functions flip the columns or rows (respectively) of a matrix; "LR" stands for "left-right" and "UD" stands for [...] The post Flip it. Flip it good. appeared first on The DO Loop.

## Difference operators as matrices

July 24, 2017
By

For a time series { y1, y2, ..., yN }, the difference operator computes the difference between two observations. The kth-order difference is the series { yk+1 - y1, ..., yN - yN-k }. In SAS, the DIF function in the DATA step computes differences between observations. The DIF function [...] The post Difference operators as matrices appeared first on The DO Loop.

## Rotation matrices and 3-D data

November 7, 2016
By

Rotation matrices are used in computer graphics and in statistical analyses. A rotation matrix is especially easy to implement in a matrix language such as the SAS Interactive Matrix Language (SAS/IML). This article shows how to implement three-dimensional rotation matrices and use them to rotate a 3-D point cloud. Define […] The post Rotation matrices and 3-D data appeared first on The DO Loop.

## Counting observations for which two events occur

October 31, 2016
By

Every year near Halloween I write an article in which I demonstrate a simple programming trick that is a real treat to use. This year's trick (which features the CMISS function and the crossproducts matrix in SAS/IML) enables you to count the number of observations that are missing for pairs […] The post Counting observations for which two events occur appeared first on The DO Loop.