{"id":9571,"library":"causalmodels","title":"Causalmodels","description":"Causalmodels is a Python library for defining, analyzing, and inferring causal relationships from data, drawing inspiration from Judea Pearl's do-calculus. It provides tools for building Bayesian causal models, performing matching, and conducting regression-based causal inference. The current version is 0.4.0, with an irregular release cadence.","status":"active","version":"0.4.0","language":"python","source_language":"en","source_url":"https://github.com/roronya/causalmodels","tags":["causal inference","bayesian models","treatment effect","econometrics","statistics"],"install":[{"cmd":"pip install causalmodels","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Numerical operations","package":"numpy"},{"reason":"Scientific computing","package":"scipy"},{"reason":"Data manipulation","package":"pandas"},{"reason":"Statistical modeling and estimation","package":"statsmodels"},{"reason":"Machine learning utilities and models","package":"scikit-learn"}],"imports":[{"wrong":"from causalmodels import BayesianModel","symbol":"BayesianModel","correct":"from causalmodels import BayesianModel"}],"quickstart":{"code":"import pandas as pd\nimport numpy as np\nfrom causalmodels.regression import Regression\n\n# Simulate some data with a known causal effect\nnp.random.seed(42)\nn_samples = 1000\n\n# Confounder Z affects both Treatment X and Outcome Y\nZ = np.random.normal(0, 1, n_samples)\n# Treatment X is affected by Z\nX = 0.5 * Z + np.random.normal(0, 1, n_samples)\n# Outcome Y is affected by X and Z\nY = 2.0 * X + 1.0 * Z + np.random.normal(0, 1, n_samples)\n\ndata = pd.DataFrame({'Z': Z, 'X': X, 'Y': Y})\n\n# Initialize the Regression model\n# X: treatment variable, Y: outcome variable, control_variables: confounders\nmodel = Regression(data, treatment='X', outcome='Y', control_variables=['Z'])\n\n# Estimate the Average Treatment Effect (ATE)\nate_estimate = model.estimate_ate()\n\nprint(f\"Observed data with N={n_samples} samples.\")\nprint(f\"Estimated Average Treatment Effect (ATE) of X on Y, controlling for Z: {ate_estimate:.4f}\")","lang":"python","description":"This quickstart demonstrates how to use the `Regression` module to estimate the Average Treatment Effect (ATE) of a treatment variable 'X' on an outcome 'Y', while controlling for a confounder 'Z'. It simulates data reflecting a causal relationship and then applies the regression model."},"warnings":[{"fix":"Carefully define your causal graph, identify all potential confounders, and consider domain knowledge before applying methods. Validate assumptions where possible through sensitivity analysis or alternative approaches.","message":"Causal inference methods in `causalmodels` (and generally) rely on strong assumptions (e.g., no unmeasured confounders, correct specification of the causal graph). Failing to meet these assumptions can lead to biased estimates.","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure your DataFrame is clean, handles missing values (e.g., imputation or removal) appropriately, and all columns used in causal models are of the expected numerical type before passing the data.","message":"Input data to `causalmodels` methods must be clean and appropriately preprocessed. Missing values, incorrect data types, or inconsistent column names can lead to errors or silently biased results during estimation.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"search_vec":"'0.4.0':46 'analyz':9 'base':39 'bayesian':30,54 'build':29 'cadenc':51 'calculus':24 'causal':12,31,40,52 'causalmodel':1,2 'conduct':36 'current':43 'data':15 'defin':8 'do-calculus':22 'draw':16 'econometr':58 'effect':57 'infer':11,41,53 'inspir':17 'irregular':49 'judea':19 'librari':6 'match':34 'model':32,55 'pearl':20 'perform':33 'provid':26 'python':5 'regress':38 'regression-bas':37 'relationship':13 'releas':50 'statist':59 'tool':27 'treatment':56 'version':44","created_at":"2026-04-17T01:19:35.524359+00:00","updated_at":"2026-04-17T01:19:35.524359+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmpj2m84mgi/venv/lib/python3.12/site-packages/causalmodels/__init__.py\", line 1, in <module>\n    from causalmodels.lingam import DirectLiNGAM, SVARDirectLiNGAM\n  File \"/tmp/tmpj2m84mgi/venv/lib/python3.12/site-pac"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.4.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"http://github.com/roronya/causalmodels","docs":null,"changelog":null,"pypi":"https://pypi.org/project/causalmodels/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}