gt goodness of fit methods(globaltest)
gt goodness of fit methods()所属R语言包:globaltest
Goodness of fit testing in regression models using Global Test
在使用全球测试的回归模型适合性检验的善良
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Tests the goodness of fit of a regression model against a specified alternative using the Global Test.
回归模型的拟合优度测试使用全球测试对指定替代。
用法----------Usage----------
gtPS(response, null, data, model = c("linear", "logistic", "cox", "poisson", "multinomial"), ...,
covs, bdeg = 3, nint= 10, pord = 2, interact = FALSE, robust = FALSE,
termlabels = FALSE, returnZ = FALSE)
gtKS(response, null, data, model = c("linear", "logistic", "cox", "poisson", "multinomial"), ...,
covs, quant = .25, metric = c("euclidean", "pearson"),
kernel=c("uniform", "exponential", "triangular", "neighbours", "gauss"),
robust = FALSE, scale = TRUE, termlabels = FALSE, returnZ = FALSE)
gtLI(response, null, data, ..., covs, iorder=2, termlabels = FALSE, standardize = FALSE)
bbase(x, bdeg, nint)
btensor(xs, bdeg, nint, pord, returnU=FALSE)
reparamZ(Z, pord, K=NULL, tol = 1e-10, returnU=FALSE)
reweighZ(Z, null.fit)
sterms(object, ...)
参数----------Arguments----------
参数:response
The response vector of the regression model. May be supplied as a vector, as a formula object, or as an object of class lm, glm or coxph. In the last two cases, the specification of null is not required.
响应向量回归模型。可提供作为向量,作为一个formula对象,或作为一个对象类lm,glm或coxph。在最后两种情况,的null规范不需要。
参数:null
The null design matrix. May be given as a matrix or as a half formula object (e.g. ~a+b).
空设计矩阵。可作为基质或半formula对象(例如~a+b)。
参数:data
Only used when response or null is given in formula form. An optional data frame, list or environment containing the variables used in the formulae.
只用了response或null公式的形式给出。一个可选的数据框,列表或包含在公式中使用的变量的环境。
参数:model
The type of regression model to be tested. If omitted, the function will try to determine the model from the class and values of the response argument.
回归模型的类型进行测试。如果省略,函数会尝试从类和response参数值确定模型。
参数:...
Any other arguments are also passed on to gt.
任何其他参数也传递到gt。
参数:covs
A variable or a vector of variables that are the covariates the smooth terms are function of.
一个变量或一个变量,协变量的顺利条款是功能的向量。
参数:bdeg
A vector or a list of vectors which specifies the degree of the B-spline basis, with default bdeg=3.
一个向量或向量列表中指定的B样条基的程度,与默认bdeg=3。
参数:nint
A vector or a list of vectors which specifies the number of intervals determined by equally-spaced knots, with default nint=10.
一个向量或向量指定的间距相等节确定的时间间隔的数量列表,与默认nint=10。
参数:pord
A vector or a list of vectors which specifies the order of the differences indicating the type of the penalty imposed to the coefficients, with default pord=2.
指定默认的pord=2为了表示系数施加的刑罚类型的差异,一个向量或向量列表。
参数:interact
TRUE to consider a multidimensional smooth function of covs.
TRUE考虑了covs多维光滑函数。
参数:termlabels
TRUE to consider e.g. s(log(cov)) instead of s(cov) when null=~ log(cov) and covs is missing.
TRUE考虑例如s(log(cov))而不是s(cov)当null=~ log(cov)和covs失踪。
参数:robust
TRUE to obtain an overall test which combines multiple specifications of the B-spline basis arguments (when bdeg, nint and pord are lists) or multiple specifications of the bandwidth (when quant is a vector of quantiles).
TRUE获得整体测试相结合的多种规格的B样条基参数(当bdeg,nint和pord是列表)或多种规格的带宽(当quant是一个向量位数)。
参数:returnZ
TRUE gives back the alternative design matrix used in the test.
TRUE还给替代的设计在测试中使用的矩阵。
参数:quant
The smoothing bandwidth to be used, expressed as the percentile of the distribution of distance between observations, with default the 25th percentile. To investigate the sensitivity to different choices, quant can be a vector of percentiles. See also robust argument.
要使用平滑带宽,意见之间的距离分布的百分表示,默认情况下,第25个百分。调查选择不同的敏感性,quant可以是百分向量。还可以看robust参数。
参数:metric
A character string specifying the metric to be used. The available options are "euclidean" (the default), "pearson" and "mixed" (to be implemented). "mixed" distance is chosen automatically if some of the selected covariates are not numeric.
一个字符串,指定要使用的度量。可用的选项是“欧几里德”(默认),“培”和“混合”(实施)。如果选定的协变量是不是数字,自动选择“混合”的距离。
参数:kernel
A character string giving the smoothing kernel to be used. This must be one of "uniform", "exponential", "triangular", "neighbours", or "Gauss", with default "uniform".
一个字符串,用于平滑内核。这必须是一个“统一”,“指数”,“三角”,“邻居”,或“高斯”,默认的“统一”。
参数:scale
TRUE to center and scale the covariates before computing the distance.
TRUE中心和缩放之前计算的距离变项。
参数:iorder
Order of the linear interactions, e.g. second order interactions, third order etc., with default iorder=2.
订购的非线性相互作用,例如二阶相互作用,三阶等,默认的iorder=2。
参数:standardize
TRUE standardizes all covariates of the alternative to have unit second central moment. This makes sure that the test result is independent of the relative scaling of the covariates.
TRUE,标准化,所有协变量的替代单位第二次中央时刻。这可以确保测试结果是独立的协变量的相对尺度。
参数:x
A numeric vector of values at which to evaluate the B-spline basis.
一个数值向量评估B样条的基础上。
参数:xs
A matrix or dataframe where the columns correspond to covariates values.
一个矩阵或dataframe的列对应的协变量值。
参数:returnU
codeTRUE gives back the nonpenalized part.
还给codeTRUE的nonpenalized的一部分。
参数:Z
Alternative design matrix.
替代设计矩阵。
参数:K
Penalty matrix (i.e. the penalty term is the quadratic form of K and the spline coefficients).
罚款矩阵(即K和样条系数的二次形式的惩罚项)。
参数:tol
Eigenvalues smaller than tol are considered zero.
特征值比tol被视为零较小。
参数:null.fit
Fitted null model.
装空模型。
参数:object
A gt.object from gtPS, gtKS or gtLI.
一个gt.objectgtPS,gtKS或gtLI了。
Details
详情----------Details----------
These are functions to test for specific types of lack of fit by using the Global Test. Suppose that we are concerned with the adequacy of some regression model response ~ null, such as Y ~ X1 + X2. The alternative model can be cast into the generic form response ~ null + alternative, which comprises different models that accomodate to different types of lack of fit. Thus, the specification of alternative is required. It identifies the type of lack of fit the test is directed against.
这是缺乏合适的特定类型的测试,通过使用全球测试的功能。假设,我们正在关注一些回归模型response ~ null,Y ~ X1 + X2充足。可以转换为一般形式response ~ null + alternative,其中包括容纳缺乏适合不同类型的不同模型的替代模型。因此,规范alternative需要。它确定测试是针对缺乏合适的类型。
By using gtPS, the alternative is given by a user specified sum of smooth functions of continuous covariates, e.g. alternative= ~ s(X1) when covs="X1" and alternative= ~ s(X1) + s(X2) when covs=c("X1","X2"). Smooth terms are constructed using P-splines as proposed by Eilers and Marx (1996). This approach consists in constructing a B-spline basis of degree bdeg with nint + 1 equidistant knots, where a difference penalty of order pord is applied to the basis coefficients. If interact=TRUE, the alternative is given by a multidimensional smooth function of covs, which is represented by a tensor product of marginal B-splines bases and Kronecker sum of the marginal penalties, e.g. alternative= ~ s(X1,X2) when covs=c("X1","X2") and interact=TRUE.
通过使用gtPS,另一种方法是由一个光滑函数的连续变项,如用户指定的总和alternative= ~ s(X1)当covs="X1"和alternative= ~ s(X1) + s(X2)时covs=c("X1","X2")。艾勒斯和马克思(1996)建议使用的P-样条构造光滑条款。这种方法在建设程度的B样条基组成bdeg与nint + 1等距节点,其中差异罚款的顺序pord应用的基础系数。如果interact=TRUE,covs,这是由边际B样条碱基和Kronecker积的总和边际处罚,如张量积的多维平滑函数替代alternative= ~ s(X1,X2)时covs=c("X1","X2")和interact=TRUE。
By using gtKS the alternative is given by a user specified multidimensional smooth term, e.g. alternative= ~ s(X1, X2) when covs=c("X1","X2"). Multidimensional smooth terms are represented by a kernel smoother defined by a distance measure (metric), a kernel shape (kernel) and a bandwidth (quant). Because the test is sensitive to the chosen value of quant, it is possible to specify quant as a vector of different values in combination with robust=TRUE. Distance measures for factor covariates and for the situation that both continuous and factor covariates are present are constructed as in le Cessie and van Houwelingen (1995), e.g. covs=c("X1","X2") and distance="mixed" when X1 continuous and X2 factor (to be implemented).
使用gtKS另一种方法是由用户指定的多维平稳术语,如alternative= ~ s(X1, X2)时covs=c("X1","X2")。多维平稳条款是由距离度量定义的内核平滑代表(metric),内核的形状(kernel)和带宽(quant)。因为测试是敏感的quant选择的值,它可以指定quant作为一个向量,结合不同的价值观,用robust=TRUE。乐Cessie的,面包车Houwelingen(1995),例如修建因子协变量和距离的情况下,连续和因子协变量存在措施covs=c("X1","X2")和distance="mixed"当X1连续X2因素(实施)。
By using gtLI, the alternative is given by all the possible ith-order linear interactions between covs, e.g. alternative= ~ X1:X2 + X1:X3 + X2:X3 when covs=c("X1","X2","X3") and iorder=2.
通过使用gtLI,另一种方法是给所有可能的第i阶covs,如之间的非线性相互作用alternative= ~ X1:X2 + X1:X3 + X2:X3时covs=c("X1","X2","X3")和iorder=2。
The remaining functions are meant for constructing the alternative design matrix that will be used in the alternative argument of the gt function. bbase constructs the B-spline basis for the covariate x. This function is based on the functions provided by Eilers and Marx (1996). btensor builts a tensor product of B-splines for the covariates xs, which is reparameterized according with a Kroneker sum of penalties. reparamZ reparameterizes the alternative design matrix (e.g. a spline basis B) according with the order of differences pord or via the spectral decomposition of a roughness matrix K. When several smooth terms are to be combined, reweighZ assigns equal weight to each component term.
其余的功能意味着建设alternativegt函数的参数,将使用替代设计矩阵。 bbase建协xB样条的基础上。此功能是基于艾勒斯和马克思(1996年)所提供的功能。 btensorbuilts张量积B样条为协变量xs,这是根据与处罚Kroneker总和重新参数化。 reparamZreparameterizes替代设计矩阵(如样条基B)按顺序差异pord或通过谱分解1粗糙度矩阵K。几个顺利的条件是要合并时,reweighZ同等重量分配到每个组件的术语。
See the vignette for more examples.
看到更多的例子的小插曲。
值----------Value----------
The function returns an object of class gt.object. Several operations and diagnostic plots can be made from this object.
该函数返回一个对象的类gt.object。一些操作和诊断图可从该对象。
方法----------Methods----------
sterms (gt.object): Prints the smooth terms specified by gtPS, gtKS or gtLI.
sterms(gt.object):打印gtPS,gtKS或gtLI指定的顺利条款。
注意----------Note----------
Currently linear (normal), logistic, multinomial logistic and Poisson regression models with canonical links and Cox's proportional hazards regression model are supported.
目前线性(正常),MF,多项后勤和规范链接和Cox比例风险回归模型的泊松回归模型的支持。
作者(S)----------Author(s)----------
Aldo Solari: <a href="mailto:aldo.solari@unimib.it">aldo.solari@unimib.it</a>
参考文献----------References----------
Flexible smoothing with B-splines and penalties. Statistical Science, 11: 89-121.
Biometrics 51: 600-614.
<h3>See Also</h3> The <code>gt</code> function. The <code>gt.object</code> and useful functions associated with that object.
举例----------Examples----------
# Random data[随机数据]
set.seed(0)
X1<-runif(50)
s1 <- function(x) exp(2 * x)
e <- rnorm(50)
Y <- s1(X1) + e
### gtPS[##GTPS]
res<-gtPS(Y~X1)
res@result
sterms(res)
# model input[模型的输入]
rdata<-data.frame(Y,X1)
nullmodel<-lm(Y~X1,data=rdata)
gtPS(nullmodel)
# formula input and termlabels[公式输入和termlabels]
gtPS(Y~exp(2*X1),data=rdata)
gtPS(Y~exp(2*X1),covs="exp(2 * X1)",data=rdata)
sterms(gtPS(Y~exp(2*X1),data=rdata,termlabels=TRUE))
# P-splines arguments [的P-样条论据]
gtPS(Y~X1, bdeg=3, nint=list(a=10, b=30), pord=0)
gtPS(Y~X1, bdeg=3, nint=list(a=10, b=30), pord=0, robust=TRUE)
# Random data: additive model [随机数据:加法模型]
X2<-runif(50)
s2 <- function(x) 0.2 * x^11 * (10 * (1 - x))^6 + 10 * (10 * x)^3 * (1 - x)^10
Y <- s1(X1) + s2(X2) + e
gtPS(Y~X1+X2)
gtPS(Y~X1+X2, covs="X2")
sterms(gtPS(Y~X1+X2, nint=list(a=c(10,30), b=20)))
# Random data: smooth surface[随机数据:表面光滑]
s12 <- function(a, b, sa = 1, sb = 1) {
(pi^sa * sb) * (1.2 * exp(-(a - 0.2)^2/sa^2 - (b - 0.3)^2/sb^2) +
0.8 * exp(-(a - 0.7)^2/sa^2 - (b - 0.8)^2/sb^2))
}
Y <- s12(X1,X2) + e
# Tensor product of P-splines[张量积的P-样条]
res<-gtPS(Y~X1*X2, interact=TRUE)
res@result
sterms(res)
### gtKS [##gtKS]
res<-gtKS(Y~X1*X2)
res@result
sterms(res)
gtKS(Y~X1*X2, quant=seq(.05,.95,.05), robust=TRUE)
### gtLI [##gtLI]
library(MASS)
data(Boston)
gtLI(medv~., data=Boston, standardize=TRUE)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|