Description Usage Arguments Value Note Author(s) See Also Examples
Fit model to the empirical variogram
1 2 3 4 5 6 |
vario |
Empirical variogram from |
bins |
Bins or lag distances from |
weights |
Vector of weights of the same length as |
type |
Type of variogram model to fit to the data. Default is |
start.vals |
Named list containing the start values for the variogram model:
|
control |
optional parameter for the |
Return a named list containing the following variables:
vario |
Empirical variogram values |
bins |
Empirical variogram bins/lag distances |
AIC |
AIC score of the model fit: AIC=nlog≤ft(\frac{SSE}{n}\right)+2p where n is the number of points in the variogram, SSE=∑{(\hat{x}_{i}-x_{i}})^2, and p is the number of parameters |
RMSE |
Root Mean Square Error of the model fit: √{\frac{SSE}{n}} |
params |
Named list containing the best model parameter estimates |
fit |
Predicted variogram values from the model fit |
nls.success |
did |
convergence |
did |
Selecting proper initial values is critical for fitting a reasonable model to the
empirical variogram. If these values are off, nls
will fail and fall-back
functions will be used to determine the best parameter values that minimize the
Root Mean Square Error (RMSE).
Tarik C. Gouhier (tarik.gouhier@gmail.com)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | # Load data
data(pisco.data)
# Environmental variogram
d=subset(pisco.data, subset=year==2000, select=c("latitude", "longitude", "upwelling"))
semiv=vario(data=d)
plot(semiv, xlab="Lag distance (km)")
mod.sph=vario.fit(semiv$vario, semiv$mean.bin.dist)
# Weighted least squares fit based on the number of points
mod.exp=vario.fit(semiv$vario, semiv$mean.bin.dist,
weights=semiv$npoints/sum(semiv$npoints),
type="expo")
mod.gau=vario.fit(semiv$vario, semiv$mean.bin.dist, type="gauss")
mod.lin=vario.fit(semiv$vario, semiv$mean.bin.dist, type="lin")
lines(semiv$mean.bin.dist, mod.sph$fit, col="red")
lines(semiv$mean.bin.dist, mod.exp$fit, col="black")
lines(semiv$mean.bin.dist, mod.gau$fit, col="blue")
lines(semiv$mean.bin.dist, mod.lin$fit, col="green")
legend(x="topleft", legend=paste(c("Spherical AIC:", "Exponential AIC:",
"Gaussian AIC:", "Linear AIC:"),
c(format(mod.sph$AIC, dig=2),
format(mod.exp$AIC, dig=2),
format(mod.gau$AIC, dig=2),
format(mod.lin$AIC, dig=2))), lty=1, col=c("red", "black", "blue", "green"),
bty="n")
# Correlogram
cover=subset(pisco.data, subset=year==2000,
select=c("latitude", "longitude", "mussel_abund"))
moran=vario(data=cover, type="moran")
mod.hol=vario.fit(moran$vario, moran$mean.bin.dist,
type="hole", start.vals=list(c0=0.6, a=25, c1=0.01))
mod.per=vario.fit(moran$vario, moran$mean.bin.dist, type="period",
start.vals=list(a=1, b=3, c=0))
mod.lin=vario.fit(moran$vario, moran$mean.bin.dist, type="linear")
plot(moran, xlab="Lag distance (km)", ylim=c(-0.6, 0.8))
lines(moran$mean.bin.dist, mod.per$fit, col="red")
lines(moran$mean.bin.dist, mod.hol$fit, col="black")
lines(moran$mean.bin.dist, mod.lin$fit, col="blue")
legend(x="topleft", legend=paste(c("Periodic AIC:", "Hole AIC:",
"Linear AIC:"),
c(format(mod.per$AIC, dig=2),
format(mod.hol$AIC, dig=2),
format(mod.lin$AIC, dig=2))),
lty=1, col=c("red", "black", "blue"), bty="n")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.