Reading the description of your problem more carefully: you want
a correlation structure but no random effect (or equivalently an
individual-level random effect, with no grouping)? You may have a hard
time doing
this:
* gls (nlme package) fits generalized least-squares problem (no
['G-side'] random effect, but ['R-side'] correlation models) -- but
'generalized' here means
'non-trivial correlations', not 'non-normal responses in the exponential
family'
* glmer (lme4 package) allows individual-level random effects in
GLMMs, but not R-side structures (the package author isn't sure how they
would be formulated
sensibly in a GLMM context)
* You could create an individual-level random effect and use it in
glmmPQL, but I would proceed with great caution, e.g.:
library(MASS)
bacteria$ind <- 1:nrow(bacteria)
g1 <- glmmPQL(y ~ trt + week + offset(week), random = ~ 1 | ind,
family=binomial, data=bacteria)
Are you saying you have a fixed, known correlation matrix? That
seems surprising, but if you want to do so you will probably have quite
a bit of work in front
of you -- read the appropriate chapter of Pinheiro and Bates 2000, then
probably also read some of
their papers on defining correlation structures.
I'm sorry this isn't easier, but it's not a common task.
On 10-10-22 11:26 AM, wong wrote:
> Thanks ben.
>
> The argument correlation in glmmPQL is an optional corStruct object
> describing the within-group correlation structure. However, in my
> dataset, there is no grouping among individuals. Also, each
> individual has only one observation for response y. I don't know
> how to create a corStruct object from an existing n*n correlation
> matrix (n = the number of indivdiuals = length of y). What can I
> do now? The documentation for corClasses is not quite explicit.
>
> Alex
>
> 2010/10/22 Ben Bolker : See the documentation
> for lme (nlme package), specifically ?lme and ?corClasses . Beyond
> that, see Pinheiro and Bates 2000 (Springer).
>
> On 10-10-22 05:35 AM, wong wrote:
>>>> Hi,
>>>>
>>>> I'm looking for a R package for fitting a generalized linear
>>>> mixed model g(E[y])=X²+Zu where g is a link function, ² is a
>>>> p vector of fixed effects, u is a vector of random effects,
>>>> X is design matrix, Z is an identity matrix. In our data,
>>>> each individual has only one observation for response y.
>>>> Because individuals may be correlated in some way, leading to
>>>> similar reponses, random effect u is employed to correct for
>>>> individual background effect. The variance of u is assumed
>>>> to be Var[u]=G*A~^2, in which G is a correlation matrix.
>>>>
>>>> glmmPQL in MASS has an argument for correlation. However, I
>>>> encountered an error of invalid formula when using a n*n
>>>> dimension matrix G (n is the number of individuals, and also
>>>> the length of y) for argument 'correlation' in glmmPQL. For
>>>> example:
>>>>
>>>>>
> y=sample(c(1,0),48,replace=T);x=sample(1:4,48,replace=T);id=1:48;covMat=matrix(rnorm(48*48),nrow=48)
>
>
>
>>>>
>>>>>
> glmmPQL(y~x,random=~1|id,family=binomial,correlation=covMat)
>>>> iteration 1 Error in formula.default(object) : invalid
>>>> formula
>>>>
>>>> The R help documentation for glmmPQL is very compact. No
>>>> detailed explanation. Does anybody know how to use
>>>> correlation matrix in glmmPQL? Is it good to use glmmPQL for
>>>> fitting my model?
>>>>
>>>> Thanks.
>>>>
>>>> Alex
>>>>
>>>> _______________________________________________
>>>> R-sig-mixed-models@r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>>
_______________________________________________
R-sig-mixed-models@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>
[[alternative HTML version deleted]]