[R-sig-ME] MCMCglmm:interaction bt continuous variable and categorical random effect
Joshua Wiley
jwiley.psych at gmail.com
Sun Mar 31 22:59:20 CEST 2013
Hi John,
That is the basic idea, but I doubt you want to parameterize it quite
that way. I would suggest:
Model1 <- MCMCglmm(used ~ slope + elevation + road,
random = ~ us(1 + road):wolf + pack, family = "categorical",
data = datum, prior = prior1, pr = TRUE)
which would fit a random intercept and slope by wolf, that are allowed
to be correlated, as well as a random intercept by pack (assumed
orthogonal to the others).
Having road in the fixed effects portion will give you the overall
effect, and then the random effects bit will be shrunken deviations
from that.
Cheers,
Joshua
On Sun, Mar 31, 2013 at 1:32 PM, john benson <smilodon2000 at hotmail.com> wrote:
>
>
>
>
>
>
> Hi,
> I am using MCMCglmm to fit resource selection models for wolves using logistic regression where the response variable is pixels on the landscape that are either used by, or available to, wolves. I have named the response variable "used". Observed locations of wolves are coded 1 and available locations for wolves (systematic locations across their home ranges) are coded 0. My initial interest was to assess relative selection (in a use-available context) of various environmental variables which are things like slope, elevation, and distance to roads. I'm including a random term for individual wolf to account for the unbalanced sample sizes (of observations) across individuals and a random term for pack to account for the fact that I have sampled multiple wolves within some packs. Here is my code and prior:
>
> prior1<-list(R=list(V=1,fix=1),G=list(G1=list(V=1,nu=0.002),G2=list(V=1,nu=0.002)))Model1<-MCMCglmm(used~slope+elevation+road,random=~wolf+pack,family="categorical",data=datum,prior=prior1)
> This seems to have worked quite well and the various diagnostics indicate good chain mixing and low autocorrelation, as long as I used sufficient iterations, thinning, and burnin. I am making population-level inference on the relative selection or avoidance of the fixed effects. Although not my primary question, I'd be interested in confirmation that my code looks correct for the desired inference.
> My real question is that I'd like to derive individual selection coefficients for each wolf in relation to a given environmental variable (i.e. road). I would then use these coefficients in a separate analysis to see how selection of roads varies in relation to various things such as availability of roads, genetic ancestry, etc. I have thought of 2 ways to derive the individual selection coefficients for roads for each wolf:
> 1. I could run a separate model for each wolf and simply use the fixed effect coefficient for road from each model. This seems valid but would be time consuming (because I have ~70 wolves) and seems to fail to take advantage of the random effect of wolf in the overall model which presumably could be used to derive an estimate of individual selection of a given resource.
> 2. So alternatively, I wondered if I could run the overall model, but this time include an interaction between the random effect of wolf and road (which is continuous). I'm not sure if this valid or the best way to structure the code but here is my first try:
> Model1<-MCMCglmm(used~slope+elevation,random=~wolf:road+pack,family="categorical",data=datum,prior=prior1, pr=TRUE)
>
> Again my goal is simply to derive a coefficient of selection of roads for each individual wolf from the overall model. Any help with this would be greatly appreciated and if anything in my explanation or question is unclear please let me know and I will try to clarify.
> Many thanks in advance!
> John
>
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://joshuawiley.com/
Senior Analyst - Elkhart Group Ltd.
http://elkhartgroup.com
More information about the R-sig-mixed-models
mailing list