• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
The Analysis Factor

The Analysis Factor

Statistical Consulting, Resources, and Statistics Workshops for Researchers

  • Home
  • Our Programs
    • Membership
    • Online Workshops
    • Free Webinars
    • Consulting Services
  • About
    • Our Team
    • Our Core Values
    • Our Privacy Policy
    • Employment
    • Collaborate with Us
  • Statistical Resources
  • Contact
  • Blog
  • Login

Specifying Fixed and Random Factors in Mixed Models

by Karen Grace-Martin 10 Comments

One of the difficult decisions in mixed modeling is deciding which factors are fixed and which are random. And as difficult as it is, it’s also very important. Correctly specifying the fixed and random factors of the model is vital to obtain accurate analyses.

Now, you may be thinking of the fixed and random effects in the model, rather than the factors themselves, as fixed or random. If so, remember that each term in the model (factor, covariate, interaction or other multiplicative term) has an effect. We’ll come back to how the model measures the effects for fixed and random factors.

Sadly, the definitions in many texts don’t help much with decisions to specify factors as fixed or random. Textbook examples are often artificial and hard to apply to the real, messy data you’re working with.

Here’s the real kicker. The same factor can often be fixed or random, depending on the researcher’s objective.

That’s right, there isn’t always a right or a wrong decision here. It depends on the inferences you want to make about this factor. This article outlines a different way to think about fixed and random factors.

An Example

Consider an experiment that examines beetle damage on cucumbers. The researcher replicates the experiment at five farms and on four fields at each farm.

There are two varieties of cucumbers, and the researcher measures beetle damage on each of 50 plants at the end of the season. The researcher wants to measure differences in how much damage the two varieties sustain.

The experiment then has the following factors: VARIETY, FARM, and FIELD.

Fixed factors can be thought of in terms of differences.

The effect of a categorical fixed factor is measured by differences from the overall mean.

The effect of a continuous fixed predictor (usually called a covariate) is defined by its slope–how the mean of the dependent variable differs with differing values of the predictor.

The output for fixed predictors, then, gives estimates for mean-differences or slopes.

Conclusions regarding fixed factors are particular to the values of these factors. For example, if one variety of cucumber has significantly less damage than the other, you can make conclusions about these two varieties. This says nothing about cucumber varieties that were not tested.

Random factors, on the other hand, are defined by a distribution and not by differences.

The values of a random factor are assumed to be chosen from a population with a normal distribution with a certain variance.

The output for a random factor is an estimate of this variance and not a set of differences from a mean. Effects of random factors are measured in terms of variance, not mean differences.

For example, we may find that the variance among fields makes up a certain percentage of the overall variance in beetle damage. But we’re not measuring how much higher the beetle damage is in one field compared to another. We only care that they vary, not how much they differ.

Software specification of fixed and random factors

Before we get into specifying factors as fixed and random, please note:

When you’re specifying random effects in software, like intercepts and slopes, the random factor is itself the Subject variable in your software. This differs in different software procedures. Some specifically ask for code like “Subject=FARM.” Others just put FARM after a || or some other indicator of the subject for which random intercepts and slopes are measured.

Some software, like SAS and SPSS, allow you to specify the random factors two ways. One is to list the random effects (like intercept) along with the random factor listed as a subject.

/Random Intercept | Subject(Farm)

The other is to list the random factors themselves.

/Random Farm

Both of those give you the same output.

Other software, like R and Stata, only allow the former. And neither uses the term “Subject” anywhere. But that random factor, the subject, still needs to be specified after the | or || in the random part of the model.

Specifying fixed effects is pretty straightforward.

Situations that indicate a factor should be specified as fixed:

1. The factor is the primary treatment that you want to compare.

In our example, VARIETY is definitely fixed as the researcher wants to compare the mean beetle damage on the two varieties.

2. The factor is a secondary control variable, and you want to control for differences in the specific values of this factor.

Say the researcher chose these farms specifically for some feature they had, such as specific soil types or topographies that may affect beetle damage. If the researcher wants to compare the farms as representatives of those soil types, then FARM should be fixed.

3. The factor has only two values.

Even if everything else indicates that a factor should be random, if it has only two values, the variance cannot be calculated, and it should be fixed.

Situations that indicate random factors:

1. Your interest is in quantifying how much of the overall variance to attribute to this factor.

If you want to know how much of the variation in beetle damage you can attribute to the farm at which the damage took place, FARM would be random.

2. Your interest is not in knowing which specific means differ, but you want to account for the variation in this factor.

If the farms were chosen at random, FARM should be random.

This choice of the specific farms involved in the study is key. If you can rerun the study using different specific farms–different values of the Farm factor–and still be able to draw the same conclusions, then Farm should be random. However, if you want to compare or control for these particular farms, then Farm is a fixed factor.

3. You would like to generalize the conclusions about this factor to the whole population.

There is nothing about comparing these specific fields that is of interest to the researcher. Rather, the researcher wants to generalize the results of this experiment to all fields, so FIELD is random.

4. Any interaction with a random factor is also random.

How the factors of a model are specified can have great influence on the results of the analysis and on the conclusions drawn.

 

 

Fixed and Random Factors in Mixed Models
One of the hardest parts of mixed models is understanding which factors to make fixed and which to make random. Learn the important criteria to help you decide.

Tagged With: Fixed Factor, mixed model, multilevel model, Proc Mixed, Random Factor, S-Plus, SAS, SPSS, Stata

Related Posts

  • Multilevel, Hierarchical, and Mixed Models–Questions about Terminology
  • The Difference Between Random Factors and Random Effects
  • Confusing Statistical Terms #3: Level
  • The Difference Between Crossed and Nested Factors

Reader Interactions

Comments

  1. Theresa says

    January 27, 2022 at 1:54 pm

    Dear Karen ,
    Thank you so much for this explanation , I’ve been trying to think of which of my variables in my model should be used as a random factor but to no avail not until I read this your note that I’m able to specify a random factor in my analysis .

    Reply
  2. Matey says

    August 10, 2020 at 7:05 pm

    Can one use the SPSS soft ware to run Hausman Test?

    Reply
  3. Richard Anderson says

    May 30, 2020 at 10:51 am

    Thank you. Note however that you can calculate the variance across the levels of a variable even if there are only two levels. The variance is simply the mean of the squared deviations from the mean. Thus for example, if the sampled levels of a variable are 14 and 17, then the population variance estimate is 4.7.

    Reply
    • Karen Grace-Martin says

      November 3, 2020 at 1:07 pm

      Hi Richard,

      Yes, absolutely. If you’re just calculating the descriptive variance outside of a model, this works. But in the context of a mixed model, you’re going to run out of df.

      Reply
  4. Ray says

    October 31, 2019 at 1:42 pm

    I have a question on mixed models using spss. How can one probe a continuous x continuos interaction at +-1Sd im spss? I know it can be done in r and jamovi easily, but wanted to know if you knew how this would be done in spss. Thank you!

    Reply
  5. Obinna says

    July 1, 2019 at 7:57 am

    Thank you very much, Karen, for this article. I have been trying for days to understand which of my factors to make fixed or random until I read your article. It is very clear now. You are indeed making an impact. Thank you.

    Reply
    • Karen Grace-Martin says

      August 22, 2019 at 1:33 pm

      Thanks, Obinna! Very glad it’s helpful.

      Reply
  6. sri yuliana says

    December 26, 2018 at 3:11 am

    thanks for the information,
    my question is if i have 2 kind of respondences 1=patient 2 =caregivers. “can I use that for fixed variable”?

    Reply
  7. C.A. Moffet says

    October 18, 2016 at 1:12 pm

    Thanks for your article. I have one question about one of the situations that indicate a fixed factor. If a researcher would like to compare farms as representatives of select soil types, would it not make more sense and reduce confusion if the researcher called the factor what it represents, in this case, soil type, rather than to continue calling the factor FARM? The levels, of course, should be changed to appropriate values as well, for example, farm=A might now be soil type=clay loam and farm = B might now be soil type = sand, etc.

    Reply
    • Karen Grace-Martin says

      December 13, 2018 at 1:33 pm

      Hi Corey,

      Certainly. In that design, Farm and Soil Type would be confounded, in fact. The reality is that those farms will differ on other factors as well, and you may or may not have measured those.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Please note that, due to the large number of comments submitted, any questions on problems related to a personal study/project will not be answered. We suggest joining Statistically Speaking, where you have access to a private forum and more resources 24/7.

Primary Sidebar

This Month’s Statistically Speaking Live Training

  • Member Training: Introduction to SPSS Software Tutorial

Upcoming Free Webinars

Poisson and Negative Binomial Regression Models for Count Data

Upcoming Workshops

  • Analyzing Count Data: Poisson, Negative Binomial, and Other Essential Models (Jul 2022)
  • Introduction to Generalized Linear Mixed Models (Jul 2022)

Copyright © 2008–2022 The Analysis Factor, LLC. All rights reserved.
877-272-8096   Contact Us

The Analysis Factor uses cookies to ensure that we give you the best experience of our website. If you continue we assume that you consent to receive cookies on all websites from The Analysis Factor.
Continue Privacy Policy
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT