lm - Changing significance notation in R -


r has significance codes determine statistical significance. in example below, example, dot . indicates significance @ 10% level (see sample output below).

dots can hard see, when copy-paste excel , display in times new roman.

i'd change such that:

  • * = significant @ 10%
  • ** = significant @ 5%
  • *** = significant @ 1%

is there way can this?

> y = c(1,2,3,4,5,6,7,8) > x = c(1,3,2,4,5,6,8,7) > summary(lm(y~x))  call: lm(formula = y ~ x)  residuals:     min      1q  median      3q     max  -1.0714 -0.3333  0.0000  0.2738  1.1191   coefficients:             estimate std. error t value pr(>|t|)     (intercept)   0.2143     0.6286   0.341  0.74480     x             0.9524     0.1245   7.651  0.00026 *** --- signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1  residual standard error: 0.8067 on 6 degrees of freedom multiple r-squared:  0.907, adjusted r-squared:  0.8915  f-statistic: 58.54 on 1 , 6 df,  p-value: 0.0002604 

you can create own formatting function with

mystarformat <- function(x) symnum(x, corr = false, na = false,      cutpoints = c(0, 0.01, 0.05, 0.1, 1),      symbols = c("***", "**", "*", " ")) 

and can write own coefficient formatter

show_coef <- function(mm) {      mycoef<-data.frame(coef(summary(mm)), check.names=f)      mycoef$signif = mystarformat(mycoef$`pr(>|t|)`)      mycoef$`pr(>|t|)` = format.pval(mycoef$`pr(>|t|)`)      mycoef } 

and model, can run with

mm <- lm(y~x) show_coef(mm) #              estimate std. error   t value  pr(>|t|) signif # (intercept) 0.2142857  0.6285895 0.3408993 0.7447995        # x           0.9523810  0.1244793 7.6509206 0.0002604    *** 

Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -