R Tutorial : Further testing (Spatial Statistics in R)

DataCamp · Beginner ·🔢 Mathematical Foundations ·6y ago

Key Takeaways

The video demonstrates the use of Spatial Statistics in R, specifically the quadrat test, nearest neighbor distribution, and Ripley's K function, to analyze spatial point processes. It also introduces Monte Carlo testing for complete spatial randomness.

Full Transcript

one problem with the quadrat test is that you have to choose a set of sub regions two few and you don't have many numbers for the statistical test to have much power too many and your regions don't have many points in them and you lose power too there are alternative tests that don't depend on arbitrary subdivisions instead relying on estimating properties of the spatial point process from the events one such property is the nearest neighbor distribution look at each event in your pattern and find the distance to the nearest event so here as nearest neighbor is B B's nearest neighbor is a and season areas neighbor is B that gives us three distances do this for every event plot a histogram to give an estimate of the probability density function of the nearest neighbor distribution a corresponding cumulative distribution function the probability of finding a nearest neighbor within a distance D is named G for a completely spatially random process the theoretical form of G can be worked out exactly so for a process with lambda events per unit area it looks like this spats that uses the GS function to estimate G given a PPP object and an optional distance vector the lines in this plot include two Corrections for edge effects because events near the edge of the window have less area in which the nearest neighbor might have been and this will bias the estimator so G s has a correction argument to choose these edge correction algorithms another useful function of spatial point processes is the ripley's reduced second moment measure better known as the K function K is the number of expected events to be found at a given distance from an event scaled by the intensity to estimate it for some given distance D visit each event in turn and count the number of other events in a circle of radius D take the average that's K of D do that for a number of values of D and you can plot the function for a completely spatially random process this gives K of equals pi times D squared the area of a circle of radius D but how much variation can be expected from an estimate K so that it can be used as a test for complete spatial randomness well first create 99 completely spatially random point patterns in your window and compute the 99 estimates of K you can plot them now compute K for the data and plot it over the simulation estimates is it bigger than the simulations at any point that's an indication of clustering at that scale since the data at that point outranks all 99 simulations you can say it rejects the null hypothesis at a p-value of 0.01 using 99 simulations just makes the division easy since you divided by 99 plus 1 for the data 100 to get the p-value this sort of test where you generate replicates from your hypothesis compute test statistics or functions and compared with the statistic from the data is called a Monte Carlo test it's commonly used in spatial statistics because working out the theoretical distribution of things can be somewhat tricky in the next few exercises you'll explore the nearest neighbor distribution and do some Monte Carlo testing

Original Description

Want to learn more? Take the full course at https://learn.datacamp.com/courses/spatial-statistics-in-r at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work. --- One problem with the quadrat test is that you have to choose a set of sub-regions: Too few, and you don't have many numbers for the statistical test to have much power. Too many, and your regions don't have many points in them and you lose power too. There are alternative tests that don't depend on arbitrary subdivisions, instead of relying on estimating properties of the spatial point process from the events. One such property is the nearest-neighbour distribution. Look at each event in your pattern and find the distance to the nearest event. Do this for every event, and plot a histogram to give an estimate of the probability density function of the nearest neighbour distribution. So here, A's nearest neighbour is B, B's nearest neighbour is A, and C's nearest neighbour is B. That gives us three distances. Do this for every event, and plot a histogram to give an estimate of the probability density function of the nearest neighbour distribution. The corresponding cumulative distribution function, the probability of finding a nearest neighbour within a distance d, is named "G". For a completely spatially random process, the theoretical form of G can be worked out exactly, so for a process with "lambda" events per unit area: It looks like this. spatstat uses the Gest() function to estimate G, given a ppp object and an optional distance vector. The lines in this plot include two corrections for edge effects. Events near the edge of the window have less area in which their nearest neighbour might have been, and this will bias the estimator. So Gest() has a "correction" argument to choose these edge-correction algorithms. Another useful function of spatial point processes is the "Ripley's reduced second-moment measure" - better known as the "K" fu
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from DataCamp · DataCamp · 0 of 60

