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

Local moran with NA #45

Open
sayala-spepi opened this issue Feb 4, 2024 · 2 comments
Open

Local moran with NA #45

sayala-spepi opened this issue Feb 4, 2024 · 2 comments

Comments

@sayala-spepi
Copy link

How Geoda calculates the local moran with NA values, because Rgeoda does not allow it because it cannot calculate with NA. What extra process does Geoda have than Rgeoda?

@lixun910
Copy link
Member

lixun910 commented Feb 4, 2024

I think it will take care of the NA values under the hood: see

rgeoda/src/rcpp_lisa.cpp

Lines 129 to 145 in 94c17da

SEXP p_localmoran(SEXP xp_w, NumericVector data, int permutations, std::string permutation_method, double significance_cutoff, int cpu_threads, int seed)
{
// grab the object as a XPtr (smart pointer) to GeoDaWeight
Rcpp::XPtr<GeoDaWeight> ptr(xp_w);
GeoDaWeight* w = static_cast<GeoDaWeight*> (R_ExternalPtrAddr(ptr));
int n = data.size();
std::vector<double> raw_data(n);
std::vector<bool> undefs(n, false);
for (int i=0; i< data.size(); ++i) {
raw_data[i] = data[i];
undefs[i] = data.is_na(i);
}
LISA* lisa = gda_localmoran(w, raw_data, undefs, significance_cutoff, cpu_threads, permutations, permutation_method, seed);
so there is no extra process needed.

@sayala-spepi
Copy link
Author

yes, but in line 141 undefs[i] = data.is_na(i); treats them to leave them out. In Rgeoda there is no line to treat the NA. Maybe that can make a difference

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