StatBytes10Feb2014_RNotebook.R

Jerzy — Feb 10, 2014, 3:13 PM

# Simple R Notebook example
# Jerzy Wieczorek, 2/10/2014

# Make some data: y = x + e
x = 1:30
e = rnorm(30)
y = x + e

# Plot the data
plot(x,y, main="y = x + e")
abline(lm(y~x))

plot of chunk unnamed-chunk-1


# Summarize the regression results
summary(lm(y~x))

Call:
lm(formula = y ~ x)

Residuals:
    Min      1Q  Median      3Q     Max 
-1.7535 -0.6546 -0.0612  0.7704  1.3227 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)   0.3070     0.3222    0.95     0.35    
x             0.9885     0.0181   54.47   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.86 on 28 degrees of freedom
Multiple R-squared:  0.991, Adjusted R-squared:  0.99 
F-statistic: 2.97e+03 on 1 and 28 DF,  p-value: <2e-16