what is scale function? Is it for variable transformation?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

what is scale function? Is it for variable transformation?

Kum-Hoe Hwang
HOwdy

I read R books about scale function for variable transformation.
Acoording to this  book
scale function leads me to better regression results. Or am I worng?

I hope somebody tell me about a scale function?
Is it for variable transformation?




--
Kum-Hoe Hwang, Phone : 82-31-250-3516Email : [hidden email]

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: what is scale function? Is it for variable transformation?

Kjetil Halvorsen
Kum-Hoe Hwang wrote:
> HOwdy
>
> I read R books about scale function for variable transformation.
> Acoording to this  book
> scale function leads me to better regression results. Or am I worng?
>
> I hope somebody tell me about a scale function?
> Is it for variable transformation?

Did you try to read
?scale
?

Look at:
 > x <- rnorm(100, 5, 10)
 > mean(x)
[1] 4.304616
 > sd(x)
[1] 9.926883
 > x <- scale(x)
 > mean(x)
[1] 5.39499e-17
 > sd(x)
[1] 1

Kjetil


>
>
>
>
> --
> Kum-Hoe Hwang, Phone : 82-31-250-3516Email : [hidden email]
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: what is scale function? Is it for variable transformation?

Gabor Grothendieck
In reply to this post by Kum-Hoe Hwang
It will change the coefficients from lm and therefore their t-values but it
will not change the residuals, fitted values, R-squared, F
statistic, etc.  For example, try this:

set.seed(1)
x <- 1:10
y <- x + rnorm(10)
lm0 <- lm(y ~ x) # without scale
lms <- lm(y ~ scale(x)) # with scale
all.equal(fitted(lm0), fitted(lms)) # TRUE

# note what the is the same and what is different
summary(lm0)
summary(lms)

Another use of scale is comparing graphs.

library(tseries)
data(USeconomic)
ts.plot(scale(USeconomic), col = 1:4)
# compare with
ts.plot(USeconomic, col = 1:4)

On 3/5/06, Kum-Hoe Hwang <[hidden email]> wrote:

> HOwdy
>
> I read R books about scale function for variable transformation.
> Acoording to this  book
> scale function leads me to better regression results. Or am I worng?
>
> I hope somebody tell me about a scale function?
> Is it for variable transformation?
>
>
>
>
> --
> Kum-Hoe Hwang, Phone : 82-31-250-3516Email : [hidden email]
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html