I am trying to run a Geographically weighted panel regression model as seen below. However I keep on getting an error of duplicate ids.
bw.GWPR(formula = formula1, data = finalprepostdataset3,
SDF = finalprepostdataset_sp,
index = c("county_id", "season"),
adaptive = TRUE, approach = "AIC",
p = 2, effect = "twoways", model = "within",
doParallel=T, cluster.number=4,
kernel = "bisquare", longlat = FALSE, bigdata = T)
Error in { : task 1 failed - "duplicate couples (id-time)
finalprepostdataset_sp is a spatial copy of finalprepostdataset3. I read guides to get rid of this problem (my understanding is that it derives from the way plm handles panel data) but I still am getting errors. To be clearer, I can run this code successfully:
plm(
formula=formula1,
data=finalprepostdataset3,
effect = "time",
model = "within",
index = c("county_id", "season"),
)
And:
any(table(index(finalprepostdataset3$county_id, finalprepostdataset3$season), useNA = "ifany")!=1)
FALSE
Indicating, as I understand it, no duplicates.
But the first code would not run.
Any help would be appreciated. Posting here due to people's familiarity with plm.
Hard to tell without a reproducible example. Function
bw.GWPRseems to stem from packageGWPR.lightandplmfrom packageplm, both of which are not indidicated in the question.If you
plmstatement runs successfully without a warning, you should be safe not to have doublicated compbinations of the observational unit (county_id) and time dimension (season) in your data.However, to check you would leave out the
indexfunction in your test (or usedindexon a pdata.frame (not on variables))