[R-sig-ME] How to use nlmer on a dataset with multiple fixed and random effects
Lauren Hooton
lauren.hooton at gmail.com
Thu May 10 18:53:29 CEST 2012
>
>>
>> Hello,
>>
>> I am trying to model the effect of weather variables on bat activity
>> (passes/hour) over three years and multiple geographic locations.
>> Specifically, the effects are:
>>
>> Fixed = temperature, wind speed, wind direction, pressure,
>> precipitation, relative humidity
>> Random = year, week, detector, hour
>> (Within each year there were multiple detectors recording bat
>> activity, and these detectors (locations) changed each year).
>>
>> I started out using glmer() in lme4, with the following code:
>> LACI.model.8 <-
>> glmer(LACI~AvgTemp+AvgSpeed+AvgDirection+Pressure+
>> Precip+RH+(1|year)+(1|weeks_July1)+(1|detector)+(1|GMT_hour),
>> data=allbatwxstd, family=poisson)
>
> A quick question: can you use a quadratic function of one or
> more of your continuous predictors in your model? That is nonlinear
> in terms of the original predictor, but it is still a linear *model*
> (i.e. it is linear in terms of the parameters of the model). You can
> use either (e.g.) Pressure + I(Pressure^2), or (more numerically
> stable and statistically sounder but possibly harder to interpret)
> poly(Pressure,2) to add a quadratic term in Pressure ...
>
> (Sorry if this isn't relevant, I'm posting in a hurry)
>
Thanks for responding - a few others have also suggested including
quadratic terms. However, I'm not sure that quadratic is the best fit
for the data either....the residual plots are still not great. My
uncertainty as to what would be the best method for my data led me to
want to pursue non-linear methods. Perhaps I should have phrased my
question as: How do you know which model is the best? Ie: a glmer with
or without quadratic terms? A non-linear model?
Is the best method to look at the fitted values vs the residuals?
Thanks,
Lauren
More information about the R-sig-mixed-models
mailing list