Rev 6563 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File nlme/man/Variogram.gls.Rd% Part of the nlme package for R% Distributed under GPL 2 or later: see nlme/LICENCE.note\name{Variogram.gls}\title{Calculate Semi-variogram for Residuals from a gls Object}\usage{\method{Variogram}{gls}(object, distance, form, resType, data,na.action, maxDist, length.out, collapse, nint, breaks,robust, metric, \dots)}\alias{Variogram.gls}\arguments{\item{object}{an object inheriting from class \code{"\link{gls}"}, representinga generalized least squares fitted model.}\item{distance}{an optional numeric vector with the distances betweenresidual pairs. If a grouping variable is present, only thedistances between residual pairs within the same group should begiven. If missing, the distances are calculated based on thevalues of the arguments \code{form}, \code{data}, and\code{metric}, unless \code{object} includes a \code{corSpatial}element, in which case the associated covariate (obtained with the\code{getCovariate} method) is used.}\item{form}{an optional one-sided formula specifying the covariate(s)to be used for calculating the distances between residual pairs and,optionally, a grouping factor for partitioning the residuals (whichmust appear to the right of a \code{|} operator in\code{form}). Default is \code{~1}, implying that the observationorder within the groups is used to obtain the distances.}\item{resType}{an optional character string specifying the type ofresiduals to be used. If \code{"response"}, the "raw" residuals(observed - fitted) are used; else, if \code{"pearson"}, thestandardized residuals (raw residuals divided by the correspondingstandard errors) are used; else, if \code{"normalized"}, thenormalized residuals (standardized residuals pre-multiplied by theinverse square-root factor of the estimated error correlationmatrix) are used. Partial matching of arguments is used, so only thefirst character needs to be provided. Defaults to \code{"pearson"}.}\item{data}{an optional data frame in which to interpret the variablesin \code{form}. By default, the same data used to fit \code{object}is used.}\item{na.action}{a function that indicates what should happen when thedata contain \code{NA}s. The default action (\code{na.fail}) causesan error message to be printed and the function to terminate, if thereare any incomplete observations.}\item{maxDist}{an optional numeric value for the maximum distance usedfor calculating the semi-variogram between two residuals. By defaultall residual pairs are included.}\item{length.out}{an optional integer value. When \code{object}includes a \code{corSpatial} element, its semi-variogram values arecalculated and this argument is used as the \code{length.out}argument to the corresponding \code{Variogram} method. Defaults to\code{50}.}\item{collapse}{an optional character string specifying the type ofcollapsing to be applied to the individual semi-variogram values. Ifequal to \code{"quantiles"}, the semi-variogram values are splitaccording to quantiles of the distance distribution, with equalnumber of observations per group, with possibly varying distanceinterval lengths. Else, if \code{"fixed"}, the semi-variogram valuesare divided according to distance intervals of equal lengths, withpossibly different number of observations per interval. Else, if\code{"none"}, no collapsing is used and the individualsemi-variogram values are returned. Defaults to \code{"quantiles"}.}\item{nint}{an optional integer with the number of intervals to beused when collapsing the semi-variogram values. Defaults to \code{20}.}\item{robust}{an optional logical value specifying if a robustsemi-variogram estimator should be used when collapsing theindividual values. If \code{TRUE} the robust estimator isused. Defaults to \code{FALSE}.}\item{breaks}{an optional numeric vector with the breakpoints for thedistance intervals to be used in collapsing the semi-variogramvalues. If not missing, the option specified in \code{collapse} isignored.}\item{metric}{an optional character string specifying the distancemetric to be used. The currently available options are\code{"euclidean"} for the root sum-of-squares of distances;\code{"maximum"} for the maximum difference; and \code{"manhattan"}for the sum of the absolute differences. Partial matching ofarguments is used, so only the first three characters need to beprovided. Defaults to \code{"euclidean"}.}\item{\dots}{some methods for this generic require additionalarguments. None are used in this method.}}\description{This method function calculates the semi-variogram for the residualsfrom a \code{gls} fit. The semi-variogram values are calculated forpairs of residuals within the same group level, if a grouping factoris present. If \code{collapse} is different from \code{"none"}, theindividual semi-variogram values are collapsed using either a robustestimator (\code{robust = TRUE}) defined in Cressie (1993), or theaverage of the values within the same distance interval. Thesemi-variogram is useful for modeling the error term correlationstructure.}\value{a data frame with columns \code{variog} and \code{dist} representing,respectively, the semi-variogram values and the correspondingdistances. If the semi-variogram values are collapsed, an extracolumn, \code{n.pairs}, with the number of residual pairs used in eachsemi-variogram calculation, is included in the returned data frame. If\code{object} includes a \code{corSpatial} element, a data frame withits corresponding semi-variogram is included in the returned value, asan attribute \code{"modelVariog"}. The returned value inherits fromclass \code{Variogram}.}\references{Cressie, N.A.C. (1993), "Statistics for Spatial Data", J. Wiley & Sons.}\author{José Pinheiro and Douglas Bates \email{bates@stat.wisc.edu}}\seealso{\code{\link{gls}},\code{\link{Variogram}},\code{\link{Variogram.default}},\code{\link{Variogram.lme}},\code{\link{plot.Variogram}}}\examples{fm1 <- gls(weight ~ Time * Diet, BodyWeight)Vm1 <- Variogram(fm1, form = ~ Time | Rat)print(head(Vm1), digits = 3)}\keyword{models}