plot_sptime {pspatreg} | R Documentation |
Plot of time trends for spatio-temporal models in 3d.
Description
Make plots of the temporal trends for each region
fitted with pspatfit
function.
Usage
plot_sptime(object, data, time_var, reg_var)
Arguments
object |
object returned from |
data |
either sf or dataframe with the data. |
time_var |
name of the temporal variable in data. |
reg_var |
name of the regional variable in data. |
Value
time series plots of the temporal trend for each region
Author(s)
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 |
References
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. (2013). Regression. Models, Methods and Applications. Springer.
Wood, S.N. (2017). Generalized Additive Models. An Introduction with
R
(second edition). CRC Press, Boca Raton.
Examples
library(pspatreg)
data(unemp_it, package = "pspatreg")
lwsp_it <- spdep::mat2listw(Wsp_it)
###### FORMULA OF THE MODEL
form3d_psanova <- 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))
####### FIT the model
sp3danova <- pspatfit(form3d_psanova,
data = unemp_it,
listw = lwsp_it,
method = "Chebyshev")
summary(sp3danova)
######## Plot of temporal trend for each province
plot_sptime(sp3danova,
data = unemp_it,
time_var = "year",
reg_var = "prov")