## S3 method for class 'ppm':
model.matrix(object, data=model.frame(object), ..., keepNA=TRUE) ## S3 method for class 'kppm':
model.matrix(object, data=model.frame(object), ...,
keepNA=TRUE)
## S3 method for class 'lppm':
model.matrix(object, data=model.frame(object), ..., keepNA=TRUE)
"ppm"
or "kppm"
or "lppm"
.na.action
) passed to
model.matrix.lm
.keepNA=TRUE
).model.matrix
. They extracts the design matrix of a
spatial point process model (class "ppm"
or "kppm"
or "lppm"
). 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 "lppm"
)
fitted to spatial point pattern data.
Such objects are produced by the model-fitting
functions ppm
, kppm
and lppm
.
The methods model.matrix.ppm
, model.matrix.kppm
and model.matrix.lppm
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
.
model.matrix
,
model.images
,
ppm
,
kppm
,
lppm
,
ppm.object
,
quad.ppm
,
residuals.ppm
fit <- ppm(cells, ~x)
head(model.matrix(fit))
# matrix with two columns: '(Intercept)' and 'x'
kfit <- kppm(redwood, ~x, "Thomas")
m <- model.matrix(kfit)
Run the code above in your browser using DataLab