3
$\begingroup$

I have this model:

$$v_{ij} = 1 - x \beta + \delta_i + e_{ij}$$

where $\delta_i$ is the i-th random effect, $e_{ij}$ is the usual error term. I have obtained the betas and now wish to derive the fitted values. How could I do that? Do i need to calculate them as:

$$ \hat v_{ij} = 1 - x \hat\beta $$

or need to add the random effect too? If so, how?

$\endgroup$
  • $\begingroup$ @Macro, thanks for your edit. Can you please tell me how to use such equations on this website? $\endgroup$ – Günal Feb 18 '13 at 15:08
  • $\begingroup$ No problem. The same syntax used for $\LaTeX$ can be used to produce equations on this site. You can look at $\LaTeX$ resources for general questions and you can look at text I entered to produce the markup above by clicking the "edit" button above. $\endgroup$ – Macro Feb 18 '13 at 16:25
1
$\begingroup$

I think that we should sometimes include the random effect and sometimes we shoud not, according to the situation. For instance consider a one-way random effects ANOVA to model a random sampling of some lots (the random effect) and some individuals in each lot. If you want to predict the value of an individual taken at random in a lot which is itself taken at random, then you should not include the random effect.

$\endgroup$
  • $\begingroup$ Well spotted; in general though "fitted" refers to an estimate for an actual individual from the sample. You are referring to future predictions mostly, and even then if you assume that the grouping of the estimation point is known/of interest you will "add" the random effects' influence. You describe a "mean response" with your example. $\endgroup$ – usεr11852 Feb 15 '13 at 18:16
  • $\begingroup$ @user11852 All the question relies on the meaning of the word "fitted" :) $\endgroup$ – Stéphane Laurent Feb 15 '13 at 19:30
  • $\begingroup$ @ Stéphane: This statement is true practically by definition. :) As I said I do see the valid point you are making but I still think that my meaning of the word is the correct one! :D $\endgroup$ – usεr11852 Feb 15 '13 at 20:04
  • $\begingroup$ @user11852 I believ you. But we are not sure the OP is interested in the correct meaning. $\endgroup$ – Stéphane Laurent Feb 15 '13 at 21:12
  • $\begingroup$ @user11852, by "fitted" I do not mean the future predictions. I mean the predictions of the values we already have. I want to compare them with the observed ones to see the goodness of the fit $\endgroup$ – Günal Feb 18 '13 at 14:29
1
$\begingroup$

You need to add their random effect also, otherwise you are looking only on the mean response, excluding information/influence from the grouping of the data; Stéphane's post gives some reasons why you would like to do that.

Coming back to a more general case: Are you using one of the standard packages in R (lme4, nlme, MCMCglmm)? Usually they do have an in-build function to return fitted values. Otherwise you need to calculate a vector holding the realization of your random effects and add the appropriate displacement (in your model it appears you are just having random intercepts and not slopes) to your "mean" prediction. Roughly speaking those realization of the random effects coefficients $\gamma$ are :

$\hat{\gamma_i} = [Z_i^T Z_i + \sigma^2 \Psi_{\theta}^{-1}]^{-1} Z_i^T r_i$,

where $r_i = (y_i - X_i \beta)$ is the residuals vector, $Z_i$ the random-effects design matrix, $\Psi_\theta$ is the general covariance matrix and $\sigma$ is your residual (measurement error) variance parameter. (I used $\gamma$ instead of $\delta$ cause sometimes $\delta$ is reserved for indicator functions)

A lot of standard references on linear mixed effects models give this formula on how to calculate the realization of the group-specific vector $\gamma$. I used the paper "Estimation for High-Dimensional Linear Mixed-Effects Models Using $l$1-Penalization" by Schelldorfer et al. as reference but that was just because it happened to be one I was working on recently. Textbooks should have it also.

$\endgroup$
  • $\begingroup$ I am not using the package programmes in R. I am using the vector of regression coefficients and design matrix. When I obtain the likelihood, I used the random effect. So, do I need to calculate the fitted values using random effect? $\endgroup$ – Günal Feb 18 '13 at 14:52
  • $\begingroup$ Yes; taking in account what you said on the other comment also. (what you mean about "When I obtain the likelihood, I used the random effect."?) If what you want is the predictions for the measurements you already have then you want to add the random intercept. $\endgroup$ – usεr11852 Feb 18 '13 at 17:09
  • $\begingroup$ @usεr11852 Will you please elaborate more on phi value(theta)? It seems the phi value has the dimension of (n x n ) where n is the number of grouping factor for random effect. How could I get those values in R by using lme4 package?. $\endgroup$ – Tay Shin May 29 '16 at 18:24
  • $\begingroup$ @TayShin: I guess you mean $\Psi_\theta$ (psi) and not $\Phi$ (phi) right? In general: $\gamma_i \sim N(0,\Psi_\theta)$. Yes you are correct, this is of dimensions $q \times q$. The cited paper explains this in detail. You can get these using the getME function (eg. getME(fm1,'Z'), etc.) See ?getME and methods(class="merMod") for mode lme4 specific calls. $\endgroup$ – usεr11852 May 29 '16 at 20:08
  • $\begingroup$ @usεr11852 wow Thanks for the fast reply! :D However, I don't think [getME] function in lme4 doesnt support for the covariance factor. Also, could I ask one extra question? is there any "name/term" for above equation or can you please give me a terminology so that I could look up for the some document that drive above equation. Thank you very much :D $\endgroup$ – Tay Shin May 30 '16 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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