Title: | Analysis of Field Trials with Geostatistics & Spatial AR Models |
---|---|
Description: | Perform analysis of variance when the experimental units are spatially correlated. There are two methods to deal with spatial dependence: Spatial autoregressive models (see Rossoni, D. F., & Lima, R. R. (2019) <doi:10.28951/rbb.v37i2.388>) and geostatistics (see Pontes, J. M., & Oliveira, M. S. D. (2004) <doi:10.1590/S1413-70542004000100018>). For both methods, there are three multicomparison procedure available: Tukey, multivariate T, and Scott-Knott. |
Authors: | Castro L. R. [aut, cre, cph], Renato R. R. [aut, ths], Rossoni D. F. [aut], Nogueira C.H. [aut] |
Maintainer: | Castro L. R. <[email protected]> |
License: | GPL-3 |
Version: | 0.99.4 |
Built: | 2024-10-31 18:36:58 UTC |
Source: | https://github.com/cran/spANOVA |
Fit an analysis of variance model using geostatistics for modeling the spatial dependence among the observations.
aovGeo(model, cutoff = 0.5, tol = 1e-3) ## S3 method for class 'spVariofitRCBD' aovGeo(model, cutoff = 0.5, tol = 0.001)
aovGeo(model, cutoff = 0.5, tol = 1e-3) ## S3 method for class 'spVariofitRCBD' aovGeo(model, cutoff = 0.5, tol = 0.001)
model |
an object of class spVariofit. |
cutoff |
a value in (0,1] interval representing the percentage of the maximum distance adopted to estimate the variogram in the algorithm suggested by Pontes & Oliveira (2004). See 'Details'. |
tol |
the desired accuracy. |
Three assumptions are made about the error in the analysis of variance (ANOVA):
1. The errors come from a normal distribution.
2. The errors have the same variance.
3. The errors are uncorrelated.
However, in many experiments, especially field trials, there is a type of correlation generated by the sample locations known as spatial autocorrelation, and this condition violates the independence assumption.
In that way, we need to regard this spatial autocorrelation and include it in the final model. It could be done adopting a geostatistical model to characterize the spatial variability among the observations directly in the covariance matrix.
The geostatistical modeling is based on the residuals of the standard model (where the errors are assumed to be independent, uncorrelated and having a normal distribution with mean 0 and constant variance). The basic idea is using them to estimate the residuals of the spatially autocorrelated model in order to fit a theoretical geostatistic model to build the covariance matrix. As Pointed by Pontes & Oliveira (2004), this task can be done using the following algorithm
1 - Extract the residuals from the standard model
2 - Fit a variogram based on residuals obtained in step 1.
3 - Fit a theoretical model to describe the spatial dependence observed in the variogram.
4 - On basis in the theoretical model fitted in step 3 and its parameter estimates, create the covariance matrix.
5 - Estimate the residuals using the covariance matrix obtained in step 4 and use them to create a variogram.
6 - Fit a theoretical model to the residual variogram obtained in step 5 and use its parameters estimates to build a new covariance matrix.
7 - Repeat 5 to 6 until convergence.
Step 1 is implemented in spVariog. Steps 2 and 3 are implemented in spVariofit. aovGeo implements steps 4 to 7 and needs a cutoff argument to define the maximum distance in the computation of the residual variogram described in step 6
In presence of spatial trend, the model is modified in order to include the effect of the spatial coordinates.
aovGeo
returns an object of class
"GEOanova".
The functions summary
and anova are used to obtain and print a summary
and analysis of variance table of the results.
An object of class "GEOanova" is a list containing the following components:
DF |
degrees of freedom of coordinates (in presence of spatial trend), treatments, block (if RCBD), residual and total. |
SS |
sum of squares of coordinates (in presence of spatial trend), treatments, block (if RCBD), residual and total. |
MS |
mean of squares of coordinates (in presence of spatial trend), treatments, block (if RCBD), residual and total. |
Fc |
F statistic calculated for coordinates (in presence of spatial trend), treatment and block (if RCBD). |
p.value |
p-value associated to F statistic for coordinates (in presence of spatial trend), treatment and block (if RCBD). |
residuals |
residuals extracted from the model |
params |
variogram parameter estimates from Pontes & Oliveira (2004) algorithm. |
type |
type of trend in the data. It can be "trend" or "cte". |
model |
geostatistical model used to describe the spatial dependence. |
data |
data set used in the analysis. |
des.mat |
design matrix. |
beta |
parameter estimates of the linear model taking into account the spatial dependence. |
n |
number of observations. |
vcov |
covariance matrix built taking into account the spatial dependence. |
design |
character string indicating the name of the experimental design. |
Nogueira, C. H., de Liima, R. R., & de Oliveira, M. S. (2013). Aprimoramento da Análise de Variância: A Influência da Proximidade Espacial. Rev. Bras. Biom, 31(3), 408-422.
Nogueira, C.H., et al. (2015). Modelagem espacial na análise de um plantio experimental de candeia. Rev. Bras. Biom., São Paulo, v.33, n.1, p.14-29.
Pontes, J. M., & de Oliveira, M. S. (2004). An alternative proposal to the analysis of field experiments using geostatistics. Ciência e Agrotecnologia, 28(1), 135-141.
Gotway, C. A., & Cressie, N. A. (1990). A spatial analysis of variance applied to soil water infiltration. Water Resources Research, 26(11), 2695-703.
data("crd_simulated") #Geodata object geodados <- as.geodata(crd_simulated, coords.col = 1:2, data.col = 3, covar.col = 4) h_max <- summary(geodados)[[3]][[2]] dist <- 0.6*h_max # Computing the variogram variograma <- spVariog(geodata = geodados, trend = "cte", max.dist = dist, design = "crd", scale = FALSE) plot(variograma, ylab = "Semivariance", xlab = "Distance") # Gaussian Model ols <- spVariofit(variograma, cov.model = "gaussian", weights = "equal", max.dist = dist) lines(ols, col = 1) # Compute the model and get the analysis of variance table mod <- aovGeo(ols, cutoff = 0.6) anova(mod)
data("crd_simulated") #Geodata object geodados <- as.geodata(crd_simulated, coords.col = 1:2, data.col = 3, covar.col = 4) h_max <- summary(geodados)[[3]][[2]] dist <- 0.6*h_max # Computing the variogram variograma <- spVariog(geodata = geodados, trend = "cte", max.dist = dist, design = "crd", scale = FALSE) plot(variograma, ylab = "Semivariance", xlab = "Distance") # Gaussian Model ols <- spVariofit(variograma, cov.model = "gaussian", weights = "equal", max.dist = dist) lines(ols, col = 1) # Compute the model and get the analysis of variance table mod <- aovGeo(ols, cutoff = 0.6) anova(mod)
Fit a completely randomized design when the experimental units have some degree of spatial dependence using a Spatial Lag Model (SAR).
aovSar.crd(resp, treat, coord, seq.radius)
aovSar.crd(resp, treat, coord, seq.radius)
resp |
Numeric or complex vector containing the values of the response variable. |
treat |
Numeric or complex vector containing the treatment applied to each experimental unit. |
coord |
Matrix of point coordinates. |
seq.radius |
Complex vector containing a radii sequence used to set the neighborhood pattern. The default sequence has ten numbers from 0 to half of the maximum distance between the samples, if no sample is found in this interval the sequence upper limit is increased by 10% and so on. |
Three assumptions are made about the error in the analysis of variance (ANOVA):
1. the errors are normally distributed and, on average, zero;
2. the errors all have the same variance (they are homoscedastic), and
3. the errors are unrelated to each other (they are independent across observations).
When these assumptions are not satisfied, data transformations in the response variable are often used to circumvent this problem. For example, in absence of normality, the Box-Cox transformation can be used.
However, in many experiments, especially field trials, there is a type of correlation generated by the sample locations known as spatial correlation, and this condition violates the independence assumption. errors are spatially correlated, by using a data transformation discussed in Long (1996)
where denotes the autoregressive spatial parameter of the SAR model
estimated by lagsarlm,
is the overall mean and
is
a spatial neighborhood matrix which neighbors are defined as the samples located within
a radius, this radius is specified as a sequence in
seq.radius
. For each radius
in seq.radius
the model is computed as well its AIC, then the radius chosen is the
one that minimizes AIC.
The aim of this transformation is converting autocorrelated observations into non-correlated observations in order to apply the analysis of variance and obtain suitable inferences.
aovSar.crd
returns an object of class
"SARanova".
The functions summary
and anova are used to obtain and print a summary
and analysis of variance table of the results.
An object of class "SARanova" is a list containing the following components:
DF |
degrees of freedom of rho, treatments, residual and total. |
SS |
sum of squares of rho, treatments and residual. |
MS |
mean square of rho, treatments and residual. |
Fc |
F statistic calculated for treatment. |
residuals |
residuals of the adjusted model. |
p.value |
p-value associated to F statistic for treatment. |
rho |
the autoregressive parameter. |
Par |
data.frame with the radius tested and its AIC. |
y_orig |
vector of response. |
y_ajus |
vector of adjusted response. |
treat |
vector of treatment applied to each experimental unit. |
modelAdj |
model of class |
modelstd |
data frame containing the ANOVA table using non-adjusted response. |
namey |
response variable name. |
namex |
treatment variable name. |
Long, D.S., 1996. Spatial statistics for analysis of variance of agronomic field trials. In: Arlinghaus, S.L. (Ed.), Practical Handbook of Spatial Statistics. CRC Press, Boca Raton, FL, pp. 251–278.
Rossoni, D. F.; Lima, R. R. . Autoregressive analysis of variance for experiments with spatial dependence between plots: a simulation study. Revista Brasileira de Biometria, 2019.
Scolforo, Henrique Ferraço, et al. "Autoregressive spatial analysis and individual tree modeling as strategies for the management of Eremanthus erythropappus." Journal of forestry research 27.3 (2016): 595-603.
data("crd_simulated") resp <- crd_simulated$y treat <- crd_simulated$trat coord <- cbind(crd_simulated$coordX, crd_simulated$coordY) cv <- aovSar.crd(resp, treat, coord) #Summary for class SARanova summary(cv) #Anova for class SARanova anova(cv)
data("crd_simulated") resp <- crd_simulated$y treat <- crd_simulated$trat coord <- cbind(crd_simulated$coordX, crd_simulated$coordY) cv <- aovSar.crd(resp, treat, coord) #Summary for class SARanova summary(cv) #Anova for class SARanova anova(cv)
Fit a completely randomized design when the experimental units have some degree of spatial dependence using a Spatial Lag Model (SAR).
aovSar.gen(formula, coord, seq.radius, data = NULL)
aovSar.gen(formula, coord, seq.radius, data = NULL)
formula |
A formula specifying the model. |
coord |
A matrix or data.frame of point coordinates. |
seq.radius |
A complex vector containing a radii sequence used to set the neighborhood pattern. The default sequence has ten numbers from 0 to half of the maximum distance between the samples. |
data |
A data frame in which the variables specified in the formula will be found. |
Three assumptions are made about the error in the analysis of variance (ANOVA):
1. the errors are normally distributed and, on average, zero;
2. the errors all have the same variance (they are homoscedastic), and
3. the errors are unrelated to each other (they are independent across observations).
When these assumptions are not satisfied, data transformations in the response variable are often used to circumvent this problem. For example, in absence of normality, the Box-Cox transformation can be used.
However, in many experiments, especially field trials, there is a type of correlation generated by the sample locations known as spatial correlation, and this condition violates the independence assumption. In this setting, this function provides an alternative for using ANOVA when the errors are spatially correlated, by using a data transformation discussed in Long (1996)
where denotes the autoregressive spatial parameter of the SAR model estimated by
lagsarlm,
is the overall mean and W is a spatial neighborhood matrix which neighbors are defined as the
samples located within a radius, this radius is specified as a sequence in
seq.radius
. For each radius
in seq.radius
the model is computed as well its AIC, then the radius chosen is the one
that minimizes AIC.
The aim of this transformation is converting autocorrelated observations into non-correlated observations in order to apply the analysis of variance and obtain suitable inferences.
aovSar.gen
returns an object of class
"SARaov".
The functions summary and anova are used to obtain and print a summary and analysis of variance
table of the results.
An object of class "SARaov" is a list containing the following components:
DF |
degrees of freedom of rho, treatments, residual and total. |
SS |
sum of squares of residuals and total. |
residuals |
residuals of the adjusted model. |
MS |
mean square of residuals and total. |
rho |
the autoregressive parameter. |
Par |
data.frame with the radius tested and its AIC. |
modelAdj |
model of class |
modelstd |
data frame containing the ANOVA table using non-adjusted response. |
namey |
response variable name. |
Long, D. S. "Spatial statistics for analysis of variance of agronomic field trials." Practical handbook of spatial statistics. CRC Press, Boca Raton, FL (1996): 251-278.
Rossoni, D. F.; Lima, R. R. . Autoregressive analysis of variance for experiments with spatial dependence between plots: a simulation study. Revista Brasileira de Biometria, 2019
Scolforo, Henrique Ferraço, et al. "Autoregressive spatial analysis and individual tree modeling as strategies for the management of Eremanthus erythropappus." Journal of forestry research 27.3 (2016): 595-603.
data("crd_simulated") coord <- cbind(crd_simulated$coordX, crd_simulated$coordY) cv <- aovSar.gen(y ~ trat, coord, data = crd_simulated) cv #Summary for class SARanova summary(cv) #Anova for class SARanova anova(cv)
data("crd_simulated") coord <- cbind(crd_simulated$coordX, crd_simulated$coordY) cv <- aovSar.gen(y ~ trat, coord, data = crd_simulated) cv #Summary for class SARanova summary(cv) #Anova for class SARanova anova(cv)
Fit a randomized complete block design when the experimental units have some degree of spatial dependence using a Spatial Lag Model (SAR).
aovSar.rcbd(resp, treat, block, coord, seq.radius)
aovSar.rcbd(resp, treat, block, coord, seq.radius)
resp |
Numeric or complex vector containing the values of response variable. |
treat |
Numeric or complex vector containing the treatment applied to each experimental unit. |
block |
Numeric or complex vector specifying the blocks. |
coord |
Matrix of point coordinates or a SpatialPoints Object. |
seq.radius |
Complex vector containing a radii sequence used to set the neighborhood pattern. The default sequence has ten numbers from 0 to half of the maximum distance between the samples. |
Three assumptions are made about the error in the analysis of variance (ANOVA):
1. the errors are normally distributed and, on average, zero;
2. the errors all have the same variance (they are homoscedastic), and
3. the errors are unrelated to each other (they are independent across observations).
When these assumptions are not satisfied, data transformations in the response variable are often used to circumvent this problem. For example, in absence of normality, the Box-Cox transformation can be used.
However, in many experiments, especially field trials, there is a type of correlation generated by the sample locations known as spatial correlation, and this condition violates the independence assumption. In this setting, this function provides an alternative for using ANOVA when the errors are spatially correlated, by using a data transformation discussed in Long (1996)
where denotes the autoregressive spatial parameter of the SAR model estimated by
lagsarlm,
is the overall mean and
is a spatial neighborhood matrix which neighbors are defined as the
samples located within a radius, this radius is specified as a sequence in
seq.radius
. For each radius
in seq.radius
the model is computed as well its AIC, then the radius chosen is the one
that minimizes AIC.
The aim of this transformation is converting autocorrelated observations into non-correlated observations in order to apply the analysis of variance and obtain suitable inferences.
aovSar.rcbd
returns an object of class
"SARanova".
The functions summary and anova are used to obtain and print a summary and analysis of variance
table of the results.
An object of class "SARanova" is a list containing the following components:
DF |
degrees of freedom of rho, treatments, residual and total. |
SS |
sum of squares of rho, treatments and residual. |
Fc |
F statistic calculated for treatment. |
residuals |
residuals of the adjusted model. |
p.value |
p-value associated to F statistic for treatment. |
rho |
the autoregressive parameter. |
Par |
data.frame with the radii tested and its AIC. |
y_orig |
vector of response. |
y_ajus |
vector of adjusted response. |
treat |
vector of treatment applied to each experimental unit. |
modelAdj |
model of class |
modelstd |
data frame containing the ANOVA table using non-adjusted response. |
namey |
response variable name. |
namex |
treatment variable name. |
Long, D.S., 1996. Spatial statistics for analysis of variance of agronomic field trials. In: Arlinghaus, S.L. (Ed.), Practical Handbook of Spatial Statistics. CRC Press, Boca Raton, FL, pp. 251–278.
Rossoni, D. F.; Lima, R. R. . Autoregressive analysis of variance for experiments with spatial dependence between plots: a simulation study. Revista Brasileira de Biometria, 2019
Scolforo, Henrique Ferraço, et al. "Autoregressive spatial analysis and individual tree modeling as strategies for the management of Eremanthus erythropappus." Journal of forestry research 27.3 (2016): 595-603.
data("rcbd_simulated") # Fitting the model model <- aovSar.rcbd(rcbd_simulated$y, rcbd_simulated$trat, rcbd_simulated$block, cbind(rcbd_simulated$coordX, rcbd_simulated$coordY)) # Summary for class SARanova summary(model) # Anova for class SARanova anova(model)
data("rcbd_simulated") # Fitting the model model <- aovSar.rcbd(rcbd_simulated$y, rcbd_simulated$trat, rcbd_simulated$block, cbind(rcbd_simulated$coordX, rcbd_simulated$coordY)) # Summary for class SARanova summary(model) # Anova for class SARanova anova(model)
Compute Tukey's contrast matrix
contr.tuk(x)
contr.tuk(x)
x |
a vector of means. |
Computes the matrix of contrasts for comparisons of mean levels.
The matrix of contrasts with treatments in row names is returned
x <- c(10, 5, 8, 4, 12, 18) contr.tuk(x)
x <- c(10, 5, 8, 4, 12, 18) contr.tuk(x)
Simulated data set for CRD
This dataset was simulated under a gaussian random field containing 15 treatments and 8 replication with mean 10.
Lucas Castro [email protected]
Simulated data set for RCBD
This dataset was simulated under a gaussian random field containing 15 treatments and 3 blocks with 3 replication.
Lucas Castro [email protected]
Shiny app for analysis of variance with spatially correlated errors
spANOVAapp(external = TRUE)
spANOVAapp(external = TRUE)
external |
logical. If true, the system's default web browser will be launched automatically after the app is started. |
This function does not return any value directly. It launches a Shiny application for analyzing variance with spatially correlated errors.
spANOVAapp(external = TRUE)
spANOVAapp(external = TRUE)
Compute cross-validation for an object of class spVariofit
.
spCrossvalid(x, ...)
spCrossvalid(x, ...)
x |
an object of class |
... |
further arguments to be passed to |
This function is a wrapper to xvalid
function of the package geoR.
Please check its documentation for additional information.
An object of the class "xvalid" which is a list with the following components:
data |
the original data. |
predicted |
the values predicted by cross-validation. |
krige.var |
the cross-validation prediction variance. |
error |
the differences data - predicted value. |
std.error |
the errors divided by the square root of the prediction variances. |
prob |
the cumulative probability at original value under a normal distribution with parameters given by the cross-validation results. |
data("crd_simulated") dados <- crd_simulated #Geodata object geodados <- as.geodata(dados, coords.col = 1:2, data.col = 3, covar.col = 4) h_max <- summary(geodados)[[3]][[2]] dist <- 0.6*h_max # Computing the variogram variograma <- spVariog(geodata = geodados, trend = "cte", max.dist = dist, design = "crd", scale = FALSE) plot(variograma, ylab = "Semivariance", xlab = "Distance") # Spherical Model ols1 <- spVariofit(variograma, cov.model = "spherical", weights = "equal", max.dist = dist) #Using crossvalidation to assess the error ols1.cv <- spCrossvalid(ols1)
data("crd_simulated") dados <- crd_simulated #Geodata object geodados <- as.geodata(dados, coords.col = 1:2, data.col = 3, covar.col = 4) h_max <- summary(geodados)[[3]][[2]] dist <- 0.6*h_max # Computing the variogram variograma <- spVariog(geodata = geodados, trend = "cte", max.dist = dist, design = "crd", scale = FALSE) plot(variograma, ylab = "Semivariance", xlab = "Distance") # Spherical Model ols1 <- spVariofit(variograma, cov.model = "spherical", weights = "equal", max.dist = dist) #Using crossvalidation to assess the error ols1.cv <- spCrossvalid(ols1)
Use a multivariate t student distribution to assess the equality of means.
spMVT(x, sig.level = 0.05, verbose = TRUE) ## S3 method for class 'SARanova' spMVT(x, sig.level = 0.05, verbose = TRUE) ## S3 method for class 'GEOanova' spMVT(x, sig.level = 0.05, verbose = TRUE)
spMVT(x, sig.level = 0.05, verbose = TRUE) ## S3 method for class 'SARanova' spMVT(x, sig.level = 0.05, verbose = TRUE) ## S3 method for class 'GEOanova' spMVT(x, sig.level = 0.05, verbose = TRUE)
x |
a fitted model object of class SARcrd, SARrcbd or GEOanova. |
sig.level |
a numeric value between zero and one giving the significance level to use. |
verbose |
should messages be printed during loading? |
For objects of class SARcrd or SARrcbd this function performs the general
linear hypothesis method provided by the function glht
on the adjusted
response.
For objects of class GEOanova, the test is modified to accommodate the spatial dependence among the observations as pointed out by Nogueira (2017)
a data frame containing the original mean, the spatially filtered mean and its group. For the class GEOanova, the spatial dependence is filtered out using geostatistics, while for the class SARanova the adjusted response based on SAR model is employed.
Nogueira, C. H. Testes para comparações múltiplas de médias em experimentos com tendência e dependência espacial. 142 f. Tese (Doutorado em Estatística e Experimentação Agropecuária) | Universidade Federal de Lavras, Lavras, 2017
data("crd_simulated") #Geodata object geodados <- as.geodata(crd_simulated, coords.col = 1:2, data.col = 3, covar.col = 4) h_max <- summary(geodados)[[3]][[2]] dist <- 0.6*h_max # Computing the variogram variograma <- spVariog(geodata = geodados, trend = "cte", max.dist = dist, design = "crd", scale = FALSE) plot(variograma, ylab = "Semivariance", xlab = "Distance") # Gaussian Model ols <- spVariofit(variograma, cov.model = "gaussian", weights = "equal", max.dist = dist) lines(ols, col = 1) # Compute the model and get the analysis of variance table mod <- aovGeo(ols, cutoff = 0.6) # Multivariate T test spMVT(mod)
data("crd_simulated") #Geodata object geodados <- as.geodata(crd_simulated, coords.col = 1:2, data.col = 3, covar.col = 4) h_max <- summary(geodados)[[3]][[2]] dist <- 0.6*h_max # Computing the variogram variograma <- spVariog(geodata = geodados, trend = "cte", max.dist = dist, design = "crd", scale = FALSE) plot(variograma, ylab = "Semivariance", xlab = "Distance") # Gaussian Model ols <- spVariofit(variograma, cov.model = "gaussian", weights = "equal", max.dist = dist) lines(ols, col = 1) # Compute the model and get the analysis of variance table mod <- aovGeo(ols, cutoff = 0.6) # Multivariate T test spMVT(mod)
This function implements the Scott-Knott Clustering Algorithm for objects of class SARcrd, SARrcbd, and GEOanova.
spScottKnott(x, sig.level = 0.05, verbose = TRUE) ## S3 method for class 'SARanova' spScottKnott(x, sig.level = 0.05, verbose = TRUE) ## S3 method for class 'GEOanova' spScottKnott(x, sig.level = 0.05, verbose = TRUE)
spScottKnott(x, sig.level = 0.05, verbose = TRUE) ## S3 method for class 'SARanova' spScottKnott(x, sig.level = 0.05, verbose = TRUE) ## S3 method for class 'GEOanova' spScottKnott(x, sig.level = 0.05, verbose = TRUE)
x |
a fitted model object of class SARcrd, SARrcbd or GEOanova. |
sig.level |
a numeric value between zero and one giving the significance level to use. |
verbose |
should messages be printed during loading? |
For objects of class SARcrd or SARrcbd this function performs the standard Scott-Knott
Clustering Algorithm provided by the function SK
on the
adjusted response.
For objects of class GEOanova, the method is modified to take into account the spatial dependence among the observations. The method is described in Nogueira (2017).
a data frame containing the means and its group
Nogueira, C. H. Testes para comparações múltiplas de médias em experimentos com tendência e dependência espacial. 142 f. Tese (Doutorado em Estatística e Experimentação Agropecuária) | Universidade Federal de Lavras, Lavras, 2017
data("crd_simulated") #Geodata object geodados <- as.geodata(crd_simulated, coords.col = 1:2, data.col = 3, covar.col = 4) h_max <- summary(geodados)[[3]][[2]] dist <- 0.6*h_max # Computing the variogram variograma <- spVariog(geodata = geodados, trend = "cte", max.dist = dist, design = "crd", scale = FALSE) plot(variograma, ylab = "Semivariance", xlab = "Distance") # Gaussian Model ols <- spVariofit(variograma, cov.model = "gaussian", weights = "equal", max.dist = dist) # Compute the model and get the analysis of variance table mod <- aovGeo(ols, cutoff = 0.6) # Scott-Knott clustering algorithm spScottKnott(mod)
data("crd_simulated") #Geodata object geodados <- as.geodata(crd_simulated, coords.col = 1:2, data.col = 3, covar.col = 4) h_max <- summary(geodados)[[3]][[2]] dist <- 0.6*h_max # Computing the variogram variograma <- spVariog(geodata = geodados, trend = "cte", max.dist = dist, design = "crd", scale = FALSE) plot(variograma, ylab = "Semivariance", xlab = "Distance") # Gaussian Model ols <- spVariofit(variograma, cov.model = "gaussian", weights = "equal", max.dist = dist) # Compute the model and get the analysis of variance table mod <- aovGeo(ols, cutoff = 0.6) # Scott-Knott clustering algorithm spScottKnott(mod)
Perform multiple comparisons of means treatments based on the Studentized range statistic when the errors are spatially correlated.
spTukey(x, sig.level = 0.05, verbose = TRUE) ## S3 method for class 'SARanova' spTukey(x, sig.level = 0.05, verbose = TRUE) ## S3 method for class 'GEOanova' spTukey(x, sig.level = 0.05, verbose = TRUE)
spTukey(x, sig.level = 0.05, verbose = TRUE) ## S3 method for class 'SARanova' spTukey(x, sig.level = 0.05, verbose = TRUE) ## S3 method for class 'GEOanova' spTukey(x, sig.level = 0.05, verbose = TRUE)
x |
A fitted model object of class SARcrd, SARrcbd or GEOanova. |
sig.level |
A numeric value between zero and one giving the significance level to use. |
verbose |
should messages be printed during loading? |
For objects of class SARcrd or SARrcbd this function performs the standard
Tukey's ‘Honest Significant Difference’ method provided by the function
TukeyHSD
on the adjusted response.
For objects of class GEOanova, the method is modified to take into account
the spatial dependence among the observations. First, we estimate a
contrast matrix () using cont.tuk function and then after estimate the
spatial mean of each treatment (
) we can assess the significance of
the contrast by
where and
is the number of treatments,
is the level of significance,
is the degree of freedom of the model,
is the variance of
the i-th contrast.
a data frame containing the original mean, the spatially filtered mean and its group. For the class GEOanova, the spatial dependence is filtered out using geostatistics, while for the class SARanova the adjusted response based on SAR model is employed.
Nogueira, C. H. Testes para comparações múltiplas de médias em experimentos com tendência e dependência espacial. 142 f. Tese (Doutorado em Estatística e Experimentação Agropecuária) | Universidade Federal de Lavras, Lavras, 2017
data("crd_simulated") #Geodata object geodados <- as.geodata(crd_simulated, coords.col = 1:2, data.col = 3, covar.col = 4) h_max <- summary(geodados)[[3]][[2]] dist <- 0.6*h_max # Computing the variogram variograma <- spVariog(geodata = geodados, trend = "cte", max.dist = dist, design = "crd", scale = FALSE) plot(variograma, ylab = "Semivariance", xlab = "Distance") # Gaussian Model ols <- spVariofit(variograma, cov.model = "gaussian", weights = "equal", max.dist = dist) lines(ols, col = 1) # Compute the model and get the analysis of variance table mod <- aovGeo(ols, cutoff = 0.6) # Tukey's HSD spTukey(mod)
data("crd_simulated") #Geodata object geodados <- as.geodata(crd_simulated, coords.col = 1:2, data.col = 3, covar.col = 4) h_max <- summary(geodados)[[3]][[2]] dist <- 0.6*h_max # Computing the variogram variograma <- spVariog(geodata = geodados, trend = "cte", max.dist = dist, design = "crd", scale = FALSE) plot(variograma, ylab = "Semivariance", xlab = "Distance") # Gaussian Model ols <- spVariofit(variograma, cov.model = "gaussian", weights = "equal", max.dist = dist) lines(ols, col = 1) # Compute the model and get the analysis of variance table mod <- aovGeo(ols, cutoff = 0.6) # Tukey's HSD spTukey(mod)
Fit a parametric model to a variogram created by the function spVariog.
spVariofit(x, ...)
spVariofit(x, ...)
x |
an object of class |
... |
further arguments to be passed to |
This function is a wrapper to variofit
and can be used to fit a
parametric model to a variogram using either ordinary least squares or weighted least squares.
It takes as the main argument a spVariog object and others arguments should be passed
to ...
such as "cov.model" and so on.
an object of class SpVariofit
which is a list containing the following
components:
mod |
an object of class |
data.geo |
an object of class geodata |
des.mat |
the design matrix |
trend |
a character specifying the type of spatial trend |
data("crd_simulated") dados <- crd_simulated #Geodata object geodados <- as.geodata(dados, coords.col = 1:2, data.col = 3, covar.col = 4) h_max <- summary(geodados)[[3]][[2]] dist <- 0.6*h_max # Computing the variogram variograma <- spVariog(geodata = geodados, trend = "cte", max.dist = dist, design = "crd", scale = FALSE) plot(variograma, ylab = "Semivariance", xlab = "Distance") # Spherical Model ols1 <- spVariofit(variograma, cov.model = "spherical", weights = "equal", max.dist = dist) lines(ols1)
data("crd_simulated") dados <- crd_simulated #Geodata object geodados <- as.geodata(dados, coords.col = 1:2, data.col = 3, covar.col = 4) h_max <- summary(geodados)[[3]][[2]] dist <- 0.6*h_max # Computing the variogram variograma <- spVariog(geodata = geodados, trend = "cte", max.dist = dist, design = "crd", scale = FALSE) plot(variograma, ylab = "Semivariance", xlab = "Distance") # Spherical Model ols1 <- spVariofit(variograma, cov.model = "spherical", weights = "equal", max.dist = dist) lines(ols1)
Compute empirical residual variogram for a Completely Randomized Design (CRD) or a Randomized Complete Block Design (RCBD) by a call to variog function of the package geoR.
spVariog(geodata, resp = NULL, treat = NULL, block = NULL, coords = NULL, data = NULL, trend = c("cte", "1st"), scale = FALSE, max.dist, design = c("crd", "rcbd"), ...)
spVariog(geodata, resp = NULL, treat = NULL, block = NULL, coords = NULL, data = NULL, trend = c("cte", "1st"), scale = FALSE, max.dist, design = c("crd", "rcbd"), ...)
geodata |
an object of class |
resp |
either a vector of response variables or a character giving the column name where it can be found in 'data'. Optional argument, just required if geodata is not provided. |
treat |
either a vector of treatment factors or a character giving the column name where it can be found in 'data'. Optional argument, just required if geodata is not provided. |
block |
either a vector of block factors or a character giving the column name where it can be found in 'data'. Optional argument, just required if geodata is not provided. |
coords |
either a 2-column matrix containing the spatial coordinates or a character vector giving the columns name where the coordinates can be found in 'data'. Optional argument, just required if geodata is not provided. |
data |
a data frame in which the variables specified as characters will be found. Optional argument, just required if geodata is not provided. |
trend |
type of spatial trend considered. |
scale |
logical argument. Should the coordinates be scaled? We recommend this argument to be set as TRUE if your spatial coordinates have high values as in UTM coordinate system otherwise, you could get errors in the calculations. See ‘Details’. |
max.dist |
numerical value defining the maximum distance for the variogram.
See |
design |
type of experimental design. "crd" corresponds to Completely Randomized Design and "rcbd" corresponds to Randomized Complete Block Design. |
... |
further arguments to be passed to |
This function provides a wrapper to variog to compute residual variogram for experimental designs. The residuals are obtained by
where Y is the vector of response, X is the design matrix built according to the experimental design
chosen, and is the vector of coefficients estimated by the linear model.
If scale = TRUE the spatial coordinates will be scaled for numerical reasons. The scale is made by subtracting the minimum spatial coordinate value from all others.
An object of class spVariog which is a list with the following components:
vario.res |
an object of class variogram |
data.geo |
an object of class geodata |
des.mat |
the design matrix |
trend |
a character specifying the type of spatial trend |
data("crd_simulated") dados <- crd_simulated #Geodata object geodados <- as.geodata(dados, coords.col = 1:2, data.col = 3, covar.col = 4) h_max <- summary(geodados)[[3]][[2]] dist <- 0.6*h_max # Computing the variogram variograma <- spVariog(geodata = geodados, trend = "cte", max.dist = dist, design = "crd", scale = FALSE) plot(variograma, ylab = "Semivariance", xlab = "Distance")
data("crd_simulated") dados <- crd_simulated #Geodata object geodados <- as.geodata(dados, coords.col = 1:2, data.col = 3, covar.col = 4) h_max <- summary(geodados)[[3]][[2]] dist <- 0.6*h_max # Computing the variogram variograma <- spVariog(geodata = geodados, trend = "cte", max.dist = dist, design = "crd", scale = FALSE) plot(variograma, ylab = "Semivariance", xlab = "Distance")