r-tools to analyse bird data_henk sierdsema_bird numbers 2016

58
R-tools to analyse bird data Henk Sierdsema Christian Kampichler

Upload: henk-sierdsema

Post on 22-Jan-2018

70 views

Category:

Data & Analytics


1 download

TRANSCRIPT

Page 1: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

R-tools to analyse bird data

Henk Sierdsema

Christian Kampichler

Page 2: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Bird data

• Monitoring data

• Atlas data

• Casual observations and lists

Saxifraga – Piet Munsterman

Page 3: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Bird data analysis

• Trends

• Distribution maps

• Trend maps / change

maps

Saxifraga – Piet Munsterman

Page 4: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Analysis tools

• Dedicated programs

– Trends: TRIM

– Maps: GIS (ArcGis, QGis), Maxent

• Scripting

Saxifraga – Piet Munsterman

Page 5: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016
Page 6: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

• Free

• http://www.r-project.org/

• Large user community

• Many plugins called ‘packages’ dedicated

to specific statistical issues

Page 7: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

• You can perfom very basic and very advanced statistics with R

• But it’s also very useful if you have to (almost) the same thing many times, like: – Make trends graphs for 100 species

– Make correlation plots for 100 species and 50 variables

– Make distribution maps for 100 species

• And if you want to redo an analysis because you got new data

Page 8: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Trend analysis of monitoring data

• Most organisations use TRIM to calculate

trends

Page 9: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

TRIM

• Data files needed for TRIM

– Observations

– For automated runs (batches): Command-file

Page 10: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

TRIM-observation file

• Complete matrix: – Positive observations

– Zero-observations

– Missing values

– (Covariates)

5 1976 -1

5 1977 -1

5 1978 -1

5 1979 -1

5 1980 0

5 1981 -1

5 1982 0

5 1983 1

5 1984 0

5 1985 0

5 1986 5

5 1987 0

Page 11: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Statistics in TRIM

• Generalized Estimating Equations

– Modelling of repeated/correlated

observations

– Robust regression method

– Estimating procedure, no likelihood function

Page 12: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

TRIM output

• Estimated numbers per site per year

• Trend estimates

• Basic graphs in interactive mode

Page 13: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

BirdStats

• Facilitate data preparation, trend

calculation and retrieval of output

• Access-database

Page 14: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

BirdStats

• However, also requires data-processing

before data can be read into BirdStats

• Limited flexibility

• Other option: make R-script to prepare

data and retrieval of output

Page 15: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

TRIM R-script

• Retrieve data directly from database or

read .csv-files

• Set number of parameters like:

– Time period (can be species specific)

– Species selection

– Site-selection (shape or csv-file)

Page 16: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

TRIM R-script

• Run TRIM in batch mode with tcf-

command files

• Retrieve TRIM-output

• Makes observations maps and maps

Saxifraga – Mark Zekhuis

Page 17: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

TRIM R-script

• Retrieve data directly from Postgres-

database or read .csv-files:

– Sites

– Visits

– Observations

Page 18: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Examples

• Make files for TRIM

– make.TRIM.files()

• Run TRIM

• Import TRIM-output

– Import.TRIM.output()

Page 19: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Examples

• Read data ## ROUTE LOCATIONS

pktrute <- read.csv2("pktrute.csv", as.is = TRUE,

fileEncoding = "UTF8")

## SPECIES CODES AND NAMES

speciescodes <- read.csv2("speciescodes.csv", as.is = TRUE,

fileEncoding = "UTF8")

• Set parameters minyear <- 1976

maxyear <- 2015

map.format <- "pdf“

test.run <- TRUE

Page 20: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Output: maps with observations

© Danish bird data: DOF

Page 21: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Output: trend graphs

Page 22: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

MAPS

Page 23: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Spatial modeling with TRIMmaps

Saxifraga – Piet Munsterman

Page 24: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

TRIMmaps

• Facilitate production of maps from

monitoring data and casual

observations

• R-programme

• Open source / freeware

Page 25: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Statistics TRIMmaps

• Combination of

– Regression type statistics

– Spatial interpolation of residuals

• Uses TRIM-input (data-files) or -output

(F1-files) and a number of other formats

Page 26: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Interpolation of residuals

• Inversed Distance Weighting (IDW)

• Kriging

Include observed local deviations from regression model

Better maps

Page 27: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Combined map

interpolated residuals

regression model

Page 28: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

What do you need to run TRIMmaps ?

Page 29: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Observations

• Counts

• Presence-absence

• Presence-only

• Local trend data

• CSV-file

• TRIM F1- or dat-files

Page 30: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Site/location info

• X- and Y-coordinates

Page 31: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Environmental maps

• Raster maps

– Like:

• Climate

• Land use

• Landscape

Page 32: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Optional: site specific covariates

• Environmental characteristics for sites

that have a different spatial extend than

the prediction grids

– Like:

• buffers around points

• Transects with distance bands

• Plots with natural bounderies

• Squares that are bigger than the prediction grid

• Have to be pre-prepared with GIS

Page 33: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

And some basic R-knowledge

We even made a small course for you

Page 34: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Running TRIMmaps

Page 35: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Zeroes

• Add zeroes for TRIM F1- or dat-files

• Generate zeroes with Maxent

Page 36: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Overlay with environmental data

sets

• Climate

• Altitude (DTM)

• Land cover

• …

Page 37: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Regression models

• GLM

• GAM

• MARS

• Mixed models

• Boosted Regression Trees

• Random Forests

• ..

Page 38: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Output

• Maps

– Observations

– Predictions regression

– Residuals

– Combined map

• Regression models

• Model validations

• Shape-files, ASCII-grids and geoTIFF with predictions

Page 39: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Observations

Page 40: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Distribution maps: regression

predictions

Page 41: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Interpolated residuals

Page 42: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Distribution maps

Regression predictions and

interpolated residuals

Regression predictions

Interpolated residuals

Page 43: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Variable contributions

Variable Relative

importance (%)

Precipitation Seasonality 18.8

Precipitation of Driest Month 17.4

Arable land 15.6

Precipitation of Warmest Quarter 8.5

Temperature Seasonality 6.1

Potential evapotranspiration 5.8

Silt soil 4.7

Mean Temperature of Driest

Quarter 3.9

Complex cultivation patterns 3.6

Page 44: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Response curves

18 20 22 24 26 28 302

46

81

0

bio_15

Pre

dic

ted

co

un

t

19.9 %

0.0 0.2 0.4 0.6 0.8 1.0

23

45

6

c00_f12_1km

Pre

dic

ted

co

un

t

16.6 %

30 35 40 45

34

56

78

bio_14

Pre

dic

ted

co

un

t

15.9 %

160 180 200 220

3.0

3.2

3.4

3.6

bio_18

Pre

dic

ted

co

un

t

8.8 %

5600 5800 6000 6200 6400

3.1

3.2

3.3

3.4

3.5

bio_4

Pre

dic

ted

co

un

t

6 %

480 520 560 600

3.0

3.4

3.8

4.2

pet_he_yr

Pre

dic

ted

co

un

t

5.4 %

Page 45: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Model quality

• Explained deviance

• Error statistics (MAE, MFE)

• ROC-plots

• Cross-validation

• Covariate maps

• QQ-plots, etc

Page 46: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Combining

trend and distribution:

trend maps

Page 47: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Trend maps

• Standardized difference between the

average count in the last three years and

the first three years of the period of

interest

Nend of period – Nstart of period

(N1+N2)/2

Page 48: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Corn Bunting trend 1984-1995

Page 49: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Corn Bunting trend 1994-2005

Page 50: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Corn Bunting trend 2004-2015

Page 51: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Difference maps

• Difference between predicted

distribution in two time periods

Saxifraga – Piet Munsterman

Page 52: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Absolute difference map

2010

2000

Page 53: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Important remarks

• Bird observed Birds present !

• Assumes minor influence of differences in

detection probabilities between habitats

• Next steps: account for imperfect

detection

Page 54: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Comparison with other R-

packages

• Site-specific covariates

– like buffer around point or transect

– downscaling larger grids

• Account for spatial correlation in

residuals

• Use TRIM-files for input

Page 55: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Download TRIMmaps

www.sovon.nl/nl/content/trimmaps

Page 56: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Download TRIMmaps

or simply google ‘trimmaps’

Page 57: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Installing TRIMmaps

• Install R

• Install 64-bits Java manually!

• Run ‘install_TRIMmaps.r’

• Check dependent packages with

firstLibraryStart()

• That’s it!

Page 58: R-tools to analyse bird data_Henk sierdsema_Bird numbers 2016

Thank you for your attention… And we are happy to help you with the use of TRIMmaps!

[email protected]

An extented version of this presentation

can be download from Slideshare.net

Saxifraga – Mark Zekhuis