Last active
November 7, 2016 17:06
-
-
Save paulhendricks/be04b2c9f07591496491cccd733641a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| n <- 10000 | |
| alpha <- rnorm(n, 20, 5) # Customers spend on average $20 per transaction | |
| plot(density(alpha)) | |
| b <- 10 # Customers who are petite spend on average $10 more per transaction | |
| petite <- rbinom(n, size = 1, prob = 0.25) # Let's say 25% of customers are petite | |
| eps <- rnorm(n, 0, 5) # Add some error | |
| plot(density(eps)) | |
| y_true <- alpha + b * petite + eps | |
| plot(density(y_true)) | |
| y_true[y_true < 0] <- 0 | |
| plot(density(y_true)) | |
| summary(glm(y_true ~ petite)) | |
| y_true_binary <- 1 * (y_true > 40) | |
| summary(glm(y_true_binary ~ petite, family = binomial)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment