[R-sig-eco] How to combine multiple conditions to sum rows

2013-07-23 Thread MAUD BERLINCOURT
Dear R-list,

I'm looking at association btw individuals. Below is an example of the dataset.
id = individual i
neighb1 = first individual associated with individual i
neighb2 = second individual associated with individual i
Etc
nb_assoc = total number of association at time t
date = date in POSIXct format
dT = time difference btw date(t) - date(t-1)  => always 4 seconds

id neighb1 neighb2 neighb3 neighb4 nb_assocdate dT
LP0014  LP00161 04/10/2011 00:05:03  4
LP0014  LP00161 04/10/2011 00:05:07  4
LP0014  LP00161 04/10/2011 00:05:11  4
LP0014  LP00161 04/10/2011 00:05:15  4
LP0014  LP00161 04/10/2011 00:05:19  4
LP0014  LP00161 04/10/2011 00:05:23  4
LP0014  LP00161 04/10/2011 00:05:27  4
LP0014  LP0016  LP00172 04/10/2011 00:05:31  4
LP0014  LP0016  LP00172 04/10/2011 00:05:35  4
LP0014  LP0016  LP00172 04/10/2011 00:05:39  4
LP0014  LP0016  LP00172 04/10/2011 00:05:43  4
LP0014  LP0016  LP00172 04/10/2011 00:05:47  4

I want to calculate the time an individual I spent with one, two or more other 
individuals.

I tried to calculate it separately for each association
result <- aggregate(data$dT ~ data$id+data$neighb1, FUN=sum)
result2 <- aggregate(data$dT ~ data$id+data$neighb2, FUN=sum)
Etc

And then merge result and result2 by "id" but it doesn't work.

In the end what I'd like is a table with:

Id / total time spent with neighb1 / total time spent with neighb1 and neighb2 
/ etc / total time spent in association (regardless who it was with)


Any suggestion/idea would be much appreciated!
Thanks.

Cheers,

Maud

Maud Berlincourt
Ph.D. Candidate
School of Life and Environmental Sciences
Deakin University
221 Burwood Highway
Burwood, Victoria 3125
Australia
E-Mail:   mberl...@deakin.edu.au
Mobile:  (+61) 0412 864162



[[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] R help

2013-07-23 Thread Amy Henry
Dear R experts,

I fitted my spatial data to a glm.nb model. I decided to detect and correct
for spatial autocorrelation using ME{spdep}. If the glm.nb model is not
significant should I still check for spatial autocorrelation, i.e can
removing spatial autocorrelation uncover significance?

Also, when attempting ME on glm.nb that is significant, I get this warning
after I add the eigenvectors into the model. Can you help me to understand
what I did wrong?

Warning messages:

1: In theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
control$trace >  ... :

  iteration limit reached

Here is all the code

> tu1<-glm.nb(total.aeg~Total.number.of.units, data=inhdb, offset(x))

> tuME<-ME(total.aeg~Total.number.of.units, data=inhdb, family="poisson",
offset(x), listw=sw.nb, alpha=0.5)

> tuME

   Eigenvector ZI pr(ZI)

0   NA NA   0.40

1   43 NA   0.39

2   19 NA   0.39

3   18 NA   0.36

4   34 NA   0.35

5   23 NA   0.41

6   25 NA   0.39

7   56 NA   0.36

8   51 NA   0.47

9   46 NA   0.41

10  36 NA   0.32

etc.

> inhdb$eigen_43<-fitted(tuME)[,1]

> inhdb$eigen_19<-fitted(tuME)[,2]

> tuglmME<-glm.nb(total.aeg~Total.number.of.units+fitted(tuME), data=inhdb,
offset(x))

There were 27 warnings (use warnings() to see them)



Thank you for your help!

Amy

[[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] Heat Map for species - code from Numerical Ecology with R‏

2013-07-23 Thread Valerie Mucciarelli
Hello,

I am relatively new to R and I am working through the code that is provided in 
the book Numerical Ecology with 
R:http://xa.yimg.com/kq/groups/19243105/1919134110/name/Numerical.pdf (pg 79)

 and I have run across an error message that I can't seem to figure out.

 I am using the vegan, ade4, gclus and cluster packages. The code is as follows:

 # Ordered community table
 # Species are ordered by their weighted averages on site scores

 or <- vegemite(spe, spe.chwo)

 spe is the dataframe, here is part of it:

     AGA   ANT  BON   CAL1   CAL   CER   CRY   DES  EUTH FRY
 1  0.420 0.092 0.051 0.000 0.975 0.000 0.111 0.000 0.127 0
 2  0.000 0.000 0.007 0.002 0.915 0.000 0.000 0.000 0.151 0
 4  0.000 0.008 0.000 0.009 0.124 0.003 0.000 0.000 0.095 0
 7  0.000 0.002 0.003 0.002 0.121 0.002 0.000 3.573 0.180 0
 12 0.000 0.020 0.000 0.002 0.444 0.001 0.000 0.000 0.242 0
 13 8.727 0.000 0.000 0.000 0.743 0.000 0.000 0.000 0.050 0
 14 2.163 0.009 0.000 0.003 1.121 0.000 0.000 0.000 0.051 0
 15 0.000 0.004 0.000 0.000 0.109 0.000 0.000 0.000 0.007 0
 18 9.021 0.018 0.002 0.000 0.286 0.000 0.000 0.000 0.028 0
 19 0.000 0.038 0.000 0.019 0.509 0.000 0.000 0.000 0.155 0

 spe.chwo came from:

 spe.norm <- decostand(spe, "normalize")
 spe.ch <- vegdist(spe.norm, "euc")
 spe.ch.UPGMA <- hclust(spe.ch, method = "average")
 spe.chwo <- reorder.hclust(spe.ch.UPGMA, spe.ch)


 and the error is:

 Error in vegemite(spe, spe.chwo) :
 Cowardly refusing to use longer than 1 char symbols:
 Use scale

 The data in the dataframe is biomass data recorded to 4 digits. I'm wondering 
if this code is not working because my data is more than one digit long.

 Any suggestions or insight on how to get this code to work would be greatly 
appreciated.

 Thank you,

 Val  
___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


[R-sig-eco] create point grid within polygon

2013-07-23 Thread David García Callejas
Hi all,

is it possible to create an object of class
SpatialPoint/SpatialPointDataFrame, with a given resolution, constrained to
a certain SpatialPolygon?

In QGis, for example, I can create a rectangular layer of points and then
clip it to the extent of a polygon. The ideal solution in R would be to
create the point layer directly within the polygon boundaries, to avoid the
computational cost of clipping it afterwards (I am expecting a very large
(~10^5) number of points)

Thanks,

David

[[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] Question related to rgeos package

2013-07-23 Thread Weber, Marc
Once you create your buffer using gBuffer, you can run gIntersects using your 
GPS relocations and the buffer, i.e:

within <- gIntersects(GPS relocations, buffer)



And then just do a table on the resulting matrix to see which are true, i.e.:

table(within)



This should give you exact number of points included in the buffer area.





Marc Weber

Geographer

Western Ecology Division

US EPA

200 S.W. 35th Street

Corvallis, OR 97333

Voice: (541) 754-4469

email: weber.m...@epa.gov

***





   1. Question related to rgeos package (Dylann Kersusan)





--



Message: 1

Date: Tue, 23 Jul 2013 11:26:02 +0200

From: Dylann Kersusan 
mailto:kersusan.dyl...@gmail.com>>

To: r-sig-ecology@r-project.org

Subject: [R-sig-eco] Question related to rgeos package

Message-ID:

  
mailto:CAEcqiB9WTB=nXy1QOqbnPb+ALE8HuO99TNEqSu9LQRu=kdj...@mail.gmail.com>>

Content-Type: text/plain



Dear all,



I am currently working on GPS relocations and more specifically on the study of 
territoriality (lynx and wolverine).



I'd like to use the function gBuffer from the rgeos package to apply a buffer 
area to a home-range. What I'd like to get is the exact number of points 
included in the buffer area. Does anyone knows if it is possible to extract 
that from str() or summary() or some other kind of output? And if not included 
in the function's output, do you think of something else that I could use or 
add to this?



Thanx a lot,

Regards



--

Dylann Kersusan

Master Biodiversity and Conservation

Zoology dept. Stockholm University

--

Grims? Wildlife Research Center

Ecology dept. SLU

Riddarhyttan-Sweden



  [[alternative HTML version deleted]]







--



___

R-sig-ecology mailing list

R-sig-ecology@r-project.org

https://stat.ethz.ch/mailman/listinfo/r-sig-ecology





End of R-sig-ecology Digest, Vol 64, Issue 17




[[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] Two-sided significant test for null models

2013-07-23 Thread Rob Robinson
also consider
?p.adjust

cheers
rob

** The new Bird Atlas is coming: http://www.bto.org/shop/bird-atlas  ***

Dr Rob Robinson, Principal Ecologist
British Trust for Ornithology, The Nunnery, Thetford, Norfolk, IP24 2PU
Ph: +44 (0)1842 750050 E: rob.robin...@bto.org
Fx: +44 (0)1842 750030 W: www.bto.org/about-bto/our-staff/rob-robinson

== "How can anyone be enlightened, when truth is so poorly lit" ===



On 23 July 2013 11:53, Cayetano Gutiérrez Cánovas  wrote:
> Thanks Bob / Dylan:
>
> Bob:
> I am concerned with the possibility of increase the risk of false
> positives because two tests are actually performing.
>
> What do you think of multiplying p-value by 2 (the number of tests) to
> control risk?
>
> set.seed(10)
> rnorm(999)->null.dist
> obs<-2.5
> alpha<-0.05
> pval=mean(obs>null.dist)
> min(pval, 1-pval)*2
>
> Dylan:
> If tried with this, but it seems that wilcox.test need two variables of
> the same length
>
> wilcox.test(obs, null.dist,alternative=c("two.sided"),paired=T,conf.int=T)
> Error en wilcox.test.default(obs, null.dist, alternative =
> c("two.sided"),  :
>'x' and 'y' must have the same length
>
> Best wishes
> Tano
> --
> *Cayetano Gutiérrez Cánovas*
> Aquatic Ecology Group 
> Universidad de Murcia (Spain)
>
> website 
> Scholar Google Citations
> 
> Lessons from nature 
> skype: tano.gc
> twitter: @LdN_Esp 
>
> [[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


Re: [R-sig-eco] Two-sided significant test for null models

2013-07-23 Thread Cayetano Gutiérrez Cánovas
Thanks Bob / Dylan:

Bob:
I am concerned with the possibility of increase the risk of false 
positives because two tests are actually performing.

What do you think of multiplying p-value by 2 (the number of tests) to 
control risk?

set.seed(10)
rnorm(999)->null.dist
obs<-2.5
alpha<-0.05
pval=mean(obs>null.dist)
min(pval, 1-pval)*2

Dylan:
If tried with this, but it seems that wilcox.test need two variables of 
the same length

wilcox.test(obs, null.dist,alternative=c("two.sided"),paired=T,conf.int=T)
Error en wilcox.test.default(obs, null.dist, alternative = 
c("two.sided"),  :
   'x' and 'y' must have the same length

Best wishes
Tano
-- 
*Cayetano Gutiérrez Cánovas*
Aquatic Ecology Group 
Universidad de Murcia (Spain)

website 
Scholar Google Citations 

Lessons from nature 
skype: tano.gc
twitter: @LdN_Esp 

[[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] Two-sided significant test for null models

2013-07-23 Thread Bob O'Hara

On 07/23/2013 12:06 PM, Cayetano Gutiérrez Cánovas wrote:

Dear all,

I'd like to test the two-side significance of an observed value being
lower or higher in comparison to a null distribution, but I don't know
how to build this in R code. Can anybody help me with some code or any R
function?

Let's say  'null.dist' the null distribution, 'obs' the observed value
and 'alpha' the probability of Type I error.
set.seed(10)
rnorm(999)->null.dist
obs<-1.5
alpha<-0.05

pval=mean(obs>null.dist)
min(pval, 1-pval)<0.05

Bob

--

Bob O'Hara

Biodiversity and Climate Research Centre
Senckenberganlage 25
D-60325 Frankfurt am Main,
Germany

Tel: +49 69 7542 1863
Mobile: +49 1515 888 5440
WWW:   http://www.bik-f.de/root/index.php?page_id=219
Blog: http://blogs.nature.com/boboh
Journal of Negative Results - EEB: www.jnr-eeb.org

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


[R-sig-eco] Two-sided significant test for null models

2013-07-23 Thread Cayetano Gutiérrez Cánovas
Dear all,

I'd like to test the two-side significance of an observed value being 
lower or higher in comparison to a null distribution, but I don't know 
how to build this in R code. Can anybody help me with some code or any R 
function?

Let's say  'null.dist' the null distribution, 'obs' the observed value 
and 'alpha' the probability of Type I error.
set.seed(10)
rnorm(999)->null.dist
obs<-1.5
alpha<-0.05

Thanks in advance
Best wishes
Tano
-- 
*Cayetano Gutiérrez Cánovas*
Aquatic Ecology Group 
Universidad de Murcia (Spain)

website 
Scholar Google Citations 

Lessons from nature 
skype: tano.gc
twitter: @LdN_Esp 

[[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] Question related to rgeos package

2013-07-23 Thread Dylann Kersusan
Dear all,

I am currently working on GPS relocations and more specifically on the
study of territoriality (lynx and wolverine).

I'd like to use the function gBuffer from the rgeos package to apply a
buffer area to a home-range. What I'd like to get is the exact number of
points included in the buffer area. Does anyone knows if it is possible to
extract that from str() or summary() or some other kind of output? And if
not included in the function's output, do you think of something else that
I could use or add to this?

Thanx a lot,
Regards

-- 
Dylann Kersusan
Master Biodiversity and Conservation
Zoology dept. Stockholm University
--
Grimsö Wildlife Research Center
Ecology dept. SLU
Riddarhyttan-Sweden

[[alternative HTML version deleted]]

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology