vignettes/demo-one-dim-location.Rmd
demo-one-dim-location.Rmd
We have two objectives 1. Demonstrate how SpatPCA captures the most dominant spatial pattern of variation based on different signal-to-noise ratios. 2. Represent how to use SpatPCA for one-dimensional data
We want to generate 100 random sample based on - The spatial signal for the true spatial pattern is distributed normally with - The noise follows the standard normal distribution.
We can see simulated central realizations change in a wide range more frequently than the others.
SpatPCA::spatpca
cv <- spatpca(x = position, Y = realizations)
eigen_est <- cv$eigenfn
It is hard to see a crystal clear spatial pattern via the simulated sample shown below.
The following panel indicates that SpatPCA outperforms to PCA visually when the signal-to-noise ratio is quite lower.
cv <- spatpca(x = position, Y = realizations)
eigen_est <- cv$eigenfn
data.frame(
position = position,
true = true_eigen_fn,
spatpca = eigen_est[, 1],
pca = svd(realizations)$v[, 1]
) %>%
gather(estimate, eigenfunction, -position) %>%
ggplot(aes(x = position, y = eigenfunction, color = estimate)) +
geom_line() +
base_theme