Difference between revisions of "Least squares modelling (2013)"
Jump to navigation
Jump to search
Kevin Dunn (talk | contribs) m |
Kevin Dunn (talk | contribs) m |
||
Line 7: | Line 7: | ||
| vimeoID4 = 60688909 | | vimeoID4 = 60688909 | ||
| vimeoID5 = 60862565 | | vimeoID5 = 60862565 | ||
| vimeoID6 = | | vimeoID6 = 61138805 | ||
| vimeoID7 = | | vimeoID7 = | ||
| vimeoID8 = | | vimeoID8 = | ||
Line 30: | Line 30: | ||
| video_download_link5_MP4_size = 375 M | | video_download_link5_MP4_size = 375 M | ||
| video_notes5 = | | video_notes5 = | ||
| video_download_link6_MP4 = | | video_download_link6_MP4 = http://learnche.mcmaster.ca/media/4C3-2013-Class-08A.mp4 | ||
| video_download_link6_MP4_size = M | | video_download_link6_MP4_size = 372 M | ||
| video_notes6 = | | video_notes6 = | ||
| video_download_link7_MP4 = | | video_download_link7_MP4 = |
Revision as of 23:22, 5 March 2013
Class date(s): | 08 February 2013 to 07 March 2013 | ||||
(PDF) | Course slides | ||||
| |||||
| |||||
| |||||
| |||||
| |||||
| |||||
Course notes and slides
- Course textbook (print chapter 4)
- Slides for class
Software source code
Take a look at the software tutorial.
Code used in class
Least squares demo
x <- c(10, 8, 13, 9, 11, 14, 6, 4, 12, 7, 5)
y <- c(8.04, 6.95, 7.58, 8.81, 8.33, 9.96, 7.24, 4.26, 10.84, 4.82, 5.68)
plot(x,y)
model.ls <- lm(y ~ x)
summary(model.ls)
coef(model.ls)
confinf(model.ls)
names(model.ls)
model$resisduals
resid(model.ls)
plot(x, y)
abline(model.ls)
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")