View source: R/plot_timetrend.R
| plot_timetrend | R Documentation |
In models including a spatio-temporal trend plot a time trend for each spatial unit in the dataframe. It can be useful to detect heterogeneous pattern of time trends for each spatial unit.
plot_timetrend(sptsarfit, data, time = "year", spat = "region", xlab = "Time", ylab = "Time Trend", title = "Non-Parametric Time Trend by Spatial Unit")
sptsarfit |
psar object fitted using |
data |
dataframe with the data. |
time |
name of variable including the temporal coordinate. Default "year". |
spat |
name of variable including the spatial units. Default "region". |
xlab |
label of x-axis. Default "Time". |
ylab |
label of y-axis. Default "Time Trend". |
title |
title of graphics. Default "Non-Parametric Time Trend by Spatial Unit" |
Roman Minguez roman.minguez@uclm.es
plot_main_spt plot main terms of non-parametric
spatial (2d) or spatio-temporal (3d) trends in ANOVA models.
plot.gam plot the terms fitted by
gam function in mgcv package.
################################################
###################### Examples using a panel data of rate of
###################### unemployment for 103 Italian provinces in period 1996-2014.
library(sptpsar)
data(unemp_it); Wsp <- Wsp_it
###############################################
# Spatio-temporal semiparametric ANOVA model without spatial lag
# Interaction terms f12,f1t,f2t and f12t with nested basis
# Remark: It is necessary to include ntime as argument
# Remark: nest_sp1, nest_sp2 and nest_time must be divisors of nknots
form4 <- 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),ntime=19)
sptanova <- psar(form4,data=unemp_it,
control=list(thr=1e-2,maxit=200,trace=FALSE))
plot_timetrend(sptanova,data=unemp_it,time="year",
spat="name")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.