## Bayesian fitting of Spatial General Model with heteroscedastic normal error term.

### Description

Performs the Bayesian fitting of Heterocedastic Spatial General Model with normal error term

### Usage

```hetero_general(y,X,Z, W1,W2=NULL, nsim, burn, step, b_pri, B_pri,g_pri,G_pri, beta_0,
gammas_0, rho_0, lambda_0, kernel = NULL,
plot = TRUE,mateq=TRUE)
```

### Arguments

 `y` Object of class matrix, with the dependent variable `X` Object of class matrix, with covariates of mean model `Z` Object of class matrix, with covariates of dispersion model `W1` Object of class matrix, nb or listw related to response variable Spatial Contiguity Matrix, Anselin(1988) `W2` Object of class matrix, nb or listw related to error term Spatial Contiguity Matrix, Anselin(1988). It's NULL by default. `nsim` A number that indicates the amount of iterations `burn` A number that indicates the amount of iterations to be burn at the beginning of the chain `step` A number that indicates the length between samples in chain that generate the point estimates for each parameter. `b_pri` A vector with the prior mean of beta `B_pri` A matrix with the prior variance of beta `g_pri` A vector with the prior mean of gamma `G_pri` A vector with the prior variance of gamma `beta_0` A vector with start values for beta chain `gammas_0` A number with start value for gamma chain `rho_0` A number with start value for rho chain `lambda_0` A number with start value for lambda chain `kernel` Distribution used in transition kernel to get samples of rho and lambda, it can be "uniform" or "normal" `plot` If it is TRUE present the graph of the chains `mateq` Logical variable indicating whether W1=W2 or not.

### Details

hetero_general is a function made in order to fit Spatial General Model with a normal heteroscedatic disturbance term through MCMC methods as Metropolis-Hastings algorithm, under two proposals for trasition kernel to get samples of spatial lag parameters, rho and lambda, and aided by working variables approach to get samples of conditional posterior distribution of gamma vector.

### Value

List with the following:

 `Bestimado` Estimated coefficients of beta `Gammaest` Estimated coefficient of gamma `Rhoest` Estimated coefficient of rho `Lambdaest` Estimated coefficient of lambda `DesvBeta` Estimated standard deviations of beta `DesvGamma` Estimated standard deviation of gamma `DesvRho` Estimated standard deviation of rho `DesvLambda` Estimated standard deviation of lambda `AccRate1` Acceptance Rate for samples of gamma `AccRate2` Acceptance Rate for samples of rho `AccRate3` Acceptance Rate for samples of lambda `BIC` Value of Bayesian Information Criterion `DIC` Value of Deviance Information Criterion

### Author(s)

Jorge Sicacha-Parada <jasicachap@unal.edu.co>, Edilberto Cepeda-Cuervo <ecepedac@unal.edu.co>

### References

1. Cepeda C. E. (2001). Modelagem da variabilidade em modelos lineares generalizados. Unpublished Ph.D. tesis. Instituto de Matematicas. Universidade Federal do Rio do Janeiro.

2.Cepeda, E. and Gamerman D. (2005). Bayesian Methodology for modeling parameters in the two-parameter exponential family. Estadistica 57, 93 105.

3.Cepeda C., E. and Gamerman D. (2001). Bayesian Modeling of Variance Heterogeneity in Normal Regression Models. Brazilian Journal of Probability and Statistics. 14, 207-221.

4.Luc Anselin, Spatial Econometrics: Methods and Models, Kluwer Academic, Boston, 1988.

5. D. Gamerman, Markov Chains Monte Carlo: Stochastic Simulation for bayesian Inference, Chapman and Hall, 1997.

6. James Le Sage and Kelley Pace, Introduction to Spatial Econometrics, Chapman & Hall/CRC, Boca Raton, 2009.

### Examples

```library(spdep)
library(mvtnorm)
library(pscl)
n=49
x0=rep(1,n)
x1=runif(n,0,400)
x2=runif(n,10,23)
x3=runif(n,0,10)
X=cbind(x0,x1,x2)
Z=cbind(x0,x1,x3)
gammas=c(-8,0.026,-0.4)
Sigma=diag(c(exp(Z%*%gammas)))
data(oldcol)
W1=COL.nb
matstand=nb2mat(W1)
A=diag(n)-0.70*matstand
B=diag(n)-0.20*matstand
miu=solve(A)%*%(-35+0.35*x1-1.7*x2)
Sigma2=t(solve(A)%*%solve(B))%*%Sigma%*%solve(A)%*%solve(B)
y=rmvnorm(1,miu,Sigma2)
y_1=t(y)
y=y_1
data(oldcol)
W1=COL.nb
hetero_general(y,X,Z,W1=W1,nsim=500,burn=25,step=5,b_pri=rep(0,3),B_pri=diag(rep(1000,3)),
g_pri=rep(0,3),G_pri=diag(rep(1000,3)),
beta_0=rep(0,3),gammas_0=c(10,0,0),rho_0=0.5,lambda_0=0.5,
kernel="normal",plot="FALSE",mateq="TRUE")
```