title: How to format beta0 and beta1 with confidence intervals in R?
body: <p>I need to calculate β^0 and β^1 for a simple linear regression yi = β0 + β1xi with 87% confidence intervals for β0 and β1 and have to display my results with three significant digits in the following format:</p>
  
  <pre><code>      Est    L    U
  beta0 1.13 0.889 1.37
  beta1 3.57 1.950 5.19
  </code></pre>
  
  <p>What code should I use to get it in this format?</p>
  
  <p>I have done the following, but cannot figure out how to show Intercept and x as beta0 and beta1 with their Estimate and Lower CI and Upper CI:</p>
  
  <pre><code>&gt; M &lt;- lm(y ~ x) # fit linear model
  &gt; signif(coef(M), digits = 2) # MLE's of beta
  (Intercept)           x 
        -5.40        0.13 
  &gt; 
  &gt; signif(confint(M, level = 0.87), digits = 3)
               6.5 % 93.5 %
  (Intercept) -5.710 -5.160
  x            0.127  0.136
  </code></pre>
  
  <p>I'm doing this in RStudio</p>
  
  <p>EDIT:
  I've used data.frame to get it like this:</p>
  
  <pre><code>&gt; # data.frame for MLE's of beta with 87% confidence interval for beta0 and beta1
  &gt; data.frame(df, stringsAsFactors = )
          Est      L      U
  beta0 -5.40 -5.710 -5.160
  beta1  0.13  0.127  0.136
  &gt; Est &lt;- c(-5.40, 0.13)
  &gt; L &lt;- c(-5.710, 0.127)
  &gt; U &lt;- c(-5.160, 0.136)
  &gt; df &lt;- data.frame(Est,L,U)
  &gt; row.names(df) &lt;- c('beta0', 'beta1')
  </code></pre>
  
  <p>But is there a better way of getting it in this form using the built-in R functions lm, coef, confint?</p>