Dear subscribers and Prof. Bivand,

I am using lagsarlm function in spdep package to study my research problem.
I am trying to use restaurants' price, rating, and some other variables to
explain their customer visit. So customer visit is my dependent variable,
and I have 6 independent variables. I want to use the spatial mixed model
so that I can find out whether there are spatial correlated issue in my
independent variables. I understand that for the spatial mixed model, the
lagsarlm function calculates the spatial lag coefficients for all the 6
independent variable, but what I really want is just for two of them.

So I checked the course code for lagsarlm function to see where I should
modify based on my need. I figured I should change the part that construct
the WX matrix. My modification is as follows:

if (m > 1) {
      WX <- matrix(nrow = n, ncol = 2)
        wx1 <- lag.listw(listw, x[, 7], zero.policy = zero.policy)
        wx2 <- lag.listw(listw, x[, 8], zero.policy = zero.policy)
        if (any(is.na(wx)))
          stop("NAs in lagged independent variable")
        WX <- cbind(wx1, wx2)
    }

and all the other parts remain same. However, when I run this self-defined
function, R keeps giving me the following error message:

Error in get("verbose", envir = .spdepOptions) :
  object '.spdepOptions' not found

I have made sure that I loaded the spdep package before I run this
function.

Could you please let me know why I get this error and how should I fix it?

I really appreciate any help or suggestion you could give to me.


Best,

Michelle

	[[alternative HTML version deleted]]

