Next: , Previous: , Up: octave.dataset   [Contents]


8.2.45.11 octave.dataset.cars

Static Method: out = cars ()

Speed and Stopping Distances of Cars

Description

Speed of cars and distances taken to stop. Note that the data were recorded in the 1920s.

Format

speed

Speed (mph).

dist

Stopping distance (ft).

Source

Ezekiel, M. (1930). Methods of Correlation Analysis. New York: Wiley.

References

McNeil, D. R. (1977). Interactive Data Analysis. New York: Wiley.

Examples


t = octave.dataset.cars;


# TODO: Add Lowess smoothed lines to the plots

figure;
plot (t.speed, t.dist, "o");
xlabel ("Speed (mph)"); ylabel("Stopping distance (ft)");
title ("cars data");

figure;
loglog (t.speed, t.dist, "o");
xlabel ("Speed (mph)"); ylabel("Stopping distance (ft)");
title ("cars data (logarithmic scales)");

# TODO: Do the linear model plot

# Polynomial regression
figure;
plot (t.speed, t.dist, "o");
xlabel ("Speed (mph)"); ylabel("Stopping distance (ft)");
title ("cars polynomial regressions");
hold on
xlim ([0 25]);
x2 = linspace (0, 25, 200);
for degree = 1:4
  [P, S, mu] = polyfit (t.speed, t.dist, degree);
  y2 = polyval(P, x2, [], mu);
  plot (x2, y2);
endfor