id string | prompt string | test_cases list | tier string | language string |
|---|---|---|---|---|
p2_001 | Run a fixed effects panel regression of y on x with entity fixed effects using xtreg. The data has panel structure with 'id' as the entity and 'time' as the time variable. Return the coefficient on x. | [
{
"id": "case_01",
"setup_code": "clear\ninput id time x y\n1 1 1 5\n1 2 2 7\n1 3 3 9\n2 1 2 8\n2 2 3 10\n2 3 4 12\n3 1 1 6\n3 2 2 8\n3 3 3 10\nend\nxtset id time",
"expected_outputs": {
"type": "scalar",
"key": "_b[x]",
"value": 2
},
"tolerance": 0.000001,
"language": "sta... | sacred | stata |
p2_002 | Perform two-stage least squares (2SLS) regression using ivregress. Regress y on endogenous variable x, using z as an instrument. Return the coefficient on x. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 12345\nset obs 100\ngen z = rnormal()\ngen e = rnormal()\ngen x = 2*z + 0.5*e\ngen y = 3*x + e",
"expected_outputs": {
"type": "scalar",
"key": "_b[x]",
"value": 3
},
"tolerance": 0.15000000000000002,
"language": "stata"
}... | sacred | stata |
p2_003 | Calculate the Herfindahl-Hirschman Index (HHI) for market concentration. Given market shares in variable 'share' (as decimals summing to 1), compute HHI = sum of squared shares * 10000. Return the HHI value. | [
{
"id": "case_01",
"setup_code": "clear\ninput share\n0.5\n0.3\n0.2\nend",
"expected_outputs": {
"type": "scalar",
"key": "hhi",
"value": 3800
},
"tolerance": 0.01,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput share\n0.25\n0.25\n0.25\n0.... | dev | stata |
p2_004 | Compute the Gini coefficient for income inequality from variable 'income'. Use the formula: G = (2 * sum(i * y_i) / (n * sum(y_i))) - (n+1)/n, where y_i is sorted income and i is rank. Return the Gini coefficient. | [
{
"id": "case_01",
"setup_code": "clear\ninput income\n10\n10\n10\n10\nend",
"expected_outputs": {
"type": "scalar",
"key": "gini",
"value": 0
},
"tolerance": 0.000001,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput income\n1\n2\n3\n4\n5\n... | dev | stata |
p2_005 | Run a difference-in-differences regression. You have variables: outcome, treat (treatment group indicator), post (post-treatment period), and treat_post (interaction). Return the coefficient on the interaction term (the DiD estimate). | [
{
"id": "case_01",
"setup_code": "clear\ninput treat post outcome\n0 0 10\n0 0 11\n0 1 12\n0 1 13\n1 0 15\n1 0 16\n1 1 22\n1 1 23\nend\ngen treat_post = treat * post",
"expected_outputs": {
"type": "scalar",
"key": "_b[treat_post]",
"value": 5
},
"tolerance": 0.000001,
"lan... | sacred | stata |
p2_006 | Calculate the first-order autocorrelation (lag-1) of variable 'y' in a time series. Use correlate y L.y after tsset. Return r(rho). | [
{
"id": "case_01",
"setup_code": "clear\ninput time y\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\nend\ntsset time",
"expected_outputs": {
"type": "scalar",
"key": "r(rho)",
"value": 1
},
"tolerance": 0.000001,
"language": "stata"
},
{
"id": "case_02",
"setup_code":... | sacred | stata |
p2_007 | Run a probit regression of binary outcome y on x. Return the coefficient on x (not marginal effect). | [
{
"id": "case_01",
"setup_code": "clear\nset seed 123\nset obs 200\ngen x = rnormal()\ngen y = (1.5*x + rnormal() > 0)",
"expected_outputs": {
"type": "scalar",
"key": "_b[x]",
"value": 2.0840848
},
"tolerance": 0.206324,
"language": "stata"
},
{
"id": "case_02",
... | dev | stata |
p2_008 | Calculate the variance inflation factor (VIF) for variable x1 in a regression with x1 and x2. After regress y x1 x2, use estat vif and return the VIF for x1. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 111\nset obs 100\ngen x1 = rnormal()\ngen x2 = rnormal()\ngen y = x1 + x2 + rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "vif_x1",
"value": 1
},
"tolerance": 0.1,
"language": "stata"
},
{
"id": "case_02... | dev | stata |
p2_009 | Perform a Chow test for structural break at observation 'breakpoint'. Regress y on x for the full sample, then test if coefficients differ before/after the break. Return the F-statistic. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 100\nset obs 20\ngen x = _n\ngen period = (_n > 10)\ngen y = 2*x + 0.5*period + 0.2*period*x + rnormal()*2\nscalar breakpoint = 10",
"expected_outputs": {
"type": "scalar",
"key": "F_chow",
"value": 10.44
},
"tolerance": 1.034,
... | sacred | stata |
p2_010 | Calculate the elasticity of y with respect to x at the mean values. Run reg ln_y ln_x where ln_y = log(y) and ln_x = log(x). The coefficient on ln_x is the elasticity. Return this elasticity. | [
{
"id": "case_01",
"setup_code": "clear\ninput x y\n1 2\n2 8\n3 18\n4 32\n5 50\nend",
"expected_outputs": {
"type": "scalar",
"key": "_b[ln_x]",
"value": 2
},
"tolerance": 0.1,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput x y\n1 10\n2 14... | dev | stata |
p2_011 | Compute the Durbin-Watson statistic for autocorrelation in regression residuals. After reg y x, use estat dwatson and return the d statistic. | [
{
"id": "case_01",
"setup_code": "clear\ninput time x y\n1 1 2.1\n2 2 3.9\n3 3 6.2\n4 4 7.8\n5 5 10.1\n6 6 11.9\n7 7 14.2\n8 8 15.8\nend\ntsset time",
"expected_outputs": {
"type": "scalar",
"key": "dw",
"value": 3.4626883
},
"tolerance": 0.17313442,
"language": "stata"
}... | sacred | stata |
p2_012 | Run a random effects panel regression of y on x using xtreg, re. Return the coefficient on x. | [
{
"id": "case_01",
"setup_code": "clear\ninput id time x y\n1 1 1 5\n1 2 2 8\n1 3 3 11\n2 1 2 7\n2 2 3 10\n2 3 4 13\n3 1 1 4\n3 2 2 7\n3 3 3 10\nend\nxtset id time",
"expected_outputs": {
"type": "scalar",
"key": "_b[x]",
"value": 3
},
"tolerance": 0.2,
"language": "stata"
... | dev | stata |
p2_013 | Calculate the interquartile range (IQR = Q3 - Q1) for variable 'x'. Return the IQR value. | [
{
"id": "case_01",
"setup_code": "clear\ninput x\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\nend",
"expected_outputs": {
"type": "scalar",
"key": "iqr",
"value": 6
},
"tolerance": 0.5,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput x\n10\n20\n... | sacred | stata |
p2_014 | Compute the coefficient of variation (CV = std/mean * 100) for variable 'x'. Return the CV as a percentage. | [
{
"id": "case_01",
"setup_code": "clear\ninput x\n10\n10\n10\n10\nend",
"expected_outputs": {
"type": "scalar",
"key": "cv",
"value": 0
},
"tolerance": 0.01,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput x\n1\n2\n3\n4\n5\nend",
"expec... | sacred | stata |
p2_015 | Run a logistic regression of binary y on x. Calculate and return the odds ratio for x (exp of coefficient). | [
{
"id": "case_01",
"setup_code": "clear\nset seed 101\nset obs 300\ngen x = rnormal()\ngen p = invlogit(0.7*x)\ngen y = runiform() < p",
"expected_outputs": {
"type": "scalar",
"key": "or_x",
"value": 2.0132528
},
"tolerance": 0.2,
"language": "stata"
},
{
"id": "ca... | dev | stata |
p2_016 | Perform a Hausman test comparing fixed effects vs random effects. Return the chi-squared test statistic. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 555\nset obs 90\ngen id = ceil(_n/3)\ngen time = mod(_n-1,3)+1\ngen x = rnormal()\ngen u = rnormal()\nbysort id: gen alpha = rnormal() if _n==1\nbysort id: replace alpha = alpha[1]\ngen y = 2*x + alpha + u\nxtset id time",
"expected_outputs": {
"ty... | sacred | stata |
p2_017 | Calculate the skewness of variable 'x'. Use summarize, detail and return r(skewness). | [
{
"id": "case_01",
"setup_code": "clear\ninput x\n1\n2\n3\n4\n5\nend",
"expected_outputs": {
"type": "scalar",
"key": "r(skewness)",
"value": 0
},
"tolerance": 0.01,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput x\n1\n1\n1\n1\n10\nend",
... | sacred | stata |
p2_018 | Calculate the kurtosis of variable 'x'. Use summarize, detail and return r(kurtosis). | [
{
"id": "case_01",
"setup_code": "clear\nset seed 42\nset obs 1000\ngen x = rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "r(kurtosis)",
"value": 2.8006081
},
"tolerance": 0.28,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput x... | dev | stata |
p2_019 | Compute the geometric mean of positive variable 'x'. Formula: exp(mean(ln(x))). Return the geometric mean. | [
{
"id": "case_01",
"setup_code": "clear\ninput x\n1\n2\n4\n8\nend",
"expected_outputs": {
"type": "scalar",
"key": "gmean",
"value": 2.828427
},
"tolerance": 0.00001,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput x\n10\n10\n10\nend",
... | dev | stata |
p2_020 | Calculate the harmonic mean of positive variable 'x'. Formula: n / sum(1/x). Return the harmonic mean. | [
{
"id": "case_01",
"setup_code": "clear\ninput x\n1\n2\n4\nend",
"expected_outputs": {
"type": "scalar",
"key": "hmean",
"value": 1.714286
},
"tolerance": 0.00001,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput x\n5\n5\n5\nend",
"expec... | sacred | stata |
p2_021 | Winsorize variable 'x' at the 5th and 95th percentiles. Replace values below p5 with p5 and above p95 with p95. Return the mean of winsorized x. | [
{
"id": "case_01",
"setup_code": "clear\nset obs 100\ngen x = _n",
"expected_outputs": {
"type": "scalar",
"key": "r(mean)",
"value": 50.5
},
"tolerance": 0.5,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\nset seed 123\nset obs 200\ngen x = rno... | sacred | stata |
p2_022 | Run a regression with robust (heteroskedasticity-consistent) standard errors. reg y x, robust. Return the robust standard error for the coefficient on x. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 999\nset obs 100\ngen x = rnormal()\ngen e = rnormal() * abs(x)\ngen y = 2*x + e",
"expected_outputs": {
"type": "scalar",
"key": "_se[x]",
"value": 0.201152
},
"tolerance": 0.010058,
"language": "stata"
},
{
"id": "... | dev | stata |
p2_023 | Compute the between-group variance share (R-squared from regressing y on group means). This equals 1 - (within variance / total variance). Return this ratio. | [
{
"id": "case_01",
"setup_code": "clear\ninput group y\n1 10\n1 12\n1 11\n2 20\n2 22\n2 21\n3 30\n3 32\n3 31\nend",
"expected_outputs": {
"type": "scalar",
"key": "between_share",
"value": 0.99
},
"tolerance": 0.02,
"language": "stata"
},
{
"id": "case_02",
"set... | dev | stata |
p2_024 | Calculate the adjusted R-squared from a regression of y on x1 and x2. Return e(r2_a) after the regression. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 111\nset obs 50\ngen x1 = rnormal()\ngen x2 = rnormal()\ngen y = 2*x1 + 3*x2 + rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "e(r2_a)",
"value": 0.9
},
"tolerance": 0.09000000000000001,
"language": "stata"
},
... | sacred | stata |
p2_025 | Run a regression with an interaction term. Regress y on x1 x2 and x1*x2 (interaction). Return the coefficient on the interaction term c.x1#c.x2. | [
{
"id": "case_01",
"setup_code": "clear\ninput x1 x2 y\n1 1 5\n1 2 7\n2 1 6\n2 2 12\n3 1 7\n3 2 17\nend",
"expected_outputs": {
"type": "scalar",
"key": "_b[c.x1#c.x2]",
"value": 4
},
"tolerance": 0.1,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "cle... | dev | stata |
p2_026 | Perform bootstrap estimation of the standard error of the mean of y with 100 replications. Return the bootstrap standard error. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 42\nset obs 50\ngen y = rnormal(10, 2)",
"expected_outputs": {
"type": "scalar",
"key": "bs_se",
"value": 0.28
},
"tolerance": 0.04,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\nset seed 84\nse... | dev | stata |
p2_027 | Calculate the mode (most frequent value) of discrete variable 'x'. If there are ties, return the smallest mode. Return the mode. | [
{
"id": "case_01",
"setup_code": "clear\ninput x\n1\n2\n2\n3\n3\n3\n4\nend",
"expected_outputs": {
"type": "scalar",
"key": "mode_x",
"value": 3
},
"tolerance": 0,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput x\n5\n5\n5\n10\n10\n15\nend"... | dev | stata |
p2_028 | Compute the entropy of a categorical variable 'x'. Entropy = -sum(p_i * ln(p_i)) where p_i is the proportion in each category. Return the entropy. | [
{
"id": "case_01",
"setup_code": "clear\ninput x\n1\n1\n2\n2\nend",
"expected_outputs": {
"type": "scalar",
"key": "entropy",
"value": 0.693147
},
"tolerance": 0.00001,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput x\n1\n1\n1\n1\nend",
... | dev | stata |
p2_029 | Calculate the effective number of observations accounting for clustering. Use the formula: n_eff = n / (1 + (m-1)*rho) where n is sample size, m is average cluster size, and rho is intraclass correlation. Return n_eff. | [
{
"id": "case_01",
"setup_code": "clear\ninput cluster y\n1 10\n1 12\n1 11\n2 20\n2 22\n2 21\n3 15\n3 17\n3 16\nend",
"expected_outputs": {
"type": "scalar",
"key": "n_eff",
"value": 3
},
"tolerance": 0.15,
"language": "stata"
},
{
"id": "case_02",
"setup_code":... | sacred | stata |
p2_030 | Run a Poisson regression of count variable y on x. Return the coefficient on x. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 444\nset obs 200\ngen x = rnormal()\ngen lambda = exp(1 + 0.5*x)\ngen y = rpoisson(lambda)",
"expected_outputs": {
"type": "scalar",
"key": "_b[x]",
"value": 0.5
},
"tolerance": 0.05,
"language": "stata"
},
{
"id": "... | sacred | stata |
p2_031 | Standardize variable 'x' to have mean 0 and standard deviation 1. Create variable 'z' = (x - mean(x)) / sd(x). Return the maximum value of z. | [
{
"id": "case_01",
"setup_code": "clear\ninput x\n1\n2\n3\n4\n5\nend",
"expected_outputs": {
"type": "scalar",
"key": "z_max",
"value": 1.2649111
},
"tolerance": 0.000001,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput x\n10\n20\n30\nend",... | sacred | stata |
p2_032 | Calculate the median absolute deviation (MAD) of variable 'x'. MAD = median(|x - median(x)|). Return MAD. | [
{
"id": "case_01",
"setup_code": "clear\ninput x\n1\n2\n3\n4\n5\nend",
"expected_outputs": {
"type": "scalar",
"key": "mad",
"value": 1
},
"tolerance": 0.000001,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput x\n1\n1\n2\n2\n100\nend",
... | sacred | stata |
p2_033 | Compute the Spearman rank correlation between variables 'x' and 'y'. Use spearman command and return rho. | [
{
"id": "case_01",
"setup_code": "clear\ninput x y\n1 10\n2 20\n3 30\n4 40\n5 50\nend",
"expected_outputs": {
"type": "scalar",
"key": "r(rho)",
"value": 1
},
"tolerance": 0.000001,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput x y\n1 50\... | sacred | stata |
p2_034 | Perform principal component analysis on x1, x2, x3 and return the eigenvalue of the first principal component. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 999\nset obs 100\ngen x1 = rnormal()\ngen x2 = x1 + 0.1*rnormal()\ngen x3 = x1 + 0.1*rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "ev1",
"value": 3
},
"tolerance": 0.3,
"language": "stata"
},
{
"id": "c... | sacred | stata |
p2_035 | Calculate the F-statistic for testing joint significance of x1 and x2 in a regression of y on x1, x2, and x3. Use test x1 x2 after regression and return F. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 777\nset obs 100\ngen x1 = rnormal()\ngen x2 = rnormal()\ngen x3 = rnormal()\ngen y = 2*x1 + 3*x2 + rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "r(F)",
"value": 460.67
},
"tolerance": 0.1,
"language": "stata"
... | dev | stata |
p2_036 | Calculate the Akaike Information Criterion (AIC) for a regression model. After reg y x1 x2, use estat ic to get the AIC. Return the AIC value from the information criteria matrix. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 123\nset obs 50\ngen x1 = rnormal()\ngen x2 = rnormal()\ngen y = x1 + x2 + rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "aic",
"value": 141.48
},
"tolerance": 0.5,
"language": "stata"
},
{
"id": "case_0... | dev | stata |
p2_037 | Run a tobit regression for censored data. Variable y is left-censored at 0. Return the coefficient on x. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 111\nset obs 200\ngen x = rnormal()\ngen ystar = 2*x + rnormal()\ngen y = max(0, ystar)",
"expected_outputs": {
"type": "scalar",
"key": "_b[x]",
"value": 1.96
},
"tolerance": 0.15,
"language": "stata"
},
{
"id": "ca... | dev | stata |
p2_038 | Calculate the Theil index for inequality measurement. Theil = (1/n) * sum((y_i/mean_y) * ln(y_i/mean_y)). Return the Theil index. | [
{
"id": "case_01",
"setup_code": "clear\ninput y\n10\n10\n10\n10\nend",
"expected_outputs": {
"type": "scalar",
"key": "theil",
"value": 0
},
"tolerance": 0.000001,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput y\n1\n2\n3\n4\nend",
"e... | sacred | stata |
p2_039 | Compute the leverage (hat values) for each observation in a regression. Return the maximum leverage value. | [
{
"id": "case_01",
"setup_code": "clear\ninput x y\n1 2\n2 4\n3 6\n4 8\n5 10\nend",
"expected_outputs": {
"type": "scalar",
"key": "max_leverage",
"value": 0.6
},
"tolerance": 0.000001,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput x y\n1... | sacred | stata |
p2_040 | Calculate Cook's distance for each observation and return the maximum Cook's D value. | [
{
"id": "case_01",
"setup_code": "clear\ninput x y\n1 2\n2 4\n3 6\n4 8\n5 100\nend",
"expected_outputs": {
"type": "scalar",
"key": "max_cooksd",
"value": 2.25
},
"tolerance": 0.5,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\nset seed 222\nset... | sacred | stata |
p2_041 | Run a regression with clustered standard errors by group variable 'cluster'. Return the clustered standard error for x. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 333\nset obs 100\ngen cluster = ceil(_n/10)\ngen x = rnormal()\ngen u = rnormal()\nbysort cluster: gen cluster_effect = rnormal() if _n==1\nbysort cluster: replace cluster_effect = cluster_effect[1]\ngen y = 2*x + cluster_effect + u",
"expected_outputs":... | dev | stata |
p2_042 | Compute the partial correlation between x and y, controlling for z. Return the partial correlation coefficient. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 100\nset obs 100\ngen z = rnormal()\ngen x = 0.5*z + rnormal()\ngen y = 0.5*z + rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "partial_r",
"value": -0.04
},
"tolerance": 0.02,
"language": "stata"
},
{
"i... | dev | stata |
p2_043 | Calculate the semi-elasticity: the percentage change in y for a one-unit change in x. Run reg ln_y x and return _b[x]*100. | [
{
"id": "case_01",
"setup_code": "clear\ninput x y\n0 100\n1 110\n2 121\n3 133\n4 146\nend\ngen ln_y = ln(y)",
"expected_outputs": {
"type": "scalar",
"key": "semi_elast",
"value": 9.467416
},
"tolerance": 0.000001,
"language": "stata"
},
{
"id": "case_02",
"set... | sacred | stata |
p2_044 | Perform a Breusch-Pagan test for heteroskedasticity after regressing y on x. Return the chi-squared statistic. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 444\nset obs 100\ngen x = runiform(1, 10)\ngen y = 2*x + rnormal()*x",
"expected_outputs": {
"type": "scalar",
"key": "r(chi2)",
"value": 15.73
},
"tolerance": 0.1,
"language": "stata"
},
{
"id": "case_02",
"setu... | dev | stata |
p2_045 | Calculate the Root Mean Square Error (RMSE) from a regression of y on x. RMSE = sqrt(e(rss)/e(N)). Return RMSE. | [
{
"id": "case_01",
"setup_code": "clear\ninput x y\n1 2\n2 4\n3 6\n4 8\n5 10\nend",
"expected_outputs": {
"type": "scalar",
"key": "rmse",
"value": 0
},
"tolerance": 0.01,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\nset seed 123\nset obs 100\... | sacred | stata |
p2_046 | Run an ordered probit regression of ordered outcome y (values 1,2,3) on x. Return the coefficient on x. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 111\nset obs 300\ngen x = rnormal()\ngen ystar = x + rnormal()\ngen y = 1 + (ystar > -0.5) + (ystar > 0.5)",
"expected_outputs": {
"type": "scalar",
"key": "_b[x]",
"value": 0.96
},
"tolerance": 0.01,
"language": "stata"
}... | dev | stata |
p2_047 | Calculate the share of variance explained by the first k principal components. Run pca on x1 x2 x3 and return the proportion of variance explained by PC1. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 777\nset obs 100\ngen x1 = rnormal()\ngen x2 = x1 + 0.1*rnormal()\ngen x3 = x1 + 0.1*rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "pc1_share",
"value": 1
},
"tolerance": 0.01,
"language": "stata"
},
{
"... | dev | stata |
p2_048 | Estimate a negative binomial regression for overdispersed count data. Return the coefficient on x. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 999\nset obs 300\ngen x = rnormal()\ngen lambda = exp(1 + 0.5*x)\ngen alpha = 0.5\ngen y = rpoisson(lambda * rgamma(1/alpha, alpha))",
"expected_outputs": {
"type": "scalar",
"key": "_b[x]",
"value": 0.46
},
"tolerance": 0.1,
... | dev | stata |
p2_049 | Calculate the mean squared prediction error using leave-one-out cross-validation for reg y x. Return the CV-MSE. | [
{
"id": "case_01",
"setup_code": "clear\ninput x y\n1 2\n2 4\n3 6\n4 8\n5 10\nend",
"expected_outputs": {
"type": "scalar",
"key": "cv_mse",
"value": 0
},
"tolerance": 0.1,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\nset seed 42\nset obs 20\n... | sacred | stata |
p2_050 | Compute the condition number of the X'X matrix (excluding the constant) from a regression of y on the X variables. The condition number is defined as sqrt(max eigenvalue / min eigenvalue) of X'X. Return the condition number. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 111\nset obs 100\ngen x1 = rnormal()\ngen x2 = rnormal()\ngen y = x1 + x2 + rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "cond_num",
"value": 1.04
},
"tolerance": 0.1,
"language": "stata"
},
{
"id": "ca... | dev | stata |
p3_001 | Estimate a vector autoregression (VAR) with 2 lags for variables y1 and y2. Return the coefficient on L1.y1 in the y2 equation. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 123\nset obs 100\ngen time = _n\ngen y1 = 0\ngen y2 = 0\nforvalues i = 3/100 {\n qui replace y1 = 0.5*y1[_n-1] + 0.2*y2[_n-1] + rnormal() in `i'\n qui replace y2 = 0.3*y1[_n-1] + 0.4*y2[_n-1] + rnormal() in `i'\n}\ntsset time",
"expected_outputs": ... | dev | stata |
p3_002 | Perform the Augmented Dickey-Fuller test for unit root on variable y. Return the test statistic. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 456\nset obs 200\ngen time = _n\ngen y = sum(rnormal())\ntsset time",
"expected_outputs": {
"type": "scalar",
"key": "adf_stat",
"value": -1.96
},
"tolerance": 0.1,
"language": "stata"
},
{
"id": "case_02",
"setu... | dev | stata |
p3_003 | Test for Granger causality: does x Granger-cause y? Run a VAR and test if lags of x jointly predict y. Return the chi-squared statistic. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 111\nset obs 150\ngen time = _n\ngen x = rnormal()\ngen y = 0\nforvalues i = 3/150 {\n qui replace y = 0.5*x[_n-1] + 0.3*y[_n-1] + rnormal() in `i'\n}\ntsset time",
"expected_outputs": {
"type": "scalar",
"key": "granger_chi2",
"valu... | dev | stata |
p3_004 | Estimate a GARCH(1,1) model for variable y. Return the ARCH coefficient (alpha). | [
{
"id": "case_01",
"setup_code": "clear\nset seed 222\nset obs 500\ngen time = _n\ngen e = rnormal()\ngen h = 1\ngen y = 0\nforvalues i = 2/500 {\n qui replace h = 0.1 + 0.2*e[_n-1]^2 + 0.7*h[_n-1] in `i'\n qui replace e = sqrt(h)*rnormal() in `i'\n qui replace y = e in `i'\n}\ntsset time",
"ex... | dev | stata |
p3_005 | Perform the Johansen cointegration test between y1 and y2 using vecrank with 2 lags. Return the trace statistic for the null hypothesis of rank=0. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 333\nset obs 200\ngen time = _n\ngen e1 = rnormal()\ngen e2 = rnormal()\ngen y1 = sum(e1)\ngen y2 = y1 + rnormal()\ntsset time",
"expected_outputs": {
"type": "scalar",
"key": "trace_stat",
"value": 86
},
"tolerance": 8.6,
"... | dev | stata |
p3_006 | Estimate a Cox proportional hazards model for survival data with time variable 't', failure indicator 'd', and covariate 'x'. Return the hazard ratio for x. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 444\nset obs 200\ngen x = rnormal()\ngen lambda = exp(0.5*x)\ngen t = -ln(runiform())/lambda\ngen d = (t < 5)\nreplace t = min(t, 5)\nstset t, failure(d)",
"expected_outputs": {
"type": "scalar",
"key": "hr_x",
"value": 1.57
},
... | dev | stata |
p3_007 | Calculate the Kaplan-Meier survival probability at time t=2. Return S(2). | [
{
"id": "case_01",
"setup_code": "clear\ninput t d\n0.5 1\n1.0 1\n1.5 0\n2.0 1\n2.5 1\n3.0 0\n3.5 1\n4.0 1\nend\nstset t, failure(d)",
"expected_outputs": {
"type": "scalar",
"key": "surv_t2",
"value": 0.6
},
"tolerance": 0.000001,
"language": "stata"
},
{
"id": "ca... | sacred | stata |
p3_008 | Estimate propensity scores using logit of treatment on x1 and x2, then calculate the Average Treatment Effect on the Treated (ATT) using nearest-neighbor matching. Return ATT. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 555\nset obs 200\ngen x1 = rnormal()\ngen x2 = rnormal()\ngen p = invlogit(-1 + 0.5*x1 + 0.3*x2)\ngen treat = runiform() < p\ngen y0 = 2 + x1 + rnormal()\ngen y1 = y0 + 3\ngen y = cond(treat, y1, y0)",
"expected_outputs": {
"type": "scalar",
... | sacred | stata |
p3_009 | Estimate a dynamic panel model using the Arellano-Bond GMM estimator. Regress y on L.y and x with xtabond. Return the coefficient on L.y. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 666\nset obs 500\ngen id = ceil(_n/10)\ngen time = mod(_n-1, 10) + 1\nxtset id time\ngen x = rnormal()\ngen u = rnormal()\ngen y = x + u if time == 1\nbysort id (time): replace y = 0.6*L.y + 0.5*x + u if time > 1",
"expected_outputs": {
"type": "sc... | dev | stata |
p3_010 | Perform a Seemingly Unrelated Regression (SUR) estimation for two equations: y1 = a1 + b1*x1 and y2 = a2 + b2*x2. Return b1. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 777\nset obs 100\ngen x1 = rnormal()\ngen x2 = rnormal()\ngen e1 = rnormal()\ngen e2 = 0.5*e1 + rnormal()*sqrt(0.75)\ngen y1 = 1 + 2*x1 + e1\ngen y2 = 2 + 3*x2 + e2",
"expected_outputs": {
"type": "scalar",
"key": "_b[y1:x1]",
"value": ... | dev | stata |
p3_011 | Estimate a regression discontinuity design. The running variable is 'x', treatment threshold is 0, and outcome is 'y'. Return the local average treatment effect at the threshold. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 888\nset obs 200\ngen x = runiform(-2, 2)\ngen treat = (x >= 0)\ngen y = 1 + 0.5*x + 3*treat + rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "late",
"value": 3.03
},
"tolerance": 0.2,
"language": "stata"
},
... | dev | stata |
p3_012 | Calculate the inverse Mills ratio for a Heckman selection model. Estimate a probit of select on all z* variables (all variables starting with z). Predict the linear index xb, then compute lambda = normalden(xb)/normal(xb) for selected observations (select==1). Return the mean of lambda. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 999\nset obs 300\ngen z = rnormal()\ngen select = (0.5*z + rnormal() > 0)\ngen y = 1 + rnormal() if select",
"expected_outputs": {
"type": "scalar",
"key": "mean_lambda",
"value": 0.7
},
"tolerance": 0.05,
"language": "stata... | dev | stata |
p3_013 | Perform quantile regression at the 90th percentile. Return _b[x] from qreg y x, q(.9). | [
{
"id": "case_01",
"setup_code": "clear\nset seed 100\nset obs 200\ngen x = rnormal()\ngen y = 1 + 2*x + (1 + 0.5*x)*rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "_b[x]",
"value": 2.651779
},
"tolerance": 0.2,
"language": "stata"
},
{
"id": "case_02",
... | dev | stata |
p3_014 | Estimate a multinomial logit model for outcome y (values 1,2,3) on x. Return the coefficient on x for outcome 2 vs base outcome 1. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 200\nset obs 500\ngen x = rnormal()\ngen v2 = 0.5*x + rnormal()\ngen v3 = x + rnormal()\ngen p1 = 1/(1 + exp(v2) + exp(v3))\ngen p2 = exp(v2)/(1 + exp(v2) + exp(v3))\ngen u = runiform()\ngen y = 1 + (u > p1) + (u > p1 + p2)",
"expected_outputs": {
... | dev | stata |
p3_015 | Calculate the Long-Run Variance using Newey-West HAC estimator with 4 lags. After reg y x, vce(hac nwest 4), return _se[x]. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 300\nset obs 200\ngen time = _n\ntsset time\ngen x = rnormal()\ngen e = 0\nforvalues i = 2/200 {\n qui replace e = 0.7*e[_n-1] + rnormal() in `i'\n}\ngen y = 2*x + e",
"expected_outputs": {
"type": "scalar",
"key": "_se[x]",
"value":... | dev | stata |
p3_016 | Compute the eigenvalues of a 3x3 matrix A. Return the largest eigenvalue. | [
{
"id": "case_01",
"setup_code": "clear\nmatrix A = (4, 1, 1 \\ 1, 4, 1 \\ 1, 1, 4)",
"expected_outputs": {
"type": "scalar",
"key": "max_eigen",
"value": 6
},
"tolerance": 0.000001,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\nmatrix A = (2, ... | sacred | stata |
p3_017 | Compute the determinant of matrix A. Return det(A). | [
{
"id": "case_01",
"setup_code": "clear\nmatrix A = (1, 2 \\ 3, 4)",
"expected_outputs": {
"type": "scalar",
"key": "det_A",
"value": -2
},
"tolerance": 0.000001,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\nmatrix A = (2, 0, 0 \\ 0, 3, 0 \\ 0... | sacred | stata |
p3_018 | Perform Cholesky decomposition of symmetric positive definite matrix A. Return the (1,1) element of the lower triangular matrix L where A = LL'. | [
{
"id": "case_01",
"setup_code": "clear\nmatrix A = (4, 2 \\ 2, 5)",
"expected_outputs": {
"type": "scalar",
"key": "L11",
"value": 2
},
"tolerance": 0.000001,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\nmatrix A = (9, 0, 0 \\ 0, 4, 0 \\ 0, 0... | sacred | stata |
p3_019 | Invert matrix A and return the (1,1) element of A^(-1). | [
{
"id": "case_01",
"setup_code": "clear\nmatrix A = (4, 7 \\ 2, 6)",
"expected_outputs": {
"type": "scalar",
"key": "Ainv_11",
"value": 0.6
},
"tolerance": 0.000001,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\nmatrix A = (1, 0 \\ 0, 2)",
... | sacred | stata |
p3_020 | Run a Wald test for the hypothesis that _b[x1] = _b[x2] after reg y x1 x2. Return the F statistic (r(F)). | [
{
"id": "case_01",
"setup_code": "clear\nset seed 400\nset obs 100\ngen x1 = rnormal()\ngen x2 = rnormal()\ngen y = 2*x1 + 2*x2 + rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "r(F)",
"value": 0.08
},
"tolerance": 0.008,
"language": "stata"
},
{
"id": "... | dev | stata |
p3_021 | Estimate a three-stage least squares (3SLS) system with two simultaneous equations where y1 depends on y2 and x1, and y2 depends on y1 and z2. Return the coefficient on x1 in the first equation. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 600\nset obs 200\ngen x1 = rnormal()\ngen z2 = rnormal()\ngen e1 = rnormal()\ngen e2 = 0.5*e1 + rnormal()*sqrt(0.75)\ngen y2 = 2*z2 + e2\ngen y1 = 1.5*y2 + 2*x1 + e1",
"expected_outputs": {
"type": "scalar",
"key": "_b[y1:x1]",
"value":... | dev | stata |
p3_022 | Perform kernel density estimation at x=0 using an Epanechnikov kernel with bandwidth 0.5. Return the density estimate f(0). | [
{
"id": "case_01",
"setup_code": "clear\nset seed 700\nset obs 500\ngen x = rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "f_0",
"value": 0.38
},
"tolerance": 0.019,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\nset seed 800\nset o... | dev | stata |
p3_023 | Estimate local polynomial regression (lpoly) of y on x and return the predicted value at x=0. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 900\nset obs 200\ngen x = runiform(-2, 2)\ngen y = x^2 + rnormal()*0.5",
"expected_outputs": {
"type": "scalar",
"key": "yhat_0",
"value": 0.10439015
},
"tolerance": 0.05,
"language": "stata"
},
{
"id": "case_02",
... | dev | stata |
p3_024 | Calculate the Likelihood Ratio test statistic comparing nested models: y on x1 vs y on x1 x2. LR = 2*(LL_full - LL_restricted). Return LR. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 111\nset obs 100\ngen x1 = rnormal()\ngen x2 = rnormal()\ngen y = 2*x1 + 3*x2 + rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "lr_stat",
"value": 248.67833
},
"tolerance": 12.4339165,
"language": "stata"
},
... | dev | stata |
p3_025 | Perform a Monte Carlo simulation: generate 1000 samples of size 30 from N(0,1), compute the sample mean for each, and return the standard deviation of these means (should approximate 1/sqrt(30)). | [
{
"id": "case_01",
"setup_code": "clear\nset seed 12345",
"expected_outputs": {
"type": "scalar",
"key": "mc_sd",
"value": 0.19
},
"tolerance": 0.019000000000000003,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\nset seed 2024",
"expected_ou... | dev | stata |
p3_026 | Calculate the Bayesian Information Criterion (BIC) for a regression model. BIC = n*ln(RSS/n) + k*ln(n). Return BIC. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 333\nset obs 100\ngen x1 = rnormal()\ngen x2 = rnormal()\ngen y = x1 + x2 + rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "bic",
"value": 21.99
},
"tolerance": 0.2,
"language": "stata"
},
{
"id": "case_0... | dev | stata |
p3_027 | Perform stepwise regression with forward selection using p-value threshold 0.05. Start with y on nothing, potentially add x1, x2, x3. Return the number of variables selected. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 444\nset obs 100\ngen x1 = rnormal()\ngen x2 = rnormal()\ngen x3 = rnormal()\ngen y = 2*x1 + 3*x2 + rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "n_selected",
"value": 2
},
"tolerance": 0.2,
"language": "stata"... | dev | stata |
p3_028 | Estimate a LASSO regression using cvlasso or similar. Return the coefficient on x1 from the model with optimal lambda. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 666\nset obs 200\ngen x1 = rnormal()\ngen x2 = rnormal()\ngen x3 = rnormal()\ngen x4 = rnormal()\ngen x5 = rnormal()\ngen y = 3*x1 + 2*x2 + rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "b_x1_lasso",
"value": 3
},
"... | dev | stata |
p3_029 | Calculate the Sargan-Hansen J statistic for overidentification in a GMM/IV model. Return the J statistic. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 777\nset obs 200\ngen z1 = rnormal()\ngen z2 = rnormal()\ngen z3 = rnormal()\ngen e = rnormal()\ngen x = z1 + z2 + z3 + 0.3*e\ngen y = 2*x + e",
"expected_outputs": {
"type": "scalar",
"key": "j_stat",
"value": 2.8
},
"tolerance... | dev | stata |
p3_030 | Estimate a fractional response model (fractional logit) for y in [0,1] on x. Use glm y x, family(binomial) link(logit). Return _b[x]. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 888\nset obs 200\ngen x = rnormal()\ngen ystar = invlogit(1 + 0.8*x)\ngen y = ystar + rnormal()*0.1\nreplace y = max(0.01, min(0.99, y))",
"expected_outputs": {
"type": "scalar",
"key": "_b[x]",
"value": 0.739278
},
"tolerance":... | dev | stata |
p3_031 | Perform a permutation test for difference in means between two groups. Generate 1000 permutations and return the p-value. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 999\ninput group y\n1 10\n1 12\n1 11\n1 13\n1 14\n2 15\n2 17\n2 16\n2 18\n2 19\nend",
"expected_outputs": {
"type": "scalar",
"key": "perm_pval",
"value": 0.008
},
"tolerance": 0.005,
"language": "stata"
},
{
"id": "... | sacred | stata |
p3_032 | Calculate the Nelson-Aalen cumulative hazard estimate at time t=2. Return H(2). | [
{
"id": "case_01",
"setup_code": "clear\ninput t d\n0.5 1\n1.0 1\n1.5 1\n2.0 1\n2.5 0\n3.0 1\nend\nstset t, failure(d)",
"expected_outputs": {
"type": "scalar",
"key": "H_t2",
"value": 0.95
},
"tolerance": 0.000001,
"language": "stata"
},
{
"id": "case_02",
"set... | sacred | stata |
p3_033 | Test for serial correlation in panel data residuals. First-difference y and x, regress D.y on D.x, get residuals, then regress residuals on lagged residuals with clustered standard errors. Return the F statistic from the final regression. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 100\nset obs 300\ngen id = ceil(_n/10)\ngen time = mod(_n-1, 10) + 1\nxtset id time\ngen x = rnormal()\ngen e = rnormal()\nbysort id (time): replace e = 0.7*e[_n-1] + rnormal() if _n > 1\ngen y = 2*x + e",
"expected_outputs": {
"type": "scalar",
... | dev | stata |
p3_034 | Estimate a sample selection model (Heckman two-step). Selection equation: select on z, outcome equation: y on x. Return the coefficient on x. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 200\nset obs 500\ngen z = rnormal()\ngen x = rnormal()\ngen e1 = rnormal()\ngen e2 = 0.5*e1 + rnormal()*sqrt(0.75)\ngen select = (0.5*z + e1 > 0)\ngen ystar = 1 + 2*x + e2\ngen y = ystar if select",
"expected_outputs": {
"type": "scalar",
"ke... | dev | stata |
p3_035 | Calculate the impulse response function: the effect of a one-unit shock to y1 on y2 after 3 periods in a VAR(1). Return IRF(3). | [
{
"id": "case_01",
"setup_code": "clear\nset seed 300\nset obs 200\ngen time = _n\ngen y1 = rnormal()\ngen y2 = 0\nforvalues i = 2/200 {\n qui replace y2 = 0.5*y1[_n-1] + 0.3*y2[_n-1] + rnormal() in `i'\n}\ntsset time",
"expected_outputs": {
"type": "scalar",
"key": "irf_3",
"value"... | dev | stata |
p3_036 | Perform an Im-Pesaran-Shin panel unit root test on variable y. Return the standardized Z-t-tilde-bar statistic (r(zttildebar)). | [
{
"id": "case_01",
"setup_code": "clear\nset seed 400\nset obs 500\ngen id = ceil(_n/50)\ngen time = mod(_n-1, 50) + 1\nxtset id time\ngen y = sum(rnormal())\nbysort id (time): replace y = sum(rnormal())",
"expected_outputs": {
"type": "scalar",
"key": "r(zttildebar)",
"value": 0.8
... | dev | stata |
p3_037 | Estimate a control function approach for endogeneity. First stage: regress x on z to get residuals v. Second stage: regress y on x and v. Return coefficient on x. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 500\nset obs 200\ngen z = rnormal()\ngen e = rnormal()\ngen x = z + 0.5*e\ngen y = 3*x + e",
"expected_outputs": {
"type": "scalar",
"key": "_b[x]",
"value": 3
},
"tolerance": 0.01,
"language": "stata"
},
{
"id": "ca... | sacred | stata |
p3_038 | Calculate the forecast error variance decomposition (FEVD): what fraction of y2's variance at horizon 4 is due to shocks in y1? Return the fraction. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 600\nset obs 200\ngen time = _n\ngen y1 = 0\ngen y2 = 0\nforvalues i = 2/200 {\n qui replace y1 = 0.7*y1[_n-1] + rnormal() in `i'\n qui replace y2 = 0.3*y1[_n-1] + 0.5*y2[_n-1] + rnormal() in `i'\n}\ntsset time",
"expected_outputs": {
"type":... | sacred | stata |
p3_039 | Estimate average marginal effects (AME) after a probit regression. Return the AME for x. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 700\nset obs 80\ngen x = rnormal()\ngen y = (x + rnormal() > 0)",
"expected_outputs": {
"type": "scalar",
"key": "ame_x",
"value": 0.36
},
"tolerance": 0.018,
"language": "stata"
},
{
"id": "case_02",
"setup_code... | dev | stata |
p3_040 | Calculate the Oaxaca-Blinder decomposition for wage gap between two groups. Return the explained portion of the gap. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 800\nset obs 400\ngen group = (_n > 200)\ngen educ = 12 + 2*rnormal() + 2*group\ngen wage = 10 + 2*educ + rnormal() + 5*group",
"expected_outputs": {
"type": "scalar",
"key": "explained",
"value": 4
},
"tolerance": 0.4,
"lan... | dev | stata |
p3_041 | Estimate a zero-inflated Poisson model for count data with excess zeros. Return the coefficient on x in the count equation. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 900\nset obs 300\ngen x = rnormal()\ngen zero_inflate = (runiform() < 0.3)\ngen lambda = exp(1 + 0.5*x)\ngen y = cond(zero_inflate, 0, rpoisson(lambda))",
"expected_outputs": {
"type": "scalar",
"key": "_b[x]",
"value": 0.51
},
... | dev | stata |
p3_042 | Estimate the treatment effect using difference-in-differences. The data has a treated unit and post-treatment period. Return the interaction coefficient as synth_effect. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 111\nset obs 200\ngen unit = ceil(_n/20)\ngen time = mod(_n-1, 20) + 1\ngen treated_unit = (unit == 1)\ngen post = (time > 10)\ngen treat = treated_unit*post\ngen treat_effect = 5*treat\ngen y = unit + 0.1*time + treat_effect + rnormal()",
"expected_outp... | dev | stata |
p3_043 | Calculate the heterogeneity parameter tau-squared in a meta-analysis using DerSimonian-Laird method. Return tau-squared. | [
{
"id": "case_01",
"setup_code": "clear\ninput effect se\n0.5 0.1\n0.6 0.12\n0.4 0.15\n0.7 0.08\n0.55 0.11\nend",
"expected_outputs": {
"type": "scalar",
"key": "tau2",
"value": 0.001229
},
"tolerance": 0.000001,
"language": "stata"
},
{
"id": "case_02",
"setup_... | sacred | stata |
p3_044 | Estimate a mixed-effects (multilevel) model with random intercepts by group. Return the variance of the random intercepts. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 222\nset obs 300\ngen group = ceil(_n/10)\ngen x = rnormal()\nbysort group: gen u = rnormal()*2 if _n==1\nbysort group: replace u = u[1]\ngen y = 1 + 2*x + u + rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "var_u",
"value":... | dev | stata |
p3_045 | Calculate the effective sample size for survey data with complex design (stratification and clustering). Return the design effect (DEFF). | [
{
"id": "case_01",
"setup_code": "clear\nset seed 333\nset obs 500\ngen strata = ceil(_n/100)\ngen cluster = ceil(_n/10)\ngen y = strata + cluster/10 + rnormal()\ngen pw = 1\nsvyset cluster [pw=pw], strata(strata)",
"expected_outputs": {
"type": "scalar",
"key": "deff",
"value": 0.16
... | sacred | stata |
p3_046 | Compute the average treatment effect (ATE) as the difference in mean outcomes between treated (treat==1) and control (treat==0) groups, using only observations with non-missing y. Return mean(y|treat==1) - mean(y|treat==0). | [
{
"id": "case_01",
"setup_code": "clear\nset seed 444\nset obs 200\ngen treat = (_n > 100)\ngen y = 5 + 3*treat + rnormal()\nreplace y = . if runiform() < 0.2 & treat==1",
"expected_outputs": {
"type": "scalar",
"key": "upper_bound",
"value": 3.4
},
"tolerance": 0.3,
"langu... | dev | stata |
p3_047 | Calculate the local Wald estimator (fuzzy RD) at threshold c=0. Instrument treatment D with indicator (x >= 0). Return LATE. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 555\nset obs 300\ngen x = runiform(-2, 2)\ngen z = (x >= 0)\ngen comply = runiform() < (0.3 + 0.5*z)\ngen D = z * comply\ngen y = 1 + 4*D + 0.5*x + rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "late",
"value": 5.0013049
... | dev | stata |
p3_048 | Estimate a stochastic frontier model for production function with inefficiency. The data has y = 0.6*ln(x) + v - u where v is noise and u is inefficiency. Create lnx = log(x) and run frontier y lnx. Return the coefficient on lnx. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 666\nset obs 200\ngen x = runiform(1, 10)\ngen v = rnormal()*0.2\ngen u = abs(rnormal())*0.3\ngen y = log(x^0.6) + v - u",
"expected_outputs": {
"type": "scalar",
"key": "_b[lnx]",
"value": 0.5862443
},
"tolerance": 0.0175873290... | dev | stata |
p3_049 | Calculate the Rosenbaum bounds for sensitivity analysis after propensity score matching. Use psmatch2 to match treat on x with outcome y, then use rbounds at Gamma=2. Return the upper bound p-value (sig+). | [
{
"id": "case_01",
"setup_code": "cap ssc install psmatch2, replace\ncap ssc install rbounds, replace\nclear\nset seed 777\nset obs 100\ngen x = rnormal()\ngen treat = (x + rnormal() > 0)\ngen y = 3*treat + x + rnormal()",
"expected_outputs": {
"type": "scalar",
"key": "pval_upper_g2",
... | dev | stata |
p3_050 | Estimate a model with spatial dependence. Regress y on a spatial lag variable (y_neighbor) and x. Return the spatial lag coefficient as scalar rho. | [
{
"id": "case_01",
"setup_code": "clear\nset seed 888\nset obs 100\ngen id = _n\ngen x = rnormal()\ngen e = rnormal()\n* Simplified: use neighbor average as spatial lag\ngen y_neighbor = .\nforvalues i = 2/99 {\n local prev = `i' - 1\n local next = `i' + 1\n replace y_neighbor = (x[`prev'] + x[`nex... | dev | stata |
Stata Econometrics Benchmark
250 natural-language econometrics & statistics tasks, each solvable with a short Stata program and graded by executing the generated code against 1250 hidden numeric test cases (5 per problem). This is an execution-based benchmark: a solution is correct only if running it reproduces the expected numeric result within a per-case tolerance — not by string match.
At a glance
- 250 problems, 1250 test cases (5 per problem)
- Target language: Stata
- Grading: execution-based, numeric comparison within per-case
tolerance - Difficulty tiers: 109
dev(development/visible) + 141sacred(held-out) - Topics: panel/FE regression, IV/2SLS, MLE, time series (VAR/IRF, unit roots), survival, matrix algebra, inequality & concentration indices, diagnostics (VIF, Durbin–Watson, Hausman, Chow), and more.
Schema
One JSON object per line. Problem-level fields:
| field | type | description |
|---|---|---|
id |
string | Unique problem id (e.g. p2_001). |
prompt |
string | The task, in natural language. The model must return Stata code that solves it. |
test_cases |
list | 5 independent graded cases (see below). |
tier |
string | dev or sacred. |
language |
string | Always stata. |
Each entry in test_cases:
| field | type | description |
|---|---|---|
id |
string | Case id (case_01 … case_05). |
setup_code |
string | Stata code that prepares the data/state (e.g. input … end, xtset). Runs before the model's solution. |
expected_outputs |
object | { "type": "scalar", "key": <stata expression>, "value": <number> }. |
tolerance |
float | Max allowed absolute difference between the evaluated key and value. |
language |
string | Always stata. |
Example
{
"id": "p2_001",
"prompt": "Run a fixed effects panel regression of y on x with entity fixed effects using xtreg. The data has panel structure with 'id' as the entity and 'time' as the time variable. Return the coefficient on x.",
"test_cases": [
{
"id": "case_01",
"setup_code": "clear\ninput id time x y\n1 1 1 5\n1 2 2 7\n1 3 3 9\n2 1 2 8\n2 2 3 10\n2 3 4 12\n3 1 1 6\n3 2 2 8\n3 3 3 10\nend\nxtset id time",
"expected_outputs": {
"type": "scalar",
"key": "_b[x]",
"value": 2.0
},
"tolerance": 1e-06,
"language": "stata"
},
{
"id": "case_02",
"setup_code": "clear\ninput id time x y\n1 1 0 10\n1 2 1 13\n1 3 2 16\n2 1 1 5\n2 2 2 8\n2 3 3 11\nend\nxtset id time",
"expected_outputs": {
"type": "scalar",
"key": "_b[x]",
"value": 3.0
},
"tolerance": 1e-06,
"language": "stata"
}
],
"tier": "sacred",
"language": "stata"
}
How grading works
For each test case:
- Run
setup_code(loads/constructs the dataset, sets the panel/time structure, etc.). - Append and run the model's generated Stata solution.
- Evaluate the Stata expression in
expected_outputs.keyand compare it numerically toexpected_outputs.value. - The case passes iff
abs(evaluated - value) <= tolerance.
A problem is typically scored as solved only when all 5 cases pass, which guards against solutions that hard-code one answer or overfit a single dataset.
Answer-key families
key is a Stata expression evaluated after the solution runs. The common families:
| family | meaning | example |
|---|---|---|
_b[...], _se[...] |
estimated coefficient / standard error from the last estimation | _b[x] |
r(...) |
r-class returned results (e.g. summarize, correlate) |
r(mean) |
e(...) |
e-class estimation results | e(N), e(r2) |
result, named scalars |
a problem-specific scalar the solution must compute and store | gini, hhi, F_chow, late |
Observed key families in this release: r (435), _b (180), result (80), _se (25), e (20), hr_x (10), late (10), max_eigen (10), det_A (10), b_x (10), elem (10), hhi (5).
Tiers
dev(109) — intended for development, prompt iteration, and visible evaluation.sacred(141) — held-out set kept separate from model development to give a cleaner generalization estimate.
Contamination note. This is a public release, so the
sacredsplit is now on the open web and may eventually appear in pretraining corpora. Treat scores accordingly and prefer fresh/private problems for high-stakes leaderboard claims.
Usage
from datasets import load_dataset
ds = load_dataset("eltokh7/stata-econ-bench", split="test")
print(ds[0]["prompt"])
print(ds[0]["test_cases"][0]["expected_outputs"]) # {'type': 'scalar', 'key': '_b[x]', 'value': 2.0}
# Filter to held-out problems
sacred = ds.filter(lambda r: r["tier"] == "sacred")
Or read the raw JSONL directly:
import json
data = [json.loads(line) for line in open("stata_econ_bench.jsonl")]
You need a working Stata installation (batch mode) to actually grade generated solutions.
License
Released under CC-BY-4.0. If you use this benchmark, please credit the source.
@misc{stata_econ_bench,
title = {Stata Econometrics Benchmark},
author = {Eltoukhy, Khaled},
year = {2026},
howpublished = {Hugging Face Datasets},
url = {https://huggingface.co/datasets/eltokh7/stata-econ-bench}
}
- Downloads last month
- 14