[R-sig-eco] glm weights and offsets
Dear list members, I am running a negative binomial glm using glm.nb and would like to model the [zero inflated] counts as a function of Treatment (four different treatments). Samples of counts varied in duration (time searching for animals to count), and the overall population of animals at the sites of the treatments varied. I am interested only in the effect of Treatment but must account for the effects of varying sample durations and varying population sizes. I have attempted to do this by adding log(Duration) as an offset and 1/PopulationSize as a weight: glm.nb(Counts ~ Treatment + offset(log(Duration)), weights=1/PopulationSize) Or should I be adding both of them as offsets? glm.nb(Counts ~ Treatment + offset(log(Duration)) + offset(log(CD$PodMigHrPeriodWeight))) I'm confused by the difference in weights and offsets in glm and glm.nb. Any help would be wonderful. Chandra [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] question on gls model interpretation
Dear Iris, The expected value of any treatment combination can be calculated as sum of the coefficients. For example: E(no comptetitors, no insecticide) = Intercept E(many competitors, high concentration) = Intercept + conditionold + contaminationhigh + conditionold:contaminationhigh The non-significant interactions would mean that effects of competition and insecticide are simple summed. You have two interaction parameters that significantly differ from zero. For example, conditionold:contaminationhigh=1.2005231. This value can be interpreted by two ways. High insecticede concentration has a strong negative effect if no competion (contaminationhigh=-1.2825250), but it has negligible effect, if competition is stong: -1.2825250+1.2005231=-0.0820019. The interaction parameter measures the difference between two levels of competition in the effect of insecticide. Another interpretation is that interaction coefficient measures the difference between two levels of insecticide treatment in the effect of strong competition (ie. in the decrease of abundance caused by strong competition). From mathematical point of view these two interpretations are equivalent. You can choose either. Best wishes Zoltan 2013.01.29. 14:54 keltezéssel, "Iris Kröger" írta: Dear R-Sig-Ecology, I'm analysing an experiment about mosquito larvae beeing treated with 3 conditions (no competitors added = "algae", few competitors added ="new", many competitors added ="old"). After 2 weeks I contaminated all conditions with 3 insecticide concentrations (no treatment = "control", low concentration ="low", medium concentration = "medium", high concentration ="high"). The effect of treatments was observed over a time period of 35 days. Now I would like to analyse, if there is a synergistic effect of condition and insecticide treatment. I used a gls model (see below). (Important: the mosquito larval abundances differed significantly between conditions when insecticide contamination was applied. I'm not sure if this is a problem for the further analyses) Obviously there is a synergistic effect (condition * contamination, p<0.001), but I don't know how to interpret the output. Which treatments did the model compare?Does it mean, that the effect of medium and high contamination increased significantly at old-condition compared with the effect at algae-condition? (This I can hardly believe. Mosquito larval abundances were close to zero even without contamination at condition-old&contamination-control , hence an additional effect of insecticide treatment should be hardly detectable. I would rather expect an effect at condition-new in combination with contamination...) I used: mod1<-gls(log10(mosquito+1) ~condition * contamination , data=MK , correlation = corAR1(form=~day |bucket), weights=varIdent(form= ~ 1|condition), method="REML") summary(mod1) anova(mod1) The output was: anova(mod5) Denom. DF: 258 numDF F-value p-value (Intercept) 1 221.04772 <.0001 condition 2 243.79461 <.0001 contamination 3 24.71058 <.0001 condition:contamination 6 23.92481 <.0001 Coefficients: Value Std.Error t-value p-value (Intercept) 1.9778939 0.1391071 14.218493 0. conditionnew -0.771 0.1610017 -4.823963 0. conditionold -1.8958920 0.1461519 -12.972068 0. contaminationhigh -1.2825250 0.1840214 -6.969433 0. contaminationlow -0.2044417 0.1840214 -1.110967 0.2676 contaminationmedium -0.7833268 0.1840214 -4.256715 0. conditionnew:contaminationhigh 0.1011773 0.2129852 0.475044 0.6352 conditionold:contaminationhigh 1.2005231 0.1933408 6.209364 0. conditionnew:contaminationlow -0.1917487 0.2129852 -0.900291 0.3688 conditionold:contaminationlow 0.1496570 0.1933408 0.774058 0.4396 conditionnew:contaminationmedium -0.1454105 0.2129852 -0.682726 0.4954 conditionold:contaminationmedium 0.7940461 0.1933408 4.106978 0.0001 Can anyone help me? Many thanks, Iris [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology -- Botta-Dukát Zoltán Ökológiai és Botanikai Intézet Magyar Tudományos Akadémia Ökológiai Kutatóközpont 2163. Vácrátót, Alkotmány u. 2-4. tel: +36 28 360122/157 fax: +36 28 360110 botta-dukat.zol...@okologia.mta.hu www.okologia.mta.hu Zoltán BOTTA-Dukát Institute of Ecology and Botany Hungarian Academy of Sciences Centre for Ecological Research H-2163 Vácrátót, Alkomány u. 2-4. HUNGARY Phone: +36 28 360122/157 Fax..: +36 28 360110 botta-dukat.zol...@okologia.mta.hu www.okologia.mta.hu ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
[R-sig-eco] question on gls model interpretation
Dear R-Sig-Ecology, I'm analysing an experiment about mosquito larvae beeing treated with 3 conditions (no competitors added = "algae", few competitors added ="new", many competitors added ="old"). After 2 weeks I contaminated all conditions with 3 insecticide concentrations (no treatment = "control", low concentration ="low", medium concentration = "medium", high concentration ="high"). The effect of treatments was observed over a time period of 35 days. Now I would like to analyse, if there is a synergistic effect of condition and insecticide treatment. I used a gls model (see below). (Important: the mosquito larval abundances differed significantly between conditions when insecticide contamination was applied. I'm not sure if this is a problem for the further analyses) Obviously there is a synergistic effect (condition * contamination, p<0.001), but I don't know how to interpret the output. Which treatments did the model compare?Does it mean, that the effect of medium and high contamination increased significantly at old-condition compared with the effect at algae-condition? (This I can hardly believe. Mosquito larval abundances were close to zero even without contamination at condition-old&contamination-control , hence an additional effect of insecticide treatment should be hardly detectable. I would rather expect an effect at condition-new in combination with contamination...) I used: mod1<-gls(log10(mosquito+1) ~condition * contamination , data=MK , correlation = corAR1(form=~day |bucket), weights=varIdent(form= ~ 1|condition), method="REML") summary(mod1) anova(mod1) The output was: > anova(mod5) Denom. DF: 258 numDF F-value p-value (Intercept) 1 221.04772 <.0001 condition 2 243.79461 <.0001 contamination 3 24.71058 <.0001 condition:contamination 6 23.92481 <.0001 Coefficients: Value Std.Error t-value p-value (Intercept) 1.9778939 0.1391071 14.218493 0. conditionnew -0.771 0.1610017 -4.823963 0. conditionold -1.8958920 0.1461519 -12.972068 0. contaminationhigh -1.2825250 0.1840214 -6.969433 0. contaminationlow -0.2044417 0.1840214 -1.110967 0.2676 contaminationmedium -0.7833268 0.1840214 -4.256715 0. conditionnew:contaminationhigh 0.1011773 0.2129852 0.475044 0.6352 conditionold:contaminationhigh 1.2005231 0.1933408 6.209364 0. conditionnew:contaminationlow -0.1917487 0.2129852 -0.900291 0.3688 conditionold:contaminationlow 0.1496570 0.1933408 0.774058 0.4396 conditionnew:contaminationmedium -0.1454105 0.2129852 -0.682726 0.4954 conditionold:contaminationmedium 0.7940461 0.1933408 4.106978 0.0001 Can anyone help me? Many thanks, Iris [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] Mixed effects and nested designs in ADONIS
Ok, that is good to know, then. Thank you very much for your replies. Regards, Adrian Rasmussen On Mon, Jan 28, 2013 at 3:17 PM, Alfredo Tello wrote: > Hi Adrian, > > Have a look at this thread. It might help. > > > http://r-sig-ecology.471788.n2.nabble.com/adonis-once-again-td6232010.html#a6233574 > > A > > > On Mon, Jan 28, 2013 at 11:09 AM, Steve Brewer wrote: > >> Adrian, >> >> Others have asked similar questions, for example, how to get adonis to >> handle repeated-measures designs. The issue in both cases is how to get >> adonis to use more than one error term in testing effects in a >> hierarchical design. I'll be interested to see the responses, because as >> far as I know, no one has ever responded to this query with a solution. >> This suggests to me that no one has developed code to get adonis to use >> more than one error term to test effects. I could be (and hope) that I am >> wrong. >> >> Good luck, >> Steve >> >> >> J. Stephen Brewer >> Professor >> Department of Biology >> PO Box 1848 >> University of Mississippi >> University, Mississippi 38677-1848 >> Brewer web page - http://home.olemiss.edu/~jbrewer/ >> FAX - 662-915-5144 >> Phone - 662-915-1077 >> >> >> >> >> On 1/28/13 5:14 AM, "Adrian Rasmussen" wrote: >> >> >Dear members. >> > >> >I have a relatively simple question about how to create a formula in >> >adonis, when I have observations that are spatially clustered, and a >> block >> >design. >> > >> >Here is a simple description of my study design: >> >I have three forest management categories. >> >In each management category I have several clusters of logs. >> >In each cluster, I have selected 5 logs randomly, and mounted an insect >> >trap on each selected log. >> >In addition, for one of the 5 logs, I have mounted a smaller, but >> similar, >> >type of insect trap. >> > >> >My question is if there is a significant difference in species >> composition >> >between forest management categories. And I would like to include both >> >types of traps in the same test. >> > >> >Here is the test I have used so far: >> > >> >adonis(Species ~ Category, permutations=4999, strata=TrapType) >> >Species = Species matrix with traps in rows, and species in columns. This >> >matrix includes both types of traps. >> >Category = A vector which specifies which forest management category the >> >trap is located in. >> >TrapType = A vector which specifies the trap type. >> > >> >Thus, I consider the two different traps as different blocks, as they do >> >not sample from the insect community in the same way, and are thus not >> >directly comparable, only similar. >> > >> >As you can tell, this model ignores the nested design, and assumes that >> >all >> >the traps are equally independent. >> > >> >How can I formulate the model so that it takes into consideration the >> >cluster the trap is located in? I have searched around for some time now, >> >but I cannot find any solution to this problem. >> > >> >Any hints would be greatly appreciated! >> > >> >Additionally: As far as I understand, my use of strata on trap type, is >> >analogous to how they have specified the block design in the adonis help >> >page, in the vegan package help document. However, if you feel that I >> have >> >used the strata-function wrong, I would like to hear your opinion. >> > >> >Regards, >> >Adrian Rasmussen >> > >> >Master student in general ecology, >> >University of Life Sciences, >> >Ås, Norway >> > >> > [[alternative HTML version deleted]] >> > >> >___ >> >R-sig-ecology mailing list >> >R-sig-ecology@r-project.org >> >https://stat.ethz.ch/mailman/listinfo/r-sig-ecology >> >> ___ >> R-sig-ecology mailing list >> R-sig-ecology@r-project.org >> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology >> > > > > -- > Alfredo Tello (http://alfredotello.com) > Sustainable Aquaculture Group > Institute of Aquaculture > University of Stirling > Scotland, UK. > [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
[R-sig-eco] ccf problems
Hello everybody, I am sorry if my questions are too simple or not easily understandable. Im not a native English speaker and this is my first analysis using this function. I have a problem with a cross correlation function and I would like to understand how I have to perform it in R. I have yearly data of an independent variable (x) from 1982 to 2010, and I also have yearly data of a variable (y)from 1990 to 2010. I think y could be influenced by the variable (x) with a delay of 6 years. When I plot the data of x from 1986 to 2006 against the data of y from 1990 to 2010, the graphic has a opposite trend, i.e. when the variable x was high in the 1986, the variable y was low in 1990 and so on until the end of the time series. Consequently I aspect that the two time series are correlated with a negative correlation value. Namely: Yyear=f(xyear-Lag). And corr has a negative value. I write here the script I have performed in R. a) x<-c(105.3381,126.2792,121.7298,110.35,133.1647,140.5724,183.8853,177.0154,181.2147,186.4154,209.6958,205.029 2,184.9683, 222.9683,219.8538,268.1029,249.1545,228.942,198.2119,171.0913,146.346,166.3192,163.5747,173.3394,180.7952,176.8276,159.7074,150.6029,110.9653) y<-c(32.93415,45.75486,29.36993,23.70824,21.30857,19.78977,16.88913,22.25963,19.32558,19.73704,22.62746,28.90173,27.66794, 26.23163,28.69109,22.04674,26.47496,33.03602,41.62231,28.96627,31.80892) x<-ts(x) y<-ts(y) dumb<-ccf( x,y, ylab = "cross-correlation", xlab = "Time lag", main = "y influenced by x") dumb Autocorrelations of series X, by lag -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0.083 0.133 0.253 0.323 0.386 0.515 0.544 0.609 0.448 0.118 0 1 2 3 4 5 6 7 8 9 -0.154 -0.283 -0.416 -0.326 -0.265 -0.217 -0.285 -0.340 -0.315 -0.254 10 - 0.188 My question is: Is the script correct to ask the question I need to answer? X and y have to heve the same length (i.e. I have to consider the same number of years)? What does this result means? My interpretation is: the higher correlation was a lag of -3 years. It means that what happened to x variable in 1987 influenced y in 1990? Also, if it was not correct, is correct to write: b) c(105.3381,126.2792,121.7298,110.35,133.1647,140.5724,183.8853,177.0154,181.2147,186.4154,209.6958,205.029 2,184.9683, 222.9683,219.8538,268.1029,249.1545,228.942,198.2119,171.0913,146.346,166.3192,163.5747,173.3394,180.7952,176.8276,159.7074,150.6029,110.9653) y<-c(32.93415,45.75486,29.36993,23.70824,21.30857,19.78977,16.88913,22.25963,19.32558,19.73704,22.62746,28.90173,27.66794, 26.23163,28.69109,22.04674,26.47496,33.03602,41.62231,28.96627,31.80892) x<-ts(x) y<-ts(y) dumb<-ccf( x[3:23],y, ylab = "cross-correlation", xlab = "Time lag", main = "y influenced by x") dumb Autocorrelations of series X, by lag -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0.104 0.221 0.257 0.393 0.478 0.601 0.517 0.406 0.087 -0.270 0 1 2 3 4 5 6 7 8 9 -0.481 -0.397 -0.344 -0.241 -0.284 -0.349 -0.337 -0.265 -0.198 -0.161 10 0.044 As I understand this results mean that the higher correlation is observed when the lag =0. That means a difference of 6 years that I set up when I wrote x[3:23] that simply means work with years from 1984 to 2004. In summary I would like to know: 1) if the analysis is correct in the way a) or in the way b) 2) if there is another way to demonstrate that the variable x have an influence on the variable y with a delay of 6 years. Thank very much to anybody who could help me. Larissa [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology