What Is a Random Effect? Explained Without Formulas

In short

A random effect is not a "random" effect in the everyday sense. It is how you tell the model that your observations arrived in groups and that those groups are a sample, not the full list. The practical difference from a fixed effect is what each one hands back. A fixed effect estimates a number you care about in its own right (how much better the treatment arm does than the control arm); a random effect estimates no individual numbers you care about, it estimates how far the groups sit from each other and summarizes that spread as a standard deviation. You need one whenever two observations from the same box — two patients at the same hospital, two measurements from the same person, two pupils in the same classroom — resemble each other more than two picked at random, because that breaks the independence assumption and leaves your standard errors far too small. A random intercept says each group starts at a different level; a random slope says the effect you are studying is not the same size in every group.

You have spent two weeks reading about mixed models and you still cannot answer the one question blocking you: what goes in as random? Textbooks define it with matrices, a reviewer asks for "by-participant random intercepts" without saying why, and every tutorial uses the same sleep-deprivation reaction-time dataset. There is not a single matrix here. You will leave knowing what separates a fixed effect from a random one, what each looks like in a real health study, how a random intercept differs from a random slope, and how to decide whether your own design needs one.

Your data almost never arrive one at a time

Everything you learned first — the t test, ANOVA, regression — rests on an assumption that fits in one line: every observation carries new information, independent of the others. In health research that is almost never true. You recruit across six trial sites. You measure the same person four times. You hand the scale to whole classrooms because the school will not let you pull pupils out one by one. In all three cases the data arrive in boxes, and inside each box the observations resemble each other.

Two patients at the same hospital share a protocol, a staffing level, a waiting list and a catchment area. Two measurements from the same person share the entire person: their history, the way they read questionnaire items, their habit of ticking the extremes. Two pupils in the same classroom share a teacher, a timetable and each other. That resemblance has a name and a number: the intraclass correlation coefficient, ICC, the share of the total variation that lives between boxes rather than within them.

Ignore the boxes and the model believes it has more independent information than you actually collected. Standard errors come out small, intervals narrow and p values generous. This is not a third-decimal quibble: with 40 patients per site and an ICC of just .05, the effective information in your sample drops to about a third, so 800 patients behave like 271. A test that lands at p = .01 when you treat them as independent can evaporate once the clustering is counted properly. That direction — standard errors that are too small — holds for whatever you compare between boxes, which is usually exactly what you care about: the treatment arm, the type of site. For a predictor that varies inside the box the bias can run the other way; the underlying problem is the same one, that the model does not know which row came from where.

A random effect is how you tell the model where the boxes are. It is not a statistical patch or a reviewer’s whim: it is part of describing how you collected the data, exactly as the design is. And like the rest of your assumptions, it is far cheaper to settle while you are planning than once the manuscript is written and someone asks.

Fixed or random: the question that settles it

Drop the definitions you have read. The working question is this: are the levels sitting in your dataset the ones you care about, or are they a sample from a wider family? Treatment and control are the ones you care about — run the study again and you still have treatment and control. The six sites are not: run it again in another region and they would be six different sites, and what you want to survive is a conclusion about hospitals in general, not about those six. The first kind goes in as fixed; the second, as random.

What each gives back differs too. A fixed effect returns a number per level, and that number is the result: the group difference, the slope for age, the coefficient you defend in the discussion. A random effect returns a standard deviation: how far the sites sit from one another once everything else is accounted for. It is a different kind of result, which is why it is not read as a coefficient or discussed as "significant". You can test it — the small print is further down — but the test is not what makes it worth having.

If the vocabulary has been confusing you, that is not your fault. Gelman (2005) collected five definitions of "fixed" and "random" circulating in the literature at the same time, contradicting each other; in econometrics, "fixed effects" means close to the opposite of what it means here. So decide with the question above — do I care about this specific level, or about the variation across levels? — rather than with whichever label your textbook happens to use.

