stats helpers {agsemisc}R Documentation

Misc R statistics helper functions

Description

a.findcorrelations(df, vars1, vars2, min.cor checks pairs of variables for correlation. Returns a sorted vector of pairwise correlations whose absolute value is greater-or-equal min.cor. Uses all pairs of variables from dataframe df mentioned in character vectors (vars1 x vars2), except that is returns only the lower triangle of that matrix if vars2 is missing. Assesses the variable itself and also the corresponding rank vector (for rank correlations) Value pairs containing NAs are ignored in each cor call individually.

a.iqr(x) computes the inter-quartile range of numeric vector x.

a.proportion.test(x1, x2, y1, y2) tests the proportion x1/x2 against y1/y2 using both Fisher exact p and Chi-squared test, prints results of both and returns results of Chi-squared. If totals=TRUE, tests x1/(x2-x1) against y1/(y2-y1) instead. The arguments must be scalars, not vectors.

a.qr(x) computes the quartile ratio (q75/q25) of numeric vector x.

a.rankval(x) ranks the values from vector x using rank() but leaves NAs as NAs.

a.showextremes(df, vars, largest, showalso) shows the records from data frame df that contain the largest largest values (or the largest smallest if largest is negative) with respect to each of df's variables whose name is mentioned in vars (which is a character vector). The extreme records for each of these variables are found; from each record, only these variables plus those whose name is mentioned in character vector showalso are shown.

Usage

a.findcorrelations(df, vars1=names(df), vars2=vars1, min.cor=0.5)

a.iqr(x)

a.proportion.test(x1, x2, y1, y2, totals=FALSE)

a.qr(x)

a.rankval(x)

a.showextremes(df, vars, largest=5, showalso=NULL)

Arguments

df a dataframe, see description above.
vars1 a character vector, see description above.
vars2 a character vector, see description above.
min.cor a number in range 0..1, see description above.
x a vector, see description above.
x1 see description above.
x2 see description above.
y1 see description above.
y2 see description above.
totals a logical value, see description above.
vars a character vector, see description above.
largest an integer, see description above.
showalso a character vector, see description above.

Author(s)

Lutz Prechelt prechelt@inf.fu-berlin.de

Examples

data(iris)
summary(iris$Sepal.Width)
a.iqr(iris$Sepal.Width)
a.qr(iris$Sepal.Width)
a.findcorrelations(iris)
a.proportion.test(7,11, 17,19)
a.showextremes(iris, c("Sepal.Width","Sepal.Length"), largest = -5,
               showalso = c("Petal.Length"))


[Package agsemisc version 1.1-3 Index]