cor.holdout | R Documentation |
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
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, ...)
x , y |
Numeric vectors of variables to correlate.
In case of the print function, |
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. |
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.
Sercan Kahveci
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.