One practical constraint the definitions leave out: to estimate how much groups vary, you need groups. Three or four will not do it, in the same way you cannot estimate a decent standard deviation from four people. The rules of thumb in circulation run from Kreft’s (1996) "30 groups of 30" to Maas and Hox (2005), who found the standard errors of the level-2 variance running too small below roughly 50 groups. None of these is a law; they are rules of thumb. Where almost everyone does agree is the floor: with fewer than five groups, that factor goes in as fixed or does not go in at all.

Three structures you meet every week in health research

Patients within sites. The textbook case. You recruit across several hospitals, the site goes in as random and the treatment, which is what you care about, goes in as fixed. Watch one common trap: if the intervention is allocated by whole site — everyone at site A gets the program, everyone at site B gets usual care — your power is driven by the number of sites, not the number of patients. Fifty extra patients at the same site add far less information than the sample size suggests.

Measurements within patients. Here the box is the person. Four measurements (baseline, post, 3 months, 12 months) from 90 patients are not 360 independent data points; they are 90 people measured four times. Participant goes in as random, time point as fixed. This is the same ground repeated-measures ANOVA covers, with two advantages that matter in clinical work: a mixed model tolerates missing waves and unequal timing without discarding the whole patient. The full comparison is in mixed models versus repeated-measures ANOVA.

Pupils within classrooms within schools. Three levels, and here the clustering is not cosmetic: for academic attainment, published school-level values tend to sit between .10 and .25 (Hedges and Hedberg, 2007). At that size, ignoring the classroom does not shift your third decimal, it shifts your conclusion. The same applies to school-based wellbeing and bullying studies, which are recruited class by class for purely logistical reasons.

The one that slips past everybody: crossed structures. If twenty therapists see patients from both arms, the therapist is not nested within arm, it crosses it. And if your experiment shows each participant 30 faces or 40 clinical vignettes, the stimuli are also a sample from a wider family. Judd, Westfall and Kenny (2012) showed that treating them as fixed inflates the false positive rate well beyond the nominal 5%, and that error has been getting published in experimental psychology for decades.

Random intercept: every group starts somewhere different

Picture your scatterplot with one line drawn inside each site. A random intercept says those lines are parallel but sit at different heights: the district general hospital admits more severe cases, the teaching hospital sees less comorbidity, the private clinic has a shorter waiting list. The model does not ask you to explain why. You tell it the starting height changes from site to site, and it estimates by how much.

What comes out is a single number: the standard deviation between sites. If your outcome is a 0-63 depression scale and the between-site SD is 3.2, what you are saying is that roughly two thirds of the sites fall inside a band about six and a half points wide — the mean ±1 SD — before anything that happens inside them is counted. Compare that with the residual standard deviation, the one for patients within the same site, and you have the ICC: the share of the total taken up simply by which door the patient walked through.

Yes, you can look at each site’s own number, but these are not raw means. The model shrinks them toward the overall mean in proportion to how little it knows about each: a site with 6 patients sits close to the grand mean, a site with 300 stays near where its own data put it. That shrinkage is not smoothing for the sake of it. It is what stops the site with six patients and two lucky outcomes from appearing as the best hospital in the study.

With a random intercept alone you are assuming something specific: that the effect you care about — the treatment, the passage of time, age — is exactly the same size in every group, and that the only thing changing between them is the starting point. Sometimes that is defensible and enough. When it is not, you need the slope.

Random slope: the effect is not the same everywhere

Back to the lines. A random slope tilts them: they stop being parallel. It says the treatment works better at some sites than others, or that some patients improve faster than others across follow-up. You are still not estimating each site’s effect as your headline result; you are estimating how much that effect varies from site to site, which is a genuinely different clinical question and often a more interesting one.

Not everything can carry a random slope, and the rule is mechanical. Only a variable that varies within the groups can. Follow-up time varies within each patient, so a by-patient slope for time is possible. Hospital type, public or private, does not vary within a hospital: by definition there are no two values inside the same box, so that line has nothing to tilt against. When your software reports an impossible model, this is often what happened.

