# How to create a glmm for continuous and categorical explanatory variables and binary response?

After weeks of reading and trying I decided to post my question here because I could not find a convincing solution. I radio tracked two animals for several months and now I want to find out 1) what influences the activity of the animals and 2) when (hour after sunset) they are showing the highest activity and 3) what influences the travel distance.

For question 1) I created a generalized linear mixed model, with animal as a random factor looking like this: glmer(cbind(active,inactive)~offspring+season+observation_time+temperature+precipitation+season:temperature+season:precipitation+temperature:precipitation,family=binomial)

offspring and season are factors coded with 0 and 1,observation_time in minutes, temperature is in °C and precipitation in mm.

The first lines of the summary() are showing that:

AIC BIC logLik deviance 438.3251 460.0690 -209.1625 418.3251

Random effects: Groups Name Variance Std.Dev. Name (Intercept) 0.06594 0.2568
Number of obs: 65, groups: Name, 2

So my question is: is this model build up correctly? Is there an improvement possible or neccessary? It is very difficult to work with this data, because most diagnostic plots which are usually used to evaluate models are different because of the random factor. I also wanted to boxcox transform the response but one animal showed no activity one day (the activity is zero) and therefore this is not possible. I try to eliminate variables or interaction terms but in most cases I can only eliminate one interaction term. After that all variables and interaction terms seems to be significant. For variable selection I use differend aproaches (AIC, BIC, AVOVA).

For the 3) question I created a LMM like this: lmer(sqrt(distance)~aktivity+season+offspring+observation_time+temperature+precipitation+season:temperature+...(other interaction terms)

The result from summary():

REML criterion at convergence: 513.0257

Random effects: Groups Name Variance Std.Dev. Name (Intercept) 11.6 3.405
Residual 295.8 17.199
Number of obs: 62, groups: Name, 2

Does any of this values tell me something about the goodness of my model?

How can I check if data transformation is neccessary? And if yes, which one?

I'm honest, I'm quite new in this field and all I learnd about R and statistics do not really work with glmm or lmm. Or it's to complicated for me. I also created a gam without the random factor to check the relationship between the variables and response but I don't know what to do with the results (seems to be no linear relationship between activity and observation_time and rainfall). How do I fit variables to my model? An other idea is to fit the model without the random factor and add the random factor afterwards. Would it be ok to do it like this?

For the second question - at which hour after sunset they are showing the highest activity - I have no idea how the model could be build up...

Sorry for the amount of questions but I'm working for weeks on this and it is very frustrating... Thanks in advance for all your ideas and help! Iris

## migrated from stackoverflow.comDec 30 '13 at 12:02

This question came from our site for professional and enthusiast programmers.

• What were the very first five things you did with this data after getting it? That looks like an awfully complicated model for only 65 observations. – rawr Dec 30 '13 at 7:45
• After the 65 radio-tracking sessions I had a table consisting of around 1800 data points. Then I aggregated the table so that one row represents one tracking session. Since that I'm looking for possibilities to do my analyzes (it's my masterthesis so I have to find a possibility to do anlyze the data...) – user3121752 Dec 30 '13 at 8:17
• This question appears to be off-topic because it is about stats – user1317221_G Dec 30 '13 at 9:19