functions{ real cost_density(real x, // Function argument real xc, // Complement of function argument // on the domain (defined later) real[] theta, // parameters real[] x_r, // data (real) int[] x_i) { // data (integer) real mu = theta[1]; real sigma = theta[2]; real max_c = theta[3]; int num_bidders = x_i[1]; real out; out = (num_bidders - 1)*(lognormal_lcdf(x | mu, sigma) - lognormal_lcdf(max_c | mu, sigma)); return(exp(out)); } vector getGenerativeTotalAuctionHazard(int N, int[] J, // num bidders in each auction vector costs, matrix X, vector beta_costs, real sigma, real c_max, data real[] x_r ){ vector[N] mus; vector[N] numerators; vector[N] denominators; vector[N] out; mus = X * beta_costs; // NOTE: This assumes homogeneous bidders so that g_j(b_i) = g(b_i | X_j) = g(b_i | X_i) = g_i(b_i) for (n in 1:N){ numerators[n] = integrate_1d(cost_density, 0.0, // left limit c_max, // right limit { mus[n], sigma, costs[n] }, //theta x_r, { J[n] }, //x_i 0.001 ); denominators[n] = exp( (J[n] - 1)*(lognormal_lcdf(costs[n] | mus[n], sigma) - lognormal_lcdf(c_max | mus[n], sigma)) ); out[n] = numerators[n] / denominators[n]; } return(out); } } data { int N; // Number of auction-bidder obs int K; // number of auction-bidder feaures int J[N]; // Number of bidders in each auction matrix[N, K] X; // Auction-bidder features vector[N] bids; } transformed data { real x_r[0]; } parameters { vector[K] beta; real sigma; real c_max; vector[N] costs; } model { vector[N] inv_hazards; //prior to_vector(beta) ~ normal(0,1); sigma ~ normal(1,0.01); c_max ~ normal(3, 1); //likelihood for(i in 1:N){ costs[i] ~ normal(X[i] * beta, sigma) T[,c_max]; //empirical bid distribution } // inv_hazards = getGenerativeTotalAuctionHazard( N, J, // num bidders in each auction costs, X, beta, sigma, c_max, x_r ); (bids - costs) ~ normal(inv_hazards , 1); }