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

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

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

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.

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

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

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)

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

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