Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scale back linear regression coefficients in R from scaled and centered data

I'm fitting a linear model using OLS and have scaled my regressors with the function scale in R because of the different units of measure between variables. Then, I fit the model using the lm command and get the coefficients of the fitted model. As far as I know the coefficients of the fitted model are not in the same units of the original regressors variables and therefore must be scaled back before they can be interpreted. I have been searching for a direct way to do it by couldn't find anything. Does anyone know how to do that?

Please have a look to the code, could you please help me implementing what you proposed?

library(zoo)
filename="DataReg4.csv"
filepath=paste("C:/Reg/",filename, sep="")
separator=";"
readfile=read.zoo(filepath, sep=separator, header=T, format = "%m/%d/%Y", dec=".")
readfile=as.data.frame(readfile)
str(readfile)
DF=readfile
DF=as.data.frame(scale(DF)) 
fm=lm(USD_EUR~diff_int+GDP_US+Net.exports.Eur,data=DF)
summary(fm)
plot(fm)

I'm sorry this is the data.

http://www.mediafire.com/?hmcp7urt0ag8187

like image 507
nopeva Avatar asked Dec 05 '22 12:12

nopeva


2 Answers

If you used the scale function with default arguments then your regressors will be centered (subtracting their mean) and divided by their standard deviations. You can interpret the coefficients without transforming them back to the original units:

Holding everything else constant, on average, a one standard deviation change in one of the regressors is associated with a change in the dependent variable corresponding to the coefficient of that regressor.

If you have included an intercept term in your model keep in mind that the interpretation of the intercept will change. The estimated intercept now represents the average level of the dependent variable when all of the regressors are at their average levels. This is a result of subtracting the mean from each variable.

To interpret the coefficients in non-standard deviation terms, just calculate the standard deviation of each regressor and multiple that by the coefficient.

like image 181
Dan Gerlanc Avatar answered Jan 20 '23 12:01

Dan Gerlanc


To de-scale or back-transform regression coefficients from a regression done with scaled predictor variable(s) and non-scaled response variable the intercept and slope should be calculated as:

A = As - Bs*Xmean/sdx
B = Bs/sdx

thus the regression is,

Y = As - Bs*Xmean/sdx + Bs/sdx * X

where

As = intercept from the scaled regression
Bs = slope from the scaled regression
Xmean = the mean of the scaled predictor variable
sdx = the standard deviation of the predictor variable

This can be adjusted if Y was also scaled but it appears you decided not to do that ultimately with your dataset.

like image 25
DirtStats Avatar answered Jan 20 '23 12:01

DirtStats