Challenger dataset

#Launch challenger dataset
launch <- read.csv("challenger.csv")
# estimate beta manually
b <- cov(launch$temperature, launch$distress_ct) / var(launch$temperature)
b
## [1] -0.04753968
#estimate alpha manually
a <- mean(launch$distress_ct) - b * mean(launch$temperature)
a
## [1] 3.698413
# calculate the correlation of launch data
r <- cov(launch$temperature, launch$distress_ct) /
       (sd(launch$temperature) * sd(launch$distress_ct))
r
## [1] -0.5111264
cor(launch$temperature, launch$distress_ct)
## [1] -0.5111264
# computing the slope using correlation
r * (sd(launch$distress_ct) / sd(launch$temperature))
## [1] -0.04753968
# confirming the regression line using the lm function (not in text)
model1 <- lm(distress_ct ~ temperature, data = launch)
model1
## 
## Call:
## lm(formula = distress_ct ~ temperature, data = launch)
## 
## Coefficients:
## (Intercept)  temperature  
##     3.69841     -0.04754
summary(model1)
## 
## Call:
## lm(formula = distress_ct ~ temperature, data = launch)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5608 -0.3944 -0.0854  0.1056  1.8671 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)   
## (Intercept)  3.69841    1.21951   3.033  0.00633 **
## temperature -0.04754    0.01744  -2.725  0.01268 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5774 on 21 degrees of freedom
## Multiple R-squared:  0.2613, Adjusted R-squared:  0.2261 
## F-statistic: 7.426 on 1 and 21 DF,  p-value: 0.01268
# simple multiple regression function
reg <- function(y, x) {
  x <- as.matrix(x)
  x <- cbind(Intercept = 1, x)
  b <- solve(t(x) %*% x) %*% t(x) %*% y
  colnames(b) <- "estimate"
  print(b)
}
# examine the launch data
str(launch)
## 'data.frame':    23 obs. of  4 variables:
##  $ distress_ct         : int  0 1 0 0 0 0 0 0 1 1 ...
##  $ temperature         : int  66 70 69 68 67 72 73 70 57 63 ...
##  $ field_check_pressure: int  50 50 50 50 50 50 100 100 200 200 ...
##  $ flight_num          : int  1 2 3 4 5 6 7 8 9 10 ...
# test regression model
reg(y = launch$distress_ct, x = launch[2])
##                estimate
## Intercept    3.69841270
## temperature -0.04753968
# use regression model with multiple regression
reg(y = launch$distress_ct, x = launch[2:4])
##                          estimate
## Intercept             3.527093383
## temperature          -0.051385940
## field_check_pressure  0.001757009
## flight_num            0.014292843
# confirming the multiple regression result using the lm function (not in text)
model2 <- lm(distress_ct ~ temperature + field_check_pressure + flight_num, data = launch)
model2
## 
## Call:
## lm(formula = distress_ct ~ temperature + field_check_pressure + 
##     flight_num, data = launch)
## 
## Coefficients:
##          (Intercept)           temperature  field_check_pressure  
##             3.527093             -0.051386              0.001757  
##           flight_num  
##             0.014293
summary(model2)
## 
## Call:
## lm(formula = distress_ct ~ temperature + field_check_pressure + 
##     flight_num, data = launch)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.65003 -0.24414 -0.11219  0.01279  1.67530 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)  
## (Intercept)           3.527093   1.307024   2.699   0.0142 *
## temperature          -0.051386   0.018341  -2.802   0.0114 *
## field_check_pressure  0.001757   0.003402   0.517   0.6115  
## flight_num            0.014293   0.035138   0.407   0.6887  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.565 on 19 degrees of freedom
## Multiple R-squared:   0.36,  Adjusted R-squared:  0.259 
## F-statistic: 3.563 on 3 and 19 DF,  p-value: 0.03371

Findings:

  • A simple linear regression shows a statistically significant negative relationship between launch temperature and O-ring distress count.
  • Lower temperatures are associated with higher numbers of distress incidents.
  • Adding field check pressure and flight number does not meaningfully improve the model, indicating temperature is the primary predictor.

Challenger 2 Dataset

