class: title-slide, inverse, center, middle # R migration, etc <div style="position: absolute; bottom: 15px; vertical-align: center; left: 10px"> <img src="../slides/images/02-foundation-vertical-white.png" height="200"> </div> --- # We've spent all day talking about R - Many people do distance sampling analyses in Distance - Windows GUI program - Developed at St Andrews since 1997 - Easy to start but harder for more complicated projects --- class: inverse, center, middle <img src="http://distancesampling.org/Distance/images/analysis.jpg"> --- # Distance is bad at some things - Fiddly to do GIS stuff - Spatial modelling is hard, Distance doesn't have all the tools - Writing a lot of models can be time consuming --- class: inverse, center, middle # ๐The future๐ --- # R is good - Easy to investigate more complicated models - Audit of what you did - Reproducible analyses --- class: inverse, center, middle # How do we get there from here? --- # `readdst` - R package to automatically convert Distance projects - Distance projects are just an Access database - "Frees" your data from the format and converts models --- # A quick example ```r library(readdst) converted <- convert_project(project_file) ``` --- # What's in that? ```r converted ``` ``` ## ID Name Status ## 1 3 FI - MR dist+size+sex+exp Not Run ## 2 2 FI - MR dist Not Run ## 3 7 io.pi Not Run ## 4 9 FI - Petersen 1 Not Run ## 5 10 FI - Petersen 2 Not Run ## 6 1 FI - Petersen Ran OK ## 7 6 io.fi Ran OK ## 8 4 ds (single platform) Ran OK ## 9 5 trial Ran OK ## 10 8 test intervals Ran OK ``` --- # Let's run an analysis ```r analysis_1 <- run_analysis(converted[[1]]) summary(analysis_1) ``` ``` ## ## Summary for trial.fi object ## Number of observations : 162 ## Number seen by primary : 124 ## Number seen by secondary (trials) : 142 ## Number seen by both (detected trials): 104 ## AIC : 510.766 ## ## ## Conditional detection function parameters: ## estimate se ## (Intercept) 1.006805 0.189555 ## ## Estimate SE CV ## Average p 0.7323944 0.03799900 0.05188325 ## Average primary p(0) 0.7323944 0.03715144 0.05072601 ## N in covered region 169.3076923 11.64565922 0.06878399 ``` --- # Oh our data is there too! ```r ls(converted[[1]]$env) ``` ``` ## [1] "data" "obs.table" "region.table" "sample.table" ## [5] "units" ``` (an *environment*) --- # The data ```r head(converted[[1]]$env$data) ``` ``` ## object observer detected sex exposure distance size Study.Area ## 1 1 1 1 1 1 2.68 2 GolfteesExercise ## 2 1 2 0 1 1 2.68 2 GolfteesExercise ## 3 2 1 1 1 0 3.33 2 GolfteesExercise ## 4 2 2 0 1 0 3.33 2 GolfteesExercise ## 5 3 1 1 0 0 0.34 1 GolfteesExercise ## 6 3 2 0 0 0 0.34 1 GolfteesExercise ## Region.Label Sample.Label ## 1 Default Default ## 2 Default Default ## 3 Default Default ## 4 Default Default ## 5 Default Default ## 6 Default Default ``` --- # Checking results ```r test_stats(converted[[1]]) ``` ``` ## Statistic Distance_value mrds_value Difference Pass ## 1 AIC 510.765991 510.76603075588 0.00000007784 โ ## 2 log-likelihood -254.4 -254.4 0 โ ## 3 density 0.309649706 0.30964972527 0.00000004933 โ ## 4 CV(density) 0.07345 0.08365 0.13886 ## 5 individuals 520.211487 520.21153846193 0.00000009893 โ ## 6 CV(individuals) 0.07345 0.08365 0.13886 ``` --- # Recap - Distance can be a great way to start an analysis - More complicated stuff can be easier in R - `readdst` does the conversion for you - Checks results in case there are differences