Question about a resampling procedure with LME

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about a resampling procedure with LME

Thiago Souza
Hello all,



First, I'm sorry for this long question, guys.


I’d like to know if the diversity of waterbirds affect zooplankton
diversity in natural temporary pools over two seasonal periods (wet and
dry). I’ve sampled zooplankton in 38 10x15 cm plots on the pool’s shore
sediment (in the same place where birds usually) in both seasonal periods.
I used a model of bird feet and simulated them walking on the sediment of
each plot. Then, I washed the bird feet (of each plot separately) into
containers with filtered water. The zooplankton that emerged from this
water were identified.


Unfortunately, I was not able to collect birds at the same plot (and at the
same time) that I simulated their footprint. Rather, I’ve made 38 samples
(during 9 months immediately after each seasonal period) of bird
communities (direct observation on each pool).


Thus, I do not believe that can use any classic model (such as anova
designs) because birds and zooplankton were not collected at the same
sampling unit.

To do this, I thought to randomly select *10* plots of each combination of
zooplankton sampling, that is: 10 samples from pool 1/wet season, 10 from
pool 1/dry season, 10 from pool 2/wet season and 10 from pool 2/dry season.
I did the same with bird samples, selecting 10 samples by pool and season
combination. Then, we run a lme model using species richness of birds
(independent variable) and zooplankton (dependent variable), and season as
independent variable. The variables were nested in pool. I repeated (for
loop) this procedure 1000 times and calculated the number of times that the
model was significant (p < 0.05) and the accompanying F values (for bird
richness and season effects).


I’d like to hear from you if this procedure make any sense. Please, see
below a reproducible example. Thank you very much!


Note: I’m pretty sure that the for loop could be shorter ;)



library(nlme)



#### Fake da ta



## zooplankton table

ric.zoo <- rnorm(120, 20, 2)

pool <- factor(rep(c("pool1", "pool2"), 60))

season <- factor(rep(rep(c("dry", "wet"), each=30), 2))

tab <- data.frame(pool, season, ric.zoo)



## birds table

ric.bird <- rnorm(76, 10, 2)

pool_b <- factor(rep(c("pool1", "pool2"), 38))

season_b <- factor(rep(rep(c("dry", "wet"), each=19), 2))

tab_b <- data.frame(pool=pool_b, season=season_b, ric.bird)



## Dataset to be used in for loops

bird.p.val <- numeric()

season.p.val <- numeric()

bird.f <- numeric()

season.f <- numeric()

pool.sort <- rep(c("pool1", "pool2"), each=20)

season.sort <- rep(rep(c("wet", "dry"), each=10), 2)

factor.sort <- data.frame(pool=pool.sort, season=season.sort)

nreps <- 1000





for(i in 1:nreps){

  subset1 <- subset(tab, pool=="pool1"&season=="wet")

  subsample1 <- subset1[sample(nrow(subset1), 10),][,3]

  subset2 <- subset(tab, pool=="pool1"&season=="dry")

  subsample2 <- subset2[sample(nrow(subset2), 10),][,3]

  subset3 <- subset(tab, pool=="pool2"&season=="wet")

  subsample3 <- subset3[sample(nrow(subset3), 10),][,3]

  subset4 <- subset(tab, pool=="pool2"&season=="dry")

  subsample4 <- subset4[sample(nrow(subset4), 10),][,3]

  subbird1 <- subset(tab_b, pool=="pool1"&season=="wet")

  subsbird1 <- subbird1[sample(nrow(subbird1), 10),][,3]

  subbird2 <- subset(tab_b, pool=="pool1"&season=="dry")

  subsbird2 <- subbird2[sample(nrow(subbird2), 10),][,3]

  subbird3 <- subset(tab_b, pool=="pool2"&season=="wet")

  subsbird3 <- subbird3[sample(nrow(subbird3), 10),][,3]

  subbird4 <- subset(tab_b, pool=="pool2"&season=="dry")

  subsbird4 <- subbird4[sample(nrow(subbird4), 10),][,3]

  ric.sort.zoo <- c(subsample1, subsample2, subsample3, subsample4)

  ric.sort.birds <- c(subsbird1, subsbird2, subsbird3, subsbird4)

  df40 <- data.frame(ric.zoo=ric.sort.zoo, ric.bird=ric.sort.birds,
factor.sort)

  lm.nested <- lme(ric.zoo~ric.bird+season, random=~1|pool, data=df40,
method="REML")#MODELO

  mod <- anova.lme(lm.nested, type="sequential", adjustSigma = FALSE)

  bird.p.val[i] <- mod$`p-value`[2]

  season.p.val[i] <- mod$`p-value`[3]

  bird.f[i] <- mod$`F-value`[2]

  season.f[i] <- mod$`F-value`[3]

}





