Load the carbig sample data set.
The variables Acceleration and Displacement contain data for car acceleration and displacement, respectively. The variable Cylinders contains data for the number of cylinders in each car engine.
Create a table from the car data variables using the table function.
tbl=406×3 table
Acceleration Displacement Cylinders
____________ ____________ _________
12 307 8
11.5 350 8
11 318 8
12 304 8
10.5 302 8
10 429 8
9 454 8
8.5 440 8
10 455 8
8.5 390 8
17.5 133 4
11.5 350 8
11 351 8
10.5 383 8
11 360 8
10 383 8
⋮
The Cylinders data has an inherent ordering. Fit an ordinal multinomial regression model using Acceleration and Displacement as predictor variables and Cylinders as the response.
mdl is a multinomial regression model object that contains the results of fitting an ordinal multinomial regression model to the data.
Predict the response category, cumulative category probabilities, and 99% confidence interval bounds for a car with an acceleration of 16 and an engine displacement of 80.
cumprobs = 1×4
0.0792 1.0000 1.0000 1.0000
lower = 1×4
0.0787 1.0000 1.0000 1.0000
upper = 1×4
0.0798 1.0000 1.0000 1.0000
The output shows that the predicted response category is 4. The vector cumprobs shows the cumulative probabilities for each category in Cylinders. To view the category probabilities on which the prediction is based, calculate the category probabilities.
catprobs = 1×5
0.0792 0.9208 0.0000 0.0000 0.0000
The second value in the vector catprobs has the highest probability. Display an ordered list of the categories in Cylinders.
The output shows that the second category corresponds to cars with four cylinders. Therefore, the category with the highest category probability is 4.