[R] "model.response" error

Bang jbang at uiuc.edu
Wed Jan 12 18:13:44 CET 2005


When I installed R 2.0.1 (replacing 1.9.0) for Windows, a code using
"model.response" began acting up.  Here are the first several lines of a
code I had been tweaking for a spatial model (the code is mostly that of
Roger Bivand--I am adapting it to a slightly different data structure and
the problem I'm sure is with my changes, not his code).

<command name> <- function (formula, data = list(), weights, na.action =
na.fail, type = "lag", quiet = TRUE, zero.policy = FALSE, tol.solve = 1e-07,
tol.opt = .Machine$double.eps^0.5, sparsedebug = FALSE)
{
    mt <- terms(formula, data = data)
    mf <- lm(formula, data, na.action = na.action, method = "model.frame")
    na.act <- attr(mf, "na.action")
    if (!is.matrix.csr(weights))
        cat("\nWarning: weights matrix not in sparse form\n")
    switch(type, lag = if (!quiet)
        cat("\nSpatial lag model\n"), mixed = if (!quiet)
        cat("\nSpatial mixed autoregressive model\n"), stop("\nUnknown model
type\n"))
    if (!quiet)
        cat("Jacobian calculated using weights matrix eigenvalues\n")
    y <- model.response(mf, "numeric")
    if (any(is.na(y))) stop("NAs in dependent variable")
    x <- model.matrix(mt, mf)
    if (any(is.na(x))) stop("NAs in independent variable")
    if (nrow(x) != nrow(weights))
        stop("Input data and weights have different dimensions")
    n <- nrow(x)
    m <- ncol(x)

When it reads the "Y" variable in the command:

"y <- model.response(mf, "numeric")"

The error it gives is:

"Error in model.response(mf, "numeric") : No direct or inherited method
for function "model.response" for this call"

The problem is puzzling me because it is not something I encountered when I
was running the same code in 1.9.0, but is causing problems in 2.0.1

Thanks, and any comments on debugging the error are welcome. 

Jim

Well I AM missing the back of my head.you COULD cut me a little slack!
-Homer Simpson




More information about the R-help mailing list