Solved – Does lm() use partial correlation – R Squared Change

linear modellmmultiple regressionrregression

I come from an SPSS background and am attempting to move to R for it's superior flexibility and data manipulation abilities. I have some concerns however as to whether the lm() is really using partial correlations.

I'm basically trying to run a linear regression, using something similar to the "enter" setting in SPSS, which essentially builds the model one variable at a time, reporting the change in $R^2$ with each additional variable. This allows you to determine how much predictive power each variable adds to the model.

When I run the same analysis in R however, I don't get any information on the $R^2$ contributed by individual variables, and I'm not even sure that it's using partial corrrelations to calculate the p-values it's reporting!

My code follows:

summary(m1 <- lm(totalprop ~ cos(Angle) + Alignment + colour + 
  Angle*Alignment, dataset))

My questions:

  1. Does R use partial correlations to determine reported p-values from lm()?
  2. How can I make R report change in $R^2$ with each additional variable.
  3. How can I make R act like SPSS in calulating the model piece by piece? Is this possible without running multiple iterations of the lm() function? If not, how does one control for the effects of covariates in R?

Best Answer

Another function that you might find useful is lm.sumSquares in the lmSupport package. Basically, if you have the following model:

mod1 <- lm(dv ~ iv1 + iv2 + iv3, data = d)

Executing the following will give you the delta R squared (the semipartial correlation squared) and PRE (the partial correlation squared) for iv1, iv2, and iv3:

lm.sumSquares(mod1)

lmSupport also contains the function lm.deltaR2 that allows you to compare custom models against each other to obtain the change in R squared and the F-statistic associated with the R squared change. So, going back to the above example, if you also had this second model:

mod2 <- lm(dv ~ iv1 + iv2 + iv3 + iv4 + iv5, data = d)

Then you could do the following to obtain the R squared change for adding iv4 and iv5 and the accompanying F statistic and p-value:

lm.deltaR2(mod1, mod2)

Hope that helps!

Related Question