[R-sig-eco] sunflower pollination analysis

Mollie Brooks mollieebrook@ @ending from gm@il@com
Tue May 15 17:55:09 CEST 2018


Hi Mariano, (Sorry for resending. I accidentally didn’t reply-all.)

Because Poisson GLMs use a log link, your offset should be log(cap).

model2 <- glm(visits ~ offset(log(cap)) + block + hybrid + distance, family=poisson, data=sunflower_data)

Then, using the DHARMa package, I can see the data are overdispersed relative to the Poisson distribution.

library(DHARMa)
simulationOutput <- simulateResiduals(fittedModel = model2, n = 1000)
testDispersion(simulationOutput = simulationOutput, alternative ="greater")

So you should use the negative binomial distribution instead. 

library(MASS)
model3 <- glm.nb(visits ~ offset(log(cap)) + block + hybrid + distance, data=sunflower_data)

You can also check residuals using DHARMa (https://cran.r-project.org/web/packages/DHARMa/vignettes/DHARMa.html <https://cran.r-project.org/web/packages/DHARMa/vignettes/DHARMa.html>)

simulationOutput <- simulateResiduals(fittedModel = model3, n = 1000)
plotSimulatedResiduals(simulationOutput = simulationOutput)

cheers,
Mollie

———————————
Mollie E. Brooks, Ph.D.
Research Scientist
National Institute of Aquatic Resources
Technical University of Denmark

> On 15May 2018, at 17:26, Mariano Devoto <mdevoto at agro.uba.ar> wrote:
> 
> Hi. I am trying to model the visits of pollinators to sunflower heads in a
> field experiment. My response variable is the number of insect visits in
> 15' periods looking at a variable number of flower heads at a time. The
> experiment includes three sunflower hybrids. Samples were taken at three
> distances from the field margin (2, 20 and 100m). There are two complete
> blocks in the experiment. I added the number of flower heads as an offset
> variable as they varied among samples.
> 
> Here is a workable code:
> 
> require(RCurl) #need this to download data from Google Drive
> my.file <- getURL("
> https://docs.google.com/spreadsheets/d/e/2PACX-1vQq-Clbksm1S3Qq2_V9FBuEfUVno11Dytk0v9eJ2j7e7FpXHYqigaqJlcTyt5u2ipfVUjrKbAFL294e/pub?output=csv
> ")
> sunflower_data <- read.csv(textConnection(my.file), head=T)
> str(sunflower_data)
> model1 <- glm(visits ~ offset(cap) + block + hybrid + distance,
> family=poisson, data=sunflower_data)
> summary(model1)
> plot(model1)
> #First diagnostic plot suggests residuals have a trend
> #Other diagnostic plots suggest observation #35 is too influential, so...
> 
> model2 <- glm(visits ~ offset(cap) + block + hybrid + distance,
> family=poisson, data=sunflower_data[-35,])
> summary(model2)
> plot(model2)
> #things look a bit better, but residuals in diagnostic plot #1 still show a
> trend. What should I try next?
> 
> Any advice is much appreciated.
> 
> Mariano
> 
> *Dr. Mariano Devoto*
> 
> Profesor Adjunto - Cátedra de Botánica General, Facultad de Agronomía de la
> UBA
> Investigador Adjunto del CONICET
> 
> Av. San Martín 4453 - C1417DSE - C. A. de Buenos Aires - Argentina
> +5411 4524-8069
> *https://www.researchgate.net/profile/Mariano_Devoto
> <https://www.researchgate.net/profile/Mariano_Devoto>*
> 
> <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> Libre
> de virus. www.avg.com
> <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


	[[alternative HTML version deleted]]



More information about the R-sig-ecology mailing list