challenger2 <- read.csv("challenger2.csv", stringsAsFactors = TRUE)
str(challenger2)
## 'data.frame':    29 obs. of  4 variables:
##  $ distress_ct         : int  0 1 0 0 0 0 0 0 1 1 ...
##  $ temperature         : int  66 70 69 68 67 72 73 70 57 63 ...
##  $ field_check_pressure: int  50 50 50 50 50 50 100 100 200 200 ...
##  $ flight_num          : int  1 2 3 4 5 6 7 8 9 10 ...
# estimate beta manually
b <- cov(challenger2$temperature, challenger2$distress_ct) / var(challenger2$temperature)
b
## [1] -0.03364796
# estimate alpha manually
a <- mean(challenger2$distress_ct) - b * mean(challenger2$temperature)
a
## [1] 2.814585
# calculate the correlation of challenger2 data
r <- cov(challenger2$temperature, challenger2$distress_ct) /
       (sd(challenger2$temperature) * sd(challenger2$distress_ct))
r
## [1] -0.3359996
cor(challenger2$temperature, challenger2$distress_ct)
## [1] -0.3359996
# computing the slope using correlation
r * (sd(challenger2$distress_ct) / sd(challenger2$temperature))
## [1] -0.03364796
# confirming the regression line using the lm function (not in text)
model <- lm(distress_ct ~ temperature, data = challenger2)
model
## 
## Call:
## lm(formula = distress_ct ~ temperature, data = challenger2)
## 
## Coefficients:
## (Intercept)  temperature  
##     2.81458     -0.03365
summary(model)
## 
## Call:
## lm(formula = distress_ct ~ temperature, data = challenger2)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.0649 -0.4929 -0.2573  0.3052  1.7090 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)  2.81458    1.24629   2.258   0.0322 *
## temperature -0.03365    0.01815  -1.854   0.0747 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7076 on 27 degrees of freedom
## Multiple R-squared:  0.1129, Adjusted R-squared:  0.08004 
## F-statistic: 3.436 on 1 and 27 DF,  p-value: 0.07474
# creating a simple multiple regression function
reg <- function(y, x) {
  x <- as.matrix(x)
  x <- cbind(Intercept = 1, x)
  b <- solve(t(x) %*% x) %*% t(x) %*% y
  colnames(b) <- "estimate"
  print(b)
}
# examine the challenger2 data
str(challenger2)
## 'data.frame':    29 obs. of  4 variables:
##  $ distress_ct         : int  0 1 0 0 0 0 0 0 1 1 ...
##  $ temperature         : int  66 70 69 68 67 72 73 70 57 63 ...
##  $ field_check_pressure: int  50 50 50 50 50 50 100 100 200 200 ...
##  $ flight_num          : int  1 2 3 4 5 6 7 8 9 10 ...
# test regression model with simple linear regression
reg(y = challenger2$distress_ct, x = challenger2[2])
##                estimate
## Intercept    2.81458456
## temperature -0.03364796
# use regression model with multiple regression
reg(y = challenger2$distress_ct, x = challenger2[2:4])
##                           estimate
## Intercept             2.239817e+00
## temperature          -3.124185e-02
## field_check_pressure -2.586765e-05
## flight_num            2.762455e-02
# confirming the multiple regression result using the lm function (not in text)
model3 <- lm(distress_ct ~ temperature + field_check_pressure + flight_num, data = challenger2)
model3
## 
## Call:
## lm(formula = distress_ct ~ temperature + field_check_pressure + 
##     flight_num, data = challenger2)
## 
## Coefficients:
##          (Intercept)           temperature  field_check_pressure  
##            2.240e+00            -3.124e-02            -2.587e-05  
##           flight_num  
##            2.762e-02
summary(model3)
## 
## Call:
## lm(formula = distress_ct ~ temperature + field_check_pressure + 
##     flight_num, data = challenger2)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.2744 -0.3335 -0.1657  0.2975  1.5284 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)  
## (Intercept)           2.240e+00  1.267e+00   1.767   0.0894 .
## temperature          -3.124e-02  1.787e-02  -1.748   0.0927 .
## field_check_pressure -2.587e-05  2.383e-03  -0.011   0.9914  
## flight_num            2.762e-02  1.798e-02   1.537   0.1369  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6926 on 25 degrees of freedom
## Multiple R-squared:  0.2132, Adjusted R-squared:  0.1188 
## F-statistic: 2.259 on 3 and 25 DF,  p-value: 0.1063

Findings:

  • The Challenger2 dataset shows the same negative relationship between temperature and O-ring distress count, but with weaker statistical significance.
  • The direction of the effect remains consistent, although the model explains less variation in distress counts. Additional predictors do not substantially improve model performance.

Comparison:

  • Both datasets consistently indicate that lower launch temperatures are associated with increased O-ring distress. The weaker significance in the
  • Challenger2 dataset reflects higher uncertainty rather than a reversal of the underlying relationship.