[R-sig-ME] Help with script for adding X and Y coordinates into a correlation formula

Douglas Bates bates at stat.wisc.edu
Sat Mar 19 09:28:22 CET 2011


On Wed, Mar 16, 2011 at 12:02 PM, Gavin Simpson <gavin.simpson at ucl.ac.uk> wrote:
> On Tue, 2011-03-08 at 08:07 -0600, Douglas Bates wrote:
>> On Tue, Mar 8, 2011 at 4:15 AM, Karen Moore <kmoore at tcd.ie> wrote:
>> > Thanks for getting back to me. Do you mean that I'm incorrect in adding
>> > random factor AND trying to add correlation structure??
>>
>> It's the nature of a generalized linear model or generalized linear
>> mixed model.  When the distribution of the response is multivariate
>> Gaussian you can model the mean and the variance-covariance structure
>> separately.  For other distributions, like a Bernoulli or binomial or
>> Poisson you can't.  Once you have specified the mean you have
>> specified the entire distribution.
>
> Dear Doug, fellow mixed modellers,
>
>> For spatial structure one approach is to incorporate the spatial
>> correlation into the Gaussian distribution of the random effects where
>> you define one random effect per location.
>
> Would the same approach apply to time series - one random effect per
> time point? What sort of covariance structure would that fit - a
> correlation between each time point?
>
> I'm quite interested in this but, if the above hasn't given it away, I'm
> not particularly as au fait with my mixed modelling knowledge as I
> probably should be. I deal a lot with environmental time series for
> which a Gamma mixed model would be a natural way to handle the data -
> but the problem is the temporal autocorrelation.
>
> With lme() we could fit on a log scale and use corStruct() objects, and
> via glmmPQL() we could do the computations for non-Gaussian models and
> include smooth terms via gamm(). Would I be misunderstanding you Doug if
> I took your comments to mean fitting a GLMM or GAMM with a corStruct()
> object for argument correlation in lme() is inappropriate?

I think so, yes.  A PQL method provides that parameter estimates for a
linear mixed model that is, in some sense, an approximation to the
generalized linear mixed model.  In the linear mixed model you can
model the variance-covariance of the conditional distribution of the
response, given the random effects, separately from the model for the
conditional mean.  In a GLMM with a Gamma conditional distribution you
can't.  So the corStruct makes sense for the LMM but not the GLMM and
the sense in which the LMM approximates the GLMM becomes even more
vague than usual.


>> May I suggest that re-route the discussion to the
>> R-SIG-Mixed-Models at R-project.org mailing list, which I have cc:'d on
>> this reply?  Several of those who read that list have more experience
>> than I do in this area.
>>
>> > On 7 March 2011 18:33, Douglas Bates <bates at stat.wisc.edu> wrote:
>> >>
>> >> On Mon, Mar 7, 2011 at 12:07 PM, Karen Moore <kmoore at tcd.ie> wrote:
>> >> > opps for got to send data
>> >> >
>> >> > On 7 March 2011 18:05, Karen Moore <kmoore at tcd.ie> wrote:
>> >> >>
>> >> >> Hi,
>> >> >>
>> >> >> Tryign to add correlation strcuture to a glm model as there are
>> >> >> geographical pairs of sites in my data set and resids of model plotted
>> >> >> against Site no. showed clear patterns
>> >> >>
>> >> >> VASCmix3<-glm( AVVAS~ fForesttype + CANOPEN +TREENO10+ LOI+ WELLF+
>> >> >> DISTWOOD+ MATNAT1000+ MATNAT1000:CANOPEN +DISTEDGE +MATFOR1000
>> >> >> ,family=poisson, data = VASCmix3stanb)
>> >> >>
>> >> >> Here trying to add structures:
>> >> >>
>> >> >> globalmix<-  formula (AVVAS~ fForesttype + CANOPEN +TREENO10+ LOI+
>> >> >> WELLF+
>> >> >> DISTWOOD+ MATNAT1000+ MATNAT1000:CANOPEN +DISTEDGE
>> >> >> +MATFOR1000+(1|fSITENO) )
>> >> >>
>> >> >> globalmixSpher <- lmer(globalmix, correlation = corSpher(form = ~ X +
>> >> >> Y ,
>> >> >> nugget= TRUE), family = poisson, data =  VASCmix3stanb)
>> >> >>
>> >> >> How do I tell R I want to take the X and Y variables from my data sheet
>> >> >> "VASCmix3stanb.txt" (attached FYI) and put into the formula adding a
>> >> >> correlation structure
>> >>
>> >> You don't.  The definition of a generalized linear model or a
>> >> generalized linear mixed model requires that the responses are
>> >> conditionally independent, given the random effects.  It is not
>> >> possible to modify the correlation structure of the responses given
>> >> the random effects because the distribution is completely determined
>> >> by the conditional mean.
>> >>
>> >
>> >
>> >
>> > --
>> > Karen Moore
>> > PhD Researcher,
>> > FORESTBIO,
>> > Department of Botany,
>> > Trinity College Dublin
>> > Ireland
>> >
>> > Ph: 00 353 (0)87 9422 502
>> >
>> > http://www.ucc.ie/en/planforbio
>> >
>>
>> _______________________________________________
>> R-sig-mixed-models at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
> --
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>  Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
>  ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
>  Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
>  Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
>  UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>
>




More information about the R-sig-mixed-models mailing list