Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spatial autocorrelation in rda #567

Open
aguilart opened this issue Feb 23, 2023 · 1 comment
Open

Spatial autocorrelation in rda #567

aguilart opened this issue Feb 23, 2023 · 1 comment

Comments

@aguilart
Copy link

I am wondering what is the best way to take into account spatial autocorrelation in RDA. My best attempt has been as follows:

data(mite)
data(mite.xy)

# Doing pcm on the coordinate data
mite.pcnm <- as.data.frame(scores(pcnm(dist(mite.xy))))

# doing the RDA
mite.var <- rda(mite ~ Condition(mite.pcnm$PCNM1, mite.pcnm$PCNM2))

It is a bit complicated that under Condition I have to write each PCNM axis, but I have not found a way to put the whole dataframe.

Is this approach valid?

Thanks

CA

@jarioksa
Copy link
Contributor

Yes, this is clumsy. However, there may be some shortcuts:

  1. Condition() accepts matrix argument (instead of data frame). Formulae mite ~ Condition(as.matrix(mite.pcnm)) or mite ~ Condition(as.matrix(mite.pcnm)[, 1:2]) should work.
  2. If formula interface is not used, input matrices can be data frames which are expanded to model matrices, or matrices which are handled like they are. If you only have partial terms, the constraints can be empty: rda(mite, , mite.pcnm) or rda(mite, , pcnm[, 1:2]).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants