Dear R experts, I am posting this question on behalf of a Japanese R user who wants to know how to change the siginificant codes default. As you know, R's default significant codes are: Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 But he says that it is usual in economics to give codes such as `***' for 0.01, `**' for 0.05 and `*' for 0.10 I don't know if this is true (common) or not, but what I as well as he are puzzled is that, apparently, there is no part in the code, say that of summary.lm, which produces these significant codes as well as the annotation above. A quick search of "rking" using keywords "significant codes star" gave me no information. Thanks in advance. I use R 2.0.0 on Debian GNU Linux (don't know his). ======================================================= Shigeru MASE <mase at is.titech.ac.jp> Tokyo Institute of Technology Dept. of Math. and Comp. Sciences, Tokyo, Japan
How to change the significant codes default?
8 messages · Uwe Ligges, (Ted Harding), Gabor Grothendieck +1 more
Shigeru Mase wrote:
Dear R experts, I am posting this question on behalf of a Japanese R user who wants to know how to change the siginificant codes default. As you know, R's default significant codes are: Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 But he says that it is usual in economics to give codes such as `***' for 0.01, `**' for 0.05 and `*' for 0.10 I don't know if this is true (common) or not, but what I as well as he are puzzled is that, apparently, there is no part in the code, say that of summary.lm, which produces these significant codes as well as the annotation above. A quick search of "rking" using keywords "significant codes star" gave me no information. Thanks in advance.
For example, calling summary(lmObject) dispatches on method summary.lm() hwich creates an object of class "summary.lm". The latter is printed by method print.summary.lm() which calls printCoefmat(). The stars are hard-coded there, and I don't think anybody is going to change that. I suggest to turn of the printing of siginificant codes by specifying print(summary(.....), signif.stars = FALSE) or by setting the corresponding option(). Uwe Ligges
I use R 2.0.0 on Debian GNU Linux (don't know his). ======================================================= Shigeru MASE <mase at is.titech.ac.jp> Tokyo Institute of Technology Dept. of Math. and Comp. Sciences, Tokyo, Japan
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
On 20-Nov-04 Uwe Ligges wrote:
Shigeru Mase wrote:
Dear R experts, I am posting this question on behalf of a Japanese R user who wants to know how to change the siginificant codes default. As you know, R's default significant codes are: Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 But he says that it is usual in economics to give codes such as `***' for 0.01, `**' for 0.05 and `*' for 0.10 I don't know if this is true (common) or not, but what I as well as he are puzzled is that, apparently, there is no part in the code, say that of summary.lm, which produces these significant codes as well as the annotation above. A quick search of "rking" using keywords "significant codes star" gave me no information. Thanks in advance.
For example, calling summary(lmObject) dispatches on method summary.lm() hwich creates an object of class "summary.lm". The latter is printed by method print.summary.lm() which calls printCoefmat(). The stars are hard-coded there, and I don't think anybody is going to change that. I suggest to turn of the printing of siginificant codes by specifying print(summary(.....), signif.stars = FALSE) or by setting the corresponding option(). Uwe Ligges
It would be possible to re-define 'printCoefmat' privately
so as to change the lines
cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1),
symbols = c("***", "**", "*", ".", " "))
towards the end of its code into whatever you prefer, e.g.
cutpoints = c(0, 0.01, 0.05, 0.1, 1),
symbols = c("***", "**", "*", " "))
or
cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1),
symbols = c("****", "***", "**", "*", " "))
(both of which are compatible with your description of what
is needed).
The most straightforward way of redefining it is to copy
the code for 'printCoefmat' into a file, e.g.
sink("printCoefmat.R")
printCoefmat
sink()
and then edit that file.
NOTE that the code written to the file does not include
the name of the function, i.e. it starts
function (x, digits = max(3, getOption("digits") - 2),....
so the first modification has to be
printCoefmat<-function(x, digits = .... )
Then, when you want your private version, simply do
source("printCoefmat.R")
and it will overlay the original version. (Experts will have
to advise whether this clashes with any "namespace" issues.
On my reading of the code, it doesn't seem to; but I'm no
expert!)
If your friend wants to use this new definition all the time,
then one way to arrange this is to put the revised function
definition (as in the edited file) into his .Rprofile,
or put the command
source("printCoefmat")
into that file.
Best wishes,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861 [NB: New number!]
Date: 20-Nov-04 Time: 19:13:23
------------------------------ XFMail ------------------------------
(Ted Harding) wrote:
On 20-Nov-04 Uwe Ligges wrote:
Shigeru Mase wrote:
Dear R experts, I am posting this question on behalf of a Japanese R user who wants to know how to change the siginificant codes default. As you know, R's default significant codes are: Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 But he says that it is usual in economics to give codes such as `***' for 0.01, `**' for 0.05 and `*' for 0.10 I don't know if this is true (common) or not, but what I as well as he are puzzled is that, apparently, there is no part in the code, say that of summary.lm, which produces these significant codes as well as the annotation above. A quick search of "rking" using keywords "significant codes star" gave me no information. Thanks in advance.
For example, calling summary(lmObject) dispatches on method summary.lm() hwich creates an object of class "summary.lm". The latter is printed by method print.summary.lm() which calls printCoefmat(). The stars are hard-coded there, and I don't think anybody is going to change that. I suggest to turn of the printing of siginificant codes by specifying print(summary(.....), signif.stars = FALSE) or by setting the corresponding option(). Uwe Ligges
It would be possible to re-define 'printCoefmat' privately
so as to change the lines
cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1),
symbols = c("***", "**", "*", ".", " "))
towards the end of its code into whatever you prefer, e.g.
cutpoints = c(0, 0.01, 0.05, 0.1, 1),
symbols = c("***", "**", "*", " "))
or
cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1),
symbols = c("****", "***", "**", "*", " "))
(both of which are compatible with your description of what
is needed).
The most straightforward way of redefining it is to copy
the code for 'printCoefmat' into a file, e.g.
sink("printCoefmat.R")
printCoefmat
sink()
and then edit that file.
NOTE that the code written to the file does not include
the name of the function, i.e. it starts
function (x, digits = max(3, getOption("digits") - 2),....
so the first modification has to be
printCoefmat<-function(x, digits = .... )
Then, when you want your private version, simply do
source("printCoefmat.R")
and it will overlay the original version. (Experts will have
to advise whether this clashes with any "namespace" issues.
On my reading of the code, it doesn't seem to; but I'm no
expert!)
Ted, it "clashes"! Functions in the namespace are looked up at first. Uwe
If your friend wants to use this new definition all the time,
then one way to arrange this is to put the revised function
definition (as in the edited file) into his .Rprofile,
or put the command
source("printCoefmat")
into that file.
Best wishes,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861 [NB: New number!]
Date: 20-Nov-04 Time: 19:13:23
------------------------------ XFMail ------------------------------
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
On 21-Nov-04 Uwe Ligges wrote:
(Ted Harding) wrote:
[...]
Then, when you want your private version, simply do
source("printCoefmat.R")
and it will overlay the original version. (Experts will have
to advise whether this clashes with any "namespace" issues.
On my reading of the code, it doesn't seem to; but I'm no
expert!)
Ted, it "clashes"! Functions in the namespace are looked up at first. Uwe
Oops! Thanks, Uwe; now I know! Cheers, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861 [NB: New number!] Date: 21-Nov-04 Time: 17:01:35 ------------------------------ XFMail ------------------------------
Uwe Ligges <ligges <at> statistik.uni-dortmund.de> writes: :
: (Ted Harding) wrote:
:
: > On 20-Nov-04 Uwe Ligges wrote:
: >
: >>Shigeru Mase wrote:
: >>
: >>>Dear R experts,
: >>>
: >>>I am posting this question on behalf of a Japanese R user
: >>>who wants to know how to change the siginificant codes default.
: >>>As you know, R's default significant codes are:
: >>>
: >>> Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
: >>>
: >>>But he says that it is usual in economics to give codes such as
: >>>
: >>> `***' for 0.01, `**' for 0.05 and `*' for 0.10
: >>>
: >>>I don't know if this is true (common) or not, but what I as well
: >>>as he are puzzled is that, apparently, there is no part in the code,
: >>>say that of summary.lm, which produces these significant codes
: >>>as well as the annotation above. A quick search of "rking" using
: >>>keywords "significant codes star" gave me no information.
: >>>
: >>>Thanks in advance.
: >>
: >>For example, calling summary(lmObject) dispatches on method
: >>summary.lm()
: >>hwich creates an object of class "summary.lm".
: >>The latter is printed by method print.summary.lm() which calls
: >>printCoefmat().
: >>
: >>The stars are hard-coded there, and I don't think anybody is going to
: >>change that. I suggest to turn of the printing of siginificant codes by
: >>specifying
: >> print(summary(.....), signif.stars = FALSE)
: >>or by setting the corresponding option().
: >>
: >>Uwe Ligges
: >
: >
: > It would be possible to re-define 'printCoefmat' privately
: > so as to change the lines
: >
: > cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1),
: > symbols = c("***", "**", "*", ".", " "))
: >
: > towards the end of its code into whatever you prefer, e.g.
: >
: > cutpoints = c(0, 0.01, 0.05, 0.1, 1),
: > symbols = c("***", "**", "*", " "))
: >
: > or
: >
: > cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1),
: > symbols = c("****", "***", "**", "*", " "))
: >
: > (both of which are compatible with your description of what
: > is needed).
: >
: > The most straightforward way of redefining it is to copy
: > the code for 'printCoefmat' into a file, e.g.
: >
: > sink("printCoefmat.R")
: > printCoefmat
: > sink()
: >
: > and then edit that file.
: > NOTE that the code written to the file does not include
: > the name of the function, i.e. it starts
: >
: > function (x, digits = max(3, getOption("digits") - 2),....
: >
: > so the first modification has to be
: >
: > printCoefmat<-function(x, digits = .... )
: >
: > Then, when you want your private version, simply do
: >
: > source("printCoefmat.R")
: >
: > and it will overlay the original version. (Experts will have
: > to advise whether this clashes with any "namespace" issues.
: > On my reading of the code, it doesn't seem to; but I'm no
: > expert!)
:
: Ted, it "clashes"! Functions in the namespace are looked up at first.
:
True, but one can still get the effect by using assignInNamespace.
For example, run these two lines (the body(...) <- line is just for
illustration here. You want to ultimately replace that line with your
redefined printCoefmat: printCoefmat <- function... as discussed by Ted.)
body(printCoefmat) <- parse(text = "cat('Greetings from printCoefmat!!!')")
assignInNamespace("printCoefmat", printCoefmat, "stats")
Now running summary.lm as shown below displays the desired Greetings line:
R> example(lm)
...snip...
R> summary(lm.D90)
Call:
lm(formula = weight ~ group - 1)
Residuals:
Min 1Q Median 3Q Max
-1.0710 -0.4938 0.0685 0.2462 1.3690
Coefficients:
Greetings from printCoefmat!!!
Residual standard error: 0.6964 on 18 degrees of freedom
Multiple R-Squared: 0.9818, Adjusted R-squared: 0.9798
F-statistic: 485.1 on 2 and 18 DF, p-value: < 2.2e-16
Dear Uwe, Ted and Gabor. Thanks for your quick and kind informations. The suggestion of Gabor combined with that of Ted works fine. Of course, I myself would not like to change R's significant codes default, but I could get a deeper insight of R language mechanism.
On 22-Nov-04 Shigeru Mase wrote:
Dear Uwe, Ted and Gabor. Thanks for your quick and kind informations. The suggestion of Gabor combined with that of Ted works fine. Of course, I myself would not like to change R's significant codes default, but I could get a deeper insight of R language mechanism.
So could I! Thanks, Gabor, for bringing 'body(...) <- ...' to the surface. Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861 [NB: New number!] Date: 22-Nov-04 Time: 09:30:47 ------------------------------ XFMail ------------------------------