spMvLM(spBayes)
spMvLM()所属R语言包:spBayes
Function for fitting multivariate Bayesian spatial regression models
函数拟合多元贝叶斯空间回归模型
译者:生物统计家园网 机器人LoveR
描述----------Description----------
The function spMvLM fits Gaussian multivariate Bayesian spatial regression models. Given a set of knots, spMvLM will also fit a predictive process model (see references below).
的功能spMvLM符合高斯分布的的多元贝叶斯空间回归模型。给定一组的结,spMvLM也符合预测过程模型(请参阅下面的参考资料)。
用法----------Usage----------
spMvLM(formula, data = parent.frame(), coords, knots,
starting, sp.tuning, priors, cov.model,
modified.pp = TRUE, n.samples, sub.samples,
verbose=TRUE, n.report=100, ...)
参数----------Arguments----------
参数:formula
for a multivariate model with q response variables, this is a list of univariate formulas. See example below.
q响应变量的多变量模型,这是一个单变量的公式列表。见下面的例子。
参数:data
an optional data frame containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which spMvLM is called.
一个可选的数据框包含在模型中的变量。如果没有找到,数据,变量environment(formula),通常是spMvLM被称为环境。
参数:coords
an n x 2 matrix of the observation coordinates in R^2 (e.g., easting and northing).
n x 2R^2(例如,东向和北向)的观察坐标矩阵。
参数:knots
either a m x 2 matrix of the predictive process knot coordinates in R^2 (e.g., easting and northing) or a vector of length two or three with the first and second elements recording the number of columns and rows in the desired knot grid. The third, optional, element sets the offset of the outermost knots from the extent of the coords extent.
m x 2矩阵的预测过程结坐标在R^2(例如,东向和北向)或长度的向量的记录的数目的列和行,在该第一和第二元件中的两个或三个与所需的结栅格。可选的第三个,元素设置从coords程度的程度的最外节的偏移量。
参数:starting
a list with each tag corresponding to a parameter name. Valid list tags are beta, A, L, phi, and nu. The value portion of each tag is a vector of parameter's starting value. For A and L the vectors are of length (q^2-q)/2+q and phi and nu are of length q. Here, A and L hold the the lower-triangle elements in column major ordering of the Cholesky square root of the spatial and non-spatial cross-covariance matrices, respectively.
与每个标记对应的参数名称的列表。有效的列表标签是beta,A,L,phi,nu。每个标签的价值部分是一个向量参数的初始值。对于A和L,向量长度(q^2-q)/2+q和phi和nu是长度q的。在这里,A和L形体的较低的三角的空间和非空间的互协方差矩阵的Cholesky平方根的顺序,分别列中主要元素。
参数:sp.tuning
a list with each tag corresponding to a parameter name. Valid list tags are A, L, phi, and nu. The value portion of each of each tag defines the step size of the proposal used in the Metropolis sampling. For A and L the vectors are of length (q^2-q)/2+q and phi and nu are of length q.
与每个标记对应的参数名称的列表。有效的列表标签是A,L,phi,nu。每个每个标签的值部分定义的提议中使用的Metropolis抽样的步长。对于A和L,向量长度(q^2-q)/2+q和phi和nu是长度q的。
参数:modified.pp
a logical value indicating if the modified predictive process should be used (see references below for details). Note, if a predictive process model is not used (i.e., knots is not specified) then this argument is ignored.
一逻辑值,如果修改后的预测过程中应使用(有关详细信息,请参阅下面的参考资料)。请注意,如果预测过程模型是不使用(即,knots没有指定),那么这个参数将被忽略。
参数:priors
a list with each tag corresponding to a parameter name. Valid list tags are K.IW, Psi.IW, phi.unif, and nu.unif (Beta priors are assumed flat). Variance parameters, K and Psi, are assumed to follow an inverse-Wishart distribution, whereas the spatial decay phi and smoothness nu parameters are assumed to follow Uniform distributions. The hyperparameters of the inverse-Wishart are passed as a list of length two, with the first and second elements corresponding to the df and qxq scale matrix, respectively. The hyperparameters of the Uniform are also passed as a vector of length 2xq with consecutive elements representing the first and second elements corresponding to the lower and upper support in the order of the univariate models given in formula.
与每个标记对应的参数名称的列表。有效的列表标签K.IW,Psi.IW,phi.unif和nu.unif(Beta先验假设持平)。方差参数,K和Psi,分别假设为逆Wishart分布,而在空间衰减phi和平滑nu参数的假设为均匀分布。逆威沙特的超长度2作为一个列表被传递,与df和qxq规模的矩阵对应的第一和第二元件,分别。作为一个向量的长度也被传递均匀的超2xq代表在formula给出的单变量模型的顺序中的下限和上限的支持对应的第一和第二元件的连续的元素。
参数:cov.model
a quoted key word that specifies the covariance function used to model the spatial dependence structure among the observations. Supported covariance model key words are: "exponential", "matern", "spherical", and "gaussian". See below for details.
一个带引号的关键字,指定的协方差函数用于模拟空间之间的依赖结构的观察。支持的协方差模型的关键词是:"exponential","matern","spherical"和"gaussian"。有关详细信息,请参见下文。
参数:n.samples
the number of MCMC iterations.
MCMC中的迭代数。
参数:sub.samples
a vector of length 3 that specifies start, end, and thin, respectively, of the MCMC samples. The default is c(1, n.samples, 1) (i.e., all samples).
一个向量的长度为3,指定起点,终点,又瘦,分别MCMC样本。默认值是c(1, n.samples, 1)(即,所有样品)。
参数:verbose
if TRUE, model specification and progress of the sampler is printed to the screen. Otherwise, nothing is printed to the screen.
如果TRUE,型号规格和进步的取样打印到屏幕上。否则,一切都被打印到屏幕上。
参数:n.report
the interval to report Metropolis acceptance and MCMC progress.
报告的时间间隔都会接受和MCMC进步。
参数:...
currently no additional arguments.
目前没有任何额外的参数。
值----------Value----------
An object of class spMvLM, which is a list with the following tags:
类的一个对象spMvLM,这是一个与下面的标签列表:
参数:coords
the n x 2 matrix specified by coords.
n x 2的矩阵指定coords。
参数:knot.coords
the m x 2 matrix as specified by knots.
m x 2矩阵指定的knots。
参数:p.samples
a coda object of posterior samples for the defined parameters.
一个coda对象定义的参数后样品。
参数:acceptance
the Metropolis sampling acceptance rate.
Metropolis抽样验收合格率。
参数:sp.effects
a matrix that holds samples from the posterior distribution of the spatial random effects. The rows of this matrix correspond to the n point observations and the columns are the posterior samples.
一个矩阵保存样本的空间随机效应的后验分布。这个矩阵的行对应的n点的观测和列后的样品。
The return object might include additional data used for subsequent prediction and/or model fit evaluation.
返回的对象可能包括额外的数据,用于以后的预测和/或模型拟合的评价。
(作者)----------Author(s)----------
Andrew O. Finley <a href="mailto:finleya@msu.edu">finleya@msu.edu</a>, <br>
Sudipto Banerjee <a href="mailto:baner009@umn.edu">baner009@umn.edu</a>
参考文献----------References----------
Hierarchical spatial modeling of additive and dominance genetic variance for large spatial trial datasets. Biometrics. DOI: 10.1111/j.1541-0420.2008.01115.x
large datasets. Computational Statistics and Data Analysis, DOI: 10.1016/j.csda.2008.09.008
参见----------See Also----------
spMvLM,spGGT
spMvLM,spGGT
实例----------Examples----------
## Not run: [#不运行:]
###################################[##################################]
##Multivariate spatial regression[#多元空间回归]
###################################[##################################]
##Generate some data[#生成一些数据。]
n <- 50 ##observed[#观察]
q <- 3
nltr <- q*(q-1)/2+q
coords <- cbind(runif(n),runif(n))
theta <- rep(3/0.5,q)
A <- matrix(0,q,q)
A[lower.tri(A,TRUE)] <- rnorm(nltr, 5, 1)
K <- A%*%t(A)
Psi <- diag(1,q)
c1 <- mvCovInvLogDet(coords=coords, knots=coords,
cov.model="exponential",
V=K, Psi=Psi, theta=theta,
modified.pp=FALSE, SWM=FALSE)
w <- mvrnorm(1,rep(0,nrow(c1$C)),c1$C)
w.1 <- w[seq(1,length(w),q)]
w.2 <- w[seq(2,length(w),q)]
w.3 <- w[seq(3,length(w),q)]
##Specify starting values and collect samples[#指定的初始值,采集样品]
K.starting <- diag(1,q)[lower.tri(diag(1,q), TRUE)]
Psi.starting <- diag(1,q)[lower.tri(diag(1,q), TRUE)]
n.samples <- 5000
m.1 <- spMvLM(list(w.1~1,w.2~1,w.3~1), coords=coords,
starting=list("beta"=rep(1,q), "phi"=rep(3/0.5,q),
"A"=K.starting, "L"=Psi.starting),
sp.tuning=list("phi"=rep(0.1,q),
"A"=rep(0.1,nltr), "L"=rep(0.1,nltr)),
priors=list("phi.Unif"=rep(c(3/1,3/0.1),q),
"K.IW"=list(q+1, diag(1,q)), "Psi.IW"=list(q+1, diag(1,q))),
modified.pp=TRUE, cov.model="exponential",
n.samples=n.samples, sub.samples=c(2500,n.samples,5),
verbose=TRUE, n.report=100)
m.1$p.samples[,paste("phi_",1:q,sep="")] <-
3/m.1$p.samples[,paste("phi_",1:q,sep="")]
print(summary(mcmc(m.1$p.samples)))
w.hat <- rowMeans(m.1$sp.effects)
w.hat.1 <- w.hat[seq(1,length(w.hat),q)]
w.hat.2 <- w.hat[seq(2,length(w.hat),q)]
w.hat.3 <- w.hat[seq(3,length(w.hat),q)]
##Take a look[#看一看]
par(mfrow=c(3,2))
surf <- mba.surf(cbind(coords,w.1),
no.X=100, no.Y=100, extend=T)$xyz.est
image(surf, main="Observed 1"); contour(surf, add=TRUE)
surf <- mba.surf(cbind(coords,w.hat.1),
no.X=100, no.Y=100, extend=T)$xyz.est
image(surf, main="Fitted 1"); contour(surf, add=TRUE)
points(m.1$knot.coords, pch=19, cex=1)
surf <- mba.surf(cbind(coords,w.2),
no.X=100, no.Y=100, extend=T)$xyz.est
image(surf, main="Observed 2"); contour(surf, add=TRUE)
surf <- mba.surf(cbind(coords,w.hat.2),
no.X=100, no.Y=100, extend=T)$xyz.est
image(surf, main="Fitted 2"); contour(surf, add=TRUE)
points(m.1$knot.coords, pch=19, cex=1)
surf <- mba.surf(cbind(coords,w.3),
no.X=100, no.Y=100, extend=T)$xyz.est
image(surf, main="Observed 3"); contour(surf, add=TRUE)
surf <- mba.surf(cbind(coords,w.hat.3),
no.X=100, no.Y=100, extend=T)$xyz.est
image(surf, main="Fitted 3"); contour(surf, add=TRUE)
points(m.1$knot.coords, pch=19, cex=1)
## End(Not run)[#(不执行)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|