# Spatial data example
set.seed(42)
spatial_data <- data.frame(
x = runif(100, 0, 100),
y = runif(100, 0, 100),
response = rnorm(100)
)
# Add spatial autocorrelation (nearby points are similar)
for (i in 2:100) {
nearest <- which.min((spatial_data$x[1:(i-1)] - spatial_data$x[i])^2 +
(spatial_data$y[1:(i-1)] - spatial_data$y[i])^2)
spatial_data$response[i] <- 0.7 * spatial_data$response[nearest] +
0.3 * rnorm(1)
}
diagnosis <- borg_diagnose(spatial_data, coords = c("x", "y"),
target = "response")
print(diagnosis)
# Clustered data example
clustered_data <- data.frame(
site = rep(1:10, each = 20),
value = rep(rnorm(10, sd = 2), each = 20) + rnorm(200, sd = 0.5)
)
diagnosis <- borg_diagnose(clustered_data, groups = "site", target = "value")
print(diagnosis)
Run the code above in your browser using DataLab