[R-sig-ME] Random& fixed variables
Ben Bolker
bbolker at gmail.com
Sun Apr 15 18:23:40 CEST 2012
Justus Deikumah <j.deikumah2 at ...> writes:
> However, I still need some assistance as follows:
>
> I have sampled birds from 2 main landscapes, Agricultural and minining areas.
>
> 32 sites in located in 16 remnant forest patches
> 16sites at edge and i6 interior patches
^^^^^^^
sites?
> are selected such that the
> adjacent matrix is either agricultural or an active mine site.
You probably want to be a little bit more careful with terminology
here:
> in each site, bird surveys were conducted for a period of 1yrs.
>
> vegetation characteistics and microclimates were messured as covaiates.
>
> With lme4, is the below grouping of site and patch ok??
> Because sites were coded 1/2 for edge/interior,matrix also same, can
> I also group by matrix??
> In the model below, can I consider put a fixed variable in my model
> aslso a random? because I was thinking I could group by matrix as
> well but knowing very well that matrix has a significant negative
> influence during data exploration.
Yes, sort of. (1) You can specify (e.g.) site WITHIN patch as
well as a main effect of site. (2) If you have a continuous
predictor (e.g. mm of precipitation/month) with more than
one observation per x value, it sometimes make sense to specify it
as a continuous fixed effect (i.e. estimating the slope)
and as a random effect (estimating deviations of groups from
the line)
I think you want:
m <- lmer(spst~(1|patch/site)+site+mtx+elev+psize+X1fr+logyr_patch,
family= poisson, data=var32)
this specifies a random effect of patch and of patch within site,
as well as a fixed-effect difference between edge and interior.
Formally this is equivalent to (1|patch)+(1|patch:site).
It's fine to have mtx={1,2} and site={1,2} (i.e. both coded
with the same dummy variables, although in the long run it's probably
more straightforward to code them as factors (mtx={"agric","mine"},
site={"edge","interior"}), for three reasons
* R will take care of translation into dummy variables
* the variables are easier to interpret (you don't have to remember
the coding yourself)
* it is easier not to screw up and have R treat variables as
continuous that you really wanted to be categorical
More information about the R-sig-mixed-models
mailing list