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

spatialSign NA handling [feature suggestion] #789

Closed
unitroot opened this issue Nov 22, 2017 · 1 comment
Closed

spatialSign NA handling [feature suggestion] #789

unitroot opened this issue Nov 22, 2017 · 1 comment

Comments

@unitroot
Copy link

@unitroot unitroot commented Nov 22, 2017

Although imputation is the methodically sound way to go in most cases, sometimes I find myself performing imputations at the very end of pre-processing (mostly with time series). Therefore, it would be nice to have a NA remove feature in the spatialSign function:

"spatialSign.default" <- function(x) { if(is.character(x) | is.factor(x)) stop("spatial sign is not defined for character or factor data") denom <- sum(x^2, na.rm = TRUE) out <- if(sqrt(denom) > .Machine$double.eps) x / sqrt(denom) else x * 0 out }

Conceptually, this is equivalent to treating NAs as zeros, which is very often at least not totally wrong.

topepo added a commit that referenced this issue Nov 26, 2017
@topepo
Copy link
Owner

@topepo topepo commented Nov 26, 2017

Good point! See 4cc54a3.

@topepo topepo closed this Nov 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.