The R scripts used in Hannunen and Tuomola "Assessing the probability of freedom from pine wood nematode based on 19 years of surveys" How to run the scripts: 1. Save all the files listed below in your working directory. 2. To get the sensitivity of the annual surveys, run the script Sensitivity.R. 3. To get the probability of freedom achieved by 2018, run the script Probability_of_freedom.R. The files needed: * Sensitivity.R calculates the sensitivity of the annual surveys in 2000-2018 for all the administrative regions and Finland and plots them as figures. With the current data, the script gives warning messages about zero-length arrows. This is because the whiskers showing the 95% confidence intervals are of zero-length in many cases. * Probability_of_freedom.R calculates the probability of freedom achieved by 2018 for a range of probabilities of invasion for all the regions and Finland and plots them as figures. If the number of iterations is high, running the script can take some time. * Data.R contains the data used in the assessment. * Sensitivity_function.R contains a function that returns the sensitivity of the annual surveys in 2000-2018 for all the regions and Finland in one array, in which dimension 1 = years, dimension 2 = regions (administrative regions in columns 1-15, Finland in column 16), and dimension 3 = iterations. * Probability_of_freedom_function.R contains a function that returns the probability of freedom achieved by 2018 for a range of probabilities of invasion for all the regions and Finland in one array, in which dimension 1 = years, dimension 2 = regions (administrative regions in columns 1-15, Finland in column 16), and dimension 3 = iterations. The order of the administrative regions in all the matrixes and arrays is the following: 1. Uusimaa, 2. Varsinais-Suomi, 3. Satakunta, 4. Häme, 5. Pirkanmaa, 6. Kaakkois-Suomi, 7. Etelä-Savo, 8. Pohjois-Savo, 9. Pohjois-Karjala, 10. Keski-Suomi, 11. Etelä-Pohjanmaa, 12. Pohjanmaa, 13. Pohjois-Pohjanmaa, 14. Kainuu, 15. Lappi