fit_terms {pspatreg} | R Documentation |
Compute terms of the non-parametric covariates in the semiparametric regression models.
Description
The fit_terms
function compute both:
Non-parametric spatial (2d) or spatio-temporal (3d) trends including the decomposition in main and interaction trends when the model is ANOVA.
Smooth functions
f(x_i)
for non-parametric covariates in semiparametric models. It also includes standard errors and the decomposition of each non-parametric term in fixed and random parts.
Usage
fit_terms(object, variables, intercept = FALSE)
Arguments
object |
object fitted using |
variables |
vector including names of non-parametric covariates.
To fit the terms of non-parametric spatial (2d) or spatio-temporal
(3d) trend this argument must be set equal to 'spttrend'.
See |
intercept |
add intercept to fitted term. Default = FALSE. |
Value
A list including:
fitted_terms | Matrix including terms in columns. |
se_fitted_terms | Matrix including standard errors of terms in columns. |
fitted_terms_fixed | Matrix including fixed part of terms in columns. |
se_fitted_terms_fixed | Matrix including standard errors of fixed part of terms in columns. |
fitted_terms_random | Matrix including random part of terms in columns. |
se_fitted_terms_random | Matrix including standard errors of random part of terms in columns. |
This object can be used as an argument of plot_terms
function
to make plots of both non-parametric trends and smooth functions of
covariates. See examples below.
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. (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.
See Also
-
pspatfit
estimate spatial or spatio-temporal semiparametric regression models. The model can be of type ps-sim, ps-sar, ps-slx, ps-sem, ps-sdm or ps-sarar. -
plot_terms
plot smooth functions of non-parametric covariates.
Examples
###################### Examples using a panel data of rate of unemployment
###################### in 103 Italian provinces during the period 1996-2014.
library(pspatreg)
data(unemp_it, package = "pspatreg")
lwsp_it <- spdep::mat2listw(Wsp_it)
####### No Spatial Trend: PSAR including a spatial
####### lag of the dependent variable
form1 <- unrate ~ partrate + agri + cons +
pspl(serv, nknots = 15) +
pspl(empgrowth, nknots = 20)
gamsar <- pspatfit(form1, data = unemp_it,
type = "sar", listw = lwsp_it)
summary(gamsar)
###### Fit non-parametric terms
###### (spatial trend must be name "spttrend")
list_varnopar <- c("serv", "empgrowth")
terms_nopar <- fit_terms(gamsar, list_varnopar)
###################### Plot non-parametric terms
plot_terms(terms_nopar, unemp_it)