40
$\begingroup$

I'm slightly confused if an independent variable (also called predictor or feature) in a statistical model, for example the $X$ in linear regression $Y=\beta_0+\beta_1 X$, is a random variable ?

$\endgroup$
3
  • 13
    $\begingroup$ The linear model is conditional on $X$, hence whether or not it is random should not matter. $\endgroup$
    – Xi'an
    Commented Nov 15, 2016 at 12:25
  • 7
    $\begingroup$ Check this. Good question, BTW. $\endgroup$ Commented Nov 15, 2016 at 13:28
  • 1
    $\begingroup$ @Xi'an, in the fixed design the linear model assumptions are not conditioned on $X$, see my answer. So, it does matter a lot. That is the reason why experiments are so much easier to interpret than observational study results $\endgroup$
    – Aksakal
    Commented Sep 19, 2017 at 13:55

4 Answers 4

28
$\begingroup$

There are two common formulations of linear regression. To focus on the concepts, I will abstract them somewhat. The mathematical description is a little more involved than the English description, so let's begin with the latter:

Linear regression is a model in which a response $Y$ is assumed to be random with a distribution determined by regressors $X$ via a linear map $\beta(X)$ and, possibly, by other parameters $\theta$.

In most cases the set of possible distributions is a location family with parameters $\alpha$ and $\theta$ and $\beta(X)$ gives the parameter $\alpha$. The archetypical example is ordinary regression in which the set of distributions is the Normal family $\mathcal{N}(\mu, \sigma)$ and $\mu=\beta(X)$ is a linear function of the regressors.

Because I have not yet described this mathematically, it's still an open question what kinds of mathematical objects $X$, $Y$, $\beta$, and $\theta$ refer to--and I believe that is the main issue in this thread. Although one can make various (equivalent) choices, most will be equivalent to, or special cases, of the following description.


  1. Fixed regressors. The regressors are represented as real vectors $X\in\mathbb{R}^p$. The response is a random variable $Y:\Omega\to\mathbb{R}$ (where $\Omega$ is endowed with a sigma field and probability). The model is a function $f:\mathbb{R}\times\Theta\to M^d$ (or, if you like, a set of functions $\mathbb{R}\to M^d$ parameterized by $\Theta$). $M^d$ is a finite dimensional topological (usually second differentiable) submanifold (or submanifold-with-boundary) of dimension $d$ of the space of probability distributions. $f$ is usually taken to be continuous (or sufficiently differentiable). $\Theta\subset\mathbb{R}^{d-1}$ are the "nuisance parameters." It is supposed that the distribution of $Y$ is $f(\beta(X), \theta)$ for some unknown dual vector $\beta\in\mathbb{R}^{p*}$ (the "regression coefficients") and unknown $\theta\in\Theta$. We may write this $$Y \sim f(\beta(X), \theta).$$

  2. Random regressors. The regressors and response are a $p+1$ dimensional vector-valued random variable $Z = (X,Y): \Omega^\prime \to \mathbb{R}^p \times \mathbb{R}$. The model $f$ is the same kind of object as before, but now it gives the conditional probability $$ Y|X \sim f(\beta(X), \theta).$$

The mathematical description is useless without some prescription telling how it is intended to be applied to data. In the fixed regressor case we conceive of $X$ as being specified by the experimenter. Thus it might help to view $\Omega$ as a product $\mathbb{R}^p\times \Omega^\prime$ endowed with a product sigma algebra. The experimenter determines $X$ and nature determines (some unknown, abstract) $\omega\in\Omega^\prime$. In the random regressor case, nature determines $\omega\in\Omega^\prime$, the $X$-component of the random variable $\pi_X(Z(\omega))$ determines $X$ (which is "observed"), and we now have an ordered pair $(X(\omega), \omega)) \in \Omega$ exactly as in the fixed regressor case.


The archetypical example of multiple linear regression (which I will express using standard notation for the objects rather than this more general one) is that $$f(\beta(X), \sigma)=\mathcal{N}(\beta(x), \sigma)$$ for some constant $\sigma \in \Theta = \mathbb{R}^{+}$. As $x$ varies throughout $\mathbb{R}^p$, its image differentiably traces out a one-dimensional subset--a curve--in the two-dimensional manifold of Normal distributions.

When--in any fashion whatsoever--$\beta$ is estimated as $\hat\beta$ and $\sigma$ as $\hat\sigma$, the value of $\hat\beta(x)$ is the predicted value of $Y$ associated with $x$--whether $x$ is controlled by the experimenter (case 1) or is only observed (case 2). If we either set a value (case 1) or observe a realization (case 2) $x$ of $X$, then the response $Y$ associated with that $X$ is a random variable whose distribution is $\mathcal{N}(\beta(x), \sigma)$, which is unknown but estimated to be $\mathcal{N}(\hat\beta(x), \hat\sigma)$.

$\endgroup$
9
  • 2
    $\begingroup$ Let me just mention, that this is a fantastic answer (but probably not for everybody). $\endgroup$
    – l7ll7
    Commented Jan 14, 2017 at 23:48
  • 7
    $\begingroup$ P.S. Do you know of any book, where these foundational question are explained as precisely as you did here ? As a mathematician, all the books I found reflected the other answers here, that are much less precise from a mathematical point of view. (This doesn't make them bad, of course, it's just that those books are not for me - I would love a book that is more precise, like this answer.) $\endgroup$
    – l7ll7
    Commented Jan 15, 2017 at 0:24
  • $\begingroup$ In the first sentence of the last paragraph, isn't $\hat{\beta}(x)$ the predicted value for $y$ (a realization of the random variable $Y$), not the predicted value for $x$? Or have I misunderstood your language, and "predicted value for $x$" means "predicted value when $x$ is the set(observed) value of $X$?" $\endgroup$
    – ivme
    Commented Oct 18, 2019 at 5:51
  • 1
    $\begingroup$ @Chad Thank you for pointing out the ambiguous language. I have edited that sentence to clarify the meaning, which is consistent with your understanding. $\endgroup$
    – whuber
    Commented Oct 18, 2019 at 13:02
  • $\begingroup$ @whuber In the random regressors case, does it matter whether we condition on X, Y | X, or on Y, X | Y? I think for the purpose of estimating the most likely values of the parameters with MLE, it does not matter. The likelihood will be the same in both cases. Do you agree? $\endgroup$
    – Sanyo Mn
    Commented Feb 21, 2023 at 10:26
16
$\begingroup$

First of all, @whuber gave an excellent answer. I'll give it a different take, maybe simpler in some sense, also with a reference to a text.

MOTIVATION

$X$ can be random or fixed in the regression formulation. This depends on your problem. For so called observational studies it has to be random, and for experiments it usually is fixed.

Example one. I'm studying the impact of exposure to electron radiation on the hardness of a metal part. So, I take a few samples of the metal part and expose the to varying levels of radiation. My exposure level is X, and it's fixed, because I set to the levels that I chose. I fully control the conditions of the experiment, or at least try to. I can do the same with other parameters, such as temperature and humidity.

Example two. You're studying the impact of economy on frequency of occurrences of fraud in credit card applications. So, you regress the fraud event counts on GDP. You do not control GDP, you can't set to a desired level. Moreover, you probably want to look at multivariate regressions, so you have other variables such as unemployment, and now you have a combination of values in X, which you observe, but do not control. In this case X is random.

Example three. You are studying the efficacy of new pesticide in field, i.e. not in the lab conditions, but in the actual experimental farm. In this case you can control something, e.g. you can control the amount of pesticide to put. However, you do not control everything, e.g. weather or soil conditions. Ok, you can control the soil to some extent, but not completely. This is an in-between case, where some conditions are observed and some conditions are controlled. There's this entire field of study called experimental design that is really focused on this third case, where agriculture research is one of the biggest applications of it.

MATH

Here goes the mathematical part of an answer. There's a set of assumptions that are usually presented when studying linear regression, called Gauss-Markov conditions. They are very theoretical and nobody bothers to prove that they hold in any practical set up. However, they are very useful in understanding the limitations of ordinary least squares (OLS) method.

