# simulate dummy data
map.width = 5 # square map width
coords = expand.grid(x = 1:map.width, y = 1:map.width) # coordinate matrix
# calculate distance
D = geosphere::distm(coords) # distance matrix
# visualize covariance matrix
image(covar_taper(D, theta = .5*max(D)))
# plot tapered covariance function
curve(covar_taper(x, theta = .5), from = 0, to = 1);abline(v = 0.5, lty = 2, col = "grey80")
# visualize covariance matrix
image(covar_exp(D, range = .2*max(D)))
# plot exponential function with different ranges
curve(covar_exp(x, range = .2), from = 0, to = 1)
curve(covar_exp(x, range = .1), from = 0, to = 1, col = "blue", add = TRUE)
legend("topright", legend = c("range = 0.2", "range = 0.1"), col = c("black", "blue"), lty = 1)
# visualize Exponential covariance matrix
image(covar_exppow(D, range = .2*max(D), shape = 1))
# visualize Exponential-power covariance matrix
image(covar_exppow(D, range = .2*max(D), shape = .5))
# plot exponential power function with different shapes
curve(covar_exppow(x, range = .2, shape = 1), from = 0, to = 1)
curve(covar_exppow(x, range = .2, shape = .5), from = 0, to = 1, col = "blue", add = TRUE)
legend("topright", legend = c("shape = 1.0", "shape = 0.5"), col = c("black", "blue"), lty = 1)
Run the code above in your browser using DataLab