spatstat (version 1.24-2)

model.depends: Identify Covariates Involved in each Model Term

Description

Given a fitted model (of any kind), identify which of the covariates is involved in each term of the model.

Usage

model.depends(object)
model.is.additive(object)

Arguments

object
A fitted model of any kind.

Value

  • A logical value or matrix.

Details

The object can be a fitted model of any kind, including models of the classes lm, glm and ppm.

To be precise, object must belong to a class for which there are methods for formula, terms and model.matrix. The command model.depends determines the relationship between the original covariates (the data supplied when object was fitted) and the canonical covariates (the columns of the design matrix). It returns a logical matrix, with one row for each canonical covariate, and one column for each of the original covariates, with the i,j entry equal to TRUE if the ith canonical covariate depends on the jth original covariate.

If the model formula of object includes offset terms (see offset), then the return value of model.depends also has an attribute "offset". This is a logical value or matrix with one row for each offset term and one column for each of the original covariates, with the i,j entry equal to TRUE if the ith offset term depends on the jth original covariate.

The command model.is.additive determines whether the model is additive, in the sense that there is no canonical covariate that depends on two or more original covariates. It returns a logical value.

See Also

ppm, model.matrix

Examples

Run this code
x <- 1:10
   y <- 3*x + 2
   z <- rep(c(-1,1), 5)
   fit <- lm(y ~ poly(x,2) + sin(z))
   model.depends(fit)
   model.is.additive(fit)

Run the code above in your browser using DataCamp Workspace