Blog Archives

Logical operators in R

December 14, 2010
By
Logical operators in R

In R, the operators “|” and “&” indicate the logical operations OR and AND. For example, to test if x equals 1 and y equals 2 we do the following: > x = 1; y = 2 > (x == 1) & (y == 2) TRUE However, if you are used to programming in

Read more »

New paper: Survival analysis

December 8, 2010
By
New paper: Survival analysis

Each year I try to carry out some statistical consultancy to give me experience in other areas of statistics and also to provide teaching examples. Last Christmas I was approached by a paediatric consultant from the RVI who wanted to carry out prospective survival analysis. The consultant, Bruce  Jaffray, had performed Nissen fundoplication surgery on

Read more »

Random variable generation (Pt 2 of 3)

December 2, 2010
By
Random variable generation (Pt 2 of 3)

Acceptance-rejection methods This post is based on chapter 1.4 of Advanced Markov Chain Monte Carlo. Another method of generating random variates from distributions is to use acceptance-rejection methods. Basically to generate a random number from , we generate a RN from an envelope distribution , where .  The acceptance-rejection algorithm is as follows: Repeat until

Read more »

Random variable generation (Pt 1 of 3)

November 28, 2010
By
Random variable generation (Pt 1 of 3)

As I mentioned in a recent post, I’ve just received a copy of Advanced Markov Chain Monte Carlo Methods. Chapter 1.4 in the book (very quickly) covers random variable generation. Inverse CDF Method A standard algorithm for generating random numbers is the inverse cdf method. The continuous version of the algorithm is as follows: 1.

Read more »

Advanced Markov Chain Monte Carlo Methods (AMCMC)

November 27, 2010
By
Advanced Markov Chain Monte Carlo Methods (AMCMC)

I’ve just received my copy of Advanced Markov Chain Monte Carlo Methods, by Liang, Liu, & Carroll. Although my PhD didn’t really involve any Bayesian methodology (and my undergrad was devoid of any Bayesian influence), I’ve found that the sort of problems I’m now tackling in systems biology demand a Bayesian/MCMC approach. There are a

Read more »

R Style Guide

November 23, 2010
By
R Style Guide

Each year I have the pleasure (actually it’s quite fun) of teaching R programming to first year mathematics and statistics students. The vast majority of these students have no experience of programming, yet think they are good with computers because they use facebook! The class has around 100 students, and there are eight practicals. In

Read more »

Assignment operators in R: ‘=’ vs. ‘<-’

November 16, 2010
By
Assignment operators in R: ‘=’ vs. ‘<-’

In R, you can use  both ‘=’ and ‘<-’ as assignment operators. So what’s the difference between them and which one should you use? What’s the difference? The main difference between the two assignment operators is scope. It’s easiest to see the difference with an example: ##Delete x (if it exists) > rm(x) > mean(x=1:10)

Read more »

Installing R packages

November 6, 2010
By
Installing R packages

Part of the reason R has become so popular is the vast array of packages available at the cran and bioconductor repositories. In the last few years, the number of packages has grown exponentially! This is a short post giving steps on how to actually install R packages. Let’s suppose you want to install the

Read more »

An analysis of the Stackoverflow Beta sites

November 1, 2010
By
An analysis of the Stackoverflow Beta sites

In the last six months or so, the behemoth of Q & A sites stackoverflow, decided to change tack and launch a number of other non-computing-language sites. To launch a site in the stackoverflow family, sites have to spend time gathering followers in Area51. Once a site has gained a critical mass, a new StackExchange

Read more »