So, the set of assumptions is different for random and fixed X, which roughly correspond to observational vs. experimental studies. Roughly, because as I shown in the third example, sometimes we're really in-between the extremes. I found the "Gauss-Markov" theorem section in Encyclopedia of Research Design by Salkind is a good place to start, it's available in Google Books.

The differing assumptions of the fixed design are as follows for the usual regression model $Y=X\beta+\varepsilon$:

  • $E[\varepsilon]=0$
  • Homoscedasticity, $E[\varepsilon^2]=\sigma^2$
  • No serial correlation, $E[\varepsilon_i,\varepsilon_j]=0$

vs. the same assumptions in the random design:

  • $E[\varepsilon|X]=0$
  • Homoscedasticity, $E[\varepsilon^2|X]=\sigma^2$
  • No serial correlation, $E[\varepsilon_i,\varepsilon_j|X]=0$

As you can see the difference is in conditioning the assumptions on the design matrix for the random design. Conditioning makes these stronger assumptions. For instance, we are not just saying, like in fixed design, that the errors have zero mean; in random design we also say they're not dependent on X, covariates.

$\endgroup$
7
  • $\begingroup$ For your serial correlation notation, I think you meant to write it as a covariance or correlation instead of expectation? I've never seen expectation written like that before with multiple variables -- is it formal? $\endgroup$
    – 24n8
    Commented Jul 10, 2020 at 20:13
  • $\begingroup$ +1 Excellent answer. You might as well add that any econometrics textbook out there is likely assuming the Independent Variable to be a R.V. and any statistics textbook out there is either assuming the Independent Variable to be fixed or listing both possibilities but flushing out the experimental context more. $\endgroup$ Commented Jul 16, 2020 at 19:16
  • $\begingroup$ You have $\varepsilon$ in the the first two assumptions, but in the final assumptions they also feature a subscript. So does the final assumption only hold with respect to the regression model applied to sample data, and not to the regression model applied to the population? $\endgroup$ Commented Sep 25, 2020 at 13:30
  • $\begingroup$ I have asked a question related to this answer in this post: stats.stackexchange.com/questions/489132/… $\endgroup$ Commented Sep 25, 2020 at 13:46
  • $\begingroup$ Aksakal, because your nonstandard use of the term "serial correlation" is causing confusion, please consider changing the term. Simply striking "serial" ought to fix the problem. If you want to be clearer, you should explicitly quantify the subscripts, as in "No correlation: for all $i\ne j, E[\varepsilon_i\varepsilon_j\mid X]=0.$" (Note, too, the removal of the comma, whose presence is probably a typographical error.) $\endgroup$
    – whuber
    Commented Sep 28, 2020 at 14:18
7
$\begingroup$

In statistics a random variable is quantity that varies randomly in some way. You can find a good discussion in this excellent CV thread: What is meant by a “random variable”?

In a regression model, the predictor variables (X-variables, explanatory variables, covariates, etc.) are assumed to be fixed and known. They are not assumed to be random. All of the randomness in the model is assumed to be in the error term. Consider a simple linear regression model as standardly formulated:
$$ Y = \beta_0 + \beta_1 X + \varepsilon \\ \text{where } \varepsilon\sim\mathcal N(0, \sigma^2) $$ The error term, $\varepsilon$, is a random variable and is the source of the randomness in the model. As a result of the error term, $Y$ is a random variable as well. But $X$ is not assumed to be a random variable. (Of course, it might be a random variable in reality, but that is not assumed or reflected in the model.)

