0

我正在使用形状文件.shp,然后将其转换为边界文件.bnd,以BayesX将其用作模型中的随机效果。但它会ERROR: map is disconnected, spatial effect cannot be estimatedBayesX日志文件中抛出一个错误。可能是什么问题呢

这是代码

fileUrl <- "http://biogeo.ucdavis.edu/data/gadm2.8/shp/ZAF_adm_shp.zip"
download.file(fileUrl, destfile = "ZAF_adm_shp.zip")
unzip(zipfile = "ZAF_adm_shp.zip",exdir = "ZAF_adm_shp")
library(BayesX)
library("R2BayesX")
shpname <- file.path(getwd(), "ZAF_adm_shp" , "ZAF_adm2")
SA_bnd <- BayesX::shp2bnd(shpname = shpname, regionnames = "ID_2", check.is.in = F)
za <- bayesx(dp2011 ~ code +   sx(ID_2, bs = "mrf", map = SA_bnd) +
               sx(ID_2, bs = "re"), iter = 1200,  step = 10, data = data)

这是数据

data<-dput(structure(list(ID_2 = 1:52, NAME_2B = structure(c(1L, 3L, 5L, 
10L, 6L, 24L, 30L, 33L, 20L, 26L, 27L, 51L, 40L, 18L, 12L, 36L, 
13L, 50L, 2L, 19L, 23L, 41L, 42L, 43L, 44L, 45L, 46L, 52L, 38L, 
8L, 28L, 47L, 48L, 37L, 17L, 22L, 32L, 21L, 25L, 29L, 35L, 39L, 
4L, 14L, 31L, 15L, 11L, 7L, 9L, 16L, 34L, 49L), .Label = c("Alfred Nzo", 
"Amajuba", "Amathole", "Bojanala", "Buffalo City", "Cacadu", 
"Cape Winelands", "Capricorn", "Central Karoo", "Chris Hani", 
"City of Cape Town", "City of Johannesburg", "City of Tshwane", 
"Dr Kenneth Kaunda", "Dr Ruth Segomotsi Mompati", "Eden", "Ehlanzeni", 
"Ekurhuleni", "eThekwini", "Fezile Dabi", "Frances Baard", "Gert Sibande", 
"iLembe", "Joe Gqabi", "John Taolo Gaetsewe", "Lejweleputswa", 
"Mangaung", "Mopani", "Namakwa", "Nelson Mandela Bay", "Ngaka Modiri Molema", 
"Nkangala", "O.R.Tambo", "Overberg", "Pixley ka Seme", "Sedibeng", 
"Sekhukhune", "Sisonke", "Siyanda", "Thabo Mofutsanyane", "Ugu", 
"Umgungundlovu", "Umkhanyakude", "Umzinyathi", "Uthukela", "Uthungulu", 
"Vhembe", "Waterberg", "West Coast", "West Rand", "Xhariep", 
"Zululand"), class = "factor"), code = structure(c(38L, 5L, 1L, 
6L, 4L, 7L, 51L, 8L, 13L, 10L, 50L, 9L, 11L, 47L, 49L, 36L, 52L, 
41L, 18L, 48L, 22L, 14L, 15L, 20L, 17L, 16L, 21L, 19L, 37L, 29L, 
27L, 28L, 30L, 40L, 26L, 24L, 25L, 46L, 39L, 43L, 44L, 45L, 31L, 
35L, 32L, 33L, 2L, 12L, 42L, 34L, 23L, 3L), .Label = c(" BUF", 
" CPT", " DC1", " DC10", " DC12", " DC13", " DC14", " DC15", 
" DC16", " DC18", " DC19", " DC2", " DC20", " DC21", " DC22", 
" DC23", " DC24", " DC25", " DC26", " DC27", " DC28", " DC29", 
" DC3", " DC30", " DC31", " DC32", " DC33", " DC34", " DC35", 
" DC36", " DC37", " DC38", " DC39", " DC4", " DC40", " DC42", 
" DC43", " DC44", " DC45", " DC47", " DC48", " DC5", " DC6", 
" DC7", " DC8", " DC9", " EKU", " ETH", " JHB", " MAN", " NMA", 
" TSH"), class = "factor"), dp2011 = c(9.7, 7.1, 11.5, 11, 7.2, 
10.7, 13.8, 12.6, 5.8, 8.2, 7.9, 12.3, 11.7, 10.8, 15.5, 7.6, 
8.1, 17.6, 11.3, 33.5, 18.4, 12.5, 14.7, 15.8, 8.9, 8.8, 20.3, 
17.6, 10.5, 10.5, 14.6, 16.4, 8.5, 10.7, 7.1, 6.6, 7.5, 9.9, 
7.5, 4.8, 11, 7.9, 5.4, 11.6, 12.5, 8.3, 14.9, 29.2, 30.7, 8.5, 
16.5, 15.8)), .Names = c("ID_2", "NAME_2B", "code", "dp2011"), row.names = c(NA, 
-52L), class = "data.frame"))
4

0 回答 0