[R-sig-Geo] spgm

Roger Bivand Roger@Biv@nd @ending from nhh@no
Sat Sep 29 14:52:18 CEST 2018


On Sat, 29 Sep 2018, Hulényi Martin wrote:

> Dear all,
>
>
> I would like to ask if there is a possibility to apply something 
> similiar to the "impacts" from spdep package for SAR regressions using 
> the spgm function from the splm package.
>

A reprex would have helped. Here is mine:

data(Produc, package = "plm")
data(usaww) # dense row-standardised weights matrix
GM <- spgm(log(gsp)~log(pcap)+log(pc)+log(emp)+unemp, data=Produc,
   listw = usaww, moments="fullweights", lag=TRUE, spatial.error = FALSE)
class(GM)
?impacts.stsls # spdep method for stsls objects
head(Produc)
length(unique(Produc$year)) # T
big <- kronecker(diag(length(unique(Produc$year))), usaww)
listw <- mat2listw(big, style="W")
tr <- trW(as(listw, "CsparseMatrix"), m=100)
impacts(GM, listw=listw)
impacts(GM, tr=tr)
summary(impacts(GM, tr=tr, R=1000), zstats=TRUE, short=TRUE)

The splm:::impacts.splm() method cannot dispatch on stsls objects, so they 
try to use the spdep:::impacts.stsls() method, but there the data rows are 
n x T but listw is only of n rows. Looking inside splm:::impacts.splm(), 
you see that a sparse kronecker product matrix is constructed - either do 
the same if your n x T is large, or follow the above using a dense 
kronecker product and cast back to listw representation to create the 
trace vector.

Hope this clarifies,

Roger

>
> Best regards,
>
>
> Martin Hul???nyi ?
>
>
> [eco.jpg]       Pred vytla???en???m tohto mailu zv???te pros???m vplyv na ???ivotn??? prostredie. ???akujeme.
> Please consider the environment before printing this e-mail. Thanks
>
> 	[[alternative HTML version deleted]]
>
>

-- 
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: Roger.Bivand using nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en


More information about the R-sig-Geo mailing list