ppm(nztrees)
 # fit the stationary Poisson process
 # to point pattern 'nztrees'
 Q <- quadscheme(nztrees) 
 ppm(Q) 
 # equivalent.
 ppm(nztrees, nd=128)
 <testonly>ppm(nztrees, nd=16)</testonly>
fit1 <- ppm(nztrees, ~ x)
 # fit the nonstationary Poisson process 
 # with intensity function lambda(x,y) = exp(a + bx)
 # where x,y are the Cartesian coordinates
 # and a,b are parameters to be estimated
fit1
coef(fit1)
coef(summary(fit1))
ppm(nztrees, ~ polynom(x,2))
<testonly>ppm(nztrees, ~ polynom(x,2), nd=16)</testonly>
 # fit the nonstationary Poisson process 
 # with intensity function lambda(x,y) = exp(a + bx + cx^2)
 library(splines)
 ppm(nztrees, ~ bs(x,df=3))
 #       WARNING: do not use predict.ppm() on this result
 # Fits the nonstationary Poisson process 
 # with intensity function lambda(x,y) = exp(B(x))
 # where B is a B-spline with df = 3
ppm(nztrees, ~1, Strauss(r=10), rbord=10)
<testonly>ppm(nztrees, ~1, Strauss(r=10), rbord=10, nd=16)</testonly>
 # Fit the stationary Strauss process with interaction range r=10
 # using the border method with margin rbord=10
ppm(nztrees, ~ x, Strauss(13), correction="periodic")
<testonly>ppm(nztrees, ~ x, Strauss(13), correction="periodic", nd=16)</testonly>
 # Fit the nonstationary Strauss process with interaction range r=13
 # and exp(first order potential) =  activity = beta(x,y) = exp(a+bx)
 # using the periodic correction.
# Huang-Ogata fit:
ppm(nztrees, ~1, Strauss(r=10), method="ho")
<testonly>ppm(nztrees, ~1, Strauss(r=10), method="ho", nd=16, nsim=10)</testonly>
 # COVARIATES
 #
 X <- rpoispp(42)
 weirdfunction <- function(x,y){ 10 * x^2 + 5 * sin(10 * y) }
 #
 # (a) covariate values as function
 ppm(X, ~ y + Z, covariates=list(Z=weirdfunction))
 #
 # (b) covariate values in pixel image
 Zimage <- as.im(weirdfunction, unit.square())
 ppm(X, ~ y + Z, covariates=list(Z=Zimage))
 #
 # (c) covariate values in data frame
 Q <- quadscheme(X)
 xQ <- x.quad(Q)
 yQ <- y.quad(Q)
 Zvalues <- weirdfunction(xQ,yQ)
 ppm(Q, ~ y + Z, covariates=data.frame(Z=Zvalues))
 # Note Q not X
 # COVARIATE FUNCTION WITH EXTRA ARGUMENTS
 #
f <- function(x,y,a){ y - a }
ppm(X, ~x + f, covariates=list(f=f), covfunargs=list(a=1/2))
 ## MULTITYPE POINT PROCESSES ### 
 # fit stationary marked Poisson process
 # with different intensity for each species
ppm(lansing, ~ marks, Poisson())
<testonly>a <- ppm(amacrine, ~ marks, Poisson(), nd=16)</testonly>
 # fit nonstationary marked Poisson process
 # with different log-cubic trend for each species
ppm(lansing, ~ marks * polynom(x,y,3), Poisson())
<testonly>ppm(amacrine, ~ marks * polynom(x,y,2), Poisson(), nd=16)</testonly>Run the code above in your browser using DataLab