stat545a-2013-hw01_inskip-jes.R

JInskip — Sep 12, 2013, 8:22 PM

n <- 60
a <- 2   ## intercept
b <- 19  ## slope
sigSq <- 0.5

set.seed(1234) ## taking control of the random number generator 
x <- runif(n)
y <- a + b * x + rnorm(n, sd = sqrt(sigSq))  #add normal noise to plot
(avgX <- mean(x))
[1] 0.4667

plot(x, y)
abline(a, b, col = "magenta")

plot of chunk unnamed-chunk-1


sessionInfo() ## build into scripts if sharing with other folks 
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] knitr_1.4.1

loaded via a namespace (and not attached):
[1] digest_0.6.3   evaluate_0.4.7 formatR_0.9    stringr_0.6.2 
[5] tools_3.0.1