listw2sn                package:spdep                R Documentation

_S_p_a_t_i_a_l _n_e_i_g_h_b_o_u_r _s_p_a_r_s_e _r_e_p_r_e_s_e_n_t_a_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     The function makes a '"spatial neighbour"' object representation
     (similar to the S-PLUS spatial statististics module representation
     of a '"listw"' spatial weights object. The object is used in
     calculating the Jacobian of the likelihood functions of spatial
     autoregressive models when the "sparse" method is chosen in
     'errorsarlm()' and 'lagsarlm()'. 'sn2listw()' is the inverse
     function to 'listw2sn()', creating a '"listw"' object from a
     '"spatial neighbour"' object

_U_s_a_g_e:

     listw2sn(listw)
     sn2listw(sn)
     spwdet(sparseweights, rho, debug=FALSE)
     logSpwdet(sparseweights, rho, debug=FALSE)

_A_r_g_u_m_e_n_t_s:

   listw: a 'listw' object from for example 'nb2listw'

      sn: a 'spatial.neighbour' object

sparseweights: a 'spatial.neighbour' object

     rho: spatial autoregressive parameter value

   debug: if TRUE, writes a log file on sparse matrix operations (name
          sparsestats) in the current directory. To be used if sparse
          estimation fails!

_D_e_t_a_i_l_s:

     The methods used for finding the determinant directly by sparse
     matrix techniques are given by R. Kelley Pace and R. P. Barry
     (1998), and are implemented here using the sparse library by
     Kenneth Kundert and Alberto Sangiovanni-Vincentelli; the same
     reference is used by the S-PLUS spatial statistics module.

     When using the sparse method, the user takes (unfortunately) full
     responsibility for possible failures, including R terminating with
     a core dump! Safeguards have been put in place to try to trap
     errant behaviour in the sparse functions' memmory allocation, but
     they may not always help. When sparsedebug is TRUE, a log file
     (sparsestats) is written in the working directory - the figure of
     interest is the number of allocated blocks. At present, 'spwdet'
     will fail when this increases over the number initially allocated,
     but will not release memory allocated by the sparse functions. In
     the event of problems, save your workspace and quit R. Problems
     seem to be related to larger n, and to an unknown trigger
     precipitating incontrolled fillin, in the course of which the
     sparse routines lose track of their memory pointers, and then
     provoke a segmentation fault trying to free unallocated memory.

_V_a_l_u_e:

     A data frame with three columns, and with class
     'spatial.neighbour': 

    from: region number id for the start of the link (S-PLUS row.id)

      to: region number id for the end of the link (S-PLUS col.id)

 weights: weight for this link

     'logSpwdet' returns log det(I - rho * W).

_A_u_t_h_o_r(_s):

     Roger Bivand Roger.Bivand@nhh.no

_R_e_f_e_r_e_n_c_e_s:

     R. Kelley Pace and R. P. Barry (1998) Quick computations of
     spatially autoregressive estimators, Geographical Analysis 29 (3)
     232-247; <URL:
     http://www.spatial-statistics.com/pace_manuscripts/ga_ms_dir/pdf/f
     in_geo_analysis.pdf>.

     Files: src/spAllocate.c, src/spBuild.c, src/spConfig.h,
     src/spDefs.h, src/spFactor.c, src/spMatrix.h, src/spUtils.c are by
     Kenneth Kundert and Alberto Sangiovanni-Vincentelli, University of
     California, Berkeley, and are from:

     <URL: http://www.netlib.org/sparse/index.html>

     (Kenneth Kundert, Sparse Matrix Techniques, in Circuit Analysis,
     Simulation and Design, Albert Ruehli (Ed.), North-Holland, 1986)

     They are copyright (c) 1985,86,87,88 by Kenneth S. Kundert and the
     University of California, with the following licence:

     Permission to use, copy, modify, and distribute this software and
     its documentation for any purpose and without fee is hereby
     granted, provided that the copyright notices appear in all copies
     and supporting documentation and that the authors and the
     University of California are properly credited.  The authors and
     the University of California make no representations as to the
     suitability of this software for any purpose.  It is provided "as
     is", without express or implied warranty.

_S_e_e _A_l_s_o:

     'nb2listw', 'errorsarlm', 'lagsarlm'

_E_x_a_m_p_l_e_s:

     data(columbus)
     col.listw <- nb2listw(col.gal.nb)
     col.listw$neighbours[[1]]
     col.listw$weights[[1]]
     col.sn <- listw2sn(col.listw)
     col.sn[col.sn[,1] == 1,]
     rho <- seq(-0.8, 0.9, 0.1)
     for (i in rho) print(paste("rho:", i, "log(det(I - rho*W))",
       logSpwdet(col.sn, i)), quote=TRUE)

