Alexandre Rodichevski
2015-02-21
It is well known that the greater the car's speed, the higher is the arrest distance.
This Shiny online application estimates the distance taken to stop a moving car. The user inserts the car's speed and obtains the distance. Furthermore, the user selects one of two regression models used in the estimation.
The application uses R dataset cars containing a collection of the speed of cars and the distances taken to stop.
There follows a bief description of the dataset.
str(cars)
'data.frame': 50 obs. of 2 variables:
$ speed: num 4 4 7 7 8 9 10 10 10 11 ...
$ dist : num 2 10 4 22 16 10 18 26 34 17 ...
The application approximates this data fitting the regression model. The model is selected by the user between linear and quadratic forms.
The linear form is: \( dist = \alpha + \beta * speed \)
model1 <- lm(dist ~ speed, cars)
The quadratic form is: \( dist = \gamma * speed^2 \)
cars$speed2 <- cars$speed^2
model2 <- lm(dist ~ speed2 - 1, cars)
The following plot shows the cars dataset and two approximations used.