[R-sig-Geo] ? model evaluation error

Brian Rubineau brubineau at sloan.mit.edu
Fri Jun 9 03:01:15 CEST 2006


Wonderful - thank you! It worked perfectly as suggested.
I will send version information as well next time.
Appreciatively,
Brian

-- 
Brian Rubineau                             PhD Candidate, Organization Studies
brubineau at sloan.mit.edu                         MIT Sloan School of Management
tel: 617.253.6680                                   50 Memorial Drive, E52-511
fax: 810.963.2738                                         Cambridge, MA  02142


Quoting Roger Bivand <Roger.Bivand at nhh.no>:

> On Thu, 8 Jun 2006, Brian Rubineau wrote:
>
>> Dear spdep sages,
>> I am a new R user, and very new spdep user, and am receiving
>> an error message (below) that to me is inscrutable.
>>
>> Error in if (attr(vlist, "mode") != "binary") stop("Not yet able to subset
>> general weights lists") :
>>         argument is of length zero
>>
>
> Say traceback(), then. But just trying things:
>
> vlist <- NULL
> if (attr(vlist, "mode") != "binary") cat("")
>
> suggests that vlist does not have a "mode" attribute. The object in
> question is one of three elements in a listw object. Maybe it would be
> helpful if you began with sessionInfo(), so that we have some knowledge of
> package versions, etc?
>
>> I'm trying to estimate a model where the network
>> effects are in disturbances to the errors.
>>
>> my command line looks so:
>
>>
>> disturbeffect.01 = errorsarlm(resp_var~predictor_vars, , my.listw,
>> na.action=na.omit, zero.policy=TRUE)
>>
>
> my.listw is a listw object that you have constructed with a weights
> element with no "mode" attribute, so when you go through na.omit, you
> induce subsetting (which checks that attribute), because spatial models
> cannot be fit id NA are present. What happens in lm() is that the
> observations including NAs are dropped, but here we need to drop the
> observations from resp_var and predictor_vars - and drop rows and columns
> from the spatial weights. Your listw object has been constructed in a way
> that makes this impossible.
>
> From examination of the object you attached (good!), it seems to have been
> created by mat2listw(), which does not (and should) set the "mode"
> attribute in listw$weights, so I'll correct that (to say "unknown").
> That function actually cannot know if the weights are "binary" or
> "general" - but yours seem to be simple "B" style weights, 0/1, so my
> suggestion would be:
>
> my.listw1 <- nb2listw(my.listw$neighbours, style="B", zero.policy=TRUE)
> summary(my.listw1, zero.policy=TRUE)
> attr(my.listw1$weights, "mode")
>
> It should run on my.listw1. By the way, if you have coordinates for your
> objects, you can look at a plot of the neighbours (?plot.nb) - to see if
> the matrix you started from represents the structure you want. Thanks for
> a full report!
>
> Best wishes,
>
> Roger
>
>> (my network has some nodes without neighbors, and my predictor_vars 
>> have some
>> NAs - but the model formula runs fine within lm() .)
>>
>> I tried the same arguments for lagsarlm() and received the exact same error.
>> I've looked through the spdep manual, and all I can find is that
>> "mode" can be an argument in a "vector()" command, but do not know
>> how this relates to my specification of my model.
>>
>> I'm attaching my listw type list, in case this is of help.
>
> (without the attachment, it would have been impossible to help - the
> commands used to make the objects can also tell a lot)
>
>> Thank you for your assistance,
>>
>> Brian
>>
>>
>
> --
> Roger Bivand
> Economic Geography Section, Department of Economics, Norwegian School of
> Economics and Business Administration, Helleveien 30, N-5045 Bergen,
> Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
> e-mail: Roger.Bivand at nhh.no
>
>
>
>




More information about the R-sig-Geo mailing list