Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

model.matrix.ppm

Extract Design Matrix from Point Process Model


Description

Given a point process model that has been fitted to spatial point pattern data, this function extracts the design matrix of the model.

Usage

## S3 method for class 'ppm'
model.matrix(object,
                              data=model.frame(object, na.action=NULL),
                              ..., 
                              Q=NULL, keepNA=TRUE)

   ## S3 method for class 'kppm'
model.matrix(object,
                              data=model.frame(object, na.action=NULL),
                              ..., 
                              Q=NULL, keepNA=TRUE)

   ## S3 method for class 'dppm'
model.matrix(object,
                              data=model.frame(object, na.action=NULL),
                              ..., 
                              Q=NULL, keepNA=TRUE)


   ## S3 method for class 'ippm'
model.matrix(object,
                              data=model.frame(object, na.action=NULL),
                              ..., 
                              Q=NULL, keepNA=TRUE,
			      irregular=FALSE)

Arguments

object

The fitted point process model. An object of class "ppm" or "kppm" or "dppm" or "ippm".

data

A model frame, containing the data required for the Berman-Turner device.

Q

A point pattern (class "ppp") or quadrature scheme (class "quad") specifying new locations where the covariates should be computed.

keepNA

Logical. Determines whether rows containing NA values will be deleted or retained.

...

Other arguments (such as na.action) passed to model.matrix.lm.

irregular

Logical value indicating whether to include the irregular score components.

Details

These commands are methods for the generic function model.matrix. They extract the design matrix of a spatial point process model (class "ppm" or "kppm" or "dppm").

More precisely, this command extracts the design matrix of the generalised linear model associated with a spatial point process model.

The object must be a fitted point process model (object of class "ppm" or "kppm" or "dppm") fitted to spatial point pattern data. Such objects are produced by the model-fitting functions ppm, kppm, and dppm.

The methods model.matrix.ppm, model.matrix.kppm, and model.matrix.dppm extract the model matrix for the GLM.

The result is a matrix, with one row for every quadrature point in the fitting procedure, and one column for every constructed covariate in the design matrix.

If there are NA values in the covariates, the argument keepNA determines whether to retain or delete the corresponding rows of the model matrix. The default keepNA=TRUE is to retain them. Note that this differs from the default behaviour of many other methods for model.matrix, which typically delete rows containing NA.

The quadrature points themselves can be extracted using quad.ppm.

Value

A matrix. Columns of the matrix are canonical covariates in the model. Rows of the matrix correspond to quadrature points in the fitting procedure (provided keepNA=TRUE).

Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner r.turner@auckland.ac.nz and Ege Rubak rubak@math.aau.dk.

See Also

Examples

fit <- ppm(cells ~ x)
   head(model.matrix(fit))
   model.matrix(fit, Q=runifpoint(5))
   kfit <- kppm(redwood ~ x, "Thomas")
   m <- model.matrix(kfit)

spatstat.core

Core Functionality of the 'spatstat' Family

v2.1-2
GPL (>= 2)
Authors
Adrian Baddeley [aut, cre], Rolf Turner [aut], Ege Rubak [aut], Kasper Klitgaard Berthelsen [ctb], Achmad Choiruddin [ctb], Jean-Francois Coeurjolly [ctb], Ottmar Cronie [ctb], Tilman Davies [ctb], Julian Gilbey [ctb], Yongtao Guan [ctb], Ute Hahn [ctb], Kassel Hingee [ctb], Abdollah Jalilian [ctb], Marie-Colette van Lieshout [ctb], Greg McSwiggan [ctb], Tuomas Rajala [ctb], Suman Rakshit [ctb], Dominic Schuhmacher [ctb], Rasmus Plenge Waagepetersen [ctb], Hangsheng Wang [ctb]
Initial release
2021-04-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.