cor.holdout: Correlation holdouts

View source: R/holdout.R

cor.holdoutR Documentation

Correlation holdouts

Description

Repeatedly remove the observation whose removal will most strongly move the correlation coefficient to zero, until it is either no longer significant or has changed its sign

Usage

cor.holdout(
  x,
  y,
  goal = c("nsig", "flip"),
  method = c("pearson", "spearman"),
  alpha = 0.05,
  verbose = FALSE
)

## S3 method for class 'cor.holdout'
print(x, ...)

Arguments

x, y

Numeric vectors of variables to correlate. In case of the print function, x is a cor.holdout object to print.

goal

Objective of observation removal: "nsig" (no longer significant) or "flip" (change of sign).

method

Correlation method, either "pearson" or "spearman"

alpha

Alpha level for significance testing

verbose

Should the function generate verbose output? Defaults to FALSE.

...

Ignored.

Value

A list with... - h: number of observations needed to reach objective - h.prop: h but as a percentage of the total degrees of freedom (total number of observations - 2) - final.r: the correlation after removal of observations - final.p: the p value after removal of observations - omit: integer vector denoting which observations were omitted at which iteration to obtain the result. A zero value indicates that the observation was excluded beforehand due to presence of NAs.

Author(s)

Sercan Kahveci

Examples


xval<-rnorm(100)

# Flip sign
cor.holdout(x=rnorm(100)+xval,y=rnorm(100)+xval,goal="flip")

# Make insignificant
cor.holdout(x=rnorm(100)+xval,y=rnorm(100)+xval,goal="nsig",method="spearman")

# No true correlation
cor.holdout(x=rnorm(100),y=rnorm(100),goal="nsig")


Spiritspeak/skMisc documentation built on April 12, 2025, 5:40 a.m.