library(s20x)
ballBearings.df = read.table("C:\\R_ENGSCI_211\\BallBearings.txt", header = TRUE)
line1=with(ballBearings.df, diameter[productionline=="line1"])
line2=with(ballBearings.df, diameter[productionline=="line2"])
diffDiameter=line1-line2
summaryStats(diffDiameter)
Minimum value: -1
Maximum value: 0.33
Mean value: -0.21
Median: -0.19
Upper quartile: 0.09
Lower quartile: -0.47
Variance: 0.2
Standard deviation: 0.45
Midspread (IQR): 0.56
Skewness: -0.37
Number of data values: 10
boxplot(diffDiameter, main = "Difference in diameter between line 1 and line 2")
We can see that the data is centered around -0.2 microns. The data ranges between -1.0 and -0.33 microns. It is slightly left-skewed.
normcheck(diffDiameter)
t.test(diffDiameter)
One Sample t-test
data: diffDiameter
t = -1.4973, df = 9, p-value = 0.1686
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
-0.5323046 0.1083046
sample estimates:
mean of x
-0.212
We are attempting to estimate the difference between the diameters of bearings produced by each line, so a paired-sample analysis is appropriate.
The diameter measurements should be independent of one another.
The data does not appear very normal based on the histogram, and the Q-Q plot shows that the data is somewhat left-skewed so it is possible that it does not fulfill the normality assumption. We do not have a enough observations to invoke the central limit theorem.
The model fitted is diffDiameteri = µ + εi, where µ is the mean difference in ball bearing diameters between line 1 and 2, and εi ∼ N(0, σ2).
We are interesting in determining the difference, if one exists, in the diameter of ball bearings produced by line one and line two.
Because we are analysing two related measurements, we analysed the difference between the diameters of balls from each line.
We observe that there is no evidence that the difference between the diameters of each line is not zero.
We estimate that the mean difference between the diameter of bearings from line one and line two is between -0.532 microns and 0.108 microns.
library(s20x)
RopeFailure.df = read.table("C:\\R_ENGSCI_211\\Ropefailure.txt", header = TRUE)
trendscatter(Time ~ Load, data = RopeFailure.df)
Fitting a simple linear regression model:
RopeFailure.lm1 = lm(Time ~ Load, data = RopeFailure.df)
plot(RopeFailure.lm1, which = 1)
We observe the fan affect in the residual plot, so a multiplicative model may be appropriate.
LogTimeLoad.fit = lm(log(Time) ~ Load, data = RopeFailure.df)
modcheck(LogTimeLoad.fit)
summary(LogTimeLoad.fit)
Call:
lm(formula = log(Time) ~ Load, data = RopeFailure.df)
Residuals:
Min 1Q Median 3Q Max
-2.9788 -2.1590 0.4689 1.6371 3.4915
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 42.1482 8.8328 4.772 0.000208 ***
Load -0.4932 0.1055 -4.675 0.000253 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.179 on 16 degrees of freedom
Multiple R-squared: 0.5774, Adjusted R-squared: 0.551
F-statistic: 21.86 on 1 and 16 DF, p-value: 0.0002533
exp(confint(LogTimeLoad.fit))
2.5 % 97.5 %
(Intercept) 1.48835e+10 2.733706e+26
Load 4.88267e-01 7.636826e-01
100 * (exp(confint(LogTimeLoad.fit)) - 1)
2.5 % 97.5 %
(Intercept) 1.48835e+12 2.733706e+28
Load -5.11733e+01 -2.363174e+01
PREDICTION INTERVAL THINGY
The fan effect observed in our residual plot indicated that a multiplicative model would be more appropriate, as equality of variance was clearly not fulfilled. Because of this, a log transformation was attempted.
We assume that observations of the failure time of ropes were independent, but there may be correlations such as wet weather that were not accounted for.
A linear model fitted to the log of Time proved to fulfill equality our assumptions of variance and is mostly normal (slightly right-tailed), and there were no excessively influential observations.
Our final model (for the median) is log(Timei) = Bo + B1 * Loadi + εi where εi ∼ N(0, σ2).
We are interested in determining how the time for polyester mooring lines varies with heavy loading, and to predict the average time to failure of ropes loaded to 79% of breaking load.
We found that the an increase in the loading on a mooring rope of 1% is associated with a decrease in time to failure of between 2.36% and 5.12%
Our model explains 57.7% of variation in time to failure
library(s20x)
PetStress.df = read.table("C:\\R_ENGSCI_211\\petstress.txt", header = TRUE)
boxplot(Rate ~ Group, data = PetStress.df)
We observe that the control group is centered around 85 bpm and ranges from 62 to 99. The friend group is centered around 92 and ranges from 78 to 102. The pet group is centered around 71 and ranges between 59 and 88.
stress.fit = lm(Rate ~ Group, data = PetStress.df)
modcheck(stress.fit)
summary(stress.fit)
Call:
lm(formula = Rate ~ Group, data = PetStress.df)
Residuals:
Min 1Q Median 3Q Max
-19.878 -4.724 -1.221 6.179 24.055
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 82.524 2.378 34.709 <2e-16 ***
GroupF 8.801 3.362 2.617 0.0123 *
GroupP -9.041 3.362 -2.689 0.0102 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 9.208 on 42 degrees of freedom
Multiple R-squared: 0.4014, Adjusted R-squared: 0.3729
F-statistic: 14.08 on 2 and 42 DF, p-value: 2.092e-05
anova(stress.fit)
Analysis of Variance Table
Response: Rate
Df Sum Sq Mean Sq F value Pr(>F)
Group 2 2387.7 1193.84 14.079 2.092e-05 ***
Residuals 42 3561.3 84.79
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
multipleComp(stress.fit)
Estimate Tukey.L Tukey.U Tukey.p
C - F -8.801067 -16.9700 -0.6321 0.0322
C - P 9.041000 0.8721 17.2099 0.0271
F - P 17.842067 9.6731 26.0110 0.0000
We are analysing the quantitative response on heart rate of three categorical variables, so we fitted a one-way ANOVA model.
We assume that the measurements taken were independent.
The residuals plot indicates that equality of variance is fulfilled. The Q-Q plot indicates that the data is quite normal. None of our observations are unduly influential.
The model fitted is Rate = µ + αi + εij where where µ is the grand mean, αi are the group effects for each category and εij is the residual for each observation, and εij ∼ N(0, σ2)
We are interested in determining the effect of the presence of dogs or friends during stressful tasks, as measured by the heart rate of participants.
We found evidence that, on average, being accompanied by a pet decreased the heartrate of dog-lovers when performing stressful tasks; as well as evidence that, on average, being accompanied by a friend increased the heart rate of participants.
We found that the presence of a friend increased the heart rate of participants by between 0.632 and 17.0BPM, while the presence of a pet decreased the heartrate of participants by between 0.872 and 17.2 BPM.
Our model explains 40.1% of the variation in the data.