Skip to content

Function scale (PR#2209)

3 messages · lucas@toulouse.inra.fr, Peter Dalgaard, Ben Bolker

#
I found a problem with scale function,
while using center=FALSE and scale=TRUE:

all column are not divided by standard error,
but divided by sqrt (1/(n-1) sum Xi^2 )

Example:
[,1]
[1,] 0.3779645
[2,] 0.7559289
[3,] 1.1338934
attr(,"scaled:scale")
[1] 2.645751

2.645751 = sqrt( 1/2 * (1+4+9) )


Antoine Lucas & Aymeric Labourdette 

--
Antoine  Lucas        
INRA, Unité de biométrie et     |  Tel 05 61 28 53 34
intelligence artificielle       |  Fax 05 61 28 53 35
http://genopole.toulouse.inra.fr/~lucas


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
lucas@toulouse.inra.fr writes:
And? That's exactly what the documentation says will happen. And
exactly what Splus does, even if perhaps surprising.
#
The function is behaving as documented ...

   "If `scale' is `TRUE' then scaling is done by dividing the (centered)
    columns of `x' by their root-mean-square, and if `scale' is `FALSE',
    no scaling is done.

   "The root-mean-square for a column is obtained by computing the
    square-root of the sum-of-squares of the non-missing values in the
    column divided by the number of non-missing values minus one."

   It says "root-mean-square", not "standard error" or "standard
deviation".  If you set center=TRUE, then the two are equivalent. If you
*want* it to scale by standard deviation just set scale=sd(l) [or in the
matrix case, scale=apply(l,2,sd)].

  Ben Bolker
On Thu, 24 Oct 2002 lucas@toulouse.inra.fr wrote: