Difference between revisions of "Least squares modelling (2013)"

From Statistics for Engineering
Jump to navigation Jump to search
Line 65: Line 65:
confint(model)  # get the coefficient confidence intervals
confint(model)  # get the coefficient confidence intervals
resid(model)    # model residuals
resid(model)    # model residuals
library(car)
qqPlot(resid(model)) # q-q plot of the residuals to check normality
qqPlot(resid(model)) # q-q plot of the residuals to check normality



Revision as of 16:00, 27 February 2013

Class date(s): 08 February 2013
Nuvola mimetypes pdf.png (PDF) Course slides
Download video: Link (plays in Google Chrome) [352 M]

Download video: Link (plays in Google Chrome) [347 M]

Download video: Link (plays in Google Chrome) [352 M]

Course notes and slides


Software source code

Take a look at the software tutorial.


Code used in class

Thermocouple data

V <- c(0.01, 0.12, 0.24, 0.38, 0.51, 0.67, 0.84, 1.01, 1.15, 1.31)
T <- c(273, 293, 313, 333, 353, 373, 393, 413, 433, 453)
plot(V, T)
model <- lm(T ~ V)
summary(model)
coef(model)
confint(model)   # get the coefficient confidence intervals
resid(model)     # model residuals
library(car)
qqPlot(resid(model)) # q-q plot of the residuals to check normality

plot(V, T)
v.new <- seq(0, 1.5, 0.1)
t.pred <- coef(model)[1] + coef(model)[2]*v.new
lines(v.new, t.pred, type="l", col="blue")

# Plot x against the residuals to check for non-linearity
plot(V, resid(model))
abline(h=0)

# Plot the raw data and the regression line in red
plot(V, T)
abline(model, col="red")