$\endgroup$
6
  • 2
    $\begingroup$ So you mean $X$ is a constant ? Because that is the only other way to make sense of $X$ from a mathematical point of view, since $\varepsilon$ is a random variable and addition is only defined between two random variables and not "something else" + random variable. Though one of the two random variables could be constant, which is the case I'm referring to. $\endgroup$
    – l7ll7
    Commented Nov 15, 2016 at 23:14
  • $\begingroup$ P.S. I looked at all the explanations from said link and none very illuminating: Why ? Because none make the connection between random variables as probabilists understand it vs. how statisticians understand it. So some answers restate the standard, precise probability theory definition, while others restate the (yet unclear to me) vague statistical definition. But none really explain the connection between these two concepts.(The only exception is the long ticket-in-a-box model answer, which may show some promise, but even so [...] $\endgroup$
    – l7ll7
    Commented Nov 15, 2016 at 23:35
  • $\begingroup$ the difference wasn't fleshed out clearly enough to be strikingly illuminating; I'll have to meditate on this specific answer to see if there's any value to it) $\endgroup$
    – l7ll7
    Commented Nov 15, 2016 at 23:35
  • 1
    $\begingroup$ No, the non-random variable way of thinking about it does not work, for two reasons: One, as I argued in the comments above, there is no such thing as a "variable" in mathematics, and two, even if it were, then addition in that case is not defined, as I argued in the comments above. $\endgroup$
    – l7ll7
    Commented Nov 16, 2016 at 9:51
  • 1
    $\begingroup$ "If I would just write "x" in mathematics, it could mean the function $x↦x$, or it could be a specific number, if $x$ was assigned a values previously, but we don't have just $x$." This is the latter case of $x$ being explicitly defined -- say, a collection of measurements (heights of adults, for example). $\endgroup$
    – Sycorax
    Commented Nov 16, 2016 at 22:54
1
$\begingroup$

Not sure if I understand the question, but if you're just asking, "must an independent variable always be a random variable", then the answer is no.

An independent variable is a variable which is hypothesised to be correlated with the dependent variable. You then test whether this is the case through modelling (presumably regression analysis).

There are a lot of complications and "ifs, buts and maybes" here, so I would suggest getting a copy of a basic econometrics or statistics book covering regression analysis and reading it thoroughly, or else getting the class notes from a basic statistics/econometrics course online if possible.

$\endgroup$
7
  • 1
    $\begingroup$ Ok, but what is it, if it is not a random variable ? Just a (therefore deterministic) function ? I'm confused regarding the mathematical nature of the object "$X$". Actually, I found in the meantime a textbook, Probability and Statistics by Papoulis, where on page 149 he says "given two random variables $X$ and $Y$ [...]" and then goes on to explain how to regress $X$ on $Y$. So he seems to understand $X$ as a random variable ? $\endgroup$
    – l7ll7
    Commented Nov 15, 2016 at 14:25
  • 1
    $\begingroup$ P.S. I want to add that there is no such thing as a "variable" in mathematics when you look at it as a "standalone" objects (my background is maths). Variables in mathematics are just parts of standalone objects (e.g. arguments of function), but have no standalone meaning. If I would just write "x" in mathematics, it could mean the function $x\mapsto x$, or it could be a specific number, if $x$ was assigned a values previously, but we don't have just $x$. And since log. regression is a mathematical model, I'm interested in the mathematical meaning of $X$. $\endgroup$
    – l7ll7
    Commented Nov 15, 2016 at 14:37
  • 1
    $\begingroup$ Ok, that's is good to know what kind of answers I can expect/is the standard at econometrics/statistics departments and I appreciate that feedback very much (I would upvote again, but I can't since I already did). The problem with mathematics is "once you go black you never go back": Yearlong training in mathematical precision will induce a feeling of uneasiness if something is not crystal-clear fleshed out until one achieves claritiy [...] $\endgroup$
    – l7ll7
    Commented Nov 15, 2016 at 23:23
  • 1
    $\begingroup$ (I would even go so far as to say that some mathematician -specifically those that don't have to do much with physics- are rendered incapable of understanding concept in a fuzzy manner: Either they understand them completely in all rigour or not at all) But I'm not going (yet) going to accept your (or the other) answers, because I need to sort this problem out with mathematical precision. (I seem to have the impression, that this confusion arises from the fact the in statistics random variables are sometimes conflated with constants that come from on specific instance of a trial where [...] $\endgroup$
    – l7ll7
    Commented Nov 15, 2016 at 23:23
  • 1
    $\begingroup$ that random variable takes on specific values -i.e. becomes a constant from the mathematical point of view- but I', unsure for the moment and would wish that a pure mathematician who know stats could explain them. Maybe some are on this site ?) $\endgroup$
    – l7ll7
    Commented Nov 15, 2016 at 23:24

Your Answer

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

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