March 2019
Beginner to intermediate
448 pages
13h 14m
English
In this example, we have a variable that flags if a client has bought a special gift pack. For each client, we have several attributes, such as the age of the customer, how much the customer has already bought, and how long they have been a client:
library(rstan) data = read.csv("./clients.csv") model ="data {int<lower = 0, upper = 1> y[99];real x[99,3];}parameters {real beta[3];real alpha;}model {beta ~ normal(5,10);for (n in 1:99)y[n] ~ bernoulli_logit(alpha + beta[1]*x[n,1] + beta[2]*x[n,2] + beta[3]*x[n,3]); ...Read now
Unlock full access