# Can random effects apply only to categorical variables?

This questions might sound stupid, but... is it correct that random effects could apply only to categorical variables (like individual id, population id, ...), e.g. say $x_i$ is categorical variable:

$y_i$ ~ $\beta_{x_i}$

$\beta_{x_i}$ ~ $Norm(\mu, \delta^2)$

but from the principle the random effect cannot apply to continuous variable (like height, mass...), say $z_i$:

$y_i$ ~ $\alpha + \beta \cdot z_{i}$

because then there is only one coefficient $\beta$ which cannot be constrained? Sounds logical but I wonder why it is never mentioned in statistical literature! Thanks!

EDIT: But what if I constrain $z_i$ like $z_i$ ~ $Norm(\mu, \delta^2)$? Is it then random effect? But this is different from the constrain I put on $\beta_{x_i}$ - here I constrain the variable whereas in the previous example I constrained the coefficient! It starts to look as a big mess to me... Anyway, it doesn't make much sense to put this constraint, because $z_i$ are known values, so maybe this idea is completely odd :-)

-
Interesting related question: stats.stackexchange.com/q/61531/5509 –  Tomas Jun 24 at 7:30

This is a good and a very basic question.

The interpretation of random effects is very domain-specific and is dependent on the modeling choice (the statistical model or being a Bayesian or frequentist). For a very good discussion, see page 245, Gelman and Hill (2007). For a Bayesian everything is random (even though parameters may have a true fixed value, they are modeled as random), and a frequentist can also choose a parameter value to be a fixed effect that would have been otherwise modeled as random (see Casella, 2008, discussion about blocks to be fixed or random in example 3.2).

Edit (after comment)

Data are fixed after you observe them. If they are continuous, they should be modeled as continuous. You can model categorical variables as categorical and sometimes as continuous (like in an ordinal variable setting). The parameters are unknown and they may be modeled as fixed or random. The parameters essentially relate response to predictors. If you want individual predictor's slope (or its coefficient in a linear model) to vary for each response, model it as random, otherwise model it as fixed. Similarly, if you want the intercept to vary regarding groups, then they should be modeled as random; otherwise they should be fixed.

-
Thanks for your answer, but hmmm.... I've put a simple question and expected somehow simple or general answer :) In your 2nd paragraph you state that in Bayesian everything is random. Please don't complicate it too much :) I intentionally asked at the model level, please forget about frequentist or bayesian - I'm interested in the principle - for which type of variables the random effects are typically used? –  Tomas Sep 8 '11 at 0:02
In the 3rd paragraph it you put a special application with time series, I'm not sure I understand it but AFAIK time series are usually discrete (not continuous) if you speak about serial correlation... Anyway, if you have somehow more general answer, please do share. Again, thank you for answer! –  Tomas Sep 8 '11 at 0:04
The randomness is in unknown things. When you have observations they are known! The only thing that you know are your data. The unknowns are the parameters and they are may be modeled as random or fixed. (sorry for the confusion; I agree, I unnecessarily made things complicated.) –  suncoolsu Sep 8 '11 at 0:05
thanks for simplifying your answer. So coming to the root of my question - so does this mean that the answer is yes, i.e. the random effects apply only to categorical variables, because the random effects apply only to parameters (not data), and the only parameters which can be modelled as random are those with multiple levels, i.e. those of a categorical variable? And the parameters of continuous variables cannot be modelled as random, because there is only 1 parameter value for continuous variable? Thanks! –  Tomas Sep 8 '11 at 0:26
In your specific setting, the answer is YES. But in general the answer, I would say, is NO because continuous variables can vary according to groups. For example, income of residents in city should be higher than village (according to you this might be two separate categorical variables for location). –  suncoolsu Sep 8 '11 at 1:42
show 1 more comment