3
$\begingroup$

I'm trying to fit linear models to my data in R. I need to use a generalised least squares method as I have heterogeneity of variance in one of my variables. I was planning to use varIdent, as the variable is nominal.

But - I also want to have a random term as my data have a nested structure, and my data need to be modelled using a binomial distribution. I can't find any information on whether this is possible using the gls command in package nlme, does anyone have any information that could help me, please?

$\endgroup$
2
  • $\begingroup$ I'm a little confused; you say you have heterogeneity of variance, which means the variance in the response differs by one of your predictors, but you also say you need a binomial distribution, which means that your response is binomial. While different variances are possible (though would be called over or underdispersion in this case), as far as I know, it's not something that is easy to check without fitting the model in the first place. How do you know the variances are different? $\endgroup$ Commented Feb 23, 2012 at 14:19
  • $\begingroup$ I'll extend Aaron's question a little - how are the variances different other than the differences binomially distributed variates would have due to different $n$ and $p$? If one of your explanatory variables has heterogeneous variance, that's not an issue, but a binomial response can't have a heterogeneous variance given $n$ and $p$. $\endgroup$
    – jbowman
    Commented Feb 23, 2012 at 22:39

1 Answer 1

2
$\begingroup$

By GLS do you mean GLM? The GLM is a method of iteratively reweighted least squares which takes the mean-variance relationship into account when estimating the model parameters. Generalized Least Squares will still either suffer from an overfitting issue (infinite weights), or overprediction (fitted probabilities greater than 1 or less than 0). The logistic regression model is commonly used to test for associations with binary outcomes. It's possible to go further and use Generalized Linear Mixed Models (GLMMs), conditional logistic regression, or Generalized Estimating Equations (GEEs) to account for certain correlation structures in the data. The nlme package has the mixed models, survival has clogit, and the geese package for GEEs.

$\endgroup$
4
  • $\begingroup$ no I meant GLS, as in can I use the gls command in nmle to specify that the variance in my data is different for different levels of a categorical variable. I want to know if this is possible (or indeed necessary) within the framework of GLMM. I am not sure whether GLMM can take account of heterogeneity of variance. It has been suggested by colleagues that GLMMs work using deviance rather than variance and so heterogeity becomes less of a problem, but I want some more opinions on this before going ahead. And thank you for reading and commenting, much appreciated! $\endgroup$
    – user9382
    Commented Feb 23, 2012 at 8:57
  • $\begingroup$ @rachelgibson: Your terminology is perhaps a little mixed up, though your above comment is clearer; GLS is a way of doing different variances, but only makes sense for linear models (not GLMs, like the binomial model). So you are looking to fit a GLM, as Adam proposes, but you have a random effect, making it a GLMM, as you mention above, but you think you may have heterogeneity of variance, so want to fit a variance structure similar to what GLS does in the normal case. $\endgroup$ Commented Feb 23, 2012 at 14:29
  • 1
    $\begingroup$ @AdamOmidpanah: I believe nlme can't do GLMs, and lme4 can't do different variance structures. $\endgroup$ Commented Feb 23, 2012 at 14:30
  • $\begingroup$ Just to make clear the acronym GLS, It is for Generalized least squares. $\endgroup$
    – Rafael
    Commented Mar 13, 2015 at 5:55

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.