SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2006.06366 · NeurIPS · 2020

A Class of Algorithms for General Instrumental Variable Models

Niki Kilbertus, Matt Kusner, Ricardo Silva

arXiv · PDF · Open in the Atlas

Code that ran

7 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 4 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 2 failures of our instrument; 2 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2006.06366.json · badge: /api/ran/2006.06366.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
nikikilbertus/general-iv-models canonical (classifier label)
classifier basis: classifier_2025
7 ran · 2 no recorded run
FunctionStatusWhere it lives
fit_kiv Ran
ran; our contract draft was wrong, not the code
nikikilbertus/general-iv-models/src/kiv.py
code served (permissive licence) · get_code("1748c3c219235dfe")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned tuple, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
from absl import logging

# Set random seed for reproducibility
np.random.seed(0)

# Create small synthetic data
n_samples = 20
n_features = 1

# Generate synthetic instrument (z), treatment (x), and outcome (y)
z = np.random.randn(n_samples, n_features).flatten()
x = np.random.randn(n_samples, n_features).flatten()
y = np.random.randn(n_samples, n_features).flatten()

# Define ARGS dictionary with all parameters for fit_kiv
ARGS = {
    'z': z,
    'x': x,
    'y': y,
    'num_xstar': 50,
    'lambda_guess': np.log(0.05),
    'xi_guess': np.log(0.05),
    'fix_hyper': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
absl, numpy, scipy, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_k_matrix Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
nikikilbertus/general-iv-models/src/kiv.py
code served (permissive licence) · get_code("eab0a73ebfbfeeae")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 2, dtype family float, shape (3, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Create small numpy arrays for x1 and x2
x1 = np.array([1.0, 2.0, 3.0])  # 3 samples
x2 = np.array([1.5, 2.5, 3.5, 4.5])  # 4 samples

# Create a scalar parameter v
v = 1.0

ARGS = {
    "x1": x1,
    "x2": x2,
    "v": v
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (3, 4) — shape (3, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
kiv1_loss Ran
ran, honoured the contract we drafted
nikikilbertus/general-iv-models/src/kiv.py
code served (permissive licence) · get_code("8d3ade0940306366")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float64, ndim 0, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

np.random.seed(0)

# Construct a valid Kerneldict with required keys and appropriate shapes
# Based on the function body, we need:
# - 'y1': used for len(df['y1']) -> n
# - 'y2': used for len(df['y2']) -> m
# - 'K_ZZ': n x n matrix (passed to make_psd)
# - 'K_Zz': n x m matrix (used in solve and subsequent operations)
# - 'K_xx': m x m matrix (used in trace)
# - 'K_xX': m x n matrix (used in matrix multiplication)
# - 'K_XX': n x n matrix (used in matrix multiplication)

n = 3  # size for y1 and first dimension of kernels
m = 2  # size for y2 and second dimension of kernels

df = {
    'y1': np.arange(n),  # 1D array of length n
    'y2': np.arange(m),  # 1D array of length m
    'K_ZZ': np.random.randn(n, n),  # n x n
    'K_Zz': np.random.randn(n, m),  # n x m
    'K_xx': np.random.randn(m, m),  # m x m
    'K_xX': np.random.randn(m, n),  # m x n
    'K_XX': np.random.randn(n, n),  # n x n
}

lam = 0.1

ARGS = {
    'df': df,
    'lam': lam,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
kiv2_loss Ran
ran, honoured the contract we drafted
nikikilbertus/general-iv-models/src/kiv.py
code served (permissive licence) · get_code("b06389f34673f75d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Set random seed for reproducibility
np.random.seed(0)

# Create a small Kerneldict with required keys
# The function uses:
# - df['y1']: shape (n,) - used in mse comparison
# - df['y2']: shape (m,) - used in kiv_pred
# - df['K_ZZ']: shape (n, n) - used in matrix operations
# - df['K_XX']: shape (n, n) - used in matrix operations
# - df['K_Zz']: shape (n, m) - used in matrix operations
# - df['K_Xtest']: shape (n, p) - used when stage == 3

n = 5  # number of training samples
m = 4  # number of y2 samples
p = 3  # number of test samples

df = {
    'y1': np.random.randn(n),
    'y2': np.random.randn(m),
    'K_ZZ': np.random.randn(n, n),
    'K_XX': np.random.randn(n, n),
    'K_Zz': np.random.randn(n, m),
    'K_Xtest': np.random.randn(n, p),
}

# Set hyperparameters
lam = 0.1
xi = 0.01

ARGS = {
    'df': df,
    'lam': lam,
    'xi': xi,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
kiv_pred Ran
ran, honoured the contract we drafted
nikikilbertus/general-iv-models/src/kiv.py
code served (permissive licence) · get_code("c58ee09cfb099e4c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned ndarray, ndim 1, dtype family float, shape (5,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Set random seed for reproducibility
np.random.seed(0)

# Create a small Kerneldict with the required keys
# The function expects:
# - 'y1': target for first stage (length n)
# - 'y2': target for second stage (length m)
# - 'K_ZZ': kernel matrix (n x n)
# - 'K_XX': kernel matrix (n x n)
# - 'K_Zz': kernel matrix (n x m)
# - 'K_Xtest': kernel matrix (n x test_size) - only used when stage==3

n = 5  # number of training samples
m = 3  # number of test samples
test_size = 4  # number of test points

df = {
    'y1': np.random.randn(n),
    'y2': np.random.randn(m),
    'K_ZZ': np.random.randn(n, n),
    'K_XX': np.random.randn(n, n),
    'K_Zz': np.random.randn(n, m),
    'K_Xtest': np.random.randn(n, test_size),
}

lam = 0.1
xi = 0.01
stage = 2

ARGS = {
    'df': df,
    'lam': lam,
    'xi': xi,
    'stage': stage,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (5,) — shape (5,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
make_psd Ran
ran, honoured the contract we drafted
nikikilbertus/general-iv-models/src/kiv.py
code served (permissive licence) · get_code("b9595fe27edb6420")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 2, dtype family float, shape (3, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Create a small non-symmetric matrix to test the make_psd function
k = np.array([
    [1.0, 2.0, 3.0],
    [4.0, 5.0, 6.0],
    [7.0, 8.0, 9.0]
])

eps = 1e-10

ARGS = {
    "k": k,
    "eps": eps
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (3, 3) — shape (3, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
mse Ran
ran, violated the contract we drafted
nikikilbertus/general-iv-models/src/kiv.py
code served (permissive licence) · get_code("202bb2cafdd7e03f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Create two small numpy arrays for MSE calculation
x = np.array([[1.0, 2.0, 3.0, 4.0],
              [5.0, 6.0, 7.0, 8.0]])

y = np.array([[1.1, 2.1, 3.1, 4.1],
              [5.1, 6.1, 7.1, 8.1]])

ARGS = {
    "x": x,
    "y": y
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_k Not yet run
unverified (harvested, no recorded run)
nikikilbertus/general-iv-models/src/kiv.py
code served (permissive licence) · get_code("8a3d1ec4bc9e7e47")
How it ran

no invocation recorded.

median_inter Not yet run
unverified (harvested, no recorded run)
nikikilbertus/general-iv-models/src/kiv.py
code served (permissive licence) · get_code("6fb3ad4405d68661")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 9 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Causal treatment effect estimation is a key problem that arises in a variety of real-world settings, from personalized medicine to governmental policy making. There has been a flurry of recent work in machine learning on estimating causal effects when one has access to an instrument. However, to achieve identifiability, they in general require one-size-fits-all assumptions such as an additive error model for the outcome. An alternative is partial identification, which provides bounds on the causal effect. Little exists in terms of bounding methods that can deal with the most general case, where the treatment itself can be continuous. Moreover, bounding methods generally do not allow for a continuum of assumptions on the shape of the causal effect that can smoothly trade off stronger background knowledge for more informative bounds. In this work, we provide a method for causal effect bounding in continuous distributions, leveraging recent advances in gradient-based methods for the optimization of computationally intractable objective functions. We demonstrate on a set of synthetic and real-world data that our bounds capture the causal effect when additive methods fail, providing a useful range of answers compatible with observation as opposed to relying on unwarranted structural assumptions. 1

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2006.06366")
get_code_for_paper("2006.06366")
have("2006.06366")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2006.06366.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2006.06366.svg)](https://syntology.ai/paper/2006.06366)

Connect an agent — have() is free.