找回密码
 注册
查看: 591|回复: 0

R语言 spBayes包 bayesGeostatExact()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-30 14:22:25 | 显示全部楼层 |阅读模式
bayesGeostatExact(spBayes)
bayesGeostatExact()所属R语言包:spBayes

                                        Simple Bayesian spatial linear model with fixed semivariogram parameters
                                         简单的贝叶斯空间有固定的半方差函数参数的线性模型

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Given a observation coordinates and fixed semivariogram parameters the bayesGeostatExact function fits a simple Bayesian spatial linear model.  
给定一个观察坐标和固定半方差函数参数bayesGeostatExact功能符合一个简单的贝叶斯空间的线性模型。


用法----------Usage----------


  bayesGeostatExact(formula, data = parent.frame(), n.samples,
                     beta.prior.mean, beta.prior.precision,
                     coords, cov.model="exponential", phi, nu, alpha,
                     sigma.sq.prior.shape, sigma.sq.prior.rate,
                     sp.effects=TRUE, verbose=TRUE, ...)



参数----------Arguments----------

参数:formula
for a univariate model, this is a symbolic description of the regression model to be fit. See example below.  
单变量模型中,这是一个象征性的回归模型是适合的描述。见下面的例子。


参数: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 spLM is called.   
一个可选的数据框包含在模型中的变量。如果没有找到,数据,变量environment(formula),通常是spLM被称为环境。


参数:n.samples
the number of posterior samples to collect.  
后的样品收集。


参数:beta.prior.mean
beta multivariate normal mean vector hyperprior.  
beta多元的正常均值向量hyperprior。


参数:beta.prior.precision
beta multivariate normal precision matrix hyperprior.  
beta多元的正常精密的矩阵hyperprior。


参数:coords
an n x 2 matrix of the observation coordinates in R^2 (e.g., easting and northing).  
n x 2R^2(例如,东向和北向)的观察坐标矩阵。


参数: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"。有关详细信息,请参见下文。


参数:phi
the fixed value of the spatial decay.  
的固定值的空间衰减。


参数:nu
if cov.model is "matern" then the fixed value of the spatial process smoothness must be specified.  
如果cov.model"matern"那么的空间过程平滑的固定值必须被指定。


参数:alpha
the fixed value of the ratio between the nugget tau.sq and partial-sill sigma.sq parameters from the specified cov.model.   
的固定值之间的比率的熔核tau.sq和部分窗台sigma.sq参数从指定的cov.model。


参数:sigma.sq.prior.shape
sigma.sq (i.e., partial-sill) inverse-Gamma shape hyperprior.  
sigma.sq(即,部分窗台)反伽马形状hyperprior。


参数:sigma.sq.prior.rate
sigma.sq (i.e., partial-sill) inverse-Gamma 1/scale hyperprior.  
sigma.sq(即,局部窗台)逆-的伽玛1/scale hyperprior。


参数:sp.effects
a logical value indicating if spatial random effects should be recovered.  
一个逻辑值,该值指示是否应收回空间随机效应。


参数:verbose
if TRUE, model specification and progress of the sampler is printed to the screen. Otherwise, nothing is printed to the screen.   
如果TRUE,型号规格和进步的取样打印到屏幕上。否则,一切都被打印到屏幕上。


参数:...
currently no additional arguments.   
目前没有任何额外的参数。


值----------Value----------

An object of class bayesGeostatExact, which is a list with the following tags:
类的一个对象bayesGeostatExact,这是一个与下面的标签列表:


参数:p.samples
a coda object of posterior samples for the defined parameters.  
一个coda对象定义的参数后样品。


参数: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点的观测和列后的样品。


参数:args
a list with the initial function arguments.   
函数的参数列表中的初始。


(作者)----------Author(s)----------



Sudipto Banerjee <a href="mailto:sudiptob@biostat.umn.edu">sudiptob@biostat.umn.edu</a>, <br>
Andrew O. Finley <a href="mailto:finleya@msu.edu">finleya@msu.edu</a>




实例----------Examples----------


## Not run: [#不运行:]

data(FBC07.dat)
Y <- FBC07.dat[1:150,"Y.2"]
coords <- as.matrix(FBC07.dat[1:150,c("coord.X", "coord.Y")])

n.samples <- 500
n = length(Y)
p = 1

phi <- 0.15
nu <- 0.5

beta.prior.mean <- as.matrix(rep(0, times=p))
beta.prior.precision <- matrix(0, nrow=p, ncol=p)

alpha <- 5/5

sigma.sq.prior.shape <- 2.0
sigma.sq.prior.rate <- 5.0

##############################[#############################]
##Simple linear model with[#简单的线性模型]
##the default exponential[#默认的指数]
##spatial decay function[#空间衰减功能]
##############################[#############################]
set.seed(1)
m.1 <- bayesGeostatExact(Y~1, n.samples=n.samples,
                          beta.prior.mean=beta.prior.mean,
                          beta.prior.precision=beta.prior.precision,
                          coords=coords, phi=phi, alpha=alpha,
                          sigma.sq.prior.shape=sigma.sq.prior.shape,
                          sigma.sq.prior.rate=sigma.sq.prior.rate)



print(summary(m.1$p.samples))

##Requires MBA package to[#需要MBA包]
##make surfaces[#使表面]
library(MBA)
par(mfrow=c(1,2))
obs.surf <-
  mba.surf(cbind(coords, Y), no.X=100, no.Y=100, extend=T)$xyz.est
image(obs.surf, xaxs = "r", yaxs = "r", main="Observed response")
points(coords)
contour(obs.surf, add=T)

w.hat <- rowMeans(m.1$sp.effects)
w.surf <-
  mba.surf(cbind(coords, w.hat), no.X=100, no.Y=100, extend=T)$xyz.est
image(w.surf, xaxs = "r", yaxs = "r", main="Estimated random effects")
points(coords)
contour(w.surf, add=T)


##############################[#############################]
##Simple linear model with[#简单的线性模型]
##the matern spatial decay[#matern的空间衰减]
##function. Note, nu=0.5 so[#函数。注意,ν= 0.5,]
##should produce the same[#应产生同样的]
##estimates as m.1[#估计M.1]
##############################[#############################]
set.seed(1)
m.2 <- bayesGeostatExact(Y~1, n.samples=n.samples,
                          beta.prior.mean=beta.prior.mean,
                          beta.prior.precision=beta.prior.precision,
                          coords=coords, cov.model="matern",
                          phi=phi, nu=nu, alpha=alpha,
                          sigma.sq.prior.shape=sigma.sq.prior.shape,
                          sigma.sq.prior.rate=sigma.sq.prior.rate)

print(summary(m.2$p.samples))

##############################[#############################]
##This time with the[#这一次的]
##spherical just for fun[#球形只是为了好玩]
##############################[#############################]
m.3 <- bayesGeostatExact(Y~1, n.samples=n.samples,
                          beta.prior.mean=beta.prior.mean,
                          beta.prior.precision=beta.prior.precision,
                          coords=coords, cov.model="spherical",
                          phi=phi, alpha=alpha,
                          sigma.sq.prior.shape=sigma.sq.prior.shape,
                          sigma.sq.prior.rate=sigma.sq.prior.rate)

print(summary(m.3$p.samples))

##############################[#############################]
##Another example but this[#另一个例子,但此]
##time with covariates[#时间与协变量]
##############################[#############################]
data(FORMGMT.dat)

n = nrow(FORMGMT.dat)
p = 5 ##an intercept an four covariates[#拦截协变量]

n.samples <- 50

phi <- 0.0012

coords <- cbind(FORMGMT.dat$Longi, FORMGMT.dat$Lat)
coords <- coords*(pi/180)*6378

beta.prior.mean <- rep(0, times=p)
beta.prior.precision <- matrix(0, nrow=p, ncol=p)

alpha <- 1/1.5

sigma.sq.prior.shape <- 2.0
sigma.sq.prior.rate <- 10.0

m.4 <-
  bayesGeostatExact(Y~X1+X2+X3+X4, data=FORMGMT.dat, n.samples=n.samples,
                     beta.prior.mean=beta.prior.mean,
                     beta.prior.precision=beta.prior.precision,
                     coords=coords, phi=phi, alpha=alpha,
                     sigma.sq.prior.shape=sigma.sq.prior.shape,
                     sigma.sq.prior.rate=sigma.sq.prior.rate)

print(summary(m.4$p.samples))



##Requires MBA package to[#需要MBA包]
##make surfaces[#使表面]
library(MBA)
par(mfrow=c(1,2))
obs.surf <-
  mba.surf(cbind(coords, resid(lm(Y~X1+X2+X3+X4, data=FORMGMT.dat))),
                 no.X=100, no.Y=100, extend=TRUE)$xyz.est
image(obs.surf, xaxs = "r", yaxs = "r", main="Observed response")
points(coords)
contour(obs.surf, add=T)

w.hat <- rowMeans(m.4$sp.effects)
w.surf <-
  mba.surf(cbind(coords, w.hat), no.X=100, no.Y=100, extend=TRUE)$xyz.est
image(w.surf, xaxs = "r", yaxs = "r", main="Estimated random effects")
contour(w.surf, add=T)
points(coords, pch=1, cex=1)

###########################################[##########################################]
##Now with synthetic data[#现在用合成数据]
###########################################[##########################################]
data(rf.n1000.dat)

Y <- rf.n1000.dat$Y
coords <- as.matrix(rf.n1000.dat[,c("x.coords","y.coords")])
w <- rf.n1000.dat$w
p <- 1
alpha <- 1/10
phi <- 3/6

beta.prior.mean <- rep(0, times=p)
beta.prior.precision <- matrix(0, nrow=p, ncol=p)

sigma.sq.prior.shape <- 2.0
sigma.sq.prior.rate <- 1/10.0

n.samples <- 50

m.5 <-
  bayesGeostatExact(Y~1, n.samples=n.samples,
                     beta.prior.mean=beta.prior.mean,
                     beta.prior.precision=beta.prior.precision,
                     coords=coords, phi=phi, alpha=alpha,
                     sigma.sq.prior.shape=sigma.sq.prior.shape,
                     sigma.sq.prior.rate=sigma.sq.prior.rate)

print(summary(m.5$p.samples))


##Requires MBA package to[#需要MBA包]
##make surfaces[#使表面]
library(MBA)
par(mfrow=c(1,2))
obs.surf <-
  mba.surf(cbind(coords, w),
                 no.X=100, no.Y=100, extend=TRUE)$xyz.est
image(obs.surf, xaxs = "r", yaxs = "r", main="Observed response")
points(coords)
contour(obs.surf, add=T)

w.hat <- rowMeans(m.5$sp.effects)
w.surf <-
  mba.surf(cbind(coords, w.hat), no.X=100, no.Y=100, extend=TRUE)$xyz.est
image(w.surf, xaxs = "r", yaxs = "r", main="Estimated random effects")
contour(w.surf, add=T)
points(coords, pch=1, cex=1)



## End(Not run)[#(不执行)]

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-6-17 03:08 , Processed in 0.026934 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表