[R-sig-ME] glmm question
Joaquín Aldabe
joaquin.aldabe at gmail.com
Tue Sep 1 22:58:44 CEST 2015
Hello, I´m trying to model de abundance of a grassland shorebird
(Buff-breasted Sandpiper, BBSA) as a function of the abundance of American
Golden Plover (AMGP) abundance, grass height and distance to the lagoon.
I´m using area as an offset.
I´ve tried a glmm with poisson errors and wanted you to see if residuals
are fine (they don´t look great, but wanted to know if they area minimally
acceptable). Also, I´m trying to understand two way interactions but I´m no
sure how to proceed, and also would like to plot the interactions and
unique variables effects (can you please provide suggestions?).
I also have problems with the predict function. In the script are the
notes. I´m attaching the data as well as the script with commentaries.
Let me know if there´s some format problem with the files.
Thank you very much in advanced.
Joaquín.
--
*Joaquín Aldabe*
*Grupo Biodiversidad, Ambiente y Sociedad*
Centro Universitario de la Región Este, Universidad de la República
Ruta 15 (y Ruta 9), Km 28.500, Departamento de Rocha
*Departamento de Conservación*
Aves Uruguay
BirdLife International
Canelones 1164, Montevideo
https://sites.google.com/site/joaquin.aldabe
<https://sites.google.com/site/perfilprofesionaljoaquinaldabe>
-------------- next part --------------
Field_name Year Month Grassland_type Prop_numero_potr_pastalto Grass_height Has_pastalt Prop_sup_pastoalt Field_area Distance_to_lagoon Flood Field_enclosure_700m Field_enclosure_350 Grazing_regime BBSA AMGP
Casas 2006 December Natural 0,375 13,0 264,0 0,1 47 4699 No 61,0 42,8 Rotational 0 0
Pradera_B 2006 December Improved 0,375 37,0 264,0 0,1 50 4426 No 66,8 46,4 Rotational 0 0
Pradera_A 2006 December Improved 0,375 4,5 264,0 0,1 32 4073 No 76,9 68,9 Rotational 0 0
Ba�o 2006 December Natural 0,375 7,0 264,0 0,1 142 2611 Yes 9,2 2,7 Continuous 65 100
Puesto 2006 December Natural 0,375 6,5 264,0 0,1 261 1864 Yes 3,1 0,0 Continuous 1 39
Tres_Porteras 2006 December Natural 0,375 6,0 264,0 0,1 92 2480 No 43,9 24,3 Continuous 0 0
Del_Medio 2006 December Natural 0,375 4,5 264,0 0,1 82 2962 No 39,6 18,5 Continuous 0 0
Sancho 2006 December Natural 0,375 3,0 264,0 0,1 244 874 Yes 26,8 6,8 Continuous 57 30
Laguna 2006 December Natural 0,375 4,5 264,0 0,1 345 459 Yes 6,5 0,0 Continuous 94 201
Bolsa_Chica 2006 December Natural 0,375 8,0 264,0 0,1 122 562 Yes 18,3 4,3 Continuous 0 1
Estero 2006 December Improved 0,375 8,0 264,0 0,1 179 2600 No 25,8 10,6 Rotational 0 1
Coronillas 2006 December Natural 0,375 3,5 264,0 0,1 150 342 Yes 7,5 0,5 Continuous 14 2
Pradera_Balneario 2006 December Improved 0,375 35,0 264,0 0,1 36 4037 No 63,9 48,1 Rotational 0 0
Primer_Potrero 2006 December Improved 0,375 35,0 264,0 0,1 43 3584 No 62,6 35,9 Rotational 0 0
Pileta 2006 December Improved 0,375 40,0 264,0 0,1 46 3046 No 43,2 28,8 Rotational 0 0
Aljibe 2006 December Improved 0,375 40,0 264,0 0,1 42 2361 No 47,4 38,3 Rotational 0 0
Casas 2007 December Natural 0,1875 4,0 347,0 18,0 47 4699 No 61,0 42,9 Rotational 0 0
Pradera_B 2007 December Improved 0,1875 30,0 347,0 18,0 50 4426 No 66,8 46,4 Rotational 0 0
Pradera_Balneario 2007 December Improved 0,1875 6,0 347,0 18,0 36 4037 No 63,9 48,1 Rotational 0 0
Primer_Potrero 2007 December Improved 0,1875 7,0 347,0 18,0 43 3584 No 62,6 35,9 Rotational 0 30
Pradera_A 2007 December Improved 0,1875 6,0 347,0 18,0 32 4073 No 76,9 68,9 Rotational 0 0
Ba�o 2007 December Natural 0,1875 3,5 347,0 18,0 142 2611 Yes 9,2 2,7 Continuous 7 64
Laguna 2007 December Natural 0,1875 4,0 347,0 18,0 345 459 Yes 6,5 0,0 Continuous 4 91
Puesto 2007 December Natural 0,1875 12,0 347,0 18,0 261 1864 Yes 3,1 0,0 Continuous 54 131
Sancho 2007 December Natural 0,1875 4,5 347,0 18,0 244 874 Yes 26,8 6,8 Continuous 66 65
Bolsa_Chica 2007 December Natural 0,1875 4,0 347,0 18,0 122 562 Yes 18,3 4,3 Continuous 52 92
Tres_Porteras 2007 December Natural 0,1875 4,0 347,0 18,0 92 2480 No 43,9 24,3 Continuous 0 0
Del_Medio 2007 December Natural 0,1875 6,5 347,0 18,0 82 2962 No 39,6 18,5 Continuous 0 0
Pileta 2007 December Improved 0,1875 14,0 347,0 18,0 46 3046 No 43,2 28,8 Rotational 0 0
Aljibe 2007 December Improved 0,1875 6,0 347,0 18,0 42 2361 No 47,4 38,3 Rotational 2 54
Coronillas 2007 December Natural 0,1875 5,0 347,0 18,0 150 342 Yes 7,5 0,5 Continuous 55 157
Estero 2007 December Improved 0,1875 7,0 347,0 18,0 179 2600 No 25,8 10,6 Rotational 0 0
Estero 2008 December Improved 0,125 5,5 82,0 4,3 179 2600 No 25,8 10,6 Rotational 22 155
Del_Medio 2008 December Natural 0,125 6,5 82,0 4,3 82 2962 No 39,6 18,5 Continuous 0 29
Tres_Porteras 2008 December Natural 0,125 5,0 82,0 4,3 92 2480 No 43,9 24,3 Continuous 3 25
Primer_Potrero 2008 December Improved 0,125 8,5 82,0 4,3 43 3584 No 62,6 35,9 Rotational 0 0
Pradera_Balneario 2008 December Improved 0,125 8,0 82,0 4,3 36 4037 No 63,9 48,1 Rotational 0 0
Casas 2008 December Natural 0,125 6,5 82,0 4,3 47 4699 No 61,0 42,9 Rotational 0 0
Laguna 2008 December Natural 0,125 5,0 82,0 4,3 345 459 Yes 6,5 0,0 Continuous 14 27
Aljibe 2008 December Improved 0,125 7,5 82,0 4,3 42 2361 No 47,4 38,3 Rotational 0 0
Bolsa_Chica 2008 December Natural 0,125 4,5 82,0 4,3 122 562 Yes 18,3 4,3 Continuous 7 22
Pileta 2008 December Improved 0,125 8,0 82,0 4,3 46 3046 No 43,2 28,8 Rotational 0 0
Coronillas 2008 December Natural 0,125 3,0 82,0 4,3 150 342 Yes 7,5 0,5 Continuous 60 118
Sancho 2008 December Natural 0,125 4,5 82,0 4,3 244 874 Yes 26,8 6,8 Continuous 59 198
Pradera_A 2008 December Improved 0,125 12,0 82,0 4,3 32 4073 No 76,9 68,9 Rotational 0 0
Pradera_B 2008 December Improved 0,125 20,0 82,0 4,3 50 4426 No 66,8 46,4 Rotational 0 0
Ba�o 2008 December Natural 0,125 5,5 82,0 4,3 142 2611 Yes 9,2 2,7 Continuous 18 152
Puesto 2008 December Natural 0,125 9,0 82,0 4,3 261 1864 Yes 3,1 0,0 Continuous 0 46
Puesto 2012 December Natural 0,75 24,6 1512,0 79,0 261 1864 Yes 3,1 0,0 Continuous 0 0
Coronillas 2012 December Natural 0,75 13,9 1512,0 79,0 150 342 Yes 7,5 0,5 Continuous 0 0
Sancho 2012 December Natural 0,75 15,4 1512,0 79,0 244 874 Yes 26,8 6,8 Continuous 0 0
Primer_Potrero 2012 December Improved 0,75 25,4 1512,0 79,0 43 3584 No 62,6 35,9 Rotational 0 0
Pradera_A 2012 December Improved 0,75 16,0 1512,0 79,0 32 4073 No 76,9 68,9 Rotational 0 0
Pradera_B 2012 December Improved 0,75 12,8 1512,0 79,0 50 4426 No 66,8 46,4 Rotational 0 0
Estero 2012 December Improved 0,75 8,5 1512,0 79,0 179 2600 No 25,8 10,6 Rotational 7 143
Tres_Porteras 2012 December Natural 0,75 9,7 1512,0 79,0 92 2480 No 43,9 24,3 Continuous 0 0
Del_Medio 2012 December Natural 0,75 3,4 1512,0 79,0 82 2962 No 39,6 18,5 Continuous 57 273
Ba�o 2012 December Natural 0,75 11,4 1512,0 79,0 142 2611 Yes 9,2 2,7 Continuous 0 0
Laguna 2012 December Natural 0,75 14,8 1512,0 79,0 345 459 Yes 6,5 0,0 Continuous 0 0
Casas 2012 December Natural 0,75 14,8 1512,0 79,0 47 4699 No 61,0 42,9 Rotational 0 0
Pradera_Balneario 2012 December Improved 0,75 13,3 1512,0 79,0 30 4037 No 63,9 48,1 Rotational 0 557
Pileta 2012 December Improved 0,75 19,0 1512,0 79,0 46 3046 No 43,2 28,8 Rotational 0 0
Aljibe 2012 December Improved 0,75 3,4 1512,0 79,0 42 2361 No 47,4 38,3 Rotational 66 253
Bolsa_Chica 2012 December Natural 0,75 35,0 1512,0 79,0 122 562 Yes 18,3 4,3 Continuous 0 0
-------------- next part --------------
my4<-read.table(file.choose(), header=T, dec=",")
#scale variables
my4s<-as.data.frame(scale(my4[,c(6,10,12,13,16)], center=T, scale=T))
my4S<-cbind(BBSA=my4$BBSA, Field_name=my4$Field_name,Grassland_type=my4$Grassland_type, Flood=my4$Flood, Year=my4$Year,my4s)
my4S$log.AMGP=scale(log(my4$AMGP+1), scale=T, center=T)
# Add Field_area to use as offset
my4S<-cbind(my4S, Field_area.o=my4$Field_area)
require(lme4)
m3.1=glmer(BBSA~log.AMGP*Distance_to_lagoon+Grass_height*Distance_to_lagoon+log.AMGP*Grass_height+Grassland_type+(1|Field_name),family="poisson", offset=log(Field_area.o),data=my4S[-61,])
summary(m3.1)
plot(fitted(m3.1),residuals(m3.1))
qqnorm(residuals(m3.1)); qqline(residuals(m3.1))
m3.1.1=update(m3.1,~.-Grassland_type)
summary(m3.1.1)
#Prediction with m3.1.1. I�m leaving as fix the variables amgp, distance to lagoon (dist), to see the effect of grass height (grass) when distance to lagoon is lowest. But I could not make prediction function work.
#Distance to lagoon
amgp=rep(-0.79,500)#0.47
dist=rep(-1.59,500)#0.52
grass=seq(-0.85,2.83, length.out=500)
area1=seq(30,345,500)#52.5
newdata=data.frame(log.AMGP=amgp, Distance_to_lagoon=dist,Grass_height=grass, Field_area.o=area1)
predglmm=predict(m3.1.1,newdata, Reform=~(1|Field_name))
More information about the R-sig-mixed-models
mailing list