I am trying to calculate the moran I index (for spatial autocorrelation) using the the following argument:
moran.test(data_total$prod_ser, dnb60.listw, randomisation=F)
The error I get is that the two objects are of different length.
Vector prod_ser belonging to data.frame data_total (first object in () ) is 2373 long (in other words data_total contain 2373 observations-firms). I am trying to see whether this variable is spatially auto-correlated.
dnb50.listw is a nb2listw object, spatial weights created based on distance between coordinates of the country's regions.Its length is 3. This object is created using a polygon shapefile, containing 25 regions.This polygon shapefile contains regions's ID, which data_total data.frame contains too (along with the regions' coordinates). 
I tried to extend the length of dnb60.listw object to 2373 (the length of prod_ser vector), but that would not be possible since it is a nb2listw object.
I also tried creating list object using data_total (since this data_frame does have coordinates and region's ID). However,I would get the following error:
Error in UseMethod("coords") :
no applicable method for 'coords' applied to an object of class "data.frame"
Is there any idea of how to make these two objects (prod_ser and dnb60.listw) of the same length so that I can do the testing?
 
    