Keywords: R-car stopping distances 1920+null.svg en A graph of car stopping distances fitted with a simple null model and residual plot Own HYanWong Created with R using the following commands <pre> svg R-car_stopping_distances_1920+null svg 8 4 8 layout t 1 2 par mar c 5 4 1 2 + 0 1 cars speed kph <- cars speed 1 609344 cars dist m <- cars dist 0 3048 plot dist m ~ speed kph data cars xlab Speed km/h ylab Stopping distance m las 1 null model <- lm dist m~1 data cars This creates and stores a model lm means Linear Model abline null model col red abline is a simple function that plots a straight line segments cars speed kph fitted values null model cars speed kph fitted values null model +residuals null model col lightblue par mar c 5 5 1 1 + 0 1 plot residuals null model type h ylim c -25 25 bty n xaxt n las 2 xlab NA ylab residual stopping distance m col lightblue grid NA NULL abline h 0 points residuals null model dev off </pre> Uncategorized 2015 March 23 |