Leaving out a random slope that is genuinely there has a consequence, and it has a direction: the standard error of the matching fixed effect comes out too small and its p value too optimistic (Schielzeth and Forstmeier, 2009). Barr, Levy, Scheepers and Tily (2013) pushed the argument to its limit with "keep it maximal": fit every random term the design justifies. Matuschek et al. (2017) later showed that with small samples the maximal structure costs you power and convergence. Sensible practice sits between them: fit the slopes the design justifies, trim only what the data cannot support, and say in the method what you trimmed and why.

The model also estimates the correlation between intercept and slope, that is, whether the sites starting worst are the ones improving most. That is real clinical information, not a decorative parameter. It is also the first thing to break when you are short of groups: a correlation of exactly 1.00 or −1.00 is the model telling you it has no data to estimate it, not a law of nature you have discovered.

How to tell whether you need one

Start with the software closed. Write down on paper what sits inside what. Every time one unit contributes more than one row to your dataset — a person measured twice, a classroom of twenty, a therapist with nine clients, a site with forty patients — you have a candidate random effect. If the sketch turns up no grouping at all, you do not need a mixed model, and fitting one just in case will only buy you convergence warnings.

The second step is quantitative, and it is the only arithmetic in this article. Fit the empty model — the grouping and nothing else, no predictors — and read the ICC. With that and your average group size you get the design effect: 1 + (n − 1) × ICC. That is the number your sample gets divided by to know how much independent information you really hold. With 25 patients per site and an ICC of .04 it comes to 1.96, so half your sample. You can get the ICC from the ICC calculator — it works with the same variance ratio used for interrater agreement, the share of the total taken by the grouping — and check how to report it in APA 7.

You will read that the decision is made with a likelihood ratio test comparing the model with and without the random term. Use it if you like, knowing two things. First, the null sits on the boundary of the parameter space, because a variance cannot be negative, so the usual p value is conservative (Stram and Lee, 1994). Second, and more important, a small ICC does not license you to ignore clustering when the groups are large. With 200 patients per site, an ICC of .01 gives a design effect of 2.99. Clustering is a fact about your design; it does not vanish because a test failed to reach .05.

The short version, for almost everything you will meet. If the same participant contributes several rows, participant goes in as random and there is nothing to debate. If you recruited across five sites or more, site does too. With two or three sites, put them in as fixed and say so. And if recruitment was by cluster — the whole class, the whole ward, the whole GP list — you declare the grouping even when the ICC comes out low, because the design imposed it, not the data.

What breaks if you ignore it, and what breaks if you overdo it

Ignoring the clustering produces false positives, and that is the error reviewers complain about. It produces a quieter one too: confusing the level at which the relationship happens. Sites that deliver more sessions per patient having better outcomes does not mean an individual patient given more sessions will improve more. Those are two questions at two levels, and a model that does not separate them blends both into one coefficient that answers neither. You separate them by centering the variable within each group, and it is one of the highest-return moves available for the effort involved.

Overdoing it has its own catalog of failures, and they all speak the same language. The model does not converge. A variance component is estimated at zero. A singular fit warning appears. Correlations between random terms run to ±1. Nearly always they mean the same thing: you asked the data for more structure than it can carry. The way out is not switching optimizers until the warning stops, it is trimming the structure back to what the design requires and saying so in the method.

When you write it up, describe the random structure in a sentence someone else could replicate: what is nested in what, what carries an intercept, what carries a slope, what you dropped for convergence. In the results, give the standard deviation of each component and the ICC. And be careful with R2: a mixed model has two, marginal (fixed effects only) and conditional (fixed plus random). They answer different questions, so the part that is not optional is saying which of the two you are reporting (Nakagawa and Schielzeth, 2013).