← Previous Next →
1 SQL Server Tutorial: Date manipulation
SQL Server Tutorial: Date manipulation
DataCamp
2 R Tutorial: Intermediate Interactive Data Visualization with plotly in R
R Tutorial: Intermediate Interactive Data Visualization with plotly in R
DataCamp
3 R Tutorial: Adding aesthetics to represent a variable
R Tutorial: Adding aesthetics to represent a variable
DataCamp
4 R Tutorial: Moving Beyond Simple Interactivity
R Tutorial: Moving Beyond Simple Interactivity
DataCamp
5 Python Tutorial: Why use ML for marketing? Strategies and use cases
Python Tutorial: Why use ML for marketing? Strategies and use cases
DataCamp
6 Python Tutorial: Preparation for modeling
Python Tutorial: Preparation for modeling
DataCamp
7 Python Tutorial: Machine Learning modeling steps
Python Tutorial: Machine Learning modeling steps
DataCamp
8 R Tutorial: The prior model
R Tutorial: The prior model
DataCamp
9 R Tutorial: Data & the likelihood
R Tutorial: Data & the likelihood
DataCamp
10 R Tutorial: The posterior model
R Tutorial: The posterior model
DataCamp
11 R Tutorial: An Introduction to plotly
R Tutorial: An Introduction to plotly
DataCamp
12 R Tutorial: Plotting a single variable
R Tutorial: Plotting a single variable
DataCamp
13 R Tutorial: Bivariate graphics
R Tutorial: Bivariate graphics
DataCamp
14 Python Tutorial: Customer Segmentation in Python
Python Tutorial: Customer Segmentation in Python
DataCamp
15 Python Tutorial: Time cohorts
Python Tutorial: Time cohorts
DataCamp
16 Python Tutorial: Calculate cohort metrics
Python Tutorial: Calculate cohort metrics
DataCamp
17 Python Tutorial: Cohort analysis visualization
Python Tutorial: Cohort analysis visualization
DataCamp
18 R Tutorial: Building Dashboards with flexdashboard
R Tutorial: Building Dashboards with flexdashboard
DataCamp
19 R Tutorial: Anatomy of a flexdashboard
R Tutorial: Anatomy of a flexdashboard
DataCamp
20 R Tutorial: Layout basics
R Tutorial: Layout basics
DataCamp
21 R Tutorial: Advanced layouts
R Tutorial: Advanced layouts
DataCamp
22 Python Tutorial: Time Series Analysis in Python
Python Tutorial: Time Series Analysis in Python
DataCamp
23 Python Tutorial: Correlation of Two Time Series
Python Tutorial: Correlation of Two Time Series
DataCamp
24 Python Tutorial: Simple Linear Regressions
Python Tutorial: Simple Linear Regressions
DataCamp
25 Python Tutorial: Autocorrelation
Python Tutorial: Autocorrelation
DataCamp
26 R Tutorial: The gapminder dataset
R Tutorial: The gapminder dataset
DataCamp
27 R Tutorial: The filter verb
R Tutorial: The filter verb
DataCamp
28 R Tutorial: The arrange verb
R Tutorial: The arrange verb
DataCamp
29 R Tutorial: The mutate verb
R Tutorial: The mutate verb
DataCamp
30 R Tutorial: What is cluster analysis?
R Tutorial: What is cluster analysis?
DataCamp
31 R Tutorial: Distance between two observations
R Tutorial: Distance between two observations
DataCamp
32 R Tutorial: The importance of scale
R Tutorial: The importance of scale
DataCamp
33 R Tutorial: Measuring distance for categorical data
R Tutorial: Measuring distance for categorical data
DataCamp
34 Python Tutorial: Plotting multiple graphs
Python Tutorial: Plotting multiple graphs
DataCamp
35 Python Tutorial: Customizing axes
Python Tutorial: Customizing axes
DataCamp
36 Python Tutorial: Legends, annotations, & styles
Python Tutorial: Legends, annotations, & styles
DataCamp
37 Python Tutorial: Introduction to iterators
Python Tutorial: Introduction to iterators
DataCamp
38 Python Tutorial: Playing with iterators
Python Tutorial: Playing with iterators
DataCamp
39 Python Tutorial: Using iterators to load large files into memory
Python Tutorial: Using iterators to load large files into memory
DataCamp
40 SQL Tutorial: Introduction to Relational Databases in SQL
SQL Tutorial: Introduction to Relational Databases in SQL
DataCamp
41 SQL Tutorial: Tables: At the core of every database
SQL Tutorial: Tables: At the core of every database
DataCamp
42 SQL Tutorial: Update your database as the structure changes
SQL Tutorial: Update your database as the structure changes
DataCamp
43 Python Tutorial: Classification-Tree Learning
Python Tutorial: Classification-Tree Learning
DataCamp
44 Python Tutorial: Decision-Tree for Classification
Python Tutorial: Decision-Tree for Classification
DataCamp
45 Python Tutorial: Decision-Tree for Regression
Python Tutorial: Decision-Tree for Regression
DataCamp
46 Python Tutorial: Census Subject Tables
Python Tutorial: Census Subject Tables
DataCamp
47 Python Tutorial: Census Geography
Python Tutorial: Census Geography
DataCamp
48 Python Tutorial: Using the Census API
Python Tutorial: Using the Census API
DataCamp
49 R Tutorial: A/B Testing in R
R Tutorial: A/B Testing in R
DataCamp
50 R Tutorial: Baseline Conversion Rates
R Tutorial: Baseline Conversion Rates
DataCamp
51 R Tutorial: Designing an Experiment - Power Analysis
R Tutorial: Designing an Experiment - Power Analysis
DataCamp
52 R Tutorial: Introduction to qualitative data
R Tutorial: Introduction to qualitative data
DataCamp
53 R Tutorial: Understanding your qualitative variables
R Tutorial: Understanding your qualitative variables
DataCamp
54 R Tutorial: Making Better Plots
R Tutorial: Making Better Plots
DataCamp
55 SQL Tutorial: OLTP and OLAP
SQL Tutorial: OLTP and OLAP
DataCamp
56 SQL Tutorial: Storing data
SQL Tutorial: Storing data
DataCamp
57 SQL Tutorial: Database design
SQL Tutorial: Database design
DataCamp
58 Python Tutorial: Introduction to spaCy
Python Tutorial: Introduction to spaCy
DataCamp
59 Python Tutorial: Statistical Models
Python Tutorial: Statistical Models
DataCamp
60 Python Tutorial: Rule-based Matching
Python Tutorial: Rule-based Matching
DataCamp

This video teaches spatial statistics in R, covering the quadrat test, nearest neighbor distribution, and Ripley's K function. It also introduces Monte Carlo testing for complete spatial randomness, allowing users to analyze and understand spatial point processes.

Key Takeaways
  1. Choose a set of sub-regions for the quadrat test
  2. Estimate the nearest neighbor distribution using the GS function
  3. Compute Ripley's K function
  4. Perform Monte Carlo testing for complete spatial randomness
  5. Compare the statistic from the data with simulation estimates
💡 The video highlights the importance of accounting for edge effects when estimating the nearest neighbor distribution and demonstrates how to use Monte Carlo testing to determine the significance of clustering at different scales.

Related Reads

Up next
Solve Any Math Problem Step by Step — Free (Type or Snap a Photo)
Zariga Tongy
Watch →