plot_sp3d | R Documentation |
Make plots and maps of the spatio-temporal trends
in 3d of the objects fitted with pspatfit
function.
plot_sp3d(object, data, time_var, time_index, addmain = TRUE, addint = TRUE)
object |
object returned from |
data |
sf object. |
time_var |
name of the temporal variable in data. |
time_index |
vector of time points to plot. |
addmain |
Add f1_main and f2_main plots in psanova case. |
addint |
Add f12_int in psanova case. |
plots and maps of the spatial trends
Roman Minguez | roman.minguez@uclm.es |
Roberto Basile | roberto.basile@univaq.it |
Maria Durban | mdurban@est-econ.uc3m.es |
Gonzalo Espana-Heredia | gehllanza@gmail.com |
Lee, D. and Durban, M. (2011). P-Spline ANOVA Type Interaction Models for Spatio-Temporal Smoothing. Statistical Modelling, (11), 49-69. <doi:10.1177/1471082X1001100104>
Eilers, P. and Marx, B. (2021). Practical Smoothing. The Joys of P-Splines. Cambridge University Press.
Fahrmeir, L.; Kneib, T.; Lang, S.; and Marx, B. (2021). Regression. Models, Methods and Applications (2nd Ed.). Springer.
Wood, S.N. (2017). Generalized Additive Models.
An Introduction with R
(second edition). CRC Press, Boca Raton.
library(pspatreg) library(sf) data(unemp_it, package = "pspatreg") lwsp_it <- spdep::mat2listw(Wsp_it) unemp_it_sf <- st_as_sf(dplyr::left_join( unemp_it, map_it, by = c("prov" = "COD_PRO"))) ######## FORMULA of the model form3d_psanova_restr <- unrate ~ partrate + agri + cons + pspl(serv, nknots = 15) + pspl(empgrowth, nknots = 20) + pspt(long, lat, year, nknots = c(18, 18, 8), psanova = TRUE, nest_sp1 = c(1, 2, 3), nest_sp2 = c(1, 2, 3), nest_time = c(1, 2, 2), f1t = FALSE, f2t = FALSE) ####### FIT the model sp3danova <- pspatfit(form3d_psanova_restr, data = unemp_it_sf) summary(sp3danova) ###### Plot spatio-temporal trends for different years plot_sp3d(sp3danova, data = unemp_it_sf, time_var = "year", time_index = c(1996, 2005, 2019), addmain = FALSE, addint = FALSE) ###### Plot of spatio-temporal trend, main effects ###### and interaction effect for a year plot_sp3d(sp3danova, data = unemp_it_sf, time_var = "year", time_index = c(2019), addmain = TRUE, addint = TRUE) #### Plot of temporal trend for each province plot_sptime(sp3danova, data = unemp_it, time_var = "year", reg_var = "prov")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.