sum(bird.p.val<0.05 )/nreps

sum(season.p.val<0.05)/nreps

--

*Thiago Gonçalves-SouzaProfessor Adjunto*

*Universidade Federal Rural de Pernambuco (UFRPE)*
*Departamento de Biologia / Área de Ecologia *

*E-mail alternativo: [hidden email] <[hidden email]>Home
page:<http://thiagocalvesouza.wix.com/ecoffun
<http://thiagocalvesouza.wix.com/ecoffun>**>*
*Google Scholar:
<http://scholar.google.com.br/citations?user=TjaP2l8AAAAJ&hl=pt-BR
<http://scholar.google.com.br/citations?user=TjaP2l8AAAAJ&hl=pt-BR>>*

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-ecology mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Reply | Threaded
Open this post in threaded view
|

Re: Question about a resampling procedure with LME

Thierry Onkelinx
Dear Thiago,

A few remarks.

Two pools are not enough to get reliable estimates for the random effect.
Although it is conceptually a random effect, it is better to use it as a
fixed effect.

At which level did you sample the bird diversity? I assume that it would be
much larger than 10 x 15 cm.  Is it a pool level or a smaller section of
the pool. Do you have coordinates of the sampling locations of both
zooplankton and the birds?

Best regards,

Thierry

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2016-11-14 3:28 GMT+01:00 Thiago Gonçalves-Souza <[hidden email]
>:

