Project

General

Profile

Feature #6382 ยป Metric_Population_Stability.R

Sydney Jones, 01/15/2014 10:52 AM

 
1
######################
2
##Population stability
3
#data format: long
4
#summing cover values by plot then by species
5
require(plyr)
6

    
7
ps.sum <- ddply(data_raw.long, .(plot, species), summarise,
8
					sum=sum(cover))
9
					
10
#calculating the mean sum and sd for each treatment
11
ps.sum.mean <- ddply(ps.sum, .(plot), summarise, 
12
						mean=mean(sum))
13
ps.sum.sd <- ddply(ps.sum, .(plot), summarise,
14
						sd=sd(sum))
15
ps.m.sd <- join(ps.sum.mean, ps.sum.sd, type="full")
16

    
17
#calculating final comm. stability value per plot						
18
ps.plot_final <- ddply(ps.m.sd, .(plot), summarise,
19
					ps=mean/sd)
20
#calculating final comm. stability value per treatment (must create trt column for ps.plot_final)
21
ps.trt_final <- ddly(ps.plot_final, .(treatment), summarise,
22
						mean=mean(ps))
23

    
24
#ANOVA on ps.sum values (must create trt column for ps.sum)
25
require(car)
26

    
27
lm.ps.sum <- lm(sum ~ treatment, data=ps.sum)
28
Anova(lm.ps.sum, type=3)
29
summary(lm.ps.sum)
30

    
31
#KW ANOVA
32
fit.ps.kw <- kruskal.test(sum ~ treatment, data=pc.sum)					
    (1-1/1)