spautolm(spdep)
spautolm()所属R语言包:spdep
Spatial conditional and simultaneous autoregression model estimation
空间条件,且同时自回归模型估计
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Function taking family and weights arguments for spatial autoregression model estimation by Maximum Likelihood, using full matrix methods, not suited to large data sets with thousands of observations. With one of the sparse matrix methods, larger numbers of observations can be handled, but the interval= argument should be set. The implementation is GLS using the single spatial coefficient value, here termed lambda, found by line search using optimize to maximise the log likelihood.
观测成千上万的家庭和重量参数函数空间自回归模型估计的最大似然法(Maximum Likelihood),使用全矩阵方法,不适合大数据集。稀疏矩阵的方法之一,可以处理大量的观察,但interval=参数应设置。实施GLS使用单一的空间系数的值,这里被称为拉姆达,网上搜索发现使用optimize最大化对数似然。
用法----------Usage----------
spautolm(formula, data = list(), listw, weights,
na.action, family = "SAR", method="full", verbose = NULL, interval=NULL,
zero.policy = NULL, tol.solve=.Machine$double.eps, llprof=NULL,
control=list())
## S3 method for class 'spautolm'
summary(object, correlation = FALSE, adj.se=FALSE,
Nagelkerke=FALSE, ...)
参数----------Arguments----------
参数:formula
a symbolic description of the model to be fit. The details of model specification are given for lm()
一个象征性的模型来描述是合适的。型号规格的细节给予lm()
参数:data
an optional data frame containing the variables in the model. By default the variables are taken from the environment which the function is called.
一个可选的数据框包含在模型中的变量。默认情况下,变量的环境,被调用的函数。
参数:listw
a listw object created for example by nb2listw
例如创建一个listw对象的nb2listw
参数:weights
an optional vector of weights to be used in the fitting process
在嵌合过程中要使用的一个可选的矢量的权重
参数:na.action
a function (default options("na.action")), can also be na.omit or na.exclude with consequences for residuals and fitted values - in these cases the weights list will be subsetted to remove NAs in the data. Note that only weights lists created without using the glist argument to nb2listw may be subsetted.
一个函数(默认options("na.action")),也可以是na.omit或na.exclude残差和拟合值与后果 - 在这些情况下,将子集的权重列表中删除NAS的数据。需要注意的是只重列表创建时没有使用的glist的参数nb2listw可能是子集。
参数:family
character string: either "SAR" or "CAR" for simultaneous or conditional autoregressions; "SMA" for spatial moving average added thanks to Jielai Ma - "SMA" is only implemented for method="full" because it necessarily involves dense matrices
字符串是"SAR"或"CAR"同时或条件自回归,“"SMA"的空间移动平均线由于结来马 - "SMA"只实施方法=<X >,因为它必然涉及到稠密矩阵
参数:method
character string: default "full" for use of full matrices, "Matrix_J" or "spam" for sparse matrices (restricted to spatial weights symmetric or similar to symmetric) using methods in either the Matrix or spam packages; “Matrix” and “spam_update” provide updating Cholesky decomposition methods. Note that users should change from spam to Matrix. Values of method may also include "LU", which provides an alternative sparse matrix decomposition approach, and the "Chebyshev" and Monte Carlo "MC" approximate log-determinant methods.
字符串:默认"full"使用全矩阵,"Matrix_J"或"spam"稀疏矩阵(对称或类似对称空间权重限制)使用矩阵或垃圾包的方法; “黑客帝国”和“spam_update”提供更新的Cholesky分解方法。请注意,用户应该改变从垃圾邮件的矩阵。值的方法还可能包括“LU”,提供了另一种稀疏矩阵分解的方法,“切比雪夫”蒙地卡罗“MC”近似数行列式的方法。
参数:verbose
default NULL, use global option value; if TRUE, reports function values during optimization.
默认为空,请使用全局选项的值,如果为TRUE,报告函数值在优化过程中。
参数:interval
search interval for autoregressive parameter when not using method="eigen"; default is c(-1,0.999), optimize will reset NA/NaN to a bound and gives a warning when the interval is poorly set; method="Matrix" will attempt to search for an appropriate interval, if find\_interval=TRUE (fails on some platforms)
自回归参数的搜索时间间隔,当不使用方法=“特征”,默认为C(-1,0.999),optimize将重置NA / NaN的一个绑定,并给出一个警告,当设定的时间间隔是不好的方法“黑客帝国”将试图寻找一个适当的时间间隔,如果找到\ _interval = TRUE(在某些平台上失败)
参数:zero.policy
default NULL, use global option value; Include list of no-neighbour observations in output if TRUE — otherwise zero.policy is handled within the listw argument
默认为空,请使用全局选项的值,如果TRUE - 输出包含列表邻居的意见,否则zero.policy处理在listw参数
参数:tol.solve
the tolerance for detecting linear dependencies in the columns of matrices to be inverted - passed to solve() (default=double precision machine tolerance). Errors in solve() may constitute indications of poorly scaled variables: if the variables have scales differing much from the autoregressive coefficient, the values in this matrix may be very different in scale, and inverting such a matrix is analytically possible by definition, but numerically unstable; rescaling the RHS variables alleviates this better than setting tol.solve to a very small value
检测线性依赖关系被倒置的矩阵中的列 - 通过solve()(默认=双精密机械公差)的耐受性。 solve()的错误可能构成的迹象糟糕的比例变量:如果变量有不同的自回归系数的尺度,这个矩阵中的值可能有很大的不同规模,反相这样一个矩阵分析的定义,但数值不稳定,重新调整的RHS变量缓解这比设置tol.solve一个很小的值
参数:llprof
default NULL, can either be an integer, to divide the feasible range into llprof points, or a sequence of spatial coefficient values, at which to evaluate the likelihood function
默认为NULL,既可以是一个整数,以分割成llprof点的可行范围,或序列的空间系数的值,在其中计算的似然函数的
参数:control
list of extra control arguments - see section below
额外的控制参数列表 - 见下文
参数:object
spautolm object from spautolm
spautolmspautolm对象
参数:correlation
logical; if 'TRUE', the correlation matrix of the estimated parameters is returned and printed (default=FALSE)
逻辑,如果TRUE,返回参数的估计的相关矩阵和打印(默认值= FALSE)
参数:adj.se
if TRUE, adjust the coefficient standard errors for the number of fitted coefficients
如果为TRUE,调整系数的拟合系数的标准误差
参数:Nagelkerke
if TRUE, the Nagelkerke pseudo R-squared is reported
如果为true,Nagelkerke伪R平方报道
参数:...
further arguments passed to or from other methods
进一步的参数传递给其他方法
Details
详细信息----------Details----------
This implementation is based on lm.gls and errorsarlm. In particular, the function does not (yet) prevent asymmetric spatial weights being used with "CAR" family models. It appears that both numerical issues (convergence in particular) and uncertainties about the exact spatial weights matrix used make it difficult to reproduce Cressie and Chan's 1989 results, also given in Cressie 1993.
是基于lm.gls和errorsarlm,这个实现。特别是,该函数不(还)避免使用“CAR”的家庭模式的非对称空间权重。看来,这两个数值的问题(特别是收敛)的确切空间权重矩阵的不确定性,使其难以重现经验Cressie,1989年生的结果,也给1993年的经验Cressie。
Note that the fitted() function for the output object assumes that the response variable may be reconstructed as the sum of the trend, the signal, and the noise (residuals). Since the values of the response variable are known, their spatial lags are used to calculate signal components (Cressie 1993, p. 564). This differs from other software, including GeoDa, which does not use knowledge of the response variable in making predictions for the fitting data.
需要注意的是拟合()函数的输出对象的假定响应变量可重构的趋势,所述信号的总和,和噪声(残差)。由于响应变量的值是已知的,它们的空间被用来计算滞后的信号分量(经验Cressie 1993年,第564页)。这不同于其他软件,包括GeoDa,其中不使用的响应变量知识为嵌合的数据进行预测。
值----------Value----------
A list object of class spautolm:
列表类的对象spautolm:
参数:fit
a list, with items:
一个列表,项目:
coefficientsML coefficient estimates
coefficientsML系数估计
SSEML sum of squared errors
SSEML误差平方和
s2ML residual variance
s2ML剩余方差
imatML coefficient covariance matrix
imatML系数协方差矩阵
signal\_trendnon-spatial component of fitted.values
信号\:_trendnon空间的组成部分,fitted.values
signal\_stochasticspatial component of fitted.values
信号\ _stochasticspatial组成部分fitted.values
fitted.valuessum of non-spatial and spatial components of fitted.values
fitted.valuessum的非空间和空间组成fitted.values的
residualsdifference between observed and fitted values
观测值和拟合值之间的residualsdifference
参数:lambda
ML autoregressive coefficient
ML自回归系数
参数:LL
log likelihood for fitted model
拟合模型的对数似然
参数:LL0
log likelihood for model with lambda=0
对数似然模型λ= 0
参数:call
the call used to create this object
用于创建此对象的调用
参数:parameters
number of parameters estimated
估计的参数的数量
参数:aliased
if not NULL, details of aliased variables
如果不为NULL,细节的别名变量
参数:method
Jacobian method chosen
雅可比方法的选择
参数:zero.policy
zero.policy used
zero.policy使用
参数:weights
case weights used
使用的情况下,权重
参数:interval
the line search interval used
间隔线搜索
参数:timings
processing timings
处理时序
参数:na.action
(possibly) named vector of excluded or omitted observations if non-default na.action argument used
参数:llprof
if not NULL, a list with components lambda and ll of equal length
如果不为NULL,与组件lambda和ll的长度相等的列表
控制参数----------Control arguments----------
tol.opt: the desired accuracy of the optimization - passed to optimize() (default=.Machine$double.eps^(2/3))
tol.opt所需的精度的优化 - 通过optimize()(默认=.Machine$double.eps^(2/3))
Imult: default 2; used for preparing the Cholesky decompositions for updating in the Jacobian function
IMULT:默认的Cholesky分解更新的雅可比函数准备
super: if NULL (default), set to FALSE to use a simplicial decomposition for the sparse Cholesky decomposition and method “Matrix_J”, set to as.logical(NA) for method “Matrix”, if TRUE, use a supernodal decomposition
超:如果NULL(默认值),设置为FALSE稀疏Cholesky分解和方法“Matrix_J”,设置为as.logical(NA)方法“黑客帝国”,如果使用的单纯分解TRUE,使用supernodal的分解
cheb_q: default 5; highest power of the approximating polynomial for the Chebyshev approximation
cheb_q 5:默认情况下,最高功率近似多项式的切比雪夫逼近
MC_p: default 16; number of random variates
mc_P的:默认16号的随机变数
MC_m: default 30; number of products of random variates matrix and spatial weights matrix
MC_m:默认为30;随机变数矩阵和空间权重矩阵的产品
spamPivot: default “MMD”, alternative “RCM”
spamPivot:默认的“MMD”,替代“RCM”
in_coef default 0.1, coefficient value for initial Cholesky decomposition in “spam_update”
in_coef默认0.1,系数的值在初始Cholesky分解“spam_update”
注意----------Note----------
The standard errors given in Waller and Gotway (2004) are adjusted for the numbers of parameters estimated, and may be reproduced by using the additional argument adj.se=TRUE in the summary method. In addition, the function returns fitted values and residuals as given by Cressie (1993) p. 564.
给出在Waller和Gotway(2004年)的标准误差进行调整,参数估计的数目,并可能使用额外的参数adj.se=TRUE的summary方法进行复制的。此外,该函数返回的拟合值和残差经验Cressie(1993)对所给出的。 564。
(作者)----------Author(s)----------
Roger Bivand <a href="mailto:Roger.Bivand@nhh.no">Roger.Bivand@nhh.no</a>
参考文献----------References----------
Ord, J. K. 1975 Estimation methods for models of spatial interaction,
参见----------See Also----------
optimize, errorsarlm, do_ldet
optimize,errorsarlm,do_ldet
实例----------Examples----------
example(NY_data)
lm0 <- lm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata)
summary(lm0)
lm0w <- lm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, weights=POP8)
summary(lm0w)
esar0 <- errorsarlm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata,
listw=listw_NY)
summary(esar0)
system.time(esar1f <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME,
data=nydata, listw=listw_NY, family="SAR", method="full", verbose=TRUE))
summary(esar1f)
system.time(esar1M <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME,
data=nydata, listw=listw_NY, family="SAR", method="Matrix", verbose=TRUE))
summary(esar1M)
## Not run: [#不运行:]
system.time(esar1M <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME,
data=nydata, listw=listw_NY, family="SAR", method="Matrix", verbose=TRUE,
control=list(super=TRUE)))
summary(esar1M)
system.time(esar1s <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME,
data=nydata, listw=listw_NY, family="SAR", method="spam", verbose=TRUE))
summary(esar1s)
esar1wf <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata,
listw=listw_NY, weights=POP8, family="SAR", method="full")
summary(esar1wf)
system.time(esar1wM <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME,
data=nydata, listw=listw_NY, weights=POP8, family="SAR", method="Matrix"))
summary(esar1wM)
esar1ws <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata,
listw=listw_NY, weights=POP8, family="SAR", method="spam")
summary(esar1ws)
esar1wlu <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata,
listw=listw_NY, weights=POP8, family="SAR", method="LU")
summary(esar1wlu)
esar1wch <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata,
listw=listw_NY, weights=POP8, family="SAR", method="Chebyshev")
summary(esar1wch)
ecar1f <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata,
listw=listw_NY, family="CAR", method="full")
summary(ecar1f)
system.time(ecar1M <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME,
data=nydata, listw=listw_NY, family="CAR", method="Matrix"))
summary(ecar1M)
ecar1s <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata,
listw=listw_NY, family="CAR", method="spam")
summary(ecar1s)
ecar1wf <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata,
listw=listw_NY, weights=nydata$POP8, family="CAR", method="full")
summary(ecar1wf)
system.time(ecar1wM <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME,
data=nydata, listw=listw_NY, weights=POP8, family="CAR", method="Matrix"))
summary(ecar1wM)
ecar1ws <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata,
listw=listw_NY, weights=POP8, family="CAR", method="spam")
summary(ecar1ws)
example(nc.sids)
ft.SID74 <- sqrt(1000)*(sqrt(nc.sids$SID74/nc.sids$BIR74) + sqrt((nc.sids$SID74+1)/nc.sids$BIR74))
lm_nc <- lm(ft.SID74 ~ 1)
sids.nhbr30 <- dnearneigh(cbind(nc.sids$east, nc.sids$north), 0, 30, row.names=row.names(nc.sids))
sids.nhbr30.dist <- nbdists(sids.nhbr30, cbind(nc.sids$east, nc.sids$north))
sids.nhbr <- listw2sn(nb2listw(sids.nhbr30, glist=sids.nhbr30.dist, style="B", zero.policy=TRUE))
dij <- sids.nhbr[,3]
n <- nc.sids$BIR74
el1 <- min(dij)/dij
el2 <- sqrt(n[sids.nhbr$to]/n[sids.nhbr$from])
sids.nhbr$weights <- el1*el2
sids.nhbr.listw <- sn2listw(sids.nhbr)
both <- factor(paste(nc.sids$L_id, nc.sids$M_id, sep=":"))
ft.NWBIR74 <- sqrt(1000)*(sqrt(nc.sids$NWBIR74/nc.sids$BIR74) + sqrt((nc.sids$NWBIR74+1)/nc.sids$BIR74))
mdata <- data.frame(both, ft.NWBIR74, ft.SID74, BIR74=nc.sids$BIR74)
outl <- which.max(rstandard(lm_nc))
as.character(nc.sids$names[outl])
mdata.4 <- mdata[-outl,]
W <- listw2mat(sids.nhbr.listw)
W.4 <- W[-outl, -outl]
sids.nhbr.listw.4 <- mat2listw(W.4)
esarI <- errorsarlm(ft.SID74 ~ 1, data=mdata, listw=sids.nhbr.listw,
zero.policy=TRUE)
summary(esarI)
esarIa <- spautolm(ft.SID74 ~ 1, data=mdata, listw=sids.nhbr.listw,
family="SAR")
summary(esarIa)
esarIV <- errorsarlm(ft.SID74 ~ ft.NWBIR74, data=mdata, listw=sids.nhbr.listw,
zero.policy=TRUE)
summary(esarIV)
esarIVa <- spautolm(ft.SID74 ~ ft.NWBIR74, data=mdata, listw=sids.nhbr.listw,
family="SAR")
summary(esarIVa)
esarIaw <- spautolm(ft.SID74 ~ 1, data=mdata, listw=sids.nhbr.listw,
weights=BIR74, family="SAR")
summary(esarIaw)
esarIIaw <- spautolm(ft.SID74 ~ both - 1, data=mdata, listw=sids.nhbr.listw,
weights=BIR74, family="SAR")
summary(esarIIaw)
esarIVaw <- spautolm(ft.SID74 ~ ft.NWBIR74, data=mdata,
listw=sids.nhbr.listw, weights=BIR74, family="SAR")
summary(esarIVaw)
ecarIaw <- spautolm(ft.SID74 ~ 1, data=mdata.4, listw=sids.nhbr.listw.4,
weights=BIR74, family="CAR")
summary(ecarIaw)
ecarIIaw <- spautolm(ft.SID74 ~ both - 1, data=mdata.4,
listw=sids.nhbr.listw.4, weights=BIR74, family="CAR")
summary(ecarIIaw)
ecarIVaw <- spautolm(ft.SID74 ~ ft.NWBIR74, data=mdata.4,
listw=sids.nhbr.listw.4, weights=BIR74, family="CAR")
summary(ecarIVaw)
nc.sids$fitIV <- append(fitted.values(ecarIVaw), NA, outl-1)
spplot(nc.sids, c("fitIV"), cuts=12) # Cressie 1993, p. 565[经验Cressie 1993年,p。 565]
data(oldcol)
COL.errW.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD,
nb2listw(COL.nb, style="W"))
summary(COL.errW.eig)
COL.errW.sar <- spautolm(CRIME ~ INC + HOVAL, data=COL.OLD,
nb2listw(COL.nb, style="W"))
summary(COL.errW.sar)
data(boston)
gp1 <- spautolm(log(CMEDV) ~ CRIM + ZN + INDUS + CHAS + I(NOX^2)
+ I(RM^2) + AGE + log(DIS) + log(RAD) + TAX + PTRATIO + B + log(LSTAT),
data=boston.c, nb2listw(boston.soi), family="SMA")
summary(gp1)
## End(Not run)[#(不执行)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|