Skip to content
Prev 26894 / 29559 Next

Question about HSAR package

Ok, it's helpful to know that I need to zoom in on those three things.

I created the Random Effects Matrix by hand in Excel, so I read that into R
and put the matrix into the format recommended here:
https://cran.r-project.org/web/packages/HSAR/vignettes/hsar.html

Below, I show how I made W, M, and Delta.mat, before I try to estimate the
model. Hopefully this helps.


constit<- readShapeSpatial("Population
Weighted/Constituencies_2008/20170209_Constit")
constit.nb<- poly2nb(constit, row.names = constit$X20160526_5)
ghana.constit.weights.binary<- nb2listw(constit.nb, style="B", zero.policy
= TRUE)

W.constit<- listw2mat(ghana.constit.weights.binary)
W.constit <- W.constit / rowSums(W.constit)
W.constit <- as(W.constit,"dgCMatrix")


dist2008<- readShapeSpatial("Population Weighted/Districts_2008/Volta
Variable/20170226_Districts")
dist2008.nb<- poly2nb(dist2008, row.names = dist2008$DIST_2008)
ghana.dist2008.weights.binary<- nb2listw(dist2008.nb, style="B",
zero.policy=T)

W.dist<- listw2mat(ghana.dist2008.weights.binary)
W.dist <- W.dist / rowSums(W.dist)
W.dist <- as(W.dist,"dgCMatrix")


Delta<- read.csv("Random Effects Matrix_Ghana.csv",
                 header = T, row.names = 1)
Delta.mat<- as.matrix(Delta)
Delta.mat <- as(Delta.mat,"dgCMatrix")
+                    + volatility + turnout_21
+                    + volatili_1 + X20160526_6
+                    + DENSITY_RD + Count_3
+                    + MEAN + pov_p_2008
+                    + gini_2008 + ferat_2008
+                    + Count_4 + literacy
+                    + grid_perCa, data=constit, W=W.constit,
+                    M=W.dist, Delta = Delta.mat,
+                    burnin = 5000, Nsim = 10000,
+                    thinning = 1, parameters.start = NULL)
Error in hsar(Count_ ~ ndc_pres_3 + volatility + turnout_21 + volatili_1 +
:
  not an S4 object
On Thu, Sep 27, 2018 at 3:57 PM Roger Bivand <Roger.Bivand at nhh.no> wrote: