CutCI: Calculate confidence intervals for grouped values

Description Usage Arguments Details Value See Also Examples

View source: R/maCorrPlot.R

Description

CutCI groups values of one variable into intervals with the same number of observations each and computes confidence intervals for the mean of another variable in each interval.

CIrho computes the normal theory confidence interval for a vector of values.

Usage

1
2
3
CutCI(dat, number = 10, func = mean, alpha=0.95)

CIrho(rho, alpha = 0.95)

Arguments

dat

a numerical data frame or matrix with two columns, the first of which gets averaged, and the second of which defines the grouping

number

the number of equal-count intervals

func

summary function for computing the mean

rho

a vector of measurements

alpha

the desired confidence level

Details

The quantiles for the confidence interval are taken from the standard normal distribution, so a reasonable number of observations per interval would be good.

Value

CutCI returns invisibly a list of length three:

x

the midpoints of the grouping intervals

y

the means within each interval, as computed by func

yci

a matrix with two columns, giving the lower and upper end of the confidence interval respectively

CIrho returns a vector of length two, containing the lower and upper end of the confidence interval.

See Also

co.intervals

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
x = rnorm(100, mean=2)
CIrho(x)

y = 2 + 3*x + rnorm(100)
cc = CutCI(cbind(x,y), number=5)
print(cc)

# Show it
plot(cc$x, cc$y)
arrows(cc$x, cc$yci[,1], cc$x, cc$yci[,2], length=0)

maCorrPlot documentation built on Nov. 8, 2020, 5:06 p.m.