# NOT RUN {
require(spdep)
data(boston)
y <- boston.c[, "CMEDV"]
x <- boston.c[,c("CRIM", "AGE")]
xconst <- boston.c[,c("ZN","DIS","RAD","NOX", "TAX","RM", "PTRATIO", "B")]
xgroup <- boston.c[,"TOWN"]
coords <- boston.c[,c("LAT","LON")]
meig <- meigen(coords=coords)
# meig <- meigen_f(coords=coords) ## for large samples
############## SVC modeling1 #################
######## (SVC on x; Constant coefficients on xconst)
res <- resf_vc(y=y,x=x,xconst=xconst,meig=meig, x_sel = FALSE )
res
plot_s(res,0) # Spatially varying intercept
plot_s(res,1) # 1st SVC
plot_s(res,2) # 2nd SVC
############## SVC modeling2 #################
######## (SVC or constant coefficients on x; Constant coefficients on xconst)
#res2 <- resf_vc(y=y,x=x,xconst=xconst,meig=meig )
############## SVC modeling3 #################
######## - Group-level SVC or constant coefficients on x
######## - Constant coefficients on xconst
######## - Group effects
#meig_g <- meigen(coords, s_id=xgroup)
#res3 <- resf_vc(y=y,x=x,xconst=xconst,meig=meig_g,xgroup=xgroup)
############## SNVC modeling1 #################
######## - SNVC, SVC, NVC, or constant coefficients on x
######## - Constant coefficients on xconst
#res4 <- resf_vc(y=y,x=x,xconst=xconst,meig=meig, x_nvc =TRUE)
############## SNVC modeling2 #################
######## - SNVC, SVC, NVC, or constant coefficients on x
######## - NVC or Constant coefficients on xconst
#res5 <- resf_vc(y=y,x=x,xconst=xconst,meig=meig, x_nvc =TRUE, xconst_nvc=TRUE)
#plot_s(res5,0) # Spatially varying intercept
#plot_s(res5,1) # 1st SNVC
#plot_s(res5,1,snvc=FALSE)# SVC in the 1st SNVC
#plot_n(res5,1,xtype="x") # NVC in the 1st NVC
#plot_n(res5,6,xtype="xconst")
# }
Run the code above in your browser using DataLab