Blog Archives

Fibonacci sequence in R and SAS

December 5, 2014
By

Because the Fibonacci sequence is simply defined by recursion, it makes for an elegant programming exercise. Here is one way to do it in SAS, and another way to do it in R. I've also included unit testing code to check that it works. Fibonacci sequence in SAS using a recursive macro: %macro fib(n);%if &n = 1 %then 1;...

Read more »

Visualizing principal components with R and Sochi Olympic Athletes

March 27, 2014
By
Visualizing principal components with R and Sochi Olympic Athletes

Principal Components Analysis (PCA) is used as a dimensionality reduction method. Here we simply explain PCA step-by-step using data about Sochi Olympic Curlers. It is hard to visualize a high dimensional space. When I took linear algebra, the book and teachers spoke about it as if were easy to visualize a hyperspace, but...

Read more »

Type I error rates in test of normality by simulation

February 26, 2014
By
Type I error rates in test of normality by simulation

This simulation tests the type I error rates of the Shapiro-Wilk test of normality in R and SAS. First, we run a simulation in R. Notice the simulation is vectorized: there are no "for" loops that clutter the code and slow the simulation. # type I erroralpha <- 0.05# number of simulationsn.simulations <- 10000#...

Read more »