Kovarianz Rechner
Online Berechnung der bivariaten Kovarianz
Geben Sie Ihre beiden Variablen in die Textfelder ein und klicken Sie auf Berechnen. Die Kovarianz misst die gemeinsame Variation zweier Variablen und zeigt, ob sie gleichgerichtet oder gegenläufig variieren.
💡 Kovarianz Definition
\(\text{Cov}(X,Y) = \frac{1}{n-1}\sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y})\) | Gemeinsame Variation zweier Variablen
Kovarianz und bivariate Analyse verstehen
Die Kovarianz ist ein fundamentales Maß der bivariaten Statistik, das die gemeinsame Variation zweier Zufallsvariablen quantifiziert. Sie gibt an, ob und wie stark zwei Variablen linear zusammenhängen. Positive Kovarianz zeigt, dass beide Variablen tendenziell in die gleiche Richtung abweichen, während negative Kovarianz einen gegenläufigen Zusammenhang anzeigt. Die Kovarianz ist die Grundlage für den Korrelationskoeffizienten und die lineare Regression.
📊 Grunddefinition
Gemeinsame Variation:
📈 Interpretation
- • Cov > 0: Positive Beziehung
- • Cov < 0: Negative Beziehung
- • Cov = 0: Keine lineare Beziehung
- • Einheit: x-Einheit × y-Einheit
🎯 Anwendungen
- • Korrelationsanalyse
- • Lineare Regression
- • Portfoliotheorie
- • Multivariate Statistik
⚙️ Eigenschaften
- • Bilinear: Cov(aX, bY) = abCov(X,Y)
- • Symmetrisch: Cov(X,Y) = Cov(Y,X)
- • Additiv in beiden Argumenten
- • Grundlage für Korrelation
Mathematische Grundlagen
📊 Formale Definition der Kovarianz
Für zwei Zufallsvariablen X und Y:
\[\text{Populations-Kovarianz: } \sigma_{XY} = E[(X - \mu_X)(Y - \mu_Y)]\] \[\text{Stichproben-Kovarianz: } s_{XY} = \frac{1}{n-1}\sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y})\] \[\text{Biased Estimator: } \hat{\sigma}_{XY} = \frac{1}{n}\sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y})\] \[\text{Verhältnis zur Korrelation: } \rho_{XY} = \frac{\text{Cov}(X,Y)}{\sigma_X \sigma_Y}\]
🔄 Kovarianz-Matrix und multivariate Erweiterung
Kovarianz in höheren Dimensionen:
\[\text{Kovarianz-Matrix: } \Sigma = \begin{pmatrix} \sigma_1^2 & \sigma_{12} & \cdots \\ \sigma_{21} & \sigma_2^2 & \cdots \\ \vdots & \vdots & \ddots \end{pmatrix}\] \[\text{Stichproben-Kovarianz-Matrix: } S = \frac{1}{n-1}(X - \bar{X})^T(X - \bar{X})\] \[\text{Eigenschaften: Symmetrisch, positiv semidefinit}\] \[\text{Determinante: } |\Sigma| = \text{generalisierte Varianz}\] \[\text{Spur: } \text{tr}(\Sigma) = \sum_{i=1}^p \sigma_i^2\]
📊 Algebraische Eigenschaften
Wichtige Rechenregeln für Kovarianzen:
\[\text{Bilinearität: } \text{Cov}(aX + bY, Z) = a\text{Cov}(X,Z) + b\text{Cov}(Y,Z)\] \[\text{Varianz-Zerlegung: } \text{Var}(X + Y) = \text{Var}(X) + \text{Var}(Y) + 2\text{Cov}(X,Y)\] \[\text{Cauchy-Schwarz: } |\text{Cov}(X,Y)|^2 \leq \text{Var}(X)\text{Var}(Y)\] \[\text{Unabhängigkeit: } X \perp Y \Rightarrow \text{Cov}(X,Y) = 0\] \[\text{Aber: } \text{Cov}(X,Y) = 0 \not\Rightarrow X \perp Y\]
Praktische Berechnungsbeispiele
📝 Beispiel 1: Grundberechnung
Aufgabe: Berechne Kovarianz für X = (2, 4, 6, 8) und Y = (1, 3, 7, 11)
Methode: Schritt-für-Schritt-Berechnung
Berechnung:
\[\text{Schritt 1: Mittelwerte berechnen}\] \[\bar{x} = \frac{2+4+6+8}{4} = 5, \quad \bar{y} = \frac{1+3+7+11}{4} = 5.5\] \[\text{Schritt 2: Abweichungsprodukte}\] \[(2-5)(1-5.5) = (-3)(-4.5) = 13.5\] \[(4-5)(3-5.5) = (-1)(-2.5) = 2.5\] \[(6-5)(7-5.5) = (1)(1.5) = 1.5\] \[(8-5)(11-5.5) = (3)(5.5) = 16.5\] \[\text{Schritt 3: Kovarianz}\] \[\text{Cov}(X,Y) = \frac{13.5+2.5+1.5+16.5}{4-1} = \frac{34}{3} = 11.33\]
Interpretation: Positive Kovarianz zeigt gleichgerichtete Variation
📝 Beispiel 2: Korrelationsberechnung
Aufgabe: Berechne Korrelationskoeffizient aus Kovarianz
Daten: Cov(X,Y) = 11.33 aus Beispiel 1
Analyse:
\[\text{Standardabweichungen berechnen:}\] \[s_X = \sqrt{\frac{(2-5)^2+(4-5)^2+(6-5)^2+(8-5)^2}{3}} = \sqrt{\frac{20}{3}} = 2.58\] \[s_Y = \sqrt{\frac{(1-5.5)^2+...+(11-5.5)^2}{3}} = \sqrt{\frac{50.75}{3}} = 4.11\] \[\text{Korrelationskoeffizient:}\] \[r = \frac{\text{Cov}(X,Y)}{s_X \cdot s_Y} = \frac{11.33}{2.58 \times 4.11} = \frac{11.33}{10.60} = 0.969\]
Fazit: Sehr starke positive Korrelation (r ≈ 0.97)
📝 Beispiel 3: Portfoliotheorie-Anwendung
Aufgabe: Berechne Portfoliorisiko mit Kovarianz
Szenario: Zwei Aktien mit Gewichten w₁ = 0.6, w₂ = 0.4
Analyse:
\[\text{Gegeben: } \sigma_1^2 = 0.04, \sigma_2^2 = 0.09, \sigma_{12} = 0.03\] \[\text{Portfolio-Varianz:}\] \[\sigma_p^2 = w_1^2\sigma_1^2 + w_2^2\sigma_2^2 + 2w_1w_2\sigma_{12}\] \[= (0.6)^2(0.04) + (0.4)^2(0.09) + 2(0.6)(0.4)(0.03)\] \[= 0.0144 + 0.0144 + 0.0144 = 0.0432\] \[\text{Portfolio-Standardabweichung: } \sigma_p = \sqrt{0.0432} = 0.208 = 20.8\%\]
Interpretation: Positive Kovarianz erhöht das Portfoliorisiko
Anwendungen in verschiedenen Bereichen
📈 Finanz- & Investmentanalyse
- • Portfoliooptimierung
- • Risikomanagement
- • Asset-Korrelationen
- • Hedging-Strategien
📊 Data Science & ML
- • Feature-Selektion
- • Dimensionsreduktion
- • Hauptkomponentenanalyse
- • Multikollinearität
🔬 Naturwissenschaften
- • Experimentelle Zusammenhänge
- • Messfehlerkontrolle
- • Zeitreihenanalyse
- • Genetische Korrelationen
🎓 Sozialwissenschaften
- • Umfrageanalysen
- • Verhaltensforschung
- • Bildungsstatistik
- • Demografische Studien
Erweiterte Konzepte
📊 Robuste Kovarianz-Schätzer
Alternative Schätzmethoden bei Ausreißern:
\[\text{Spearman-Kovarianz: Basiert auf Rängen statt Werten}\] \[\text{Kendall's τ: } \tau = \frac{n_c - n_d}{\binom{n}{2}}\] \[\text{Winsorized Covariance: Ersetze Extremwerte}\] \[\text{Trimmed Covariance: Entferne α% der Extremwerte}\] \[\text{M-Estimatoren: Robuste Maximum-Likelihood-Ansätze}\]
🎯 Conditional Covariance
Bedingte Kovarianz und partielle Korrelation:
\[\text{Bedingte Kovarianz: } \text{Cov}(X,Y|Z) = E[(X-E[X|Z])(Y-E[Y|Z])|Z]\] \[\text{Partielle Korrelation: } \rho_{XY|Z} = \frac{\rho_{XY} - \rho_{XZ}\rho_{YZ}}{\sqrt{(1-\rho_{XZ}^2)(1-\rho_{YZ}^2)}}\] \[\text{Semipartielle Korrelation: Kontrolle nur einer Variable}\] \[\text{Multiple Korrelation: } R_{Y|X_1,...,X_k}^2\]
📈 Zeitreihen-Kovarianz
Autokovarianz und Kreuzkovarianz bei zeitabhängigen Daten:
\[\text{Autokovarianz: } \gamma_X(h) = \text{Cov}(X_t, X_{t+h})\] \[\text{Kreuzkovarianz: } \gamma_{XY}(h) = \text{Cov}(X_t, Y_{t+h})\] \[\text{Autokorrelation: } \rho_X(h) = \frac{\gamma_X(h)}{\gamma_X(0)}\] \[\text{Kreuzkorrelation: } \rho_{XY}(h) = \frac{\gamma_{XY}(h)}{\sqrt{\gamma_X(0)\gamma_Y(0)}}\]
Computational Aspects
💻 Algorithmen und Implementierung
Effiziente Berechnung der Kovarianz:
Python (NumPy):
import numpy as np
# Kovarianz-Matrix berechnen:
cov_matrix = np.cov(X, Y, ddof=1)
# Einzelne Kovarianz:
covariance = cov_matrix[0, 1]
# Korrelationsmatrix:
corr_matrix = np.corrcoef(X, Y)
# Pandas DataFrame:
df.cov() # Kovarianz-Matrix
df.corr() # Korrelationsmatrix
R:
# Kovarianz berechnen
cov(x, y)
# Kovarianz-Matrix
cov(data_matrix)
# Korrelation
cor(x, y)
# Robuste Kovarianz
library(robustbase)
covMcd(data_matrix)
💡 Praktische Tipps
Hinweise für die korrekte Anwendung:
\[\text{1. Kovarianz-Einheiten beachten (nicht standardisiert)}\] \[\text{2. Korrelation für Stärke des Zusammenhangs nutzen}\] \[\text{3. Bei Ausreißern: robuste Alternativen verwenden}\] \[\text{4. Lineare Beziehung: Kovarianz = 0 ≠ Unabhängigkeit}\] \[\text{5. Multivariate Normalverteilung für Inferenz assumieren}\]
💡 Vorteile der Kovarianz:
- Fundamentalität: Grundlage für Korrelation und Regression
- Additivität: Ermöglicht Varianz-Zerlegung in Summen
- Matrix-Form: Multivariate Erweiterung natürlich möglich
- Portfolio-Theorie: Direkte Anwendung in Risikomodellen
📊 Wann Kovarianz verwenden:
- Bivariate Analyse: Zusammenhang zwischen zwei quantitativen Variablen
- Regression: Berechnung von Regressionskoeffizienten
- Portfolio-Optimierung: Risiko-Diversifikation berechnen
- Multivariate Statistik: PCA, Faktoranalyse, MANOVA
Arithmetisches-Mittel, DurchschnittStreuungsmaße
Geometrisches Mittel
Harmonisches Mittel
Kontraharmonisches Mittel
Log-Geometrisches Mittel
Median
Modus
Minimum und Maximum
Perzentile
Oberes Quartil
Unteres Quartil
Quantile
KurtosisKorrelation & Zusammenhang
Skewness (Statistische Schiefe)
Standardabweichung
Gepoolte Standardabweichungl
Varianz
Gepoolte Varianz
Spannweite
Interquartilsabstand (IQR)
KovarianzVerteilungsfunktionen
Korrelationskoeffizient (Pearson, Spearman)
Rangkorrelation
Empirische inverse Verteilungsfunktion CDFTest & Schätzungen
Empirische Verteilungsfunktion CDF
Five-Number Summary
T-Test (einfach)Spezielle Verteilungen:
Chi-Quadrat-Test
Wilcoxon-Test
NormalverteilungRisiko & Wahrscheinlichkeit
Binomialverteilung
Poisson-Verteilung
Exponentialverteilung
Geburtstagsparadoxon
Satz von Bayes