Doubt

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Doubt

Pietro Andre Telatin Paschoalino
Hello everyone on the list.

I am a PhD student in Brazil and I have some doubts in the area of ​​spatial econometrics, if anyone knows and can answer me I would be very grateful.

I'm using the spreg function from the sphet package. Sorry if I'm asking you an obvious question, but I couldn't solve it simply by looking in forums / reading the articles of the area.

Follow:

1- One of the arguments of the spreg function is called step1c, in this case, if I say TRUE, would I be using the efficient estimator of ρ, if false, would it just be the consistent estimator? I verified that step1c = T, brings me the same result as the gstslshet function.

2- I am having problems estimating impact after spreg, depending on the versions of my packages, or I have an error (evalue not informed), not performing the estimation, or when I can perform it, a HAC correction is applied to my standard errors (even if I don't put the HAC option on my code) and all my p-values ​​become insignificant (which is very strange since my estimators by lmsar or gstsls have significant impacts). Would you know to inform me if there is an alternative way to calculate the impacts?

As the HAC was applied to the impacts, I was also in doubt as to whether all the correction for heteroscedasticity is being done via HAC, even though I did not select this option in the models.

Thank you very much.

Pietro Andre Telatin Paschoalino


[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>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Doubt

Roger Bivand
Administrator
On Wed, 29 Jul 2020, Pietro Andre Telatin Paschoalino wrote:

> Hello everyone on the list.
>
> I am a PhD student in Brazil and I have some doubts in the area of
> ​​spatial econometrics, if anyone knows and can answer me I would be very
> grateful.
>
> I'm using the spreg function from the sphet package. Sorry if I'm asking
> you an obvious question, but I couldn't solve it simply by looking in
> forums / reading the articles of the area.
>
> Follow:
>
> 1- One of the arguments of the spreg function is called step1c, in this
>    case, if I say TRUE, would I be using the efficient estimator of ρ,
>    if false, would it just be the consistent estimator? I verified that
>    step1c = T, brings me the same result as the gstslshet function.
Please see the section on GMM, subsection spatial error model of:

https://www.jstatsoft.org/article/view/v063i18

>
> 2- I am having problems estimating impact after spreg, depending on the
>    versions of my packages, or I have an error (evalue not informed),
>    not performing the estimation, or when I can perform it, a HAC
>    correction is applied to my standard errors (even if I don't put the
>    HAC option on my code) and all my p-values ​​become insignificant
>    (which is very strange since my estimators by lmsar or gstsls have
>    significant impacts). Would you know to inform me if there is an
>    alternative way to calculate the impacts?

Without knowing your current versions, nobody knows. Report the output of
sessionInfo(), preferably for the minimal set of packages needed for a
reproducible example (without tidyverse, which loads 50+ packages that are
not relevant here).

>
> As the HAC was applied to the impacts, I was also in doubt as to whether
> all the correction for heteroscedasticity is being done via HAC, even
> though I did not select this option in the models.
>

Please provide a reproducible example using a built-in data set, posting
in plain text to make copying from your message easier than from HTML,
which often gets garbled.

Roger


--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: [hidden email]
https://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: Doubt

Pietro Andre Telatin Paschoalino
Professor, thank you very much for the answers.

First issue resolved. Step1c = T means that ρ is estimated via 2SLS instead of GS2SLS, in this case the default of spreg = GS2SLS.

Second: As you can see most of my problems arising due to the estimation of impacts.

As I reported, I was not able to estimate them, because I was having the same error that you discussed here (however, my estimation is done via spreg and not gstslshet):

https://stat.ethz.ch/pipermail/r-sig-geo/2019-January/027068.html

On my last attempt I upgraded to the package under development on R-Forge 1.7-6.

In this case, follow the pattern below that I used to estimate the impacts:

W <- as (as_dgRMatrix_listw (k2.listw), "CsparseMatrix")
trMatc <- trW (W, type = "mult")
effects <- summary (impacts (obj, tr = trMatc, R = 10000), zstats = TRUE, short = TRUE)
effects

Following this structure, in the development version, I can advance a little.

When I estimate a SAC (SARAR) model (with an option for heteroskedacticity) the results seem to be correct, and my results are built through the GSTSLS covariance matrix (practically all significant).

However when I try to verify the same issue for a SAR model, I have the error:

Error in UseMethod ("impacts", obj):  no applicable method for 'impacts' applied to an object of class "c ('sphet', 'stsls_sphet')".

One way to estimate was by specifying the spatial package

effects <- summary (spatialreg :: impacts (SARrobust, tr = trMatc, R = 10000), zstats = TRUE, short = TRUE)

however, as I said, for some reason, it is using an IV HAC variance matrix (I don't assign this in my model - which caused me the confusion about the possibility of HAC being applied in all SAR cases):

Another attempt was to use spatialreg::impacts.stsls

I am not sure if it is the way to estimate the impacts, but, again, the matrix used was IV HAC and in this specific case everything becomes insignificant.

Follow my sessionInfo()

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
 [1] sphet_1.7-6       plm_2.2-3         tseries_0.10-47   lmtest_0.9-37     zoo_1.8-8         car_3.0-8         carData_3.0-4     spdep_1.1-5
 [9] sf_0.9-5          maptools_1.0-1    xlsx_0.6.3        rgeos_0.5-3       rgdal_1.5-10      sp_1.4-2          shape_1.4.4       maps_3.3.0
[17] spDataLarge_0.4.1 spatialreg_1.1-5  Matrix_1.2-18     spData_0.3.8

loaded via a namespace (and not attached):
 [1] splines_3.6.2      gtools_3.8.2       Formula_1.2-3      Rdpack_0.11-1      expm_0.999-4       TTR_0.23-6         xlsxjars_0.6.1
 [8] cellranger_1.1.0   LearnBayes_2.15.1  pillar_1.4.4       lattice_0.20-41    glue_1.4.1         quadprog_1.5-8     digest_0.6.25
[15] sandwich_2.5-1     pkgconfig_2.0.3    bibtex_0.4.2.2     raster_3.3-7       haven_2.3.1        gmodels_2.18.1     purrr_0.3.4
[22] gdata_2.18.0       openxlsx_4.1.5     rio_0.5.16         tibble_3.0.1       generics_0.0.2     ellipsis_0.3.1     maxLik_1.3-8
[29] quantmod_0.4.17    magrittr_1.5       crayon_1.3.4       readxl_1.3.1       deldir_0.1-25      nlme_3.1-142       MASS_7.3-51.4
[36] forcats_0.5.0      xts_0.12-0         foreign_0.8-72     class_7.3-15       tools_3.6.2        data.table_1.12.8  hms_0.5.3
[43] gbRd_0.4-11        lifecycle_0.2.0    stringr_1.4.0      zip_2.0.4          compiler_3.6.2     e1071_1.7-3        rlang_0.4.7
[50] classInt_0.4-3     units_0.6-7        grid_3.6.2         miscTools_0.6-26   rstudioapi_0.11    boot_1.3-23        codetools_0.2-16
[57] abind_1.4-5        DBI_1.1.0          curl_4.3           R6_2.4.1           bdsmatrix_1.3-4    dplyr_1.0.0        KernSmooth_2.23-16
[64] rJava_0.9-12       stringi_1.4.6      Rcpp_1.0.5         vctrs_0.3.1        tidyselect_1.1.0   coda_0.19-3

Thank you.

Pietro Andre Telatin Paschoalino
Doutorando em Ciências Econômicas da Universidade Estadual de Maringá - PCE.

________________________________
De: Roger Bivand <[hidden email]>
Enviado: quarta-feira, 29 de julho de 2020 12:16
Para: Pietro Andre Telatin Paschoalino <[hidden email]>
Cc: [hidden email] <[hidden email]>
Assunto: Re: [R-sig-Geo] Doubt

On Wed, 29 Jul 2020, Pietro Andre Telatin Paschoalino wrote:

> Hello everyone on the list.
>
> I am a PhD student in Brazil and I have some doubts in the area of
> ​​spatial econometrics, if anyone knows and can answer me I would be very
> grateful.
>
> I'm using the spreg function from the sphet package. Sorry if I'm asking
> you an obvious question, but I couldn't solve it simply by looking in
> forums / reading the articles of the area.
>
> Follow:
>
> 1- One of the arguments of the spreg function is called step1c, in this
>    case, if I say TRUE, would I be using the efficient estimator of ρ,
>    if false, would it just be the consistent estimator? I verified that
>    step1c = T, brings me the same result as the gstslshet function.

Please see the section on GMM, subsection spatial error model of:

https://www.jstatsoft.org/article/view/v063i18

>
> 2- I am having problems estimating impact after spreg, depending on the
>    versions of my packages, or I have an error (evalue not informed),
>    not performing the estimation, or when I can perform it, a HAC
>    correction is applied to my standard errors (even if I don't put the
>    HAC option on my code) and all my p-values ​​become insignificant
>    (which is very strange since my estimators by lmsar or gstsls have
>    significant impacts). Would you know to inform me if there is an
>    alternative way to calculate the impacts?

Without knowing your current versions, nobody knows. Report the output of
sessionInfo(), preferably for the minimal set of packages needed for a
reproducible example (without tidyverse, which loads 50+ packages that are
not relevant here).

>
> As the HAC was applied to the impacts, I was also in doubt as to whether
> all the correction for heteroscedasticity is being done via HAC, even
> though I did not select this option in the models.
>

Please provide a reproducible example using a built-in data set, posting
in plain text to make copying from your message easier than from HTML,
which often gets garbled.

Roger



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

[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>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Doubt

Pietro Andre Telatin Paschoalino
In reply to this post by Pietro Andre Telatin Paschoalino
Hello everyone, follow my doubts about the sphet package, related to direct and indirect impacts, and simulation of standard errors.

I will be very grateful if anyone can help me.

follow my code using built-in columbus data.

library(rgdal)
library(sp)
library(raster)
library(rgeos)
library(maptools)
library(spdep)
library (splm)
library(sphet)

data(columbus, package="spdep")
listw <- spdep::nb2listw(col.gal.nb)

attach(columbus)

#i'm going direct to regression by sphet

#SAC (SARAR MODEL)

SAC.robust <- spreg(INC ~ HOVAL+DISCBD+CP, data=columbus, listw, model="sarar", het=TRUE)

#LAG MODEL

SARrobust <- spreg(INC ~ HOVAL+DISCBD+CP, data=columbus, listw, model="lag", het=TRUE)

#going to my questions about the impacts function

#FOR SAC MODEL

> W <- as(as_dgRMatrix_listw(listw), "CsparseMatrix")
Warning message:

Function as_dgRMatrix_listw moved to the spatialreg package

> trMatc <- trW(W, type="mult")

Warning message:
Function trW moved to the spatialreg package

> effects<- summary(impacts(SAC.robust, tr=trMatc, R=10000), zstats=TRUE, short=TRUE)
> effects

========================================================
Simulation results (GSTSLS variance matrix):
========================================================

 #FOR SAR MODEL
>
> effects<- summary(impacts(SARrobust, tr=trMatc, R=10000), zstats=TRUE, short=TRUE)

that gives me:

Error in UseMethod("impacts", obj) :
  no applicable method for 'impacts' applied to an object of class "c('sphet', 'stsls_sphet')"

#how i said the impacts is not computable.

#One way to compute the impacts is by:

effects<- summary(spatialreg::impacts(SARrobust, tr=trMatc, R=10000), zstats=TRUE, short=TRUE)
effects

Impact measures (lag, trace):
========================================================
Simulation results (IV HAC variance matrix):
========================================================

 the simulation of standard errors and p-values is done by IV HAC. (which left me confused because I did not specify such an
#attribute in my regression, leaving me in doubt if the standard errors of the regression had also been corrected with HAC.)

#another option is:

effects<- summary(spatialreg::impacts.stsls(SARrobust, tr=trMatc, R=10000), zstats=TRUE, short=TRUE)
effects

#again simulated through the HAC variance matrix.
#Note: In this case, generally, all p-values were not significant, but using my database, by spatialreg :: impacts, the impacts are
#statistically significant and using spatialreg :: impacts. stsls, they become insignificant.

#follow my sessionInfo (), how i Said, i'm using the version of sphet by R-forge.
>
> sessionInfo ()

R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
 [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
[10] sp_1.4-2

loaded via a namespace (and not attached):
 [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
 [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
[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
[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
[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
[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
[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
[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
[57] purrr_0.3.4        parallel_3.6.2     classInt_0.4-3     gbRd_0.4-11        dotCall64_1.0-0

Thank you.

Pietro Andre Telatin Paschoalino
Doutorando em Ci�ncias Econ�micas da Universidade Estadual de Maring� - PCE.

[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>

        [[alternative HTML version deleted]]


_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Doubt

Roger Bivand
Administrator
On Mon, 3 Aug 2020, Pietro Andre Telatin Paschoalino wrote:

> Hello everyone, follow my doubts about the sphet package, related to direct and indirect impacts, and simulation of standard errors.
>
> I will be very grateful if anyone can help me.
>
> follow my code using built-in columbus data.
>
> library(rgdal)
> library(sp)
> library(raster)
> library(rgeos)
> library(maptools)
> library(spdep)
> library (splm)
> library(sphet)
>
> data(columbus, package="spdep")
> listw <- spdep::nb2listw(col.gal.nb)
>
> attach(columbus)
>
> #i'm going direct to regression by sphet
>
> #SAC (SARAR MODEL)
>
> SAC.robust <- spreg(INC ~ HOVAL+DISCBD+CP, data=columbus, listw, model="sarar", het=TRUE)
>
> #LAG MODEL
>
> SARrobust <- spreg(INC ~ HOVAL+DISCBD+CP, data=columbus, listw, model="lag", het=TRUE)
>
> #going to my questions about the impacts function
>
> #FOR SAC MODEL
>
>> W <- as(as_dgRMatrix_listw(listw), "CsparseMatrix")
> Warning message:
>
> Function as_dgRMatrix_listw moved to the spatialreg package
>
>> trMatc <- trW(W, type="mult")
>
> Warning message:
> Function trW moved to the spatialreg package
>
>> effects<- summary(impacts(SAC.robust, tr=trMatc, R=10000), zstats=TRUE, short=TRUE)
>> effects
>
With remotes::install_github("gpiras/sphet"), you need rather:

effects<- impacts(SAC.robust, tr=trMatc, n_mvn=10000, inference=TRUE)
summary(effects)
effects <- impacts(SARrobust, tr=trMatc, n_mvn=10000, inference=TRUE)
summary(effects)

However, these are work-in-progress, and would benefit from raising an
issue on https://github.com/gpiras/sphet/issues. The values are similar
to:

library(spatialreg)
SARrobust1 <- stsls(INC ~ HOVAL+DISCBD+CP, data=columbus, listw,
   robust=TRUE)
ii <- impacts(SARrobust1, tr=trMatc, R=10000)
summary(ii, zstats=TRUE, short=TRUE)

Raising an issue would help, and this example should be included there.

Roger

> ========================================================
> Simulation results (GSTSLS variance matrix):
> ========================================================
>
> #FOR SAR MODEL
>>
>> effects<- summary(impacts(SARrobust, tr=trMatc, R=10000), zstats=TRUE, short=TRUE)
>
> that gives me:
>
> Error in UseMethod("impacts", obj) :
>  no applicable method for 'impacts' applied to an object of class "c('sphet', 'stsls_sphet')"
>
> #how i said the impacts is not computable.
>
> #One way to compute the impacts is by:
>
> effects<- summary(spatialreg::impacts(SARrobust, tr=trMatc, R=10000), zstats=TRUE, short=TRUE)
> effects
>
> Impact measures (lag, trace):
> ========================================================
> Simulation results (IV HAC variance matrix):
> ========================================================
>
> the simulation of standard errors and p-values is done by IV HAC. (which left me confused because I did not specify such an
> #attribute in my regression, leaving me in doubt if the standard errors of the regression had also been corrected with HAC.)
>
> #another option is:
>
> effects<- summary(spatialreg::impacts.stsls(SARrobust, tr=trMatc, R=10000), zstats=TRUE, short=TRUE)
> effects
>
> #again simulated through the HAC variance matrix.
> #Note: In this case, generally, all p-values were not significant, but using my database, by spatialreg :: impacts, the impacts are
> #statistically significant and using spatialreg :: impacts. stsls, they become insignificant.
>
> #follow my sessionInfo (), how i Said, i'm using the version of sphet by R-forge.
>>
>> sessionInfo ()
>
> R version 3.6.2 (2019-12-12)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 10 x64 (build 18363)
>
> Matrix products: default
>
> locale:
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C                           LC_TIME=English_United States.1252
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [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
> [10] sp_1.4-2
>
> loaded via a namespace (and not attached):
> [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
> [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
> [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
> [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
> [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
> [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
> [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
> [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
> [57] purrr_0.3.4        parallel_3.6.2     classInt_0.4-3     gbRd_0.4-11        dotCall64_1.0-0
>
> Thank you.
>
> Pietro Andre Telatin Paschoalino
> Doutorando em Ci�ncias Econ�micas da Universidade Estadual de Maring� - PCE.
>
> [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>
>
> [[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: [hidden email]
https://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: Doubt

Pietro Andre Telatin Paschoalino
Thank you!

Em 3 de ago de 2020 16:56, Roger Bivand <[hidden email]> escreveu:

On Mon, 3 Aug 2020, Pietro Andre Telatin Paschoalino wrote:

> Hello everyone, follow my doubts about the sphet package, related to direct and indirect impacts, and simulation of standard errors.
>
> I will be very grateful if anyone can help me.
>
> follow my code using built-in columbus data.
>
> library(rgdal)
> library(sp)
> library(raster)
> library(rgeos)
> library(maptools)
> library(spdep)
> library (splm)
> library(sphet)
>
> data(columbus, package="spdep")
> listw <- spdep::nb2listw(col.gal.nb)
>
> attach(columbus)
>
> #i'm going direct to regression by sphet
>
> #SAC (SARAR MODEL)
>
> SAC.robust <- spreg(INC ~ HOVAL+DISCBD+CP, data=columbus, listw, model="sarar", het=TRUE)
>
> #LAG MODEL
>
> SARrobust <- spreg(INC ~ HOVAL+DISCBD+CP, data=columbus, listw, model="lag", het=TRUE)
>
> #going to my questions about the impacts function
>
> #FOR SAC MODEL
>
>> W <- as(as_dgRMatrix_listw(listw), "CsparseMatrix")
> Warning message:
>
> Function as_dgRMatrix_listw moved to the spatialreg package
>
>> trMatc <- trW(W, type="mult")
>
> Warning message:
> Function trW moved to the spatialreg package
>
>> effects<- summary(impacts(SAC.robust, tr=trMatc, R=10000), zstats=TRUE, short=TRUE)
>> effects
>

With remotes::install_github("gpiras/sphet"), you need rather:

effects<- impacts(SAC.robust, tr=trMatc, n_mvn=10000, inference=TRUE)
summary(effects)
effects <- impacts(SARrobust, tr=trMatc, n_mvn=10000, inference=TRUE)
summary(effects)

However, these are work-in-progress, and would benefit from raising an
issue on https://github.com/gpiras/sphet/issues. The values are similar
to:

library(spatialreg)
SARrobust1 <- stsls(INC ~ HOVAL+DISCBD+CP, data=columbus, listw,
   robust=TRUE)
ii <- impacts(SARrobust1, tr=trMatc, R=10000)
summary(ii, zstats=TRUE, short=TRUE)

Raising an issue would help, and this example should be included there.

Roger

> ========================================================
> Simulation results (GSTSLS variance matrix):
> ========================================================
>
> #FOR SAR MODEL
>>
>> effects<- summary(impacts(SARrobust, tr=trMatc, R=10000), zstats=TRUE, short=TRUE)
>
> that gives me:
>
> Error in UseMethod("impacts", obj) :
>  no applicable method for 'impacts' applied to an object of class "c('sphet', 'stsls_sphet')"
>
> #how i said the impacts is not computable.
>
> #One way to compute the impacts is by:
>
> effects<- summary(spatialreg::impacts(SARrobust, tr=trMatc, R=10000), zstats=TRUE, short=TRUE)
> effects
>
> Impact measures (lag, trace):
> ========================================================
> Simulation results (IV HAC variance matrix):
> ========================================================
>
> the simulation of standard errors and p-values is done by IV HAC. (which left me confused because I did not specify such an
> #attribute in my regression, leaving me in doubt if the standard errors of the regression had also been corrected with HAC.)
>
> #another option is:
>
> effects<- summary(spatialreg::impacts.stsls(SARrobust, tr=trMatc, R=10000), zstats=TRUE, short=TRUE)
> effects
>
> #again simulated through the HAC variance matrix.
> #Note: In this case, generally, all p-values were not significant, but using my database, by spatialreg :: impacts, the impacts are
> #statistically significant and using spatialreg :: impacts. stsls, they become insignificant.
>
> #follow my sessionInfo (), how i Said, i'm using the version of sphet by R-forge.
>>
>> sessionInfo ()
>
> R version 3.6.2 (2019-12-12)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 10 x64 (build 18363)
>
> Matrix products: default
>
> locale:
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C                           LC_TIME=English_United States.1252
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [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
> [10] sp_1.4-2
>
> loaded via a namespace (and not attached):
> [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
> [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
> [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
> [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
> [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
> [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
> [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
> [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
> [57] purrr_0.3.4        parallel_3.6.2     classInt_0.4-3     gbRd_0.4-11        dotCall64_1.0-0
>
> Thank you.
>
> Pietro Andre Telatin Paschoalino
> Doutorando em Ci�ncias Econ�micas da Universidade Estadual de Maring� - PCE.
>
> [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>
>
> [[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: [hidden email]
https://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en



_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo