Learn R Programming

gear (version 0.3.4)

fitted.geolm: Extract fitted values from a geolm object

Description

Extract the fitted values, i.e., the estimated mean values, for an object produced by the geolm function for a specified set of covariates, x. If x is NULL, then then x is taken from object.

Usage

# S3 method for geolm
fitted(object, x, ...)

Arguments

object

An object produced by the geolm function.

x

A \(m \times p\) matrix of covariates for the locations where fitted values are desired. If NULL, object$x is used.

...

Not currently implemented.

Value

The vector of fitted values.

Details

If the object has a known mean, i.e., object$mu is not NULL, then the function returns the vector rep(object$mu, m). If object has estimated coefficients, then x %*% object$coeff is returned.

If x is missing, then object$x is used for x. Naturally, ncol(x) must equal length(object$coeff). If x is NULL and object$mu is not NULL, then m is taken to be 1.

See Also

fitted

Examples

Run this code
# NOT RUN {
data = data.frame(y = rnorm(10), x1 = runif(10),
                 x2 = runif(10))
d = as.matrix(dist(data[,c("x1", "x2")]))
mod = cmod_man(v = exp(-d), evar = 1)
gearmod = geolm(y ~ x1, data = data,
                coordnames = ~ x1 + x2, mod = mod)
# fitted values for original observations
fitted(gearmod)
# fitted values for new observations
fitted(gearmod, x = cbind(1, rnorm(20)))
# }

Run the code above in your browser using DataLab