MVS.CARleroux: Fit A Multivariate Spatial Generalised Linear Mixed ...
duncanplee/CARBayes Spatial Generalised Linear Mixed Models for Areal Unit Data
Package index Search the duncanplee/CARBayes package Functions 107 Source code 43 Man pages 18- Browse all...
Description Usage Arguments Value Author(s) References Examples
View source: R/MVS.CARleroux.R
Description
Fit a multivariate spatial generalised linear mixed model to areal unit data, where the response variable can be binomial, Gaussian, multinomial or Poisson. The linear predictor is modelled by known covariates and a vector of random effects. The latter account for both spatial and between variable correlation, via a Kronecker product formulation. Spatial correlation is captured by the conditional autoregressive (CAR) prior proposed by Leroux et al. (2000), and between variable correlation is captured by a between variable covariance matrix with no fixed structure. This is a type of multivariate conditional autoregressive (MCAR) model. Further details are given in the vignette accompanying this package. Independent (over space) random effects can be obtained by setting rho=0, while the intrinsic MCAR model can be obtained by setting rho=1. Inference is conducted in a Bayesian setting using Markov chain Monte Carlo (MCMC) simulation. Missing (NA) values are allowed in the response, and posterior predictive distributions are created for the missing values using data augmentation. These are saved in the "samples" argument in the output of the function and are denoted by "Y". For the multinomial model the first category in the multinomial data (first column of the response matrix) is taken as the baseline, and the covariates are linearly related to the log of the ratio (theta_j / theta_1) for j=1,...,J, where theta_j is the probability of being in category j. For a full model specification see the vignette accompanying this package.
Usage
| 1 2 3 4 | MVS.CARleroux(formula, family, data=NULL, trials=NULL, W, burnin, n.sample, thin=1, prior.mean.beta=NULL, prior.var.beta=NULL, prior.nu2=NULL, prior.Sigma.df=NULL, prior.Sigma.scale=NULL, rho=NULL, MALA=FALSE, verbose=TRUE) |
Arguments
| formula | A formula for the covariate part of the model using the syntax of the lm() function. Offsets can be included here using the offset() function. The response and the offset (if included) should be matrices of dimension K*J, where K is the number of spatial units and J is the number of different variables (categories in the multinomial model). The covariates should each be a K*1 vector, and different regression parameters are estimated for each of the J variables. Missing (NA) values are allowed in the response. |
| family | One of either "binomial", "gaussian", "multinomial", or "poisson", which respectively specify a binomial likelihood model with a logistic link function, a Gaussian likelihood model with an identity link function, a multinomial likelihood model with a logistic link function, or a Poisson likelihood model with a log link function. |
| data | An optional data.frame containing the variables in the formula. |
| trials | Only used if family="binomial" or family="multinomial". For the binomial family it is a K*J matrix matrix the same dimension as the response. A the multinomial family it is a vector of length K. |
| W | A non-negative K by K neighbourhood matrix (where K is the number of spatial units). Typically a binary specification is used, where the jkth element equals one if areas (j, k) are spatially close (e.g. share a common border) and is zero otherwise. The matrix can be non-binary, but each row must contain at least one non-zero entry. |
| burnin | The number of MCMC samples to discard as the burn-in period. |
| n.sample | The number of MCMC samples to generate. |
| thin | The level of thinning to apply to the MCMC samples to reduce their temporal autocorrelation. Defaults to 1 (no thinning). |
| prior.mean.beta | A vector of prior means for the regression parameters beta (Gaussian priors are assumed). Defaults to a vector of zeros. |
| prior.var.beta | A vector of prior variances for the regression parameters beta (Gaussian priors are assumed). Defaults to a vector with values 100000. |
| prior.nu2 | The prior shape and scale in the form of c(shape, scale) for an Inverse-Gamma(shape, scale) prior for nu2. Defaults to c(1, 0.01) and only used if family="Gaussian". |
| prior.Sigma.df | The prior degrees of freedom for the Inverse-Wishart prior for Sigma. Defaults to J+1. |
| prior.Sigma.scale | The prior J times J scale matrix for the Inverse-Wishart prior for Sigma. Defaults to the identity matrix divided by 1000. |
| rho | The value in the interval [0, 1] that the spatial dependence parameter rho is fixed at if it should not be estimated. If this arugment is NULL then rho is estimated in the model. |
| MALA | Logical, should the function use Metropolis adjusted Langevin algorithm (MALA) updates (TRUE) or simple random walk (FALSE, default) updates for the regression parameters and the random effects. If family="gaussian" the MALA argument only applies to the random effects as the regression parameters are Gibbs sampled. Not applicable if family="multinomial" where random walk updates are used. |
| verbose | Logical, should the function update the user on its progress. |
Value
| summary.results | A summary table of the parameters. |
| samples | A list containing the MCMC samples from the model. |
| fitted.values | A matrix of fitted values for each area and response variable. |
| residuals | A list with 2 elements, where each element is a matrix of a type of residuals. Each row of a matrix relates to an area and each column to a response (category). The types of residual are "response" (raw), and "pearson". |
| modelfit | Model fit criteria including the Deviance Information Criterion (DIC) and its corresponding estimated effective number of parameters (p.d), the Log Marginal Predictive Likelihood (LMPL), the Watanabe-Akaike Information Criterion (WAIC) and its corresponding estimated number of effective parameters (p.w), and the loglikelihood. |
| accept | The acceptance probabilities for the parameters. |
| localised.structure | NULL, for compatability with other models. |
| formula | The formula (as a text string) for the response, covariate and offset parts of the model |
| model | A text string describing the model fit. |
| X | The design matrix of covariates. |
Author(s)
Duncan Lee
References
Gelfand, A and Vounatsou, P (2003). Proper multivariate conditional autoregressive models for spatial data analysis, Biostatistics, 4, 11-25.
Kavanagh, L., D. Lee, and G. Pryce (2016). Is Poverty Decentralising? Quantifying Uncertainty in the Decentralisation of Urban Poverty, Annals of the American Association of Geographers, 106, 1286-1298.
Leroux B, Lei X, Breslow N (2000). "Estimation of Disease Rates in SmallAreas: A New Mixed Model for Spatial Dependence." In M Halloran, D Berry (eds.), Statistical Models in Epidemiology, the Environment and Clinical Trials, pp. 179-191. Springer-Verlag, New York.
Examples
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | ################################################# #### Run the model on simulated data on a lattice ################################################# #### Load other libraries required library(MASS) #### Set up a square lattice region x.easting <- 1:10 x.northing <- 1:10 Grid <- expand.grid(x.easting, x.northing) K <- nrow(Grid) #### set up distance and neighbourhood (W, based on sharing a common border) matrices distance <- as.matrix(dist(Grid)) W <-array(0, c(K,K)) W[distance==1] <-1 K <- nrow(W) #### Generate the correlation structures Q.W <- 0.99 * (diag(apply(W, 2, sum)) - W) + 0.01 * diag(rep(1,K)) Q.W.inv <- solve(Q.W) Sigma <- matrix(c(1,0.5,0, 0.5,1,0.3, 0, 0.3, 1), nrow=3) Sigma.inv <- solve(Sigma) J <- nrow(Sigma) N.all <- K * J precision.phi <- kronecker(Q.W, Sigma.inv) var.phi <- solve(precision.phi) #### Generate the covariate component x1 <- rnorm(K) x2 <- rnorm(K) XB <- cbind(0.1 * x1 - 0.1*x2, -0.1 * x1 + 0.1*x2, 0.1 * x1 - 0.1*x2) #### Generate the random effects phi <- mvrnorm(n=1, mu=rep(0,N.all), Sigma=var.phi) #### Generate the response data lp <-as.numeric(t(XB)) + phi prob <- exp(lp) / (1 + exp(lp)) trials.vec <- rep(100,N.all) Y.vec <- rbinom(n=N.all, size=trials.vec, prob=prob) #### Turn the data and trials into matrices where each row is an area. Y <- matrix(Y.vec, nrow=K, ncol=J, byrow=TRUE) trials <- matrix(trials.vec, nrow=K, ncol=J, byrow=TRUE) #### Run the Leroux model formula <- Y ~ x1 + x2 ## Not run: model <- MVS.CARleroux(formula=formula, family="binomial", trials=trials, W=W, burnin=20000, n.sample=100000) ## End(Not run) #### Toy example for checking model <- MVS.CARleroux(formula=formula, family="binomial", trials=trials, W=W, burnin=10, n.sample=50) |
Related to MVS.CARleroux in duncanplee/CARBayes...
duncanplee/CARBayes indexR Package Documentation
rdrr.io home R language documentation Run R code onlineBrowse R Packages
CRAN packages Bioconductor packages R-Forge packages GitHub packagesWe want your feedback!
Note that we can't provide technical support on individual packages. You should contact the package authors for that. Tweet to @rdrrHQ GitHub issue tracker [email protected]
Personal blog What can we improve? The page or its content looks wrong I can't find what I'm looking for I have a suggestion Other Extra info (optional) Submit Improve this page Embedding an R snippet on your website Add the following code to your website.
REMOVE THIS Copy to clipboard
For more information on customizing the embed code, read Embedding Snippets.
CloseTừ khóa » Phi-mvs Github
-
Ss2lyf/PHI-MVS - GitHub
-
Adahbingee/pais-mvs: Multi-view Stereo Image-based 3D ... - GitHub
-
PHI-MVS: Plane Hypothesis Inference Multi ... - Papers With Code
-
PHI-MVS: Plane Hypothesis Inference Multi-view ... - ResearchGate
-
KyrieLiu52/Awesome-MVS-walsvid - Bytemeta
-
[PDF] ArXiv:2205.02836v2 [cs.CV] 18 May 2022
-
Tong's This Is It
-
每日论文速递:计算机视觉相关(4月14日更新版)
-
Clyde Zuber - Enter Job Title Here - Wherever That Is - LinkedIn
-
CÔNG TY CỔ PHẦN AN TOÀN THÔNG TIN MVS
-
Botanical_garden (high-res Multi-view) - ETH3D Benchmark
-
How To Remove CTRL-M (^M) Characters From A File In Linux - Support
-
[PDF] CARBayes: Spatial Generalised Linear Mixed Models For Areal Unit ...