If I create a linear model where Trial number is one of the predictors, am I losing any information by treating it as continuous (when in fact it is actually discrete + ordinal)? I believe the answer is no, but my google-fu fails to find a good explanation of why.

EDIT to add: there are between 16-48 trials per block in the current set of analyses.

MORE EDITS to add: Blocks terminated after a minimum number of trials (16) and a criterion was reached (10 of previous 12 trials correct) or after 48 trials, whichever came first.

There are two types of analyses I'm performing:

(1) forward learning curves from the start of the block, which only go up to trial 16 (and thus there is no missing data).

(2) backward learning curves where trial number is normalized to the point at which a criterion was met (not the same as block termination criterion, but close enough) on a particular trial, which we call Learning Point (LP). Then trials are LP-2, LP-1, LP, LP+1, etc. The issue is that the further away you get from LP, the fewer trials are left in the data set (technically there can be an LP-23, but there are very few participants who have one). So I'm trying to run a learning-centred analysis that allows for missing data (hence using linear mixed models instead of ANOVA etc).

I'm using mat labs fitlme function, and the results of my model differ if I say that trial is ordinal vs if I leave it as a continuous variable (the default). Not in any way that actually matters to the qualitative pattern of results, but I'd like to be statistically rigorous about this.

EDIT: I'm using a mixed model with Subject as a random effect and Trial as fixed. My inclination is to treat Trial as continuous rather than ordinal because a difference of, e.g. 3 trials is half the distance between 6 trials, which is not the case if I treat it as ordinal.

  • $\begingroup$ How many trial numbers do you have? That's important for determining the best way to proceed. $\endgroup$
    – EdM
    Oct 3, 2019 at 14:24
  • $\begingroup$ Added that info to question: 16-48. $\endgroup$ Oct 4, 2019 at 15:18
  • $\begingroup$ No information is lost because the transformation from ordinal values to real/continuous values is invertible--given a real-valued trial number, you can always tell what trial it is. But, perhaps you actually want to ask about the validity of treating ordinal values as continuous, rather than information loss? $\endgroup$
    – user20160
    Oct 4, 2019 at 16:56
  • $\begingroup$ Thanks for the clarification. Why did the number of trials differ among blocks? That might pose a problem with using Trial Number as a predictor, for example if trials continued until a success or if participants chose to gave up at different times. Please say more about the overall design of the study and its intended purpose. $\endgroup$
    – EdM
    Oct 4, 2019 at 16:57
  • $\begingroup$ New edits to cover questions from user20160 and EdM. $\endgroup$ Oct 5, 2019 at 14:21

1 Answer 1


Treating ordered categorical predictors as continuous is discussed extensively on this page. With a fairly large number of ordered levels for your trial numbers you have the following two extreme approaches:

Treating trial number as a continuous predictor will only use up one degree of freedom in the analysis, but at the cost of assuming that a 1-unit change in trial number has the same effect on outcome (continuous for ordinary linear regression, log-odds for logistic regression), regardless of trial number (other things being equal). That is the critical issue with respect to "validity" of that approach, although you can test that linearity assumption in the same way you test the linearity assumption about any predictor in a regression.

At the other extreme, treating trial number as a categorical (albeit ordered) predictor will use up a large number of degrees of freedom: for 16 trial numbers, 15 degrees of freedom. That can reduce the power of your analysis substantially and runs a risk of overfitting unless you have very many subjects.

There are, however, useful intermediate choices you could make. These are compatible with mixed models of the type you wish to build.

You could use a restricted cubic spline to fit a reasonably smooth function of trial number as part of the regression. That provides flexibility in the relationship between outcome and trial number while only using up a few degrees of freedom, depending on the number of knots you specify. A quick search shows a MATLAB implementation of this approach.

Another intermediate choice, discussed on this page with several references, is to penalize the coefficients for the ordered categorical variable in a way that effectively reduces the number of degrees of freedom used up and thus the danger of overfitting when you have a large number of categories. That's implemented in the ordPens package in R, with some background to the approach described in this paper.

So to answer your question: yes, treating trial number as a continuous predictor could lose some information. How much that matters, and whether other alternatives to full categorical coding could be useful, will depend on your data and on your study design. Remember: "All models are wrong, but some are useful."

  • $\begingroup$ Thank you, this is the kind of answer I was hoping for. $\endgroup$ Oct 9, 2019 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.