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:> l<- c(1,2,3) > scale(l,F,T)[,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:> 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: > > l<- c(1,2,3) > > scale(l,F,T) > [,1] > [1,] 0.3779645 > [2,] 0.7559289 > [3,] 1.1338934 > attr(,"scaled:scale") > [1] 2.645751 > > 2.645751 = sqrt( 1/2 * (1+4+9) )And? That's exactly what the documentation says will happen. And exactly what Splus does, even if perhaps surprising. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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:
> 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:
> > l<- c(1,2,3)
> > scale(l,F,T)
> [,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
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
--
318 Carr Hall bolker@zoo.ufl.edu
Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker
Box 118525 (ph) 352-392-5697
Gainesville, FL 32611-8525 (fax) 352-392-3704
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> From: Peter Dalgaard BSA [mailto:p.dalgaard@biostat.ku.dk][...]> > And? That's exactly what the documentation says will happen. And > exactly what Splus does, even if perhaps surprising.Generally speaking, I think it is poor design for software to 'surprise' the user, even if documentation specifies the surprising activity... Is there a good reason for this behavior or is it 'just' a leftover implementation detail recoded as a specification? Except, perhaps, for the need for backwards & S-Plus compatibility, it would seem desirable to change the behavior to better match the uninformed expectation of users. Just my $0.02. -Greg LEGAL NOTICE Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._