Skip to content

Instantly share code, notes, and snippets.

View aleszib's full-sized avatar

Aleš Žiberna aleszib

View GitHub Profile
@alexhallam
alexhallam / marketing_mix.stan
Created May 22, 2018 11:47
Bayesian Methods for Media Mix Modeling with Carryover and Shape Effects 14th April 2017
functions {
// the Hill function
real Hill(real t, real ec, real slope) {
return 1 / (1 + (t / ec)^(-slope));
}
// the adstock transformation with a vector of weights
real Adstock(row_vector t, row_vector weights) {
return dot_product(t, weights) / sum(weights);
}
}
@aleszib
aleszib / stochBlockMay2021.R
Created May 5, 2021 09:29
R Code for linked stochastic blockmodeling
library(blockmodeling)
stochBlock<-function(M, clu, eps=0, each=FALSE,weights=NULL, eachProb=FALSE, nMode=NULL, limits=NULL, design0=TRUE, weightClusterSize = 1){
wc<-weightClusterSize
n<-dim(M)[1]
# mean05<-function(x)mean(c(x,0.5), na.rm=TRUE)
if(is.null(weights)){
weights<-M