# Articles by Brian Callander

### SR2 Chapter 3 Medium

April 4, 2020 |

SR2 Chapter 3 Medium Posted on 5 April, 2020 by Brian Tags: statistical rethinking, solutions, grid approximation, posterior probability, posterior predictive probability, hpdi, binomial Category: statistical-rethinking-2 Here’s my solution to the medium exercises in chapter 3 of McElreath’s Statistical Rethinking, 2nd edition. \(\DeclareMathOperator{\dbinomial}{Binomial} \DeclareMathOperator{\dbernoulli}{Bernoulli} \DeclareMathOperator{\dpoisson}{Poisson} \DeclareMathOperator{\... [Read more...]

### SR2 Chapter 3 Hard

April 4, 2020 |

SR2 Chapter 3 Hard Posted on 5 April, 2020 by Brian Tags: statistical rethinking, solutions, grid approximation, posterior predictive check, posterior predictive distribution, map, binomial, hpdi Category: statistical-rethinking-2 Here’s my solutions to the hard exercises in chapter 3 of McElreath’s Statistical Rethinking, 2nd edition. \(\DeclareMathOperator{\dbinomial}{Binomial} \DeclareMathOperator{\dbernoulli}{Bernoulli} \DeclareMathOperator{\dpoisson}{... [Read more...]

### SR2 Chapter 2 Hard

February 29, 2020 |

SR2 Chapter 2 Hard Posted on 1 March, 2020 by Brian Tags: statistical rethinking, solutions, conditional probability, counting, bayes rule, pandas Category: statistical-rethinking-2 Here’s my solution to the hard exercises in chapter 2 of McElreath’s Statistical Rethinking, 1st edition. When writing this up, I came across a very relevant article. We’ll ... [Read more...]

### SR2 Chapter 2 Medium

February 28, 2020 |

SR2 Chapter 2 Medium Posted on 29 February, 2020 by Brian Tags: statistical rethinking, solutions, conditional probability, counting, grid approximation Category: statistical-rethinking-2 Here’s my solutions to the medium exercises in chapter 2 of McElreath’s Statistical Rethinking, 1st edition. My intention is to move over to the 1nd edition when it comes out ... [Read more...]

### Speeding up Bayesian sampling with map_rect

August 8, 2019 |

Speeding up Bayesian sampling with map_rect Posted on 9 August, 2019 by Brian Tags: stan, map_rect, within-chain parallelisation, threading, ordinal regression Category: map_rect Fitting a full Bayesian model can be slow, especially with a large dataset. For example, it’d be great to analyse the climate crisis questions in ... [Read more...]

May 4, 2019 |

Hierarchical Customer Lifetime Value Posted on 5 May, 2019 by Brian Tags: customer lifetime value, recency frequency, hierarchical model, centred parameterisation, non-centred parameterisation, prior-predictive distribution, stan, e-bfmi, energy Category: customer_lifetime_value In a previous post, we described how a model of customer lifetime value (CLV) works, implemented it in Stan, and ... [Read more...]

### BDA3 Chapter 1 Exercise 9

April 12, 2019 |

BDA3 Chapter 1 Exercise 9 Posted on 13 April, 2019 by Brian Tags: bda chapter 1, solutions, simulation, poisson process Category: bda3 Here’s my solution to exercise 9, chapter 1, of Gelman’s Bayesian Data Analysis (BDA), 3rd edition. There are solutions to some of the exercises on the book’s webpage. \(\DeclareMathOperator{\dbinomial}{Binomial} \DeclareMathOperator{\... [Read more...]

April 5, 2019 |

Pareto-NBD Customer Lifetime Value Posted on 6 April, 2019 by Brian Tags: customer lifetime value, pareto-nbd, smc Category: customer_lifetime_value Suppose you have a bunch of customers who make repeat purchases - some more frequenty, some less. There are a few things you might like to know about these customers, such ... [Read more...]

### BDA3 Chapter 1 Exercise 3

March 30, 2019 |

BDA3 Chapter 1 Exercise 3 Posted on 31 March, 2019 by Brian Tags: bda chapter 1, solutions, hardy-weinberg principle Category: bda3 Here’s my solution to exercise 3, chapter 1, of Gelman’s Bayesian Data Analysis (BDA), 3rd edition. There are solutions to some of the exercises on the book’s webpage. \(\DeclareMathOperator{\dbinomial}{Binomial} \DeclareMathOperator{\dbern}{... [Read more...]

### CIS Primer Question 3.4.1

February 14, 2019 |

CIS Primer Question 3.4.1 Posted on 15 February, 2019 by Brian Tags: CISP chapter 3, solutions, front door criteria, front door adjustment Category: causal_inference_in_statistics_primer Here are my solutions to question 3.4.1 of Causal Inference in Statistics: a Primer (CISP). \(\DeclareMathOperator{\do}{do}\) If we can only measure one additional variable to ... [Read more...]

### CIS Primer Question 3.3.1

February 13, 2019 |

CIS Primer Question 3.3.1 Posted on 14 February, 2019 by Brian Tags: CISP chapter 3, solutions, backdoor criteria Category: causal_inference_in_statistics_primer Here are my solutions to question 3.3.1 of Causal Inference in Statistics: a Primer (CISP). Part a and b For the causal effect of \(X\) on \(Y\), every backdoor path must ... [Read more...]

### CIS Primer Question 3.3.2

February 13, 2019 |

CIS Primer Question 3.3.2 Posted on 14 February, 2019 by Brian Tags: CISP chapter 3, solutions, lord's paradox, simpson's paradox Category: causal_inference_in_statistics_primer Here are my solutions to question 3.3.2 of Causal Inference in Statistics: a Primer (CISP). Part a The following DAG is a possible casual graph representing the situation. We ... [Read more...]

### CIS Primer Question 3.3.3

February 13, 2019 |

CIS Primer Question 3.3.3 Posted on 14 February, 2019 by Brian Tags: CISP chapter 3, solutions, backdoor criteria Category: causal_inference_in_statistics_primer Here are my solutions to question 3.3.3 of Causal Inference in Statistics: a Primer (CISP). \(\DeclareMathOperator{\do}{do}\) The drug you have been assigned determines which ward you go to. Whether ... [Read more...]

### CIS Primer Question 3.2.1

February 9, 2019 |

CIS Primer Question 3.2.1 Posted on 10 February, 2019 by Brian Tags: CISP chapter 3, solutions, ace, risk difference, simpson's reversal Category: causal_inference_in_statistics_primer Here are my solutions to question 3.2.1 of Causal Inference in Statistics: a Primer (CISP). Here are the parameters we’ll use. Note that they are taken from ... [Read more...]

### CIS Primer Question 1.5.2

February 9, 2019 |

CIS Primer Question 1.5.2 Posted on 10 February, 2019 by Brian Tags: CISP chapter 1, solutions, simpson's reversal, product decomposition Category: causal_inference_in_statistics_primer Here are my solutions to question 1.5.2 of Causal Inference in Statistics: a Primer (CISP). I’ll use different indexing to make the notation clearer. In particular, the indices ... [Read more...]

### BDA3 Chapter 14 Exercise 3

February 9, 2019 |

BDA3 Chapter 14 Exercise 3 Posted on 10 February, 2019 by Brian Tags: bda chapter 14, solutions, quadratic form, qr decomposition Category: bda3 Here’s my solution to exercise 3, chapter 14, of Gelman’s Bayesian Data Analysis (BDA), 3rd edition. There are solutions to some of the exercises on the book’s webpage. \(\DeclareMathOperator{\dbinomial}{Binomial} \... [Read more...]