Id | Neighborhood | NeiNumber | OverallQual | SalePrice |
1 | CollgCr | 1 | 7 | 279500 |
2 | CollgCr | 1 | 7 | 208500 |
3 | CollgCr | 1 | 7 | 223500 |
4 | CollgCr | 1 | 8 | 230000 |
5 | CollgCr | 1 | 5 | 145000 |
6 | BrkSide | 2 | 5 | 118000 |
7 | BrkSide | 2 | 7 | 132000 |
8 | Sawyer | 3 | 4 | 90000 |
9 | Sawyer | 3 | 5 | 129500 |
10 | Sawyer | 3 | 5 | 144000 |
11 | NridgHt | 4 | 8 | 325300 |
12 | NridgHt | 4 | 8 | 256300 |
13 | NridgHt | 4 | 8 | 306000 |
I wish to make hierarchical bayesian model by R code but I can by find out how can I.
new<-read.csv("1242018.csv", header = TRUE, sep = ",")
install.packages("bayesm")
Z<-new$SalePrice
Z[,1]=rep(1,nrow(Z))
Z[,2]=Z[,2]-mean(Z[,2])
Z[,3]=Z[,3]-mean(Z[,3])
Z[,4]=Z[,4]-mean(Z[,4])
Z=as.matrix(Z)
hh=levels(factor(choiceAtt$id))
nhh=length(hh)
lgtdata=NULL
for (i in 1:nhh) {
y=choiceAtt[choiceAtt[,1]==hh[i],2]
nobs=length(y)
X=as.matrix(choiceAtt[choiceAtt[,1]==hh[i],c(3:16)])
lgtdata[[i]]=list(y=y,X=X)
}
cat("Finished Reading data",fill=TRUE)
fsh()
Data=list(lgtdata=lgtdata,Z=Z)
Mcmc=list(R=20000,sbeta=0.2,keep=20)
out=rhierBinLogit(Data=Data,Mcmc=Mcmc)
Get Answers For Free
Most questions answered within 1 hours.