[{"data":1,"prerenderedAt":636},["ShallowReactive",2],{"content-query-2VBNY32CMw":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"heading":10,"prompt":11,"tags":15,"files":17,"nav":17,"presets":18,"gallery":36,"body":38,"_type":629,"_id":630,"_source":631,"_file":632,"_stem":633,"_extension":634,"sitemap":635},"/tools/partial-correlation","tools",false,"","Partial Correlation Calculator for Excel & CSV","Calculate partial correlations online from Excel or CSV data. Control for confounders and isolate the relationship between variables with AI.","Partial Correlation",{"prefix":12,"label":13,"placeholder":14},"Compute partial correlations","Describe the partial correlation analysis you want to run","e.g. partial correlation between CO2 and life expectancy controlling for GDP and education",[16],"statistics",true,[19,25,30],{"label":20,"prompt":21,"dataset_url":22,"dataset_title":23,"dataset_citation":24},"Country indicators controlling for GDP","compute partial correlations between life expectancy, CO2 emissions, education, healthcare spending, and fertility rate — controlling for GDP per capita; compare side by side with Pearson correlations to show which relationships are driven by GDP; diverging heatmap","https://ourworldindata.org/grapher/life-expectancy-vs-gdp-per-capita.csv","Life expectancy vs. GDP per capita","Our World in Data",{"label":26,"prompt":27,"dataset_url":28,"dataset_title":29,"dataset_citation":24},"Energy mix partial correlations","partial correlations between fossil fuel share, renewable share, nuclear share, CO2 per capita, and electricity access — controlling for income level; compare partial vs Pearson matrix side by side; highlight cells where partial correlation differs most from Pearson","https://ourworldindata.org/grapher/share-of-electricity-production-by-source.csv","Share of electricity production by source",{"label":31,"prompt":32,"dataset_url":33,"dataset_title":34,"dataset_citation":35},"Economic indicators controlling for development","partial correlation matrix of GDP growth, trade openness, inflation, government expenditure, and current account balance — controlling for income group; identify which economic relationships survive after removing the influence of development level","https://api.worldbank.org/v2/en/indicator/NY.GDP.MKTP.KD.ZG?downloadformat=excel","GDP growth (annual %)","World Bank",[37],"/img/tools/partial-correlation.png",{"type":39,"children":40,"toc":619},"root",[41,50,71,76,110,116,182,188,298,304,412,418,472,478,507,513,530,554,585,602],{"type":42,"tag":43,"props":44,"children":46},"element","h2",{"id":45},"what-is-partial-correlation",[47],{"type":48,"value":49},"text","What Is Partial Correlation?",{"type":42,"tag":51,"props":52,"children":53},"p",{},[54,56,62,64,69],{"type":48,"value":55},"A ",{"type":42,"tag":57,"props":58,"children":59},"strong",{},[60],{"type":48,"value":61},"partial correlation",{"type":48,"value":63}," measures the relationship between two variables after ",{"type":42,"tag":57,"props":65,"children":66},{},[67],{"type":48,"value":68},"removing the shared influence of one or more control variables",{"type":48,"value":70},". Where a standard Pearson correlation between X and Y captures everything that makes them move together — including any joint influence from a third variable Z — a partial correlation strips out Z's effect and shows only the direct linear relationship between X and Y that remains.",{"type":42,"tag":51,"props":72,"children":73},{},[74],{"type":48,"value":75},"The classic example is the \"ice cream and drowning\" problem: ice cream sales and drowning deaths are strongly positively correlated (r ≈ 0.8), but this disappears almost entirely once you control for season (summer). Partial correlation of ice cream sales and drowning deaths, controlling for temperature, drops to near zero — revealing the original correlation as spurious, driven entirely by a shared confounder. In economics, CO₂ emissions and life expectancy are positively correlated across countries because both are driven by GDP; the partial correlation controlling for GDP can become negative, capturing the genuine health cost of pollution. In medicine, two biomarkers may correlate simply because both increase with age; partialling out age reveals whether they have a direct biological link.",{"type":42,"tag":51,"props":77,"children":78},{},[79,81,86,88,94,96,101,103,108],{"type":48,"value":80},"Technically, partial correlation is computed from the ",{"type":42,"tag":57,"props":82,"children":83},{},[84],{"type":48,"value":85},"precision matrix",{"type":48,"value":87}," (inverse of the correlation matrix): the partial correlation between X and Y controlling for all other variables is −precision",{"type":42,"tag":89,"props":90,"children":91},"span",{},[92],{"type":48,"value":93},"X,Y",{"type":48,"value":95}," / √(precision",{"type":42,"tag":89,"props":97,"children":98},{},[99],{"type":48,"value":100},"X,X",{"type":48,"value":102}," × precision",{"type":42,"tag":89,"props":104,"children":105},{},[106],{"type":48,"value":107},"Y,Y",{"type":48,"value":109},"). Equivalently, it equals the correlation between the residuals from regressing X on all other variables and the residuals from regressing Y on all other variables. The result is a number between −1 and +1, interpreted like a standard correlation — but now it represents only the direct relationship, not the total association.",{"type":42,"tag":43,"props":111,"children":113},{"id":112},"how-it-works",[114],{"type":48,"value":115},"How It Works",{"type":42,"tag":117,"props":118,"children":119},"ol",{},[120,131,147],{"type":42,"tag":121,"props":122,"children":123},"li",{},[124,129],{"type":42,"tag":57,"props":125,"children":126},{},[127],{"type":48,"value":128},"Upload your data",{"type":48,"value":130}," — provide a CSV or Excel file with multiple numeric columns. One row per observation. The more control variables you include, the more confounding is removed.",{"type":42,"tag":121,"props":132,"children":133},{},[134,139,141],{"type":42,"tag":57,"props":135,"children":136},{},[137],{"type":48,"value":138},"Describe the analysis",{"type":48,"value":140}," — e.g. ",{"type":42,"tag":142,"props":143,"children":144},"em",{},[145],{"type":48,"value":146},"\"partial correlation between CO₂ and life expectancy, controlling for GDP and education; compare with raw Pearson\"",{"type":42,"tag":121,"props":148,"children":149},{},[150,155,157,164,166,172,174,180],{"type":42,"tag":57,"props":151,"children":152},{},[153],{"type":48,"value":154},"Get full results",{"type":48,"value":156}," — the AI writes Python code using ",{"type":42,"tag":158,"props":159,"children":161},"a",{"href":160},"https://pandas.pydata.org/",[162],{"type":48,"value":163},"pandas",{"type":48,"value":165}," and ",{"type":42,"tag":158,"props":167,"children":169},{"href":168},"https://numpy.org/",[170],{"type":48,"value":171},"numpy",{"type":48,"value":173}," to invert the correlation matrix, compute partial correlations, and ",{"type":42,"tag":158,"props":175,"children":177},{"href":176},"https://plotly.com/python/",[178],{"type":48,"value":179},"Plotly",{"type":48,"value":181}," to render side-by-side comparison heatmaps",{"type":42,"tag":43,"props":183,"children":185},{"id":184},"interpreting-the-results",[186],{"type":48,"value":187},"Interpreting the Results",{"type":42,"tag":189,"props":190,"children":191},"table",{},[192,211],{"type":42,"tag":193,"props":194,"children":195},"thead",{},[196],{"type":42,"tag":197,"props":198,"children":199},"tr",{},[200,206],{"type":42,"tag":201,"props":202,"children":203},"th",{},[204],{"type":48,"value":205},"Output",{"type":42,"tag":201,"props":207,"children":208},{},[209],{"type":48,"value":210},"What it means",{"type":42,"tag":212,"props":213,"children":214},"tbody",{},[215,234,250,266,282],{"type":42,"tag":197,"props":216,"children":217},{},[218,229],{"type":42,"tag":219,"props":220,"children":221},"td",{},[222,227],{"type":42,"tag":57,"props":223,"children":224},{},[225],{"type":48,"value":226},"Partial r near 0",{"type":48,"value":228}," (was large in Pearson)",{"type":42,"tag":219,"props":230,"children":231},{},[232],{"type":48,"value":233},"The original correlation was spurious — driven by confounders",{"type":42,"tag":197,"props":235,"children":236},{},[237,245],{"type":42,"tag":219,"props":238,"children":239},{},[240],{"type":42,"tag":57,"props":241,"children":242},{},[243],{"type":48,"value":244},"Partial r stays large",{"type":42,"tag":219,"props":246,"children":247},{},[248],{"type":48,"value":249},"The relationship is direct — not explained by the control variables",{"type":42,"tag":197,"props":251,"children":252},{},[253,261],{"type":42,"tag":219,"props":254,"children":255},{},[256],{"type":42,"tag":57,"props":257,"children":258},{},[259],{"type":48,"value":260},"Partial r flips sign",{"type":42,"tag":219,"props":262,"children":263},{},[264],{"type":48,"value":265},"Confounders were masking or reversing the true direction of the relationship",{"type":42,"tag":197,"props":267,"children":268},{},[269,277],{"type":42,"tag":219,"props":270,"children":271},{},[272],{"type":42,"tag":57,"props":273,"children":274},{},[275],{"type":48,"value":276},"Partial r larger than Pearson",{"type":42,"tag":219,"props":278,"children":279},{},[280],{"type":48,"value":281},"Control variables were suppressing the true relationship (suppressor effect)",{"type":42,"tag":197,"props":283,"children":284},{},[285,293],{"type":42,"tag":219,"props":286,"children":287},{},[288],{"type":42,"tag":57,"props":289,"children":290},{},[291],{"type":48,"value":292},"Pearson vs Partial comparison",{"type":42,"tag":219,"props":294,"children":295},{},[296],{"type":48,"value":297},"Cells that change most between the two matrices are where confounding is strongest",{"type":42,"tag":43,"props":299,"children":301},{"id":300},"example-prompts",[302],{"type":48,"value":303},"Example Prompts",{"type":42,"tag":189,"props":305,"children":306},{},[307,323],{"type":42,"tag":193,"props":308,"children":309},{},[310],{"type":42,"tag":197,"props":311,"children":312},{},[313,318],{"type":42,"tag":201,"props":314,"children":315},{},[316],{"type":48,"value":317},"Scenario",{"type":42,"tag":201,"props":319,"children":320},{},[321],{"type":48,"value":322},"What to type",{"type":42,"tag":212,"props":324,"children":325},{},[326,344,361,378,395],{"type":42,"tag":197,"props":327,"children":328},{},[329,334],{"type":42,"tag":219,"props":330,"children":331},{},[332],{"type":48,"value":333},"Remove GDP confounder",{"type":42,"tag":219,"props":335,"children":336},{},[337],{"type":42,"tag":338,"props":339,"children":341},"code",{"className":340},[],[342],{"type":48,"value":343},"partial correlations between health indicators controlling for log GDP per capita",{"type":42,"tag":197,"props":345,"children":346},{},[347,352],{"type":42,"tag":219,"props":348,"children":349},{},[350],{"type":48,"value":351},"Specific pair",{"type":42,"tag":219,"props":353,"children":354},{},[355],{"type":42,"tag":338,"props":356,"children":358},{"className":357},[],[359],{"type":48,"value":360},"partial correlation between CO2 and life expectancy controlling for GDP, education, and urbanization",{"type":42,"tag":197,"props":362,"children":363},{},[364,369],{"type":42,"tag":219,"props":365,"children":366},{},[367],{"type":48,"value":368},"Full matrix",{"type":42,"tag":219,"props":370,"children":371},{},[372],{"type":42,"tag":338,"props":373,"children":375},{"className":374},[],[376],{"type":48,"value":377},"partial correlation matrix of all numeric columns, compare side by side with Pearson",{"type":42,"tag":197,"props":379,"children":380},{},[381,386],{"type":42,"tag":219,"props":382,"children":383},{},[384],{"type":48,"value":385},"Medical",{"type":42,"tag":219,"props":387,"children":388},{},[389],{"type":42,"tag":338,"props":390,"children":392},{"className":391},[],[393],{"type":48,"value":394},"partial correlations between biomarkers controlling for age and sex; which remain significant?",{"type":42,"tag":197,"props":396,"children":397},{},[398,403],{"type":42,"tag":219,"props":399,"children":400},{},[401],{"type":48,"value":402},"Finance",{"type":42,"tag":219,"props":404,"children":405},{},[406],{"type":42,"tag":338,"props":407,"children":409},{"className":408},[],[410],{"type":48,"value":411},"partial correlations between asset returns controlling for market return (beta-adjusted)",{"type":42,"tag":43,"props":413,"children":415},{"id":414},"assumptions-to-check",[416],{"type":48,"value":417},"Assumptions to Check",{"type":42,"tag":419,"props":420,"children":421},"ul",{},[422,432,442,452,462],{"type":42,"tag":121,"props":423,"children":424},{},[425,430],{"type":42,"tag":57,"props":426,"children":427},{},[428],{"type":48,"value":429},"Multivariate normality",{"type":48,"value":431}," — partial correlation via the precision matrix assumes the joint distribution is approximately multivariate normal; robust to mild violations with n > 50",{"type":42,"tag":121,"props":433,"children":434},{},[435,440],{"type":42,"tag":57,"props":436,"children":437},{},[438],{"type":48,"value":439},"No perfect multicollinearity",{"type":48,"value":441}," — the correlation matrix must be invertible; if two variables are perfectly correlated (r = 1.0), the precision matrix cannot be computed",{"type":42,"tag":121,"props":443,"children":444},{},[445,450],{"type":42,"tag":57,"props":446,"children":447},{},[448],{"type":48,"value":449},"Sufficient sample size",{"type":48,"value":451}," — reliable partial correlations require at least 20–30 observations per variable; with many control variables and small n, estimates become unstable",{"type":42,"tag":121,"props":453,"children":454},{},[455,460],{"type":42,"tag":57,"props":456,"children":457},{},[458],{"type":48,"value":459},"Linear relationships",{"type":48,"value":461}," — partial correlation captures only linear confounding; non-linear confounders require more complex methods",{"type":42,"tag":121,"props":463,"children":464},{},[465,470],{"type":42,"tag":57,"props":466,"children":467},{},[468],{"type":48,"value":469},"Correct control set",{"type":48,"value":471}," — you can only control for variables you include; unmeasured confounders still bias the partial correlations",{"type":42,"tag":43,"props":473,"children":475},{"id":474},"related-tools",[476],{"type":48,"value":477},"Related Tools",{"type":42,"tag":51,"props":479,"children":480},{},[481,483,489,491,497,499,505],{"type":48,"value":482},"Use the ",{"type":42,"tag":158,"props":484,"children":486},{"href":485},"/tools/correlation-matrix",[487],{"type":48,"value":488},"Correlation Matrix Calculator",{"type":48,"value":490}," for standard Pearson or Spearman pairwise correlations without controlling for other variables — the starting point before deciding whether partial correlations are needed. Use the ",{"type":42,"tag":158,"props":492,"children":494},{"href":493},"/tools/multiple-regression",[495],{"type":48,"value":496},"Multiple Regression tool",{"type":48,"value":498}," for a full regression model that simultaneously controls for multiple predictors and gives coefficient estimates, standard errors, and p-values. Use the ",{"type":42,"tag":158,"props":500,"children":502},{"href":501},"/tools/pca",[503],{"type":48,"value":504},"PCA tool",{"type":48,"value":506}," to understand the shared variance structure before deciding which variables to use as controls.",{"type":42,"tag":43,"props":508,"children":510},{"id":509},"frequently-asked-questions",[511],{"type":48,"value":512},"Frequently Asked Questions",{"type":42,"tag":51,"props":514,"children":515},{},[516,521,523,528],{"type":42,"tag":57,"props":517,"children":518},{},[519],{"type":48,"value":520},"When should I use partial correlation instead of standard correlation?",{"type":48,"value":522},"\nUse partial correlation whenever you suspect a ",{"type":42,"tag":57,"props":524,"children":525},{},[526],{"type":48,"value":527},"confounding variable",{"type":48,"value":529}," is driving the relationship you're studying. If GDP explains why CO₂ and life expectancy are correlated, partial correlation controlling for GDP reveals the direct link (if any). Common confounders to control for: age, sex, income level, geography, or time trends. If you're unsure, compare the Pearson and partial matrices — large differences indicate confounding is present.",{"type":42,"tag":51,"props":531,"children":532},{},[533,538,540,545,547,552],{"type":42,"tag":57,"props":534,"children":535},{},[536],{"type":48,"value":537},"What's the difference between partial correlation and multiple regression?",{"type":48,"value":539},"\nBoth control for confounders, but they answer different questions. ",{"type":42,"tag":57,"props":541,"children":542},{},[543],{"type":48,"value":544},"Multiple regression",{"type":48,"value":546}," gives a coefficient for each predictor — \"holding other variables constant, how much does Y change per unit increase in X?\" ",{"type":42,"tag":57,"props":548,"children":549},{},[550],{"type":48,"value":551},"Partial correlation",{"type":48,"value":553}," gives a standardized correlation between the residuals — \"what fraction of the remaining variance in Y is linearly related to X, after removing all shared variance with other variables?\" Partial correlations are symmetric (partial r of X|Y = partial r of Y|X), while regression slopes are not.",{"type":42,"tag":51,"props":555,"children":556},{},[557,562,564,569,571,576,578,583],{"type":42,"tag":57,"props":558,"children":559},{},[560],{"type":48,"value":561},"Can I compute partial correlations for a specific pair while only controlling for select variables?",{"type":48,"value":563},"\nYes — ask for ",{"type":42,"tag":142,"props":565,"children":566},{},[567],{"type":48,"value":568},"\"partial correlation between X and Y controlling only for Z\"",{"type":48,"value":570}," rather than all variables. This is called a ",{"type":42,"tag":57,"props":572,"children":573},{},[574],{"type":48,"value":575},"first-order partial correlation",{"type":48,"value":577}," (controlling for one variable) or ",{"type":42,"tag":57,"props":579,"children":580},{},[581],{"type":48,"value":582},"k-th order partial correlation",{"type":48,"value":584}," (controlling for k variables). The full precision matrix method controls for everything simultaneously.",{"type":42,"tag":51,"props":586,"children":587},{},[588,593,595,600],{"type":42,"tag":57,"props":589,"children":590},{},[591],{"type":48,"value":592},"My partial correlations are much larger than my Pearson correlations — what does that mean?",{"type":48,"value":594},"\nThis is a ",{"type":42,"tag":57,"props":596,"children":597},{},[598],{"type":48,"value":599},"suppressor effect",{"type":48,"value":601},": one of the control variables was actively hiding a relationship that exists in the data. For example, if exercise and longevity are correlated but so are exercise and injury risk, controlling for injury risk might reveal a stronger direct longevity benefit from exercise. Suppressors are less common than confounders but provide important insight when they appear.",{"type":42,"tag":51,"props":603,"children":604},{},[605,610,612,617],{"type":42,"tag":57,"props":606,"children":607},{},[608],{"type":48,"value":609},"How do I compute p-values for partial correlations?",{"type":48,"value":611},"\nThe partial correlation coefficient follows a t-distribution with n − k − 2 degrees of freedom, where k is the number of control variables. Ask the AI to ",{"type":42,"tag":142,"props":613,"children":614},{},[615],{"type":48,"value":616},"\"add p-values and significance stars to the partial correlation matrix\"",{"type":48,"value":618}," — it will compute the t-statistic for each partial correlation and report significance at the 0.05, 0.01, and 0.001 levels.",{"title":7,"searchDepth":620,"depth":620,"links":621},2,[622,623,624,625,626,627,628],{"id":45,"depth":620,"text":49},{"id":112,"depth":620,"text":115},{"id":184,"depth":620,"text":187},{"id":300,"depth":620,"text":303},{"id":414,"depth":620,"text":417},{"id":474,"depth":620,"text":477},{"id":509,"depth":620,"text":512},"markdown","content:tools:033.partial-correlation.md","content","tools/033.partial-correlation.md","tools/033.partial-correlation","md",{"loc":4},1775502468196]