<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="auto">Thank you!</div><div class="gmail_extra"><br><div class="gmail_quote">Em 3 de ago de 2020 16:56, Roger Bivand <Roger.Bivand@nhh.no> escreveu:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">On Mon, 3 Aug 2020, Pietro Andre Telatin Paschoalino wrote:
<br>
<br>
> Hello everyone, follow my doubts about the sphet package, related to direct and indirect impacts, and simulation of standard errors.
<br>
>
<br>
> I will be very grateful if anyone can help me.
<br>
>
<br>
> follow my code using built-in columbus data.
<br>
>
<br>
> library(rgdal)
<br>
> library(sp)
<br>
> library(raster)
<br>
> library(rgeos)
<br>
> library(maptools)
<br>
> library(spdep)
<br>
> library (splm)
<br>
> library(sphet)
<br>
>
<br>
> data(columbus, package="spdep")
<br>
> listw <- spdep::nb2listw(col.gal.nb)
<br>
>
<br>
> attach(columbus)
<br>
>
<br>
> #i'm going direct to regression by sphet
<br>
>
<br>
> #SAC (SARAR MODEL)
<br>
>
<br>
> SAC.robust <- spreg(INC ~ HOVAL+DISCBD+CP, data=columbus, listw, model="sarar", het=TRUE)
<br>
>
<br>
> #LAG MODEL
<br>
>
<br>
> SARrobust <- spreg(INC ~ HOVAL+DISCBD+CP, data=columbus, listw, model="lag", het=TRUE)
<br>
>
<br>
> #going to my questions about the impacts function
<br>
>
<br>
> #FOR SAC MODEL
<br>
>
<br>
>> W <- as(as_dgRMatrix_listw(listw), "CsparseMatrix")
<br>
> Warning message:
<br>
>
<br>
> Function as_dgRMatrix_listw moved to the spatialreg package
<br>
>
<br>
>> trMatc <- trW(W, type="mult")
<br>
>
<br>
> Warning message:
<br>
> Function trW moved to the spatialreg package
<br>
>
<br>
>> effects<- summary(impacts(SAC.robust, tr=trMatc, R=10000), zstats=TRUE, short=TRUE)
<br>
>> effects
<br>
>
<br>
<br>
With remotes::install_github("gpiras/sphet"), you need rather:
<br>
<br>
effects<- impacts(SAC.robust, tr=trMatc, n_mvn=10000, inference=TRUE)
<br>
summary(effects)
<br>
effects <- impacts(SARrobust, tr=trMatc, n_mvn=10000, inference=TRUE)
<br>
summary(effects)
<br>
<br>
However, these are work-in-progress, and would benefit from raising an
<br>
issue on https://github.com/gpiras/sphet/issues. The values are similar
<br>
to:
<br>
<br>
library(spatialreg)
<br>
SARrobust1 <- stsls(INC ~ HOVAL+DISCBD+CP, data=columbus, listw,
<br>
robust=TRUE)
<br>
ii <- impacts(SARrobust1, tr=trMatc, R=10000)
<br>
summary(ii, zstats=TRUE, short=TRUE)
<br>
<br>
Raising an issue would help, and this example should be included there.
<br>
<br>
Roger
<br>
<br>
> ========================================================
<br>
> Simulation results (GSTSLS variance matrix):
<br>
> ========================================================
<br>
>
<br>
> #FOR SAR MODEL
<br>
>>
<br>
>> effects<- summary(impacts(SARrobust, tr=trMatc, R=10000), zstats=TRUE, short=TRUE)
<br>
>
<br>
> that gives me:
<br>
>
<br>
> Error in UseMethod("impacts", obj) :
<br>
> no applicable method for 'impacts' applied to an object of class "c('sphet', 'stsls_sphet')"
<br>
>
<br>
> #how i said the impacts is not computable.
<br>
>
<br>
> #One way to compute the impacts is by:
<br>
>
<br>
> effects<- summary(spatialreg::impacts(SARrobust, tr=trMatc, R=10000), zstats=TRUE, short=TRUE)
<br>
> effects
<br>
>
<br>
> Impact measures (lag, trace):
<br>
> ========================================================
<br>
> Simulation results (IV HAC variance matrix):
<br>
> ========================================================
<br>
>
<br>
> the simulation of standard errors and p-values is done by IV HAC. (which left me confused because I did not specify such an
<br>
> #attribute in my regression, leaving me in doubt if the standard errors of the regression had also been corrected with HAC.)
<br>
>
<br>
> #another option is:
<br>
>
<br>
> effects<- summary(spatialreg::impacts.stsls(SARrobust, tr=trMatc, R=10000), zstats=TRUE, short=TRUE)
<br>
> effects
<br>
>
<br>
> #again simulated through the HAC variance matrix.
<br>
> #Note: In this case, generally, all p-values were not significant, but using my database, by spatialreg :: impacts, the impacts are
<br>
> #statistically significant and using spatialreg :: impacts. stsls, they become insignificant.
<br>
>
<br>
> #follow my sessionInfo (), how i Said, i'm using the version of sphet by R-forge.
<br>
>>
<br>
>> sessionInfo ()
<br>
>
<br>
> R version 3.6.2 (2019-12-12)
<br>
> Platform: x86_64-w64-mingw32/x64 (64-bit)
<br>
> Running under: Windows 10 x64 (build 18363)
<br>
>
<br>
> Matrix products: default
<br>
>
<br>
> locale:
<br>
> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
<br>
> [4] LC_NUMERIC=C LC_TIME=English_United States.1252
<br>
>
<br>
> attached base packages:
<br>
> [1] stats graphics grDevices utils datasets methods base
<br>
>
<br>
> other attached packages:
<br>
> [1] sphet_1.7-6 splm_1.4-11 spdep_1.1-5 sf_0.9-5 spData_0.3.8 maptools_1.0-1 rgeos_0.5-3 raster_3.3-7 rgdal_1.5-10
<br>
> [10] sp_1.4-2
<br>
>
<br>
> loaded via a namespace (and not attached):
<br>
> [1] Rcpp_1.0.5 bdsmatrix_1.3-4 lattice_0.20-41 deldir_0.1-25 class_7.3-15 zoo_1.8-8 gtools_3.8.2
<br>
> [8] digest_0.6.25 lmtest_0.9-37 spDataLarge_0.4.1 R6_2.4.1 coda_0.19-3 e1071_1.7-3 spam_2.5-1
<br>
> [15] pillar_1.4.4 Rdpack_0.11-1 miscTools_0.6-26 rlang_0.4.7 rstudioapi_0.11 gdata_2.18.0 gmodels_2.18.1
<br>
> [22] Matrix_1.2-18 splines_3.6.2 stringr_1.4.0 foreign_0.8-72 compiler_3.6.2 pkgconfig_2.0.3 maxLik_1.3-8
<br>
> [29] tidyselect_1.1.0 tibble_3.0.1 expm_0.999-4 codetools_0.2-16 crayon_1.3.4 dplyr_1.0.0 MASS_7.3-51.4
<br>
> [36] spatialreg_1.1-5 grid_3.6.2 nlme_3.1-142 lifecycle_0.2.0 DBI_1.1.0 magrittr_1.5 units_0.6-7
<br>
> [43] ibdreg_0.2.5 bibtex_0.4.2.2 KernSmooth_2.23-16 stringi_1.4.6 plm_2.2-3 LearnBayes_2.15.1 ellipsis_0.3.1
<br>
> [50] generics_0.0.2 vctrs_0.3.1 boot_1.3-23 sandwich_2.5-1 Formula_1.2-3 tools_3.6.2 glue_1.4.1
<br>
> [57] purrr_0.3.4 parallel_3.6.2 classInt_0.4-3 gbRd_0.4-11 dotCall64_1.0-0
<br>
>
<br>
> Thank you.
<br>
>
<br>
> Pietro Andre Telatin Paschoalino
<br>
> Doutorando em Ci�ncias Econ�micas da Universidade Estadual de Maring� - PCE.
<br>
>
<br>
> [https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon> Virus-free. www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
<br>
>
<br>
> [[alternative HTML version deleted]]
<br>
>
<br>
>
<br>
<br>
--
<br>
Roger Bivand
<br>
Department of Economics, Norwegian School of Economics,
<br>
Helleveien 30, N-5045 Bergen, Norway.
<br>
voice: +47 55 95 93 55; e-mail: Roger.Bivand@nhh.no
<br>
https://orcid.org/0000-0003-2392-6140
<br>
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en</p>
</blockquote></div><br></div>