> Hello all,
>
>
>
> First, I'm sorry for this long question, guys.
>
>
> I’d like to know if the diversity of waterbirds affect zooplankton
> diversity in natural temporary pools over two seasonal periods (wet and
> dry). I’ve sampled zooplankton in 38 10x15 cm plots on the pool’s shore
> sediment (in the same place where birds usually) in both seasonal periods.
> I used a model of bird feet and simulated them walking on the sediment of
> each plot. Then, I washed the bird feet (of each plot separately) into
> containers with filtered water. The zooplankton that emerged from this
> water were identified.
>
>
> Unfortunately, I was not able to collect birds at the same plot (and at the
> same time) that I simulated their footprint. Rather, I’ve made 38 samples
> (during 9 months immediately after each seasonal period) of bird
> communities (direct observation on each pool).
>
>
> Thus, I do not believe that can use any classic model (such as anova
> designs) because birds and zooplankton were not collected at the same
> sampling unit.
>
> To do this, I thought to randomly select *10* plots of each combination of
> zooplankton sampling, that is: 10 samples from pool 1/wet season, 10 from
> pool 1/dry season, 10 from pool 2/wet season and 10 from pool 2/dry season.
> I did the same with bird samples, selecting 10 samples by pool and season
> combination. Then, we run a lme model using species richness of birds
> (independent variable) and zooplankton (dependent variable), and season as
> independent variable. The variables were nested in pool. I repeated (for
> loop) this procedure 1000 times and calculated the number of times that the
> model was significant (p < 0.05) and the accompanying F values (for bird
> richness and season effects).
>
>
> I’d like to hear from you if this procedure make any sense. Please, see
> below a reproducible example. Thank you very much!
>
>
> Note: I’m pretty sure that the for loop could be shorter ;)
>
>
>
> library(nlme)
>
>
>
> #### Fake da ta
>
>
>
> ## zooplankton table
>
> ric.zoo <- rnorm(120, 20, 2)
>
> pool <- factor(rep(c("pool1", "pool2"), 60))
>
> season <- factor(rep(rep(c("dry", "wet"), each=30), 2))
>
> tab <- data.frame(pool, season, ric.zoo)
>
>
>
> ## birds table
>
> ric.bird <- rnorm(76, 10, 2)
>
> pool_b <- factor(rep(c("pool1", "pool2"), 38))
>
> season_b <- factor(rep(rep(c("dry", "wet"), each=19), 2))
>
> tab_b <- data.frame(pool=pool_b, season=season_b, ric.bird)
>
>
>
> ## Dataset to be used in for loops
>
> bird.p.val <- numeric()
>
> season.p.val <- numeric()
>
> bird.f <- numeric()
>
> season.f <- numeric()
>
> pool.sort <- rep(c("pool1", "pool2"), each=20)
>
> season.sort <- rep(rep(c("wet", "dry"), each=10), 2)
>
> factor.sort <- data.frame(pool=pool.sort, season=season.sort)
>
> nreps <- 1000
>
>
>
>
>
> for(i in 1:nreps){
>
>   subset1 <- subset(tab, pool=="pool1"&season=="wet")
>
>   subsample1 <- subset1[sample(nrow(subset1), 10),][,3]
>
>   subset2 <- subset(tab, pool=="pool1"&season=="dry")
>
>   subsample2 <- subset2[sample(nrow(subset2), 10),][,3]
>
>   subset3 <- subset(tab, pool=="pool2"&season=="wet")
>
>   subsample3 <- subset3[sample(nrow(subset3), 10),][,3]
>
>   subset4 <- subset(tab, pool=="pool2"&season=="dry")
>
>   subsample4 <- subset4[sample(nrow(subset4), 10),][,3]
>
>   subbird1 <- subset(tab_b, pool=="pool1"&season=="wet")
>
>   subsbird1 <- subbird1[sample(nrow(subbird1), 10),][,3]
>
>   subbird2 <- subset(tab_b, pool=="pool1"&season=="dry")
>
>   subsbird2 <- subbird2[sample(nrow(subbird2), 10),][,3]
>
>   subbird3 <- subset(tab_b, pool=="pool2"&season=="wet")
>
>   subsbird3 <- subbird3[sample(nrow(subbird3), 10),][,3]
>
>   subbird4 <- subset(tab_b, pool=="pool2"&season=="dry")
>
>   subsbird4 <- subbird4[sample(nrow(subbird4), 10),][,3]
>
>   ric.sort.zoo <- c(subsample1, subsample2, subsample3, subsample4)
>
>   ric.sort.birds <- c(subsbird1, subsbird2, subsbird3, subsbird4)
>
>   df40 <- data.frame(ric.zoo=ric.sort.zoo, ric.bird=ric.sort.birds,
> factor.sort)
>
>   lm.nested <- lme(ric.zoo~ric.bird+season, random=~1|pool, data=df40,
> method="REML")#MODELO
>
>   mod <- anova.lme(lm.nested, type="sequential", adjustSigma = FALSE)
>
>   bird.p.val[i] <- mod$`p-value`[2]
>
>   season.p.val[i] <- mod$`p-value`[3]
>
>   bird.f[i] <- mod$`F-value`[2]
>
>   season.f[i] <- mod$`F-value`[3]
>
> }
>
>
>
>
>
> sum(bird.p.val<0.05 )/nreps
>
> sum(season.p.val<0.05)/nreps
>
> --
>
> *Thiago Gonçalves-SouzaProfessor Adjunto*
>
> *Universidade Federal Rural de Pernambuco (UFRPE)*
> *Departamento de Biologia / Área de Ecologia *
>
> *E-mail alternativo: [hidden email] <[hidden email]>Home
> page:<http://thiagocalvesouza.wix.com/ecoffun
> <http://thiagocalvesouza.wix.com/ecoffun>**>*
> *Google Scholar:
> <http://scholar.google.com.br/citations?user=TjaP2l8AAAAJ&hl=pt-BR
> <http://scholar.google.com.br/citations?user=TjaP2l8AAAAJ&hl=pt-BR>>*
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-ecology mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-ecology mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Reply | Threaded
Open this post in threaded view
|

Re: Question about a resampling procedure with LME

Thiago Souza
Dear Thierry,

Thank you for your remarks.

I agree with you that I should use pool as a fixed effect.

Let me explain some points you've raised:

Bird diversity was obtained at the pool level. Unfortunately I don't have
the coordinates of zooplankton (they're 50 cm apart). Only pool coordinates
(n=2).

Thank you again

Best regards,

2016-11-16 7:01 GMT-02:00 Thierry Onkelinx <[hidden email]>:

> Dear Thiago,
>
> A few remarks.
>
> Two pools are not enough to get reliable estimates for the random effect.
> Although it is conceptually a random effect, it is better to use it as a
> fixed effect.
>
> At which level did you sample the bird diversity? I assume that it would
> be much larger than 10 x 15 cm.  Is it a pool level or a smaller section of
> the pool. Do you have coordinates of the sampling locations of both
> zooplankton and the birds?
>
> Best regards,
>
> Thierry
>
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
> Forest
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
>
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to say
> what the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
> 2016-11-14 3:28 GMT+01:00 Thiago Gonçalves-Souza <
> [hidden email]>:
>
>> Hello all,
>>
>>
>>
>> First, I'm sorry for this long question, guys.
>>
>>
>> I’d like to know if the diversity of waterbirds affect zooplankton
>> diversity in natural temporary pools over two seasonal periods (wet and
>> dry). I’ve sampled zooplankton in 38 10x15 cm plots on the pool’s shore
>> sediment (in the same place where birds usually) in both seasonal periods.
>> I used a model of bird feet and simulated them walking on the sediment of
>> each plot. Then, I washed the bird feet (of each plot separately) into
>> containers with filtered water. The zooplankton that emerged from this
>> water were identified.
>>
>>
>> Unfortunately, I was not able to collect birds at the same plot (and at
>> the
>> same time) that I simulated their footprint. Rather, I’ve made 38 samples
>> (during 9 months immediately after each seasonal period) of bird
>> communities (direct observation on each pool).
>>
>>
>> Thus, I do not believe that can use any classic model (such as anova
>> designs) because birds and zooplankton were not collected at the same
>> sampling unit.
>>
>> To do this, I thought to randomly select *10* plots of each combination of
>> zooplankton sampling, that is: 10 samples from pool 1/wet season, 10 from
>> pool 1/dry season, 10 from pool 2/wet season and 10 from pool 2/dry
>> season.
>> I did the same with bird samples, selecting 10 samples by pool and season
>> combination. Then, we run a lme model using species richness of birds
>> (independent variable) and zooplankton (dependent variable), and season as
>> independent variable. The variables were nested in pool. I repeated (for
>> loop) this procedure 1000 times and calculated the number of times that
>> the
>> model was significant (p < 0.05) and the accompanying F values (for bird
>> richness and season effects).
>>
>>
>> I’d like to hear from you if this procedure make any sense. Please, see
>> below a reproducible example. Thank you very much!
>>
>>
>> Note: I’m pretty sure that the for loop could be shorter ;)
>>
>>
>>
>> library(nlme)
>>
>>
>>
>> #### Fake da ta
>>
>>
>>
>> ## zooplankton table
>>
>> ric.zoo <- rnorm(120, 20, 2)
>>
>> pool <- factor(rep(c("pool1", "pool2"), 60))
>>
>> season <- factor(rep(rep(c("dry", "wet"), each=30), 2))
>>
>> tab <- data.frame(pool, season, ric.zoo)
>>
>>
>>
>> ## birds table
>>
>> ric.bird <- rnorm(76, 10, 2)
>>
>> pool_b <- factor(rep(c("pool1", "pool2"), 38))
>>
>> season_b <- factor(rep(rep(c("dry", "wet"), each=19), 2))
>>
>> tab_b <- data.frame(pool=pool_b, season=season_b, ric.bird)
>>
>>
>>
>> ## Dataset to be used in for loops
>>
>> bird.p.val <- numeric()
>>
>> season.p.val <- numeric()
>>
>> bird.f <- numeric()
>>
>> season.f <- numeric()
>>
>> pool.sort <- rep(c("pool1", "pool2"), each=20)
>>
>> season.sort <- rep(rep(c("wet", "dry"), each=10), 2)
>>
>> factor.sort <- data.frame(pool=pool.sort, season=season.sort)
>>
>> nreps <- 1000
>>
>>
>>
>>
>>
>> for(i in 1:nreps){
>>
>>   subset1 <- subset(tab, pool=="pool1"&season=="wet")
>>
>>   subsample1 <- subset1[sample(nrow(subset1), 10),][,3]
>>
>>   subset2 <- subset(tab, pool=="pool1"&season=="dry")
>>
>>   subsample2 <- subset2[sample(nrow(subset2), 10),][,3]
>>
>>   subset3 <- subset(tab, pool=="pool2"&season=="wet")
>>
>>   subsample3 <- subset3[sample(nrow(subset3), 10),][,3]
>>
>>   subset4 <- subset(tab, pool=="pool2"&season=="dry")
>>
>>   subsample4 <- subset4[sample(nrow(subset4), 10),][,3]
>>
>>   subbird1 <- subset(tab_b, pool=="pool1"&season=="wet")
>>
>>   subsbird1 <- subbird1[sample(nrow(subbird1), 10),][,3]
>>
>>   subbird2 <- subset(tab_b, pool=="pool1"&season=="dry")
>>
>>   subsbird2 <- subbird2[sample(nrow(subbird2), 10),][,3]
>>
>>   subbird3 <- subset(tab_b, pool=="pool2"&season=="wet")
>>
>>   subsbird3 <- subbird3[sample(nrow(subbird3), 10),][,3]
>>
>>   subbird4 <- subset(tab_b, pool=="pool2"&season=="dry")
>>
>>   subsbird4 <- subbird4[sample(nrow(subbird4), 10),][,3]
>>
>>   ric.sort.zoo <- c(subsample1, subsample2, subsample3, subsample4)
>>
>>   ric.sort.birds <- c(subsbird1, subsbird2, subsbird3, subsbird4)
>>
>>   df40 <- data.frame(ric.zoo=ric.sort.zoo, ric.bird=ric.sort.birds,
>> factor.sort)
>>
>>   lm.nested <- lme(ric.zoo~ric.bird+season, random=~1|pool, data=df40,
>> method="REML")#MODELO
>>
>>   mod <- anova.lme(lm.nested, type="sequential", adjustSigma = FALSE)
>>
>>   bird.p.val[i] <- mod$`p-value`[2]
>>
>>   season.p.val[i] <- mod$`p-value`[3]
>>
>>   bird.f[i] <- mod$`F-value`[2]
>>
>>   season.f[i] <- mod$`F-value`[3]
>>
>> }
>>
>>
>>
>>
>>
>> sum(bird.p.val<0.05 )/nreps
>>
>> sum(season.p.val<0.05)/nreps
>>
>> --
>>
>> *Thiago Gonçalves-SouzaProfessor Adjunto*
>>
>> *Universidade Federal Rural de Pernambuco (UFRPE)*
>> *Departamento de Biologia / Área de Ecologia *
>>
>> *E-mail alternativo: [hidden email] <[hidden email]>Home
>> page:<http://thiagocalvesouza.wix.com/ecoffun
>> <http://thiagocalvesouza.wix.com/ecoffun>**>*
>> *Google Scholar:
>> <http://scholar.google.com.br/citations?user=TjaP2l8AAAAJ&hl=pt-BR
>> <http://scholar.google.com.br/citations?user=TjaP2l8AAAAJ&hl=pt-BR>>*
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-ecology mailing list
>> [hidden email]
>> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>
>
>


--

*Thiago Gonçalves-SouzaProfessor Adjunto*

*Universidade Federal Rural de Pernambuco (UFRPE)*
*Departamento de Biologia / Área de Ecologia *

*E-mail alternativo: [hidden email] <[hidden email]>Home
page:<http://thiagocalvesouza.wix.com/ecoffun
<http://thiagocalvesouza.wix.com/ecoffun>**>*
*Google Scholar:
<http://scholar.google.com.br/citations?user=TjaP2l8AAAAJ&hl=pt-BR
<http://scholar.google.com.br/citations?user=TjaP2l8AAAAJ&hl=pt-BR>>*

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-ecology mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Reply | Threaded
Open this post in threaded view
|

Re: Question about a resampling procedure with LME

Thierry Onkelinx
Hi Thiago,

I think you want a hierarchical model.

bird_richness ~ Poisson(mu_br)
log(mu_br) = Season + Pool

zooplankton ~ Poisson(mu_zp)
log(mu_zp) = Season + Pool + mu_br

I think that is is feasible to fit such model with the INLA package (
www.r-inla.org).

Best regards,

Thierry

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2016-11-17 2:57 GMT+01:00 Thiago Gonçalves-Souza <[hidden email]
>:

> Dear Thierry,
>
> Thank you for your remarks.
>
> I agree with you that I should use pool as a fixed effect.
>
> Let me explain some points you've raised:
>
> Bird diversity was obtained at the pool level. Unfortunately I don't have
> the coordinates of zooplankton (they're 50 cm apart). Only pool coordinates
> (n=2).
>
> Thank you again
>
> Best regards,
>
> 2016-11-16 7:01 GMT-02:00 Thierry Onkelinx <[hidden email]>:
>
>> Dear Thiago,
>>
>> A few remarks.
>>
>> Two pools are not enough to get reliable estimates for the random effect.
>> Although it is conceptually a random effect, it is better to use it as a
>> fixed effect.
>>
>> At which level did you sample the bird diversity? I assume that it would
>> be much larger than 10 x 15 cm.  Is it a pool level or a smaller section of
>> the pool. Do you have coordinates of the sampling locations of both
>> zooplankton and the birds?
>>
>> Best regards,
>>
>> Thierry
>>
>> ir. Thierry Onkelinx
>> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
>> and Forest
>> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
>> Kliniekstraat 25
>> 1070 Anderlecht
>> Belgium
>>
>> To call in the statistician after the experiment is done may be no more
>> than asking him to perform a post-mortem examination: he may be able to say
>> what the experiment died of. ~ Sir Ronald Aylmer Fisher
>> The plural of anecdote is not data. ~ Roger Brinner
>> The combination of some data and an aching desire for an answer does not
>> ensure that a reasonable answer can be extracted from a given body of data.
>> ~ John Tukey
>>
>> 2016-11-14 3:28 GMT+01:00 Thiago Gonçalves-Souza <
>> [hidden email]>:
>>
>>> Hello all,
>>>
>>>
>>>
>>> First, I'm sorry for this long question, guys.
>>>
>>>
>>> I’d like to know if the diversity of waterbirds affect zooplankton
>>> diversity in natural temporary pools over two seasonal periods (wet and
>>> dry). I’ve sampled zooplankton in 38 10x15 cm plots on the pool’s shore
>>> sediment (in the same place where birds usually) in both seasonal
>>> periods.
>>> I used a model of bird feet and simulated them walking on the sediment of
>>> each plot. Then, I washed the bird feet (of each plot separately) into
>>> containers with filtered water. The zooplankton that emerged from this
>>> water were identified.
>>>
>>>
>>> Unfortunately, I was not able to collect birds at the same plot (and at
>>> the
>>> same time) that I simulated their footprint. Rather, I’ve made 38 samples
>>> (during 9 months immediately after each seasonal period) of bird
>>> communities (direct observation on each pool).
>>>
>>>
>>> Thus, I do not believe that can use any classic model (such as anova
>>> designs) because birds and zooplankton were not collected at the same
>>> sampling unit.
>>>
>>> To do this, I thought to randomly select *10* plots of each combination
>>> of
>>> zooplankton sampling, that is: 10 samples from pool 1/wet season, 10 from
>>> pool 1/dry season, 10 from pool 2/wet season and 10 from pool 2/dry
>>> season.
>>> I did the same with bird samples, selecting 10 samples by pool and season
>>> combination. Then, we run a lme model using species richness of birds
>>> (independent variable) and zooplankton (dependent variable), and season
>>> as
>>> independent variable. The variables were nested in pool. I repeated (for
>>> loop) this procedure 1000 times and calculated the number of times that
>>> the
>>> model was significant (p < 0.05) and the accompanying F values (for bird
>>> richness and season effects).
>>>
>>>
>>> I’d like to hear from you if this procedure make any sense. Please, see
>>> below a reproducible example. Thank you very much!
>>>
>>>
>>> Note: I’m pretty sure that the for loop could be shorter ;)
>>>
>>>
>>>
>>> library(nlme)
>>>
>>>
>>>
>>> #### Fake da ta
>>>
>>>
>>>
>>> ## zooplankton table
>>>
>>> ric.zoo <- rnorm(120, 20, 2)
>>>
>>> pool <- factor(rep(c("pool1", "pool2"), 60))
>>>
>>> season <- factor(rep(rep(c("dry", "wet"), each=30), 2))
>>>
>>> tab <- data.frame(pool, season, ric.zoo)
>>>
>>>
>>>
>>> ## birds table
>>>
>>> ric.bird <- rnorm(76, 10, 2)
>>>
>>> pool_b <- factor(rep(c("pool1", "pool2"), 38))
>>>
>>> season_b <- factor(rep(rep(c("dry", "wet"), each=19), 2))
>>>
>>> tab_b <- data.frame(pool=pool_b, season=season_b, ric.bird)
>>>
>>>
>>>
>>> ## Dataset to be used in for loops
>>>
>>> bird.p.val <- numeric()
>>>
>>> season.p.val <- numeric()
>>>
>>> bird.f <- numeric()
>>>
>>> season.f <- numeric()
>>>
>>> pool.sort <- rep(c("pool1", "pool2"), each=20)
>>>
>>> season.sort <- rep(rep(c("wet", "dry"), each=10), 2)
>>>
>>> factor.sort <- data.frame(pool=pool.sort, season=season.sort)
>>>
>>> nreps <- 1000
>>>
>>>
>>>
>>>
>>>
>>> for(i in 1:nreps){
>>>
>>>   subset1 <- subset(tab, pool=="pool1"&season=="wet")
>>>
>>>   subsample1 <- subset1[sample(nrow(subset1), 10),][,3]
>>>
>>>   subset2 <- subset(tab, pool=="pool1"&season=="dry")
>>>
>>>   subsample2 <- subset2[sample(nrow(subset2), 10),][,3]
>>>
>>>   subset3 <- subset(tab, pool=="pool2"&season=="wet")
>>>
>>>   subsample3 <- subset3[sample(nrow(subset3), 10),][,3]
>>>
>>>   subset4 <- subset(tab, pool=="pool2"&season=="dry")
>>>
>>>   subsample4 <- subset4[sample(nrow(subset4), 10),][,3]
>>>
>>>   subbird1 <- subset(tab_b, pool=="pool1"&season=="wet")
>>>
>>>   subsbird1 <- subbird1[sample(nrow(subbird1), 10),][,3]
>>>
>>>   subbird2 <- subset(tab_b, pool=="pool1"&season=="dry")
>>>
>>>   subsbird2 <- subbird2[sample(nrow(subbird2), 10),][,3]
>>>
>>>   subbird3 <- subset(tab_b, pool=="pool2"&season=="wet")
>>>
>>>   subsbird3 <- subbird3[sample(nrow(subbird3), 10),][,3]
>>>
>>>   subbird4 <- subset(tab_b, pool=="pool2"&season=="dry")
>>>
>>>   subsbird4 <- subbird4[sample(nrow(subbird4), 10),][,3]
>>>
>>>   ric.sort.zoo <- c(subsample1, subsample2, subsample3, subsample4)
>>>
>>>   ric.sort.birds <- c(subsbird1, subsbird2, subsbird3, subsbird4)
>>>
>>>   df40 <- data.frame(ric.zoo=ric.sort.zoo, ric.bird=ric.sort.birds,
>>> factor.sort)
>>>
>>>   lm.nested <- lme(ric.zoo~ric.bird+season, random=~1|pool, data=df40,
>>> method="REML")#MODELO
>>>
>>>   mod <- anova.lme(lm.nested, type="sequential", adjustSigma = FALSE)
>>>
>>>   bird.p.val[i] <- mod$`p-value`[2]
>>>
>>>   season.p.val[i] <- mod$`p-value`[3]
>>>
>>>   bird.f[i] <- mod$`F-value`[2]
>>>
>>>   season.f[i] <- mod$`F-value`[3]
>>>
>>> }
>>>
>>>
>>>
>>>
>>>
>>> sum(bird.p.val<0.05 )/nreps
>>>
>>> sum(season.p.val<0.05)/nreps
>>>
>>> --
>>>
>>> *Thiago Gonçalves-SouzaProfessor Adjunto*
>>>
>>> *Universidade Federal Rural de Pernambuco (UFRPE)*
>>> *Departamento de Biologia / Área de Ecologia *
>>>
>>> *E-mail alternativo: [hidden email] <[hidden email]>Home
>>> page:<http://thiagocalvesouza.wix.com/ecoffun
>>> <http://thiagocalvesouza.wix.com/ecoffun>**>*
>>> *Google Scholar:
>>> <http://scholar.google.com.br/citations?user=TjaP2l8AAAAJ&hl=pt-BR
>>> <http://scholar.google.com.br/citations?user=TjaP2l8AAAAJ&hl=pt-BR>>*
>>>
>>>         [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-sig-ecology mailing list
>>> [hidden email]
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>>
>>
>>
>
>
> --
>
> *Thiago Gonçalves-SouzaProfessor Adjunto*
>
> *Universidade Federal Rural de Pernambuco (UFRPE)*
> *Departamento de Biologia / Área de Ecologia *
>
> *E-mail alternativo: [hidden email] <[hidden email]>Home
> page:<http://thiagocalvesouza.wix.com/ecoffun
> <http://thiagocalvesouza.wix.com/ecoffun>**>*
> *Google Scholar:
> <http://scholar.google.com.br/citations?user=TjaP2l8AAAAJ&hl=pt-BR
> <http://scholar.google.com.br/citations?user=TjaP2l8AAAAJ&hl=pt-BR>>*
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-ecology mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology