rmh.default(spatstat)
rmh.default()所属R语言包:spatstat
Simulate Point Process Models using the Metropolis-Hastings Algorithm.
模拟点过程模型使用的Metropolis-Hastings算法。
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Generates a random point pattern, simulated from a chosen point process model, using the Metropolis-Hastings algorithm.
生成一个随机点模式,从选择的点过程模型模拟,使用的Metropolis-Hastings算法。
用法----------Usage----------
## Default S3 method:
rmh(model, start=NULL,
control=default.rmhcontrol(model),
verbose=TRUE, track=FALSE, ...)
参数----------Arguments----------
参数:model
Data specifying the point process model that is to be simulated.
指定的点过程模型,是要模拟的数据。
参数:start
Data determining the initial state of the algorithm.
数据确定的算法的初始状态。
参数:control
Data controlling the iterative behaviour and termination of the algorithm.
数据控制迭代算法的行为和终止。
参数:verbose
Logical flag indicating whether to print progress reports.
逻辑标志,指示是否打印进度报告。
参数:track
Logical flag indicating whether to save the transition history of the simulations.
逻辑标志,指示是否要保存历史的模拟过渡。
参数:...
Further arguments passed to rmhcontrol or to trend functions in model.
更多参数传递给rmhcontrol或趋势功能model。
Details
详细信息----------Details----------
This function generates simulated realisations from any of a range of spatial point processes, using the Metropolis-Hastings algorithm. It is the default method for the generic function rmh.
这个函数生成的空间点过程中的任何一个范围,使用的Metropolis-Hastings算法的模拟实现。它是默认的方法的通用函数rmh。
This function executes a Metropolis-Hastings algorithm with birth, death and shift proposals as described in Geyer and Moller (1994).
这个函数执行一个大都市Hastings算法赫耶尔和穆勒(1994年)中所描述的出生,死亡和转变的建议。
The argument model specifies the point process model to be simulated. It is either a list, or an object of class "rmhmodel", with the following components:
参数model指定的点过程模型进行模拟。它要么是一个列表,或一个对象类"rmhmodel",具有下列组件:
cif A character string specifying the choice of interpoint interaction for the point process.
到岸价一个字符串指定的点INTERPOINT互动过程的选择。
Parameter values for the conditional intensity function.
的条件强度函数的参数值。
(Optional) window in which the pattern is to be generated. An object of class "owin", or data acceptable to as.owin.
(可选)窗口,在该窗口中的图案以产生。类"owin",或数据对象的接受的as.owin。
Data specifying the spatial trend in the model, if it has a trend. This may be a function, a pixel image (of class "im"), (or a list of functions or images if the model is multitype).
数据模型中指定的空间趋势,如果它有一个趋势。这可能是一个函数,一个像素的图像(类"im"),(或列表的功能或图像,如果模型是多类型)。
If the trend is a function or functions, any auxiliary arguments ... to rmh.default will be passed to these functions, which should be of the form function(x, y, ...).
如果这种趋势的一个或多个函数,任何辅助参数...到rmh.default将通过这些函数,这应该是对的形式function(x, y, ...)。
List of possible types, for a multitype point process.
可能的类型,一个多类型的列表。
For full details of these parameters, see rmhmodel.
对于这些参数的完整详细信息,请参阅rmhmodel。
The argument start determines the initial state of the Metropolis-Hastings algorithm. It is either NULL, or an object of class "rmhstart", or a list with the following components:
参数start确定的Metropolis-Hastings算法的初始状态。它要么是NULL,或对象类"rmhstart",或与下列组件的列表:
Number of points in the initial point pattern. A single integer, or a vector of integers giving the numbers of points of each type in a multitype point pattern. Incompatible with x.start.
初始点图案中的点的数量。一个整数,或提供的数字点多类型点图案中的每个类型的整数向量。不相容的x.start。
Initial point pattern configuration. Incompatible with n.start.
初始点模式配置。不相容的n.start。
x.start may be a point pattern (an object of class "ppp"), or data which can be coerced to this class by as.ppp, or an object with components x and y, or a two-column matrix. In the last two cases, the window for the pattern is determined by model$w. In the first two cases, if model$w is also present, then the final simulated pattern will be clipped to the window model$w.
x.start可能是一个点模式(一个对象的类"ppp"),或数据可以强制转换为这个类as.ppp或对象的组件x和 y,或一个两列的矩阵。在过去的两年中,窗口的模式是由model$w。在前两种情况下,如果model$w也存在,那么最后的模拟模式将被裁剪窗口model$w。
For full details of these parameters, see rmhstart.
对于这些参数的完整详细信息,请参阅rmhstart。
The third argument control controls the simulation procedure (including conditional simulation), iterative behaviour, and termination of the Metropolis-Hastings algorithm. It is either NULL, or a list, or an object of class "rmhcontrol", with components:
第三个参数control控制,对Metropolis-Hastings算法的仿真程序(包括有条件的模拟),迭代的行为,并终止。它是NULL,或一个列表,或对象类"rmhcontrol",组件:
p The probability of proposing a “shift” (as opposed to a birth or death) in the Metropolis-Hastings algorithm.
P提出的“转变”(而不是出生或死亡)的Metropolis-Hastings算法的概率。
q The conditional probability of proposing a death (rather than a birth) given that birth/death has been chosen over shift.
Q的条件概率,提出一个死亡(而不是出生)出生/死亡已经选择了移位。
nrep The number of repetitions or iterations to be made by the Metropolis-Hastings algorithm. It should be large.
NREP的Metropolis-Hastings算法的重复或迭代的数量。它应该是大的。
Either a numerical expansion factor, or a window (object of class "owin"). Indicates that the process is to be simulated on a larger domain than the original data window w, then clipped to w when the algorithm has finished.
无论是数字的膨胀系数,或一个窗口(类的对象"owin"“)。表示该进程是一个更大的领域比原来的数据窗口上进行模拟w,然后夹到w时,该算法已完成。
The default is to expand the simulation window if the model is stationary and non-Poisson (i.e. it has no trend and the interaction is not Poisson) and not to expand in all other cases.
默认值是扩大模拟窗口,如果该模型是静止的,非泊松(即它没有趋势的相互作用是不泊松),而不是在所有其他情况下,扩大。
If the model has a trend, then in order for expansion to be feasible, the trend must be given either as a function, or an image whose bounding box is large enough to contain the expanded window.
如果模型有一个趋势,那么为了扩展是可行的,这种趋势必须提供的函数,或图像的边框是足够大,以包含扩展窗口。
periodic A logical scalar; if periodic is TRUE we simulate a process on the torus formed by identifying opposite edges of a rectangular window.
定期的逻辑标量;如果periodic是TRUE我们模拟了相反的矩形窗口的边缘形成的圆环。
ptypes A vector of probabilities (summing to 1) to be used in assigning a random type to a new point.
ptypes中要使用随机类型分配到一个新点的概率(求和1)的向量。
fixall A logical scalar specifying whether to condition on the number of points of each type.
fixall的逻辑标量,对每种类型的数目的点指定是否条件。
nverb An integer specifying how often “progress reports” (which consist simply of the number of repetitions completed) should be printed out. If nverb is left at 0, the default, the simulation proceeds silently.
nverb一个整数,指定多久“进展报告”(包括简单的重复完成的数量)被打印出来。 ,如果nverb离开为0,默认情况下,模拟进行提示。
x.cond If this argument is present, then conditional simulation will be performed, and x.cond specifies the conditioning points and the type of conditioning.
x.cond如果这种说法是存在的,条件模拟,和x.cond指定调节点和类型的调节。
For full details of these parameters, see rmhcontrol. The control parameters can also be given in the ... arguments.
对于这些参数的完整详细信息,请参阅rmhcontrol。控制参数也可以给予在...参数。
值----------Value----------
A point pattern (an object of class "ppp", see ppp.object).
点模式(类的一个对象"ppp",看到ppp.object)。
The returned value has an attribute info containing modified versions of the arguments model, start, and control which together specify the exact simulation procedure. The info attribute can be printed (and is printed automatically by summary.ppp).
返回的值有一个属性info含修改后的版本的参数model,start,control共同指定精确的模拟程序。 info属性可以打印(自动打印summary.ppp)。
The value of .Random.seed at the start of the simulations is also saved and returned as an attribute seed.
的值.Random.seed在开始的模拟也被保存,并返回作为一个属性seed。
If track=TRUE, the transition history of the algorithm is saved, and returned as an attribute history. The transition history is a data frame containing a factor proposaltype identifying the proposal type (Birth, Death or Shift) and a logical vector accepted indicating whether the proposal was accepted.
track=TRUE如果的算法,过渡的历史被保存,和返回的属性history。过渡的历史是一个数据框包含的一个因素proposaltype标识的建议(出生,死亡或Shift)和逻辑向量accepted的建议是否被接受。
条件模拟----------Conditional Simulation----------
There are several kinds of conditional simulation.
有几个种条件模拟。
Simulation conditional upon the number of points, that is, holding the number of points fixed. To do this, set control$p (the probability of a shift) equal to 1. The number of points is then determined by the starting state, which may be specified either by setting start$n.start to be a scalar, or by setting the initial pattern start$x.start.
仿真条件的点的数量,即,保持固定点的数目。要做到这一点,设置control$p(转变)的概率为1。的点的数量,然后确定由起始状态,这可能被指定,也可以通过设置start$n.start是一个标量,或通过设置的初始图案start$x.start。
In the case of multitype processes, it is possible to simulate the model conditionally upon the number of points of each type, i.e. holding the number of points of each type to be fixed. To do this, set control$p equal to 1 and control$fixall to be TRUE. The number of points is then determined by the starting state, which may be specified either by setting start$n.start to be an integer vector, or by setting the initial pattern start$x.start.
在的情况下,多类型的过程中,它是可能的模拟模型,有条件的每种类型,即持有以被固定的各类型的点的数量的点的数目时。要做到这一点,设置control$p等于1和control$fixall是TRUE。的点的数量,然后确定由起始状态,这可能被指定,也可以通过设置start$n.start是一个整数向量,或通过设置的初始图案start$x.start。
Simulation conditional on the configuration observed in a sub-window, that is, requiring that, inside a specified sub-window V, the simulated pattern should agree with a specified point pattern y.To do this, set control$x.cond to equal the specified point pattern y, making sure that it is an object of class "ppp" and that the window as.owin(control$x.cond) is the conditioning window V.
模拟条件中的一个子窗口,观察到的配置,需要的是,在一个指定的子窗口V,模拟模式应同意与一个指定的点模式y。要做到这一点,设置control$x.cond等于指定的点模式y,确保"ppp"是调节窗口,它是一个对象类as.owin(control$x.cond)和窗口V 。
Simulation conditional on the presence of specified points, that is, requiring that the simulated pattern should include a specified set of points. This is simulation from the Palm distribution of the point process given a pattern y. To do this, set control$x.cond to be a data.frame containing the coordinates (and marks, if appropriate) of the specified points.
仿真条件的指定点的存在下,即,需要的模拟图案应包括指定的一组点。这是从Palm分布的模式y点过程的模拟。要做到这一点,control$x.cond是一个data.frame包含指定的点的坐标(和标志,如果适当的话)。
For further information, see rmhcontrol.
欲了解更多信息,请参阅rmhcontrol。
Note that, when we simulate conditionally on the number of points, or conditionally on the number of points of each type, no expansion of the window is possible.
需要注意的是,当我们模拟有条件的点的数量,或有条件地对每种类型的点的数目,没有扩展的窗口是可能的。
警告----------Warnings----------
There is never a guarantee that the Metropolis-Hastings algorithm has converged to its limiting distribution.
从未有一个保证的Metropolis-Hastings算法收敛到它的极限分布。
If start$x.start is specified then expand is set equal to 1 and simulation takes place in x.start$window. Any specified value for expand is simply ignored.
如果start$x.start指定expand设置为1,模拟发生在x.start$window。任何指定的值expand将被忽略。
The presence of both a component w of model and a non-null value for x.start$window makes sense ONLY if w is contained in x.start$window.
的存在都一个组成部分w的model和非空值x.start$window是有道理的,只有w包含在x.start$window,。
For multitype processes make sure that, even if there is to be no trend corresponding to a particular type, there is still a component (a NULL component) for that type, in the list.
对于多类型确保的是,即使是不对应于特定类型的趋势,但仍有该类型的一个组件(一个NULL成分),在列表中的进程。
其他型号----------Other models----------
In theory, any finite point process model can be simulated using the Metropolis-Hastings algorithm, provided the conditional intensity is uniformly bounded.
从理论上讲,任何有限的点过程模型,可以模拟使用的Metropolis-Hastings算法,强度是一致有界提供了条件。
In practice, the list of point process models that can be simulated using rmh.default is limited to those that have been implemented in the package's internal C code. More options will be added in the future.
在实践中,列表中的点过程模型,可以模拟使用rmh.default仅限于那些已经在包的内部C代码实现。在未来将加入更多选项。
Note that the lookup conditional intensity function permits the simulation (in theory, to any desired degree of approximation) of any pairwise interaction process for which the interaction depends only on the distance between the pair of points.
请注意,lookup条件强度函数允许模拟(在理论上,任何所需的近似程度)的任何成对的相互作用仅依赖于对点之间的距离的相互作用过程。
可重复性模拟----------Reproducible simulations----------
If the user wants the simulation to be exactly reproducible (e.g. for a figure in a journal article, where it is useful to have the figure consistent from draft to draft) then the state of the random number generator should be set before calling rmh.default. This can be done either by calling set.seed or by assigning a value to .Random.seed. In the examples below, we use set.seed.
如果用户想模拟是完全重复的(例如在杂志上的文章,它是非常有用的数字一致草案征求意见稿)的数字,然后随机数发生器的状态应设置前调用<X >。这是可以做到无论是通过调用rmh.default或指定的值set.seed。在下面的例子中,我们使用的.Random.seed。
If a simulation has been performed and the user now wants to repeat it exactly, the random seed should be extracted from the simulated point pattern X by seed <- attr(x, "seed"), then assigned to the system random nunber state by .Random.seed <- seed before calling rmh.default.
已经履行的,如果模拟的用户现在要准确地重复,随机种子中提取的模拟点模式Xseed <- attr(x, "seed"),然后将其分配到系统随机nunber的状态 X>前调用.Random.seed <- seed。
(作者)----------Author(s)----------
Adrian Baddeley
<a href="mailto:Adrian.Baddeley@csiro.au">Adrian.Baddeley@csiro.au</a>
<a href="http://www.maths.uwa.edu.au/~adrian/">http://www.maths.uwa.edu.au/~adrian/</a>
and Rolf Turner
<a href="mailto:r.turner@auckland.ac.nz">r.turner@auckland.ac.nz</a>
参考文献----------References----------
pseudolikelihood for spatial point patterns. Australian and New Zealand Journal of Statistics 42, 283 – 322.
Patterns (2nd ed.) Arnold, London.
Monte Carlo methods of inference for implicit statistical models. Journal of the Royal Statistical Society, series B 46, 193 – 212.
A nonparametric estimator for pairwise-interaction point processes. Biometrika 74, 763 – 770.
Simulation procedures and likelihood inference for spatial point processes. Scandinavian Journal of Statistics 21, 359–373.
Likelihood Inference for Spatial Point Processes. Chapter 3 in O.E. Barndorff-Nielsen, W.S. Kendall and M.N.M. Van Lieshout (eds) Stochastic Geometry: Likelihood and Computation, Chapman and Hall / CRC, Monographs on Statistics and Applied Probability, number 80. Pages 79–140.
参见----------See Also----------
rmh, rmh.ppm, rStrauss, ppp, ppm, AreaInter, BadGey, DiggleGatesStibbard, DiggleGratton, Fiksel, Geyer, Hardcore, LennardJones, MultiHard, MultiStrauss, MultiStraussHard, PairPiece, Poisson, Softcore, Strauss, StraussHard, Triplets
rmh,rmh.ppm,rStrauss,ppp,ppm,AreaInter,BadGey,DiggleGatesStibbard,DiggleGratton,Fiksel,Geyer,Hardcore,LennardJones,MultiHard,MultiStrauss,MultiStraussHard,PairPiece ,Poisson,Softcore,Strauss,StraussHard,Triplets
实例----------Examples----------
## Not run: [#不运行:]
nr <- 1e5
nv <- 5000
ns <- 200
## End(Not run)[#(不执行)]
set.seed(961018)
# Strauss process.[施特劳斯的过程。]
mod01 <- list(cif="strauss",par=list(beta=2,gamma=0.2,r=0.7),
w=c(0,10,0,10))
X1.strauss <- rmh(model=mod01,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Strauss process, conditioning on n = 42:[施特劳斯在n = 42的过程中,调理:]
X2.strauss <- rmh(model=mod01,start=list(n.start=42),
control=list(p=1,nrep=nr,nverb=nv))
# Hard core process:[硬核的过程:]
mod02 <- list(cif="hardcore",par=list(beta=2,hc=0.7),w=c(0,10,0,10))
X3.hardcore <- rmh(model=mod02,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Strauss process equal to pure hardcore:[施特劳斯等于纯硬派的过程:]
mod02s <- list(cif="strauss",par=list(beta=2,gamma=0,r=0.7),w=c(0,10,0,10))
X3.strauss <- rmh(model=mod02s,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Strauss process in a polygonal window.[施特劳斯过程在一个多边形窗。]
x <- c(0.55,0.68,0.75,0.58,0.39,0.37,0.19,0.26,0.42)
y <- c(0.20,0.27,0.68,0.99,0.80,0.61,0.45,0.28,0.33)
mod03 <- list(cif="strauss",par=list(beta=2000,gamma=0.6,r=0.07),
w=owin(poly=list(x=x,y=y)))
X4.strauss <- rmh(model=mod03,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Strauss process in a polygonal window, conditioning on n = 80.[施特劳斯的多边形窗口,空调N = 80。]
X5.strauss <- rmh(model=mod03,start=list(n.start=ns),
control=list(p=1,nrep=nr,nverb=nv))
# Strauss process, starting off from X4.strauss, but with the[施特劳斯过程中,出发从X4.strauss,但随着]
# polygonal window replace by a rectangular one. At the end,[多边形窗口更换一个矩形。在末端,]
# the generated pattern is clipped to the original polygonal window.[产生的模式被裁剪到原来的多边形窗口。]
xxx <- X4.strauss
xxx$window <- as.owin(c(0,1,0,1))
X6.strauss <- rmh(model=mod03,start=list(x.start=xxx),
control=list(nrep=nr,nverb=nv))
# Strauss with hardcore:[斯特劳斯的铁杆:]
mod04 <- list(cif="straush",par=list(beta=2,gamma=0.2,r=0.7,hc=0.3),
w=c(0,10,0,10))
X1.straush <- rmh(model=mod04,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Another Strauss with hardcore (with a perhaps surprising result):[另一个斯特劳斯的铁杆也许令人惊讶的结果:]
mod05 <- list(cif="straush",par=list(beta=80,gamma=0.36,r=45,hc=2.5),
w=c(0,250,0,250))
X2.straush <- rmh(model=mod05,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Pure hardcore (identical to X3.strauss).[纯硬派(相同X3.strauss)。]
mod06 <- list(cif="straush",par=list(beta=2,gamma=1,r=1,hc=0.7),
w=c(0,10,0,10))
X3.straush <- rmh(model=mod06,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Soft core:[软核:]
w <- c(0,10,0,10)
mod07 <- list(cif="sftcr",par=list(beta=0.8,sigma=0.1,kappa=0.5),
w=c(0,10,0,10))
X.sftcr <- rmh(model=mod07,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Area-interaction process:[区域互动的过程:]
mod42 <- rmhmodel(cif="areaint",par=list(beta=2,eta=1.6,r=0.7),
w=c(0,10,0,10))
X.area <- rmh(model=mod42,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Triplets process[三胞胎过程]
modtrip <- list(cif="triplets",par=list(beta=2,gamma=0.2,r=0.7),
w=c(0,10,0,10))
X.triplets <- rmh(model=modtrip,
start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Multitype Strauss:[多类型施特劳斯:]
beta <- c(0.027,0.008)
gmma <- matrix(c(0.43,0.98,0.98,0.36),2,2)
r <- matrix(c(45,45,45,45),2,2)
mod08 <- list(cif="straussm",par=list(beta=beta,gamma=gmma,radii=r),
w=c(0,250,0,250))
X1.straussm <- rmh(model=mod08,start=list(n.start=ns),
control=list(ptypes=c(0.75,0.25),nrep=nr,nverb=nv))
# Multitype Strauss conditioning upon the total number[多类型施特劳斯空调的总数量]
# of points being 80:[点为80:]
X2.straussm <- rmh(model=mod08,start=list(n.start=ns),
control=list(p=1,ptypes=c(0.75,0.25),nrep=nr,
nverb=nv))
# Conditioning upon the number of points of type 1 being 60[空调时的类型1的点的数目是60]
# and the number of points of type 2 being 20:[和2型为20点的数目:]
X3.straussm <- rmh(model=mod08,start=list(n.start=c(60,20)),
control=list(fixall=TRUE,p=1,ptypes=c(0.75,0.25),
nrep=nr,nverb=nv))
# Multitype Strauss hardcore:[多类型施特劳斯铁杆:]
rhc <- matrix(c(9.1,5.0,5.0,2.5),2,2)
mod09 <- list(cif="straushm",par=list(beta=beta,gamma=gmma,
iradii=r,hradii=rhc),w=c(0,250,0,250))
X.straushm <- rmh(model=mod09,start=list(n.start=ns),
control=list(ptypes=c(0.75,0.25),nrep=nr,nverb=nv))
# Multitype Strauss hardcore with trends for each type:[多类型,每一种类型的趋势施特劳斯铁杆:]
beta <- c(0.27,0.08)
tr3 <- function(x,y){x <- x/250; y <- y/250;
exp((6*x + 5*y - 18*x^2 + 12*x*y - 9*y^2)/6)
}
# log quadratic trend[登录二次趋势]
tr4 <- function(x,y){x <- x/250; y <- y/250;
exp(-0.6*x+0.5*y)}
# log linear trend[对数线性趋势]
mod10 <- list(cif="straushm",par=list(beta=beta,gamma=gmma,
iradii=r,hradii=rhc),w=c(0,250,0,250),
trend=list(tr3,tr4))
X1.straushm.trend <- rmh(model=mod10,start=list(n.start=ns),
control=list(ptypes=c(0.75,0.25),
nrep=nr,nverb=nv))
# Multitype Strauss hardcore with trends for each type, given as images:[多类型,每一种类型的趋势施特劳斯铁杆,为图像:]
bigwin <- square(250)
i1 <- as.im(tr3, bigwin)
i2 <- as.im(tr4, bigwin)
mod11 <- list(cif="straushm",par=list(beta=beta,gamma=gmma,
iradii=r,hradii=rhc),w=bigwin,
trend=list(i1,i2))
X2.straushm.trend <- rmh(model=mod11,start=list(n.start=ns),
control=list(ptypes=c(0.75,0.25),expand=1,
nrep=nr,nverb=nv))
# Diggle, Gates, and Stibbard:[Diggle,盖茨和Stibbard的的:]
mod12 <- list(cif="dgs",par=list(beta=3600,rho=0.08),w=c(0,1,0,1))
X.dgs <- rmh(model=mod12,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Diggle-Gratton:[Diggle格拉顿:]
mod13 <- list(cif="diggra",
par=list(beta=1800,kappa=3,delta=0.02,rho=0.04),
w=square(1))
X.diggra <- rmh(model=mod13,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Fiksel:[Fiksel:]
modFik <- list(cif="fiksel",
par=list(beta=180,r=0.15,hc=0.07,kappa=2,a= -1.0),
w=square(1))
X.diggra <- rmh(model=modFik,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Geyer:[盖尔:]
mod14 <- list(cif="geyer",par=list(beta=1.25,gamma=1.6,r=0.2,sat=4.5),
w=c(0,10,0,10))
X1.geyer <- rmh(model=mod14,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Geyer; same as a Strauss process with parameters[盖尔一样施特劳斯过程参数]
# (beta=2.25,gamma=0.16,r=0.7):[(β= 2.25,γ= 0.16,R = 0.7):]
mod15 <- list(cif="geyer",par=list(beta=2.25,gamma=0.4,r=0.7,sat=10000),
w=c(0,10,0,10))
X2.geyer <- rmh(model=mod15,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
mod16 <- list(cif="geyer",par=list(beta=8.1,gamma=2.2,r=0.08,sat=3))
data(redwood)
X3.geyer <- rmh(model=mod16,start=list(x.start=redwood),
control=list(periodic=TRUE,nrep=nr,nverb=nv))
# Geyer, starting from the redwood data set, simulating[赫耶尔开始从红杉数据集,模拟]
# on a torus, and conditioning on n:[一个圆环,和空调的n:]
X4.geyer <- rmh(model=mod16,start=list(x.start=redwood),
control=list(p=1,periodic=TRUE,nrep=nr,nverb=nv))
# Lookup (interaction function h_2 from page 76, Diggle (2003)):[查找(第76页,Diggle(2003年)的交互功能H_2):]
r <- seq(from=0,to=0.2,length=101)[-1] # Drop 0.[删除0。]
h <- 20*(r-0.05)
h[r<0.05] <- 0
h[r>0.10] <- 1
mod17 <- list(cif="lookup",par=list(beta=4000,h=h,r=r),w=c(0,1,0,1))
X.lookup <- rmh(model=mod17,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Strauss with trend[施特劳斯与趋势]
tr <- function(x,y){x <- x/250; y <- y/250;
exp((6*x + 5*y - 18*x^2 + 12*x*y - 9*y^2)/6)
}
beta <- 0.3
gmma <- 0.5
r <- 45
mod17 <- list(cif="strauss",par=list(beta=beta,gamma=gmma,r=r),
w=square(1), trend=tr3)
X1.strauss.trend <- rmh(model=mod17,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Baddeley-Geyer[巴德利 - 赫耶尔]
r <- seq(0,0.2,length=8)[-1]
gmma <- c(0.5,0.6,0.7,0.8,0.7,0.6,0.5)
mod18 <- list(cif="badgey",par=list(beta=4000, gamma=gmma,r=r,sat=5),
w=square(1))
X1.badgey <- rmh(model=mod18,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
mod19 <- list(cif="badgey",
par=list(beta=4000, gamma=gmma,r=r,sat=1e4),
w=square(1))
set.seed(1329)
X2.badgey <- rmh(model=mod18,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Check:[检查:]
h <- ((prod(gmma)/cumprod(c(1,gmma)))[-8])^2
hs <- stepfun(r,c(h,1))
mod20 <- list(cif="lookup",par=list(beta=4000,h=hs),w=square(1))
set.seed(1329)
X.check <- rmh(model=mod20,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# X2.badgey and X.check will be identical.[x2.badgey和X.check将是相同的。]
mod21 <- list(cif="badgey",par=list(beta=300,gamma=c(1,0.4,1),
r=c(0.035,0.07,0.14),sat=5), w=square(1))
X3.badgey <- rmh(model=mod21,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Same result as Geyer model with beta=300, gamma=0.4, r=0.07,[相同的结果盖尔模型β= 300,γ= 0.4,R = 0.07,]
# sat = 5 (if seeds and control parameters are the same)[坐在= 5(如果种子和控制参数是相同的)]
# Or more simply:[或者更简单地说:]
mod22 <- list(cif="badgey",
par=list(beta=300,gamma=0.4,r=0.07, sat=5),
w=square(1))
X4.badgey <- rmh(model=mod22,start=list(n.start=ns),
control=list(nrep=nr,nverb=nv))
# Same again --- i.e. the BadGey model includes the Geyer model.[一样了---即BadGey模型包括盖尔模型。]
# Illustrating scalability.[说明可扩展性。]
## Not run: [#不运行:]
M1 <- rmhmodel(cif="strauss",par=list(beta=60,gamma=0.5,r=0.04),w=owin())
set.seed(496)
X1 <- rmh(model=M1,start=list(n.start=300))
M2 <- rmhmodel(cif="strauss",par=list(beta=0.6,gamma=0.5,r=0.4),
w=owin(c(0,10),c(0,10)))
set.seed(496)
X2 <- rmh(model=M2,start=list(n.start=300))
chk <- affine(X1,mat=diag(c(10,10)))
all.equal(chk,X2,check.attribute=FALSE)
# Under the default spatstat options the foregoing all.equal()[在的默认spatstat选项上述all.equal()]
# will yield TRUE. Setting spatstat.options(scalable=FALSE) and[将产生TRUE。设置spatstat.options(可扩展= FALSE)]
# re-running the code will reveal differences between X1 and X2.[重新运行代码,就会发现X1和X2之间的差异。]
## End(Not run)[#(不执行)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|