Commits

dan mackinlay committed 3a194dd

homework 5 action

Comments (0)

Files changed (6)

cs-36-402/homework 5/q1.r

+attach(cats)
+linfit.unsexed = lm(Hwt ~ 0 + Bwt)
+plot(Bwt, Hwt)
+abline(linfit.unsexed)

cs-36-402/homework 5/q2.R

+linfit.interactey = lm(Hwt ~ Bwt * Sex)

cs-36-402/homework 5/q3.R

+linfit.interactey = lm(Hwt ~ 0+ Bwt * Sex)

cs-36-402/homework 5/q4.R

+anova(linfit.unsexed, linfit.interactey)

cs-36-402/homework 5/q5.R

+fit.cats.1 = function(newdata) { coef(lm(Hwt ~ 0 + Bwt, data=newdata))}
+resample.cats = function () {
+  rows = sample.int(nrow(cats), replace=TRUE)
+  return(cats[rows,])
+}
+cats.1.se = function(B) {
+  sd(replicate(B, fit.cats.1(resample.cats())))
+}
+cats.1.cis = function(alpha, B) {
+  samps = replicate(B, fit.cats.1(resample.cats()))
+  quantile(samps, probs=c(alpha/2, 1-alpha/2))
+}

cs-36-402/homework 5/q6.R

Empty file added.