This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.

sleep=c(56,60,54,48,47,20,29,31,45,51,61,55,58,59,32);
show=c(14,12,17,19,16,21,23,13,19,22,9,11,18,13,24);
plot(sleep,show, pch=19, col="blue",xlab="Watch House of Cards (hours)",ylab="Sleep (hours)")

Watchhouseofcards.reg=lm(sleep~show);
Watchhouseofcards.reg$coef ## (Intercept) show ## 76.411165 -1.753655 1a) The equation for the least square regression line is y= -1.753655x + 76.411165 sleep=c(56,60,54,48,47,20,29,31,45,51,61,55,58,59,32); show=c(14,12,17,19,16,21,23,13,19,22,9,11,18,13,24); plot(sleep,show, pch=19, col="blue",xlab="Watch House of Cards(hours)",ylab="Sleep(hours)",main="1b)Nagir") sleep.reg=lm(show~sleep); abline(sleep.reg$coef,col="red")

sleep=c(56,60,54,48,47,20,29,31,45,51,61,55,58,59,32);
show=c(14,12,17,19,16,21,23,13,19,22,9,11,18,13,24);
new<-data.frame(show=15)
predict(sleep.reg,newdata=new);
## Warning: 'newdata' had 1 row but variables found have 15 rows
##        1        2        3        4        5        6        7        8
## 14.75160 13.86425 15.19527 16.52629 16.74812 22.73770 20.74117 20.29750
##        9       10       11       12       13       14       15
## 17.19179 15.86078 13.64242 14.97343 14.30793 14.08609 20.07566
set.seed(1234)
sample(1:50,12)
##  [1]  6 31 30 48 40 29  1 10 28 22 42 41
sample(1:50,12)
##  [1] 15 46 50 40 14 13  9 10 49 45  7  2
Data=c(6,31,30,48,40,29,1,10,28,22,42,41)
mean(Data)
## [1] 27.33333
Data2=c(1:50)
mean(Data2)
## [1] 25.5

c)The population mean is 25.5 and the sample mean is 27.33333. The two means are very similar with a difference of 1.83333.