This script just generates some basic summary statistics that are used as input for power calculations using the Aranda et al. data set

source("../R/libraries.R")   #the libraries script loads a common set of packages
aranda <- read.csv("../data/aranda.csv")
#Plot to check that linear relationship is reasonable as a model
plot(richness~precip, data=aranda)

# fit model in case residuals are wanted
reg<-lm(richness~precip, data=aranda)

For power, we want estimates of σx and σy. The best estimates are the standard deviations of precipitation and species richness. In the worked example, we’ve decided that a 50% change in overall richness is an important effect to detect. We need to translate this into an actual change in the response variable, and there are several ways we could do it. We will calculate the overall mean richness, and then hypothesise that the lowest precipitation has richness 25% below this value, and the highest precipitation sites have an increase of 25%. To get the effect, we just need the mean(richness)

summarise(aranda,mean=mean(richness), sd=sd(richness))
summarise(aranda,mean=mean(precip), sd=sd(precip))

The values we want are:

To calculate a slope of interest, we’ll assume that the range in precipitation is represented by the range in the existing data (113-1492). We could have also obtained this information from other sources.

LS0tCnRpdGxlOiAiUUsgQm94IDYuMTEiCm91dHB1dDoKICBodG1sX25vdGVib29rOgogICAgdGhlbWU6IGZsYXRseQotLS0KCmBgYHtyIHNldHVwLCBpbmNsdWRlPUZBTFNFfQprbml0cjo6b3B0c19jaHVuayRzZXQoZWNobyA9IFRSVUUpCmBgYAoKVGhpcyBzY3JpcHQganVzdCBnZW5lcmF0ZXMgc29tZSBiYXNpYyBzdW1tYXJ5IHN0YXRpc3RpY3MgdGhhdCBhcmUgdXNlZCBhcyBpbnB1dCBmb3IgcG93ZXIgY2FsY3VsYXRpb25zIHVzaW5nIHRoZSBBcmFuZGEgZXQgYWwuIGRhdGEgc2V0CgpgYGB7ciByZXN1bHRzPSdoaWRlJ30Kc291cmNlKCIuLi9SL2xpYnJhcmllcy5SIikgICAjdGhlIGxpYnJhcmllcyBzY3JpcHQgbG9hZHMgYSBjb21tb24gc2V0IG9mIHBhY2thZ2VzCmBgYAoKYGBge3J9CmFyYW5kYSA8LSByZWFkLmNzdigiLi4vZGF0YS9hcmFuZGEuY3N2IikKI1Bsb3QgdG8gY2hlY2sgdGhhdCBsaW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