Skip to content
Prev 77046 / 398502 Next

Backtransforming regression coefficient for scaled covariate

RE: [R] Backtransforming regression coefficient for scaled covariateYep it
is the the same.
Scaling  does both dividing and centering (this is the reason intercept
changes) and scaling is not with sd but with sum of squares divided by n-1;
so, it is not s.d. because average is not substracted
But the appropriate parameters are returned by scale()in form of attributes
(quite awful to extract)

x=1:100
a=rnorm(100)*200+x+.5*x^2+100
lm1=lm(formula= a ~ x + I(x^2))
Coefficients:
(Intercept)            x       I(x^2)
     96.463       -1.062        0.528

 lm2=lm(formula= a ~ scale(x,center=F) + scale(I(x^2),center=F) )
lm2$coeff
              (Intercept)      scale(x, center = F) scale(I(x^2), center =
F)
                 96.46283                 -62.07923
2403.00364

 lm2$coeff[2]/attributes(scale(x,center=F))$"scaled:scale"
scale(x, center = F)
           -1.061893

 lm2$coeff[3]/attributes(scale(x^2,center=F))$"scaled:scale"
scale(I(x^2), center = F)
                0.5280315

If you use the default center=T, then you also have to consider the means of
x and x^2 which are involved in the intercept.
I find this scale() a bit complicated. I never used it and perhaps I've read
the doc too fast

Regards
Andres

--
Andres Legarra Albizu
NEIKER
Apdo. 46
Vitoria-Gasteiz 01080 Spain
--

----- Original Message ----- 
From: Gorjanc Gregor
To: Andr??s Legarra ; r-help at stat.math.ethz.ch
Sent: Monday, September 12, 2005 10:12 AM
Subject: RE: [R] Backtransforming regression coefficient for scaled
covariate


Andres, this seems not to be the case. Look bellow
the coefficients. They are not the same as in unscaled
regression.
R> (lm1 <- lm(y ~ x + I(x^2)))
Call:
lm(formula = y ~ x + I(x^2))
Coefficients:
(Intercept)            x       I(x^2)
    4.62069      1.78811     -0.00751
R> ## Fit regression with transformed i.e. standardized covariate
R> (lm2 <- lm(y ~ scale(x) + I(scale(x)^2)))
Call:
lm(formula = y ~ scale(x) + I(scale(x)^2))
Coefficients:
  (Intercept)       scale(x)  I(scale(x)^2)
        75.12          29.86          -6.21
R> coef(lm2)[3]/sd(x^2)
I(scale(x)^2)
   -0.0020519
R> coef(lm2)[2]/sd(x)
scale(x)
  1.0384
-----Original Message----- 
From: Andres Legarra [mailto:alegarra at neiker.net]
Sent: Mon 2005-09-12 08:53
To: Gorjanc Gregor; r-help at stat.math.ethz.ch
Subject: Re: [R] Backtransforming regression coefficient for scaled
covariate

[R] Backtransforming regression coefficient for scaled covariate
Your
covariate in the second part of the polynomial is x^2 and not x. Therefore
the transformation should be applied to x^2.
Like this:
(lm2 <- lm(y ~ scale(x) + I(scale(x^2)) )
then you would use
coef(lm2)[3]/sd(x^2)
Andres
-- 
Andres Legarra
NEIKER
Apdo. 46
Vitoria-Gasteiz 01080 Spain