Title: | Bayesian Proposal to Fit Spatial Econometric Models |
---|---|
Description: | The purpose of this package is to fit the three Spatial Econometric Models proposed in Anselin (1988, ISBN:9024737354) in the homoscedastic and the heteroscedatic case. The fit is made through MCMC algorithms and observational working variables approach. |
Authors: | Jorge Sicacha-Parada and Edilberto Cepeda-Cuervo |
Maintainer: | Jorge Sicacha-Parada <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.1.0 |
Built: | 2024-12-18 06:29:44 UTC |
Source: | CRAN |
Performs the Bayesian fitting of Heterocedastic Spatial General Model with normal error term
hetero_general(formulamean,formulavar,data,W1,W2=NULL,nsim,burn,step,prior,initial, kernel="normal",mateq=TRUE,seed=0,impacts=TRUE)
hetero_general(formulamean,formulavar,data,W1,W2=NULL,nsim,burn,step,prior,initial, kernel="normal",mateq=TRUE,seed=0,impacts=TRUE)
formulamean |
Object of class formula with the description of the model to be fitted for the mean. |
formulavar |
Object of class formula with the description of the model to be fitted for the variance. |
data |
Data frame object with covariates of model |
W1 |
Object of class matrix, nb or listw related to Spatial Contiguity Matrix for response variable, Anselin(1988) |
W2 |
Object of class matrix, nb or listw related to Spatial Contiguity Matrix for disturbance terms, Anselin(1988) |
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. |
prior |
List with prior distributions of the parameters in the hom_sem model |
initial |
List with the initial values for the chains of each the parameters of the hom_sem model |
kernel |
Distribution used in transition kernel to get samples of lambda, it can be "uniform" or "normal" |
mateq |
Logical variable indicating whether W1=w2 or not. |
impacts |
If impacts=TRUE then impacts for the model are computed, as suggested in Le Sage and Pace (2009). |
seed |
Random seed for generating the samples of the posterior distributions. |
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.
List with the following:
summary |
Data frame with summary statistics of the marginal posterior distributions of the parameters of the model |
Acceptance_Rate |
Acceptance rate for the samples of rho, lambda and gamma. |
Criteria |
List with values of both the Bayesian Information Criterion (BIC) and the Deviance Information Criterion (DIC) |
chains |
Object of class mcmc with the samples of the marginal posterior distribution of each of the parameters of the model |
impacts |
Summary of the impacts for each explanatory variable of the model |
Jorge Sicacha-Parada <[email protected]>, Edilberto Cepeda-Cuervo <[email protected]>
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.
data(oldcol) 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))) W1=COL.nb matstand=nb2mat(W1) A=diag(n)-0.70*matstand B=diag(n)-0.20*matstand mu=solve(A)%*%(-35+0.35*x1-1.7*x2) Sigma2=t(solve(A)%*%solve(B))%*%Sigma%*%solve(A)%*%solve(B) y=t(rmvnorm(1,mu,Sigma2)) formulamean <- y ~ x0 + x1 + x2 formulavar <- ~ x0 + x1 + x3 data <- data.frame(y=y,x0=x0,x1=x1,x2=x2,x3=x3) prior <- list(b_pri=rep(0,3),B_pri=diag(rep(1000,3)), g_pri=rep(0,3),G_pri=diag(rep(1000,3))) initial <- list(beta_0=rep(0,3),gamma_0=c(0,0,0),rho_0=0.5,lambda_0=0.5) hetero_general(formulamean=formulamean,formulavar=formulavar,data=data,W1=W1, nsim=500,burn=25,step=5,prior=prior,initial=initial, kernel="normal",mateq=TRUE)
data(oldcol) 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))) W1=COL.nb matstand=nb2mat(W1) A=diag(n)-0.70*matstand B=diag(n)-0.20*matstand mu=solve(A)%*%(-35+0.35*x1-1.7*x2) Sigma2=t(solve(A)%*%solve(B))%*%Sigma%*%solve(A)%*%solve(B) y=t(rmvnorm(1,mu,Sigma2)) formulamean <- y ~ x0 + x1 + x2 formulavar <- ~ x0 + x1 + x3 data <- data.frame(y=y,x0=x0,x1=x1,x2=x2,x3=x3) prior <- list(b_pri=rep(0,3),B_pri=diag(rep(1000,3)), g_pri=rep(0,3),G_pri=diag(rep(1000,3))) initial <- list(beta_0=rep(0,3),gamma_0=c(0,0,0),rho_0=0.5,lambda_0=0.5) hetero_general(formulamean=formulamean,formulavar=formulavar,data=data,W1=W1, nsim=500,burn=25,step=5,prior=prior,initial=initial, kernel="normal",mateq=TRUE)
Performs the Bayesian fitting of Heterocedastic Spatial AutoRegressive (SAR) model with normal error term
hetero_sar(formulamean,formulavar,data,W,nsim,burn,step,prior, initial,kernel="normal",seed=0,impacts=TRUE)
hetero_sar(formulamean,formulavar,data,W,nsim,burn,step,prior, initial,kernel="normal",seed=0,impacts=TRUE)
formulamean |
Object of class formula with the description of the model to be fitted for the mean. |
formulavar |
Object of class formula with the description of the model to be fitted for the variance. |
data |
Data frame object with covariates of model |
W |
Object of class matrix, nb or listw related to Spatial Contiguity Matrix, Anselin(1988) |
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. |
prior |
List with prior distributions of the parameters in the hom_sem model |
initial |
List with the initial values for the chains of each the parameters of the hom_sem model |
kernel |
Distribution used in transition kernel to get samples of lambda, it can be "uniform" or "normal" |
impacts |
If impacts=TRUE then impacts for the model are computed, as suggested in Le Sage and Pace (2009). |
seed |
Random seed for generating the samples of the posterior distributions. |
hetero_sar is a function made in order to fit Spatial AutoRegressive (SAR) 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 parameter, rho and aided by working variables approach to get samples of conditional posterior distribution of gamma vector.
List with the following:
summary |
Data frame with summary statistics of the marginal posterior distributions of the parameters of the model |
Acceptance_Rate |
List with the acceptance rate for the samples of gamma and rho |
Criteria |
List with values of both the Bayesian Information Criterion (BIC) and the Deviance Information Criterion (DIC) |
chains |
Object of class mcmc with the samples of the marginal posterior distribution of each of the parameters of the model |
Jorge Sicacha-Parada <[email protected]>, Edilberto Cepeda-Cuervo <[email protected]>
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.
set.seed(0) data(oldcol) 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))) W=COL.nb matstand=nb2mat(W) A=diag(n)-0.75*matstand mu=solve(A)%*%(-35+0.35*x1-1.7*x2) Sigma2=t(solve(A))%*%Sigma%*%solve(A) y=t(rmvnorm(1,mu,Sigma2)) data = data.frame(y=y,x0=x0,x1=x1,x2=x2,x3=x3) formulamean <- y ~ x0+x1+x2 formulavar <- ~ x0 + x1 + x3 prior = list(b_pri=rep(0,3),B_pri=diag(rep(1000,3)),g_pri=rep(0,3),G_pri=diag(rep(1000,3))) initial = list(beta_0=rep(0,3),gamma_0=rep(0,3),rho_0=0.5) hetero_sar(formulamean,formulavar,data,W=W,nsim=500,burn=25,step=5,prior=prior, initial=initial,kernel="normal",seed=0,impacts=TRUE)
set.seed(0) data(oldcol) 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))) W=COL.nb matstand=nb2mat(W) A=diag(n)-0.75*matstand mu=solve(A)%*%(-35+0.35*x1-1.7*x2) Sigma2=t(solve(A))%*%Sigma%*%solve(A) y=t(rmvnorm(1,mu,Sigma2)) data = data.frame(y=y,x0=x0,x1=x1,x2=x2,x3=x3) formulamean <- y ~ x0+x1+x2 formulavar <- ~ x0 + x1 + x3 prior = list(b_pri=rep(0,3),B_pri=diag(rep(1000,3)),g_pri=rep(0,3),G_pri=diag(rep(1000,3))) initial = list(beta_0=rep(0,3),gamma_0=rep(0,3),rho_0=0.5) hetero_sar(formulamean,formulavar,data,W=W,nsim=500,burn=25,step=5,prior=prior, initial=initial,kernel="normal",seed=0,impacts=TRUE)
Performs the Bayesian fitting of Heterocedastic Spatial Error Model (SEM) model with normal error term
hetero_sem(formulamean,formulavar,data,W,nsim,burn,step,prior, initial,kernel="normal",seed=0)
hetero_sem(formulamean,formulavar,data,W,nsim,burn,step,prior, initial,kernel="normal",seed=0)
formulamean |
Object of class formula with the description of the model to be fitted for the mean. |
formulavar |
Object of class formula with the description of the model to be fitted for the variance. |
data |
Data frame object with covariates of model |
W |
Object of class matrix, nb or listw related to Spatial Contiguity Matrix, Anselin(1988) |
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. |
prior |
List with prior distributions of the parameters in the hom_sem model |
initial |
List with the initial values for the chains of each the parameters of the hom_sem model |
kernel |
Distribution used in transition kernel to get samples of lambda, it can be "uniform" or "normal" |
seed |
Random seed for generating the samples of the posterior distributions. |
hetero_sem is a function made in order to fit Spatial Error Model (SEM) 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 parameter, lambda, and aided by working variables approach to get samples of conditional posterior distribution of gamma vector.
List with the following:
summary |
Data frame with summary statistics of the marginal posterior distributions of the parameters of the model |
Acceptance_Rate |
List with the acceptance rate for the samples of gamma and lambda |
Criteria |
List with values of both the Bayesian Information Criterion (BIC) and the Deviance Information Criterion (DIC) |
chains |
Object of class mcmc with the samples of the marginal posterior distribution of each of the parameters of the model |
Jorge Sicacha-Parada <[email protected]>, Edilberto Cepeda-Cuervo <[email protected]>
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.
data(oldcol) 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))) W=COL.nb matstand=nb2mat(W) A=diag(n)-0.75*matstand mu=-35+0.35*x1-1.7*x2 Sigma2=t(solve(A))%*%Sigma%*%solve(A) y=t(rmvnorm(1,mu,Sigma2)) formulamean <- y ~ x0 + x1 + x2 formulavar <- ~ x0 + x1 +x3 data <- data.frame(y=y,x0=x0,x1=x1,x2=x2,x3=x3) prior = list(b_pri=rep(0,3),B_pri=diag(rep(1000,3)),g_pri=rep(0,3), G_pri=diag(rep(1000,3))) initial = list(beta_0=rep(0,3),gamma_0=c(0,0,0),lambda_0=0.5) hetero_sem(formulamean,formulavar,data,W=W,nsim=500,burn=25,step=5,prior = prior, initial = initial,kernel="normal")
data(oldcol) 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))) W=COL.nb matstand=nb2mat(W) A=diag(n)-0.75*matstand mu=-35+0.35*x1-1.7*x2 Sigma2=t(solve(A))%*%Sigma%*%solve(A) y=t(rmvnorm(1,mu,Sigma2)) formulamean <- y ~ x0 + x1 + x2 formulavar <- ~ x0 + x1 +x3 data <- data.frame(y=y,x0=x0,x1=x1,x2=x2,x3=x3) prior = list(b_pri=rep(0,3),B_pri=diag(rep(1000,3)),g_pri=rep(0,3), G_pri=diag(rep(1000,3))) initial = list(beta_0=rep(0,3),gamma_0=c(0,0,0),lambda_0=0.5) hetero_sem(formulamean,formulavar,data,W=W,nsim=500,burn=25,step=5,prior = prior, initial = initial,kernel="normal")
Performs the Bayesian fitting of Homoscedastic General Model with normal error term
hom_general(formula, data,W1,W2=NULL, nsim, burn, step,prior, initial, kernel = "normal",mateq=TRUE,impacts=TRUE,seed=0)
hom_general(formula, data,W1,W2=NULL, nsim, burn, step,prior, initial, kernel = "normal",mateq=TRUE,impacts=TRUE,seed=0)
formula |
Object of class formula with the description of the model to be fitted. |
data |
Data frame object with covariates of model |
W1 |
Object of class matrix, nb or listw related to Spatial Contiguity Matrix for response variable, Anselin(1988) |
W2 |
Object of class matrix, nb or listw related to Spatial Contiguity Matrix for disturbance terms, Anselin(1988) |
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. |
prior |
List with prior distributions of the parameters in the hom_sem model |
initial |
List with the initial values for the chains of each the parameters of the hom_sem model |
kernel |
Distribution used in transition kernel to get samples of lambda, it can be "uniform" or "normal" |
mateq |
Logical variable indicating whether W1=w2 or not. |
impacts |
If impacts=TRUE then impacts for the model are computed, as suggested in Le Sage and Pace (2009). |
seed |
Random seed for generating the samples of the posterior distributions. |
hom_general is a function made in order to fit Spatial General Model with a normal homoscedatic disturbance term through MCMC methods as Metropolis-Hastings algorithm, under two proposals for trasition kernel to get samples of spatial responde and error lag parameters, rho and lambda, respectively.
List with the following:
summary |
Data frame with summary statistics of the marginal posterior distributions of the parameters of the model |
Acceptance_Rate |
Acceptance rate for the samples of rho and lambda |
Criteria |
List with values of both the Bayesian Information Criterion (BIC) and the Deviance Information Criterion (DIC) |
chains |
Object of class mcmc with the samples of the marginal posterior distribution of each of the parameters of the model |
impacts |
Summary of the impacts for each explanatory variable of the model |
Jorge Sicacha-Parada <[email protected]>, Edilberto Cepeda-Cuervo <[email protected]>
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.
data(oldcol) n=49 x0=rep(1,n) x1=runif(n,0,400) x2=runif(n,10,23) X=cbind(x0,x1,x2) sigma2=rep(45,n) Sigma=diag(sigma2) W1=COL.nb matstand=nb2mat(W1) A=diag(n)-0.75*matstand B=diag(n)-0.20*matstand miu=solve(A)%*%(18+0.026*x1-0.4*x2) Sigma2=t(solve(A)%*%solve(B))%*%Sigma%*%solve(A)%*%solve(B) y=t(rmvnorm(1,miu,Sigma2)) formula <- y ~ x0 + x1 + x2 data <- data.frame(y=y,x0=x0,x1=x1,x2=x2) prior <- list(b_pri=rep(0,3),B_pri=diag(rep(1000,3)), r_pri=0.01,lambda_pri=0.01) initial <- list(beta_0=rep(0,3), sigma2_0=90,rho_0=0.5,lambda_0=0.5) hom_general(formula=formula,data=data,W1=COL.nb,nsim=500,burn=25,step=5, prior=prior,initial=initial,kernel="normal",mateq=TRUE)
data(oldcol) n=49 x0=rep(1,n) x1=runif(n,0,400) x2=runif(n,10,23) X=cbind(x0,x1,x2) sigma2=rep(45,n) Sigma=diag(sigma2) W1=COL.nb matstand=nb2mat(W1) A=diag(n)-0.75*matstand B=diag(n)-0.20*matstand miu=solve(A)%*%(18+0.026*x1-0.4*x2) Sigma2=t(solve(A)%*%solve(B))%*%Sigma%*%solve(A)%*%solve(B) y=t(rmvnorm(1,miu,Sigma2)) formula <- y ~ x0 + x1 + x2 data <- data.frame(y=y,x0=x0,x1=x1,x2=x2) prior <- list(b_pri=rep(0,3),B_pri=diag(rep(1000,3)), r_pri=0.01,lambda_pri=0.01) initial <- list(beta_0=rep(0,3), sigma2_0=90,rho_0=0.5,lambda_0=0.5) hom_general(formula=formula,data=data,W1=COL.nb,nsim=500,burn=25,step=5, prior=prior,initial=initial,kernel="normal",mateq=TRUE)
Performs the Bayesian fitting of Homoscedastic Spatial AutoRegressive (SAR) model with normal error term
hom_sar(formula, data, W, nsim, burn, step,prior, initial, kernel = "normal",impacts=TRUE,seed=0)
hom_sar(formula, data, W, nsim, burn, step,prior, initial, kernel = "normal",impacts=TRUE,seed=0)
formula |
Object of class formula with the description of the model to be fitted. |
data |
Data frame object with covariates of model |
W |
Object of class matrix, nb or listw related to Spatial Contiguity Matrix, Anselin(1988) |
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. |
prior |
List with prior distributions of the parameters in the hom_sem model |
initial |
List with the initial values for the chains of each the parameters of the hom_sem model |
kernel |
Distribution used in transition kernel to get samples of lambda, it can be "uniform" or "normal" |
impacts |
If impacts=TRUE then impacts for the model are computed, as suggested in Le Sage and Pace (2009). |
seed |
Random seed for generating the samples of the posterior distributions. |
hom_sar is a function made in order to fit Spatial AutoRegressive (SAR) model with a normal homoscedatic disturbance term through MCMC methods as Metropolis-Hastings algorithm, under two proposals for trasition kernel to get samples of spatial lag parameter, rho.
List with the following:
summary |
Data frame with summary statistics of the marginal posterior distributions of the parameters of the model |
Acceptance_Rate |
Acceptance rate for the samples of rho |
Criteria |
List with values of both the Bayesian Information Criterion (BIC) and the Deviance Information Criterion (DIC) |
chains |
Object of class mcmc with the samples of the marginal posterior distribution of each of the parameters of the model |
impacts |
Summary of the impacts for each explanatory variable of the model |
Jorge Sicacha-Parada <[email protected]>, Edilberto Cepeda-Cuervo <[email protected]>
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.
library(BSPADATA) ## Generate data ## data(oldcol) n=49 x0=rep(1,n) x1=runif(n,0,400) x2=runif(n,10,23) X=data.frame(x0=x0,x1=x1,x2=x2) sigma2=rep(45,n) Sigma=diag(sigma2) W=COL.nb matstand=nb2mat(W) A=diag(n)-0.90*matstand mu=solve(A)%*%(18+0.478*x1-1.3*x2) Sigma2=t(solve(A))%*%Sigma%*%solve(A) y=t(rmvnorm(1,mu,Sigma2)) data = data.frame(y=y,x0=x0,x1=x1,x2=x2) ## Fit the model ## formula <- y ~ x0+x1+x2 prior = list(b_pri=rep(0,3),B_pri=diag(rep(1000,3)),r_pri=0.01, lambda_pri=0.01) initial = list(beta_0=rep(0,3),sigma2_0=90,rho_0=0.5) model <- hom_sar(formula=formula,data=data,W,nsim=500,burn=25,step=5,prior=prior, initial=initial,kernel="normal")
library(BSPADATA) ## Generate data ## data(oldcol) n=49 x0=rep(1,n) x1=runif(n,0,400) x2=runif(n,10,23) X=data.frame(x0=x0,x1=x1,x2=x2) sigma2=rep(45,n) Sigma=diag(sigma2) W=COL.nb matstand=nb2mat(W) A=diag(n)-0.90*matstand mu=solve(A)%*%(18+0.478*x1-1.3*x2) Sigma2=t(solve(A))%*%Sigma%*%solve(A) y=t(rmvnorm(1,mu,Sigma2)) data = data.frame(y=y,x0=x0,x1=x1,x2=x2) ## Fit the model ## formula <- y ~ x0+x1+x2 prior = list(b_pri=rep(0,3),B_pri=diag(rep(1000,3)),r_pri=0.01, lambda_pri=0.01) initial = list(beta_0=rep(0,3),sigma2_0=90,rho_0=0.5) model <- hom_sar(formula=formula,data=data,W,nsim=500,burn=25,step=5,prior=prior, initial=initial,kernel="normal")
Performs the Bayesian fitting of Homoscedastic Spatial Error Model (SEM) with normal error term
hom_sem(formula, data, W, nsim, burn, step,prior, initial, kernel = "normal",seed=0)
hom_sem(formula, data, W, nsim, burn, step,prior, initial, kernel = "normal",seed=0)
formula |
Object of class formula with the description of the model to be fitted. |
data |
Data frame object with covariates of model |
W |
Object of class matrix, nb or listw related to Spatial Contiguity Matrix, Anselin(1988) |
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. |
prior |
List with prior distributions of the parameters in the hom_sem model |
initial |
List with the initial values for the chains of each the parameters of the hom_sem model |
kernel |
Distribution used in transition kernel to get samples of lambda, it can be "uniform" or "normal" |
seed |
Random seed for generating the samples of the posterior distributions. |
hom_sem is a function made in order to fit Spatial Error Model (SEM) with a normal homoscedatic disturbance term through MCMC methods as Metropolis-Hastings algorithm, under two proposals for trasition kernel to get samples of spatial error lag parameter, lambda.
List with the following:
summary |
Data frame with summary statistics of the marginal posterior distributions of the parameters of the model |
Acceptance_Rate |
Acceptance rate for the samples of lambda |
Criteria |
List with values of both the Bayesian Information Criterion (BIC) and the Deviance Information Criterion (DIC) |
chains |
Object of class mcmc with the samples of the marginal posterior distribution of each of the parameters of the model |
Jorge Sicacha-Parada <[email protected]>, Edilberto Cepeda-Cuervo <[email protected]>
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.
data(oldcol) n=49 x0=rep(1,n) x1=runif(n,0,400) x2=runif(n,10,23) X=cbind(x0,x1,x2) sigma2=rep(45,n) Sigma=diag(sigma2) W=COL.nb matstand=nb2mat(W) A=diag(n)-0.85*matstand mu=(18+0.026*x1-0.4*x2) Sigma2=t(solve(A))%*%Sigma%*%solve(A) y=t(rmvnorm(1,mu,Sigma2)) formula <- y ~ x0+x1+x2 data <- data.frame(y=y,x0=x0,x1=x1,x2=x2) prior <- list(b_pri=rep(0,3),B_pri=diag(rep(1000,3)),r_pri=0.01,lambda_pri=0.01) initial <- list(beta_0=rep(0,3),sigma2_0=90,lambda_0=0.5) hom_sem(formula=formula,data=data,W=W,nsim=500,burn=25,step=5,prior=prior, initial=initial,kernel="normal")
data(oldcol) n=49 x0=rep(1,n) x1=runif(n,0,400) x2=runif(n,10,23) X=cbind(x0,x1,x2) sigma2=rep(45,n) Sigma=diag(sigma2) W=COL.nb matstand=nb2mat(W) A=diag(n)-0.85*matstand mu=(18+0.026*x1-0.4*x2) Sigma2=t(solve(A))%*%Sigma%*%solve(A) y=t(rmvnorm(1,mu,Sigma2)) formula <- y ~ x0+x1+x2 data <- data.frame(y=y,x0=x0,x1=x1,x2=x2) prior <- list(b_pri=rep(0,3),B_pri=diag(rep(1000,3)),r_pri=0.01,lambda_pri=0.01) initial <- list(beta_0=rep(0,3),sigma2_0=90,lambda_0=0.5) hom_sem(formula=formula,data=data,W=W,nsim=500,burn=25,step=5,prior=prior, initial=initial,kernel="normal")