Max_IT
Max_IT

Reputation: 626

Importing one dimensional dataset for Complete Spatial Randomness win spatstat

I have a set of one-dimensional data points (locations on a segment), and I would like to test for Complete Spatial randomness. I was planning to run Gest (nearest neighbor), Fest (empty space) and Kest (pairwise distances) functions on it.

I am not sure how I should import my data set though. I can use ppp by setting a second dimension to 0, e.g.:

myDistTEST<- data.frame(
  col1= sample(x = 1:100, size = 50, replace = FALSE),
  col2= paste('Event', 1:50, sep = ''), stringsAsFactors = FALSE)
myDistTEST<- myDistTEST[order(myDistTEST$col1),]                        
myPPPTest<- ppp(x = myDistTEST[,1], y = replicate(n = 50, expr = 0),
                c(1,120), c(0,0))

But I am not sure it is the proper way to format my data. I have also tried to use lpp, but I am not sure how to set the linnet object. What would be the correct way to import my data? Thank you for your kind attention.

Upvotes: 1

Views: 150

Answers (1)

Ege Rubak
Ege Rubak

Reputation: 4507

It will be wrong to simply let y=0 for all your points and then proceed as if you had a point pattern in two dimensions. Your suggestion of using lpp is good. Regarding how to define the linnet and lpp try to look at my answer here.

I have considered making a small package to handle one dimensional patterns more easily in spatstat, but so far I have only started the package with a single function to make the definition of the appropriate lpp easier. If you feel adventurous you can install it from the GitHub repo via the remotes package:

remotes::install_github("rubak/spatstat.1d")

The single function you can use is called lpp1. It basically just wraps up the few steps described in the linked answer.

Upvotes: 1

Related Questions