sensor_data <- read.csv("/Users/manojdannana/Desktop/Manoj/IUPUI/class work/intro to statistics/datasets/Occupancy_Estimation.csv")
The response variable I am picking for my analysis is Room_Occupancy_Count as the dataset I have tries to see how the Room Occupancy changes when all the other variables change.
The explanatory categorical variable I am picking up is S6_PIR. S6_PIR is the value of Motion Detection Sensor that denotes whether there is motion in the room or not. It is a binary value.
H0: There is no significant difference in mean sensor readings (S6_PIR) across different categories (groups) in the dataset.
S6_PIR <- sensor_data$S6_PIR
Room_Occupancy_Count <- sensor_data$Room_Occupancy_Count
unique_values <- unique(S6_PIR)
cat("Unique Values in S6_PIR: \n")
## Unique Values in S6_PIR:
cat(unique_values)
## 0 1
cat("\n")
result_anova <- aov(S6_PIR ~ Room_Occupancy_Count, data=sensor_data)
cat("Summary of Results: \n")
## Summary of Results:
summary(result_anova)
## Df Sum Sq Mean Sq F value Pr(>F)
## Room_Occupancy_Count 1 333.0 333 6775 <2e-16 ***
## Residuals 10127 497.7 0
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The Two important values we have to look at from the above ANOVA Test are the F-Score and P-Score.
The F-Score is 6775 which is very high and It implies that there is significantly more variance in sensor readings (S6_PIR) between various room occupancy counts than there is within each occupancy count group. It indicates that sensor readings are strongly impacted by the room occupancy.
Since the p-value is extremely small (close to zero), much smaller than the typical significance level of 0.05, we reject the null hypothesis. This indicates that there is a significant difference in mean sensor readings (S6_PIR) across different room occupancy counts.
The Continuous Explanatory Variable I am considering is Mean_Temp column. This column isn’t explicitly present in the dataset. I am going to create it by taking the mean of (S1_Temp, S2_Temp, S3_Temp and S4_Temp) columns since all these columns represent the same thing and have same units.
sensor_data$Mean_Temp <- rowMeans(sensor_data[, c("S1_Temp", "S2_Temp", "S3_Temp", "S4_Temp")])
room_occupancy <- sensor_data$Room_Occupancy_Count
mean_temp <- sensor_data$Mean_Temp
correlation_coefficient <- cor(room_occupancy, mean_temp)
print(correlation_coefficient)
## [1] 0.692698
The Correlation Coefficient is 0.7 which indicates a strong positive correlation between the two columns. Hence we can proceed with building a Linear Regression Model for the two columns.
model <- lm(mean_temp ~ room_occupancy, data=sensor_data)
summary(model)
##
## Call:
## lm(formula = mean_temp ~ room_occupancy, data = sensor_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.74019 -0.23187 -0.01687 0.17063 1.17313
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 25.329374 0.003133 8085.83 <2e-16 ***
## room_occupancy 0.309440 0.003202 96.65 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2879 on 10127 degrees of freedom
## Multiple R-squared: 0.4798, Adjusted R-squared: 0.4798
## F-statistic: 9342 on 1 and 10127 DF, p-value: < 2.2e-16
The intercept may not have a practical interpretation in this
context since it represents an extrapolation to a hypothetical scenario
where the mean temperature is zero, which is unlikely to occur in
real-world situations. Therefore, interpretations and recommendations
should focus on the coefficient for
mean_temp.
Since the coefficient for mean_temp
is positive and statistically significant (p < 0.001), it suggests
that there is a positive linear relationship between mean temperature
and Room_Occupancy_Count. In other words, as the mean
temperature increases, the value of
Room_Occupancy_Count tends to increase as
well.