# NOT RUN {
require(spdep)
data(boston)
y <- boston.c[, "CMEDV"]
x <- boston.c[,c("ZN", "INDUS" ,"LSTAT")]
xconst <- boston.c[,c("CRIM", "NOX", "CHAS", "AGE", "DIS", "RAD", "TAX", "PTRATIO", "B", "RM" )]
coords <- boston.c[,c("LAT","LON")]
######## SVC model
# res <- besf_vc(y=y,x=x,xconst=xconst,coords=coords)
######## SNVC model
# res2 <- besf_vc(y=y,x=x,xconst=xconst,coords=coords,x_nvc=TRUE)
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")]
############## SVC modeling1 #################
######## (SVC on x; Constant coefficients on xconst)
#res <- besf_vc(y=y,x=x,xconst=xconst,coords=coords, 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 <- besf_vc(y=y,x=x,xconst=xconst,coords=coords )
############## SVC modeling3 #################
######## - Group-level SVC or constant coefficients on x
######## - Constant coefficients on xconst
#res3 <- besf_vc(y=y,x=x,xconst=xconst,coords=coords, s_id=xgroup)
############## SNVC modeling1 #################
######## - SNVC, SVC, NVC, or constant coefficients on x
######## - Constant coefficients on xconst
#res4 <- besf_vc(y=y,x=x,xconst=xconst,coords=coords, x_nvc =TRUE)
############## SNVC modeling2 #################
######## - SNVC, SVC, NVC, or constant coefficients on x
######## - NVC or Constant coefficients on xconst
#res5 <- besf_vc(y=y,x=x,xconst=xconst,coords=coords, 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