If the person who brought the word "random" into your life is a reviewer, the comment usually translates into one of two worries: either they spotted that your observations are clustered and your standard errors have not noticed, or they spotted that you are presenting an average effect across sites that visibly behave differently. Answering the worry underneath is worth more than bolting a term onto the model; when a reviewer asks for an analysis you do not know, understanding the concern beats the syntax every time.

Frequently asked questions

How many groups do I need before I can fit a random effect?

There is no legal minimum, but there is a practical floor: below about five groups the between-group variance comes out wild and you are better off entering the factor as fixed. The references people cite run from Kreft’s (1996) "30 groups of 30" to Maas and Hox (2005), who found downwardly biased standard errors for the level-2 variance below roughly 50 groups. With few clusters there are options: Kenward-Roger degrees of freedom corrections, cluster-robust standard errors, or Bayesian estimation with sensible priors (McNeish and Stapleton, 2016). What does not work is estimating a variance from four points and reporting it straight.

Can I put site in as a fixed effect with dummy variables instead?

You can, and with two or three sites that is the right call. Two things change. You spend one parameter per site minus one, which gets expensive at twenty sites. And your conclusions stay with those specific sites: you are describing yours, not generalizing to hospitals at large. There is a third consequence that catches people out: if you care about a variable that only varies between sites (hospital size, teaching status), you cannot estimate it with site as fixed, because the dummies have already absorbed it.

How do I know whether I need a random slope or just a random intercept?

Design first: if a predictor varies within groups and you have any reason to think its effect is not identical everywhere, the slope is justified and goes in. Data second: fit with and without, look at whether the slope’s standard deviation is appreciable next to the fixed effect itself (a slope SD close to the average effect means the effect shrinks to nothing or flips sign in some groups), and check whether the model holds. If it will not converge or the variance collapses to zero, trim and write down that you did.

Is a random effect the same thing as a mixed model?

A mixed model is one that mixes both kinds: at least one fixed effect and at least one random effect. The random effect is the component; the mixed model is the whole apparatus. The names shift with the field telling the story — multilevel, hierarchical, mixed-effects, random coefficients — but the machinery is identical. If one person says "make it multilevel" and another says "add a random effect of site", they are asking for the same thing.

My model will not converge, or a variance is estimated at zero. What now?

It is nearly always too much structure rather than a software problem. Work in order: drop the correlations between random terms first, then the least justified slopes, and keep the intercept until last. Check that the grouping variable has enough levels and that every slope you fitted belongs to a predictor that genuinely varies within groups. Center and scale your continuous predictors, which clears more warnings than you would expect. Cycling through optimizers until the complaint stops is the last resort and the worst one: the warning was telling you something.

Is this the same as the random-effects model in a meta-analysis?

Same idea in different clothing. In a random-effects meta-analysis the study plays the role of the group: instead of assuming every study estimates one single true effect, you assume the true effect varies from study to study and you estimate how much it varies. You do not care about each study’s own number for its own sake, you care about the spread, exactly as with sites. That shared logic is why a meta-analysis with several effects per study is called, with no metaphor involved, multilevel.

What goes in as random in YOUR model?

Every decision above is made with your own design on the table, not from a general rule: how many sites you actually have, whether therapists cross both arms, whether twelve classrooms will carry a random slope or only an intercept, whether what the reviewer is asking for fits the sample you already collected. That is exactly what statistical consulting is for here: we look at the real structure of your data, settle what goes in fixed and what goes in random with a justification that holds up, and you walk away with the method sentence already written.

Tell me about your design →

Keep the question that settles almost every case: are the levels I have the ones I care about, or a sample from a wider family? The first goes in fixed, the second goes in random. The intercept says where each group starts, the slope says whether the effect changes from group to group, and the ICC tells you whether any of this mattered in your data. If you want the full treatment, three levels and syntax included, carry on with the multilevel models guide.

Cite this guide

Ciudad-Fernández, V. (2026, September 4). What Is a Random Effect? Explained Without Formulas. Ciudad Science. https://analisisdedatospsicologia.com/en/blog/what-is-a-random-effect

Keep reading

All blog articles