[R] inconsistent output using 'round'

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Thu Apr 19 14:50:59 CEST 2007


Bob Green wrote:
> I am hoping for some advice regarding limiting decimal points to 3. 
> 'Round' produces the desired results except for the 97.5% confidence interval.
> Any advice as to how I modify the code to obtain output to 3 decimal 
> points for all ouput is appreciated,
>   

The rounding is fine, it is just that one of the values is huge, so that
exponential notation is used. If you insist, start playing around with
formatC. Something like

  noquote(formatC(....., digits=3, format="f", width=31) )

might do it.
> regards
>
> Bob Green
>
>
> mod.multgran <-multinom(offence ~ grandiose * violent.convictions, 
> data = kc,  na.action = na.omit)
> summary(mod.multgran, cor=F, Wald=T)
> Anova (mod.multgran)
>  > round(exp(coef(mod.multgran)),digits = 3)
>           (Intercept) grandiosey violent.convictionsy
> GBH.UW         0.583      0.147                0.806
> homicide       0.333      0.343                0.882
>           grandiosey:violent.convictionsy
> GBH.UW                             0.001
> homicide                           0.764
>  > round(exp(confint(mod.multgran)),digits =3)
> , , GBH.UW
>
>                                                  2.5 %       97.5 %
> (Intercept)                             0.341 9.990000e-01
> grandiosey                              0.040 5.370000e-01
> violent.convictionsy                    0.297 2.187000e+00
> grandiosey:violent.convictionsy 0.000 6.265942e+26
>
> , , homicide
>
>                                           2.5 % 97.5 %
> (Intercept)                             0.173  0.641
> grandiosey                      0.101  1.165
> violent.convictionsy                    0.268  2.905
> grandiosey:violent.convictionsy 0.058 10.031
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>   


-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-help mailing list