Skip to main content
deleted 34 characters in body
Source Link
caracal
  • 12.1k
  • 57
  • 68

$R^2$ is the squared correlation of the OLS prediction $\hat{Y}$ and the DV $Y$. In a multiple regression with three predictors $X_{1}, X_{2}, X_{3}$:

# generate some data
> N  <- 100
> X1 <- rnorm(N, 175, 7)                                 # predictor 1
> X2 <- rnorm(N,  30, 8)                                 # predictor 2
> X3 <- abs(rnorm(N, 60, 30))                            # predictor 3
> Y  <- 0.5*X1 - 0.3*X2 - 0.4*X3 + 10 + rnorm(N, 0, 10)  # DV
> fitX123 <- lm(Y ~ X1 + X2 + X3)  # regression
> summary(fitX123)$r.squared       # R^2
[1] 0.6361916

> Yhat <- fitted(fitX123)          # OLS prediction Yhat
> cor(Yhat, Y)^2
[1] 0.6361916

$R^2$ is also equal to the variance of $\hat{Y}$ divided by the variance of $Y$. In that sense, it is the "variance accounted for by the predictors".

> var(Yhat) / var(Y)
[1] 0.6361916

The squared semi-partial correlation of $Y$ with a predictor $X_{1}$ is equal to the increase in $R^2$ when switching from the regression with all predictors exceptadding $X_{1}$ as a predictor to the full regression with all remaining predictors. This may be taken as the unique contribution of a predictor$X_{1}$ to the proportion of variance explained by all predictors. Here, the semi-partial correlation is the correlation of $Y$ with the residuals from regression where $X_{1}$ is the predicted variable and $X_{2}$ and $X_{3}$ are the predictors.

# residuals from regression with DV X1 and predictors X2, X3
> X1.X23 <- residuals(lm(X1 ~ X2 + X3))
> (spcorYX1.X23 <- cor(Y, X1.X23))   # semi-partial correlation of Y with X1
[1] 0.3172553

> spcorYX1.X23^2                     # squared semi-partial correlation
[1] 0.1006509

> fitX23 <- lm(Y ~ X2 + X3)          # regression with DV Y and predictors X2, X3

# increase in R^2 when changing to full regression
> summary(fitX123)$r.squared - summary(fitX23)$r.squared
[1] 0.1006509

$R^2$ is the squared correlation of the OLS prediction $\hat{Y}$ and the DV $Y$. In a multiple regression with three predictors $X_{1}, X_{2}, X_{3}$:

# generate some data
> N  <- 100
> X1 <- rnorm(N, 175, 7)                                 # predictor 1
> X2 <- rnorm(N,  30, 8)                                 # predictor 2
> X3 <- abs(rnorm(N, 60, 30))                            # predictor 3
> Y  <- 0.5*X1 - 0.3*X2 - 0.4*X3 + 10 + rnorm(N, 0, 10)  # DV
> fitX123 <- lm(Y ~ X1 + X2 + X3)  # regression
> summary(fitX123)$r.squared       # R^2
[1] 0.6361916

> Yhat <- fitted(fitX123)          # OLS prediction Yhat
> cor(Yhat, Y)^2
[1] 0.6361916

$R^2$ is also equal to the variance of $\hat{Y}$ divided by the variance of $Y$. In that sense, it is the "variance accounted for by the predictors".

> var(Yhat) / var(Y)
[1] 0.6361916

The squared semi-partial correlation of $Y$ with a predictor $X_{1}$ is equal to the increase in $R^2$ when switching from the regression with all predictors except $X_{1}$ to the full regression with all predictors. This may be taken as the unique contribution of a predictor to the proportion of variance explained by all predictors. Here, the semi-partial correlation is the correlation of $Y$ with the residuals from regression where $X_{1}$ is the predicted variable and $X_{2}$ and $X_{3}$ are the predictors.

# residuals from regression with DV X1 and predictors X2, X3
> X1.X23 <- residuals(lm(X1 ~ X2 + X3))
> (spcorYX1.X23 <- cor(Y, X1.X23))   # semi-partial correlation of Y with X1
[1] 0.3172553

> spcorYX1.X23^2                     # squared semi-partial correlation
[1] 0.1006509

> fitX23 <- lm(Y ~ X2 + X3)          # regression with DV Y and predictors X2, X3

# increase in R^2 when changing to full regression
> summary(fitX123)$r.squared - summary(fitX23)$r.squared
[1] 0.1006509

$R^2$ is the squared correlation of the OLS prediction $\hat{Y}$ and the DV $Y$. In a multiple regression with three predictors $X_{1}, X_{2}, X_{3}$:

# generate some data
> N  <- 100
> X1 <- rnorm(N, 175, 7)                                 # predictor 1
> X2 <- rnorm(N,  30, 8)                                 # predictor 2
> X3 <- abs(rnorm(N, 60, 30))                            # predictor 3
> Y  <- 0.5*X1 - 0.3*X2 - 0.4*X3 + 10 + rnorm(N, 0, 10)  # DV
> fitX123 <- lm(Y ~ X1 + X2 + X3)  # regression
> summary(fitX123)$r.squared       # R^2
[1] 0.6361916

> Yhat <- fitted(fitX123)          # OLS prediction Yhat
> cor(Yhat, Y)^2
[1] 0.6361916

$R^2$ is also equal to the variance of $\hat{Y}$ divided by the variance of $Y$. In that sense, it is the "variance accounted for by the predictors".

> var(Yhat) / var(Y)
[1] 0.6361916

The squared semi-partial correlation of $Y$ with a predictor $X_{1}$ is equal to the increase in $R^2$ when adding $X_{1}$ as a predictor to the regression with all remaining predictors. This may be taken as the unique contribution of $X_{1}$ to the proportion of variance explained by all predictors. Here, the semi-partial correlation is the correlation of $Y$ with the residuals from regression where $X_{1}$ is the predicted variable and $X_{2}$ and $X_{3}$ are the predictors.

# residuals from regression with DV X1 and predictors X2, X3
> X1.X23 <- residuals(lm(X1 ~ X2 + X3))
> (spcorYX1.X23 <- cor(Y, X1.X23))   # semi-partial correlation of Y with X1
[1] 0.3172553

> spcorYX1.X23^2                     # squared semi-partial correlation
[1] 0.1006509

> fitX23 <- lm(Y ~ X2 + X3)          # regression with DV Y and predictors X2, X3

# increase in R^2 when changing to full regression
> summary(fitX123)$r.squared - summary(fitX23)$r.squared
[1] 0.1006509
added 119 characters in body
Source Link
caracal
  • 12.1k
  • 57
  • 68

$R^2$ is the squared correlation of the OLS prediction $\hat{Y}$ and the DV $Y$. In a multiple regression with three predictors $X_{1}, X_{2}, X_{3}$:

# generate some data
> N  <- 100
> X1 <- rnorm(N, 175, 7)                                 # predictor 1
> X2 <- rnorm(N,  30, 8)                                 # predictor 2
> X3 <- abs(rnorm(N, 60, 30))                            # predictor 3
> Y  <- 0.5*X1 - 0.3*X2 - 0.4*X3 + 10 + rnorm(N, 0, 10)  # DV
> fitX123 <- lm(Y ~ X1 + X2 + X3)  # regression
> summary(fitX123)$r.squared       # R^2
[1] 0.6361916

> Yhat <- fitted(fitX123)          # OLS prediction Yhat
> cor(Yhat, Y)^2
[1] 0.6361916

$R^2$ is also equal to the variance of $\hat{Y}$ divided by the variance of $Y$. In that sense, it is the "variance accounted for by the predictors".

> var(Yhat) / var(Y)
[1] 0.6361916

The squared semi-partial correlation of $Y$ with a predictor $X_{1}$ is equal to the increase in $R^2$ when switching from the regression with all predictors except $X_{1}$ to the full regression with all predictors. This may be taken as the unique contribution of a predictor to the proportion of variance explained by all predictors. Here, the semi-partial correlation is the correlation of $Y$ with the residuals from regression where $X_{1}$ is the predicted variable and $X_{2}$ and $X_{3}$ are the predictors.

# residuals from regression with DV X1 and predictors X2, X3
> X1.X23 <- residuals(lm(X1 ~ X2 + X3))
> (spcorYX1.X23 <- cor(Y, X1.X23))   # semi-partial correlation of Y with X1
[1] 0.3172553

> spcorYX1.X23^2                     # squared semi-partial correlation
[1] 0.1006509

> fitX23 <- lm(Y ~ X2 + X3)          # regression with DV Y and predictors X2, X3

# increase in R^2 when changing to full regression
> summary(fitX123)$r.squared - summary(fitX23)$r.squared
[1] 0.1006509

$R^2$ is the squared correlation of the OLS prediction $\hat{Y}$ and the DV $Y$. In a multiple regression with three predictors $X_{1}, X_{2}, X_{3}$:

# generate some data
> N  <- 100
> X1 <- rnorm(N, 175, 7)                                 # predictor 1
> X2 <- rnorm(N,  30, 8)                                 # predictor 2
> X3 <- abs(rnorm(N, 60, 30))                            # predictor 3
> Y  <- 0.5*X1 - 0.3*X2 - 0.4*X3 + 10 + rnorm(N, 0, 10)  # DV
> fitX123 <- lm(Y ~ X1 + X2 + X3)  # regression
> summary(fitX123)$r.squared       # R^2
[1] 0.6361916

> Yhat <- fitted(fitX123)          # OLS prediction Yhat
> cor(Yhat, Y)^2
[1] 0.6361916

$R^2$ is also equal to the variance of $\hat{Y}$ divided by the variance of $Y$. In that sense, it is the "variance accounted for by the predictors".

> var(Yhat) / var(Y)
[1] 0.6361916

The squared semi-partial correlation of $Y$ with a predictor $X_{1}$ is equal to the increase in $R^2$ when switching from the regression with all predictors except $X_{1}$ to the full regression with all predictors. Here, the semi-partial correlation is the correlation of $Y$ with the residuals from regression where $X_{1}$ is the predicted variable and $X_{2}$ and $X_{3}$ are the predictors.

# residuals from regression with DV X1 and predictors X2, X3
> X1.X23 <- residuals(lm(X1 ~ X2 + X3))
> (spcorYX1.X23 <- cor(Y, X1.X23))   # semi-partial correlation of Y with X1
[1] 0.3172553

> spcorYX1.X23^2                     # squared semi-partial correlation
[1] 0.1006509

> fitX23 <- lm(Y ~ X2 + X3)          # regression with DV Y and predictors X2, X3

# increase in R^2 when changing to full regression
> summary(fitX123)$r.squared - summary(fitX23)$r.squared
[1] 0.1006509

$R^2$ is the squared correlation of the OLS prediction $\hat{Y}$ and the DV $Y$. In a multiple regression with three predictors $X_{1}, X_{2}, X_{3}$:

# generate some data
> N  <- 100
> X1 <- rnorm(N, 175, 7)                                 # predictor 1
> X2 <- rnorm(N,  30, 8)                                 # predictor 2
> X3 <- abs(rnorm(N, 60, 30))                            # predictor 3
> Y  <- 0.5*X1 - 0.3*X2 - 0.4*X3 + 10 + rnorm(N, 0, 10)  # DV
> fitX123 <- lm(Y ~ X1 + X2 + X3)  # regression
> summary(fitX123)$r.squared       # R^2
[1] 0.6361916

> Yhat <- fitted(fitX123)          # OLS prediction Yhat
> cor(Yhat, Y)^2
[1] 0.6361916

$R^2$ is also equal to the variance of $\hat{Y}$ divided by the variance of $Y$. In that sense, it is the "variance accounted for by the predictors".

> var(Yhat) / var(Y)
[1] 0.6361916

The squared semi-partial correlation of $Y$ with a predictor $X_{1}$ is equal to the increase in $R^2$ when switching from the regression with all predictors except $X_{1}$ to the full regression with all predictors. This may be taken as the unique contribution of a predictor to the proportion of variance explained by all predictors. Here, the semi-partial correlation is the correlation of $Y$ with the residuals from regression where $X_{1}$ is the predicted variable and $X_{2}$ and $X_{3}$ are the predictors.

# residuals from regression with DV X1 and predictors X2, X3
> X1.X23 <- residuals(lm(X1 ~ X2 + X3))
> (spcorYX1.X23 <- cor(Y, X1.X23))   # semi-partial correlation of Y with X1
[1] 0.3172553

> spcorYX1.X23^2                     # squared semi-partial correlation
[1] 0.1006509

> fitX23 <- lm(Y ~ X2 + X3)          # regression with DV Y and predictors X2, X3

# increase in R^2 when changing to full regression
> summary(fitX123)$r.squared - summary(fitX23)$r.squared
[1] 0.1006509
Source Link
caracal
  • 12.1k
  • 57
  • 68

$R^2$ is the squared correlation of the OLS prediction $\hat{Y}$ and the DV $Y$. In a multiple regression with three predictors $X_{1}, X_{2}, X_{3}$:

# generate some data
> N  <- 100
> X1 <- rnorm(N, 175, 7)                                 # predictor 1
> X2 <- rnorm(N,  30, 8)                                 # predictor 2
> X3 <- abs(rnorm(N, 60, 30))                            # predictor 3
> Y  <- 0.5*X1 - 0.3*X2 - 0.4*X3 + 10 + rnorm(N, 0, 10)  # DV
> fitX123 <- lm(Y ~ X1 + X2 + X3)  # regression
> summary(fitX123)$r.squared       # R^2
[1] 0.6361916

> Yhat <- fitted(fitX123)          # OLS prediction Yhat
> cor(Yhat, Y)^2
[1] 0.6361916

$R^2$ is also equal to the variance of $\hat{Y}$ divided by the variance of $Y$. In that sense, it is the "variance accounted for by the predictors".

> var(Yhat) / var(Y)
[1] 0.6361916

The squared semi-partial correlation of $Y$ with a predictor $X_{1}$ is equal to the increase in $R^2$ when switching from the regression with all predictors except $X_{1}$ to the full regression with all predictors. Here, the semi-partial correlation is the correlation of $Y$ with the residuals from regression where $X_{1}$ is the predicted variable and $X_{2}$ and $X_{3}$ are the predictors.

# residuals from regression with DV X1 and predictors X2, X3
> X1.X23 <- residuals(lm(X1 ~ X2 + X3))
> (spcorYX1.X23 <- cor(Y, X1.X23))   # semi-partial correlation of Y with X1
[1] 0.3172553

> spcorYX1.X23^2                     # squared semi-partial correlation
[1] 0.1006509

> fitX23 <- lm(Y ~ X2 + X3)          # regression with DV Y and predictors X2, X3

# increase in R^2 when changing to full regression
> summary(fitX123)$r.squared - summary(fitX23)$r.squared
[1] 0.1006509