Data Types
Study guides: Exam PA, Exam MAS-I, DISC-DA, Exam ACIA-CAPSTONE
A Data Type is the class a variable belongs to according to the values it can take. A variable's data type decides which plots describe it, how it enters a model as a predictor, and which distribution can model it as a response. The data types are:
- Numeric variables, whose values are measurements or counts:
- A continuous variable takes any value in an interval, such as claim severity or amount of insurance.
- A discrete variable takes integer values, such as the number of claims on a policy.
- Categorical variables, whose values are levels:
- A nominal variable has levels that are labels with no meaningful order or spacing, such as territory, vehicle make or a class code.
- An ordinal variable has levels with a meaningful order, such as credit tiers, but the spacing between levels need not be equal.
- A binary variable has two levels, such as renewed or lapsed.
The MAS-I learning objectives distinguish categorical, ordinal and continuous predictors. There, categorical means a nominal variable.
A policy file has the columns
veh_age(whole years),territory(stored as the integers 1 to 8),credit_tier(A to E),n_claims,incurredandrenewed(Y or N). What is the data type of each column?
veh_ageis discrete numeric, and it is usually treated as continuous.territoryis nominal, because its codes are labels even though they are stored as integers.credit_tieris ordinal, because the tiers are ordered but the steps between them need not be equal.n_claimsis a discrete count.incurredis continuous, with a mass of policies at zero.renewedis binary.
Storage type and data type
The way a variable is stored does not decide its data type. A territory stored as the integers 1 to 8 is nominal, and an identifier code counts nothing. Statistical software reads what the file holds, so a categorical variable stored as numbers must be declared categorical, as a factor in R or a category in pandas.
Data types as predictors
A numeric predictor enters a model with one coefficient, which assumes the same effect for each one-unit step in its value. A categorical predictor with k levels enters a model with an intercept as k - 1 indicator variables. One level, the base level, has no indicator, because a full set of k indicators would be collinear with the intercept. Each other level then has its own coefficient.
A categorical variable coded as a single number is fitted with one slope across its arbitrarily ordered codes. A level with few observations has a coefficient with a large standard error, so an apparent difference at that level should be confirmed, or given credibility weight, before it is fully priced.
A Poisson frequency GLM with a log link was fitted with
territory(codes 1 to 8) left numeric, and its coefficient is\hat = 0.05. What relativity does the model imply between territory 8 and territory 1?
- A one-step increase in the code multiplies the fitted mean by
e^{0.05} = 1.051.- From territory 1 to territory 8 is seven steps, so the relativity is
e^{0.05 \times 7} = e^{0.35} = 1.419.- The model forces every territory to be 1.051 times the territory numbered below it, an order set by whoever assigned the codes.
- Declared categorical, territory has 7 coefficients, each estimated from its own territory's data.
Data types as responses
The data type of the response points to its distribution. A discrete count, such as a number of claims, is modeled with a count distribution such as the Poisson. A positive, right-skewed continuous amount is modeled with a Gamma distribution, and a binary response with a binomial distribution. The choice of distribution and link lists the usual pairs.
Plots for each data type
The first plot of a variable depends on its data type.
| Data type | Univariate plot | Plot against a numeric response |
|---|---|---|
| Continuous | Histogram, of the logarithm when the variable is right-skewed | Scatter plot |
| Discrete count | Bar chart with one bar per value, showing the share of zeros | Scatter plot or box plots by value |
| Categorical | Bar chart of counts or exposure by level, revealing levels with little data | Side-by-side box plots, one per level |
The Histogram, the box plot, the scatter plot and the univariate plot each have their own page.
Treating a numeric code as a measurement Territory codes, class codes and ZIP codes are stored as numbers but are labels. Fitting such a code with one slope assumes that territory 8 differs from territory 1 by seven equal steps.