####################
# READING IN DATA
####################
library(readxl)
calls_data <- read_excel("calls - Copy.xlsx")R Lab Session: Week 2
Simple Linear Regression
Question 1
What is the average number of executions per day [round to 1 decimal]?
ex_avg <- mean(calls_data$Executions)
ex_avg[1] 344.6
Question 2
What is the variance of the number of calls per day [round to 2 decimals]?
var_calls <- (sd(calls_data$Calls))^2
var_calls[1] 40051.11
Question 3
What is the standard deviation on the number of calls per day [round to 2 decimals]?
sd_calls <- sd(calls_data$Calls)
sd_calls[1] 200.1277
Question 4
What is the correlation coefficient between number of calls and executions [round to 2 decimals]?
cor(calls_data$Calls, calls_data$Executions)[1] 0.7937705
Question 5
Based on your plot there seems to be a linear relationship between calls and executions.
True
False
plot(calls_data$Calls, calls_data$Executions)True
Question 6
What is the estimated beta coefficient for calls [round to 2 decimals]?
#############################
# SIMPLE LINEAR REGRESSION
#############################
model <- lm(Executions ~ Calls, data=calls_data)
summary(model)
Call:
lm(formula = Executions ~ Calls, data = calls_data)
Residuals:
Min 1Q Median 3Q Max
-55.606 -22.206 -8.547 19.550 63.270
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -63.02046 54.59737 -1.154 0.257
Calls 0.18901 0.02521 7.497 1.28e-08 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 29.42 on 33 degrees of freedom
Multiple R-squared: 0.6301, Adjusted R-squared: 0.6189
F-statistic: 56.21 on 1 and 33 DF, p-value: 1.278e-08
0.19
Question 7
What is the estimated standard error for executions [round to 2 decimals]?
54.60
Question 8
What is the test statistic associated with calls [round to 2 decimals]?
7.50
Question 9
What is the p-value associated with executions [round to 2 decimals]?
0.26
Question 10
What is the model’s multiple R squared value [round to 2 decimals]?
0.63
Question 11
There is sufficient evidence to suggest that there is a significant linear relationship between calls and executions.
True
False
True. By testing the slope of the model, we can see that the slope is likely different from \(0\) since the test statistic for the slope is significant at the \(5\%\) significance level.