R - Bayesian
prop_model(data)
rbinom(n = 200 how many times to run the simulation, size = 100 sample size, prob = 0.42 probability)
runif(n = 6, min = 0.0, max = 1.0), random uniform sample between 0-1, 6 samples. continuous
dunif Discrete version
rbeta(n_draws, shape1 = 5, shape2 = 95), generate a distribution, the larger shape1,2 the more concentrated the distribution is, larger shape1 makes the distribution closer to 1, larger shape2 makes the distribution closer to 0
Poisson distribution
rpois(n_draws, lambda = mean_clicks)
Efficient alternative
dbinom(x = x1, size = sample size, prob= given probability) calculates specific probability, like P( x = 10 | p = 10%). args similar to rbinom though.
To generate a distribution instead of calculation one prob only, use x1 <- seq(0,100, by = 1) for example, or prob <- seq(0,1,by 0.01)
expand.grid(x,y) to generate all combination rows of 2 vectors
Normal distribution
x <- data
dnorm(x, mean = …, sd = …) calculate the likelihood for each datapoint in x. To create a distribution with dnorm, set x <- seq().
rnorm(n = … , mean = …, sd = …) simulate a distribution with n samples
Deal with very small percentage probability with log probability
visialize with plot(x,y, type = “h”)
2 complete models, bino and normal


BEST model
library(BEST) John Kurshner
BESTmcmc()
Comments
Post a Comment