Learn R Programming

descstat (version 0.1-2)

bivariate: Functions to compute statistics on bivariate distributions

Description

These functions are intended to compute from a cont_table objects covariation statistics, ie the covariance, the correlation coefficient, variance decomposition and regression line.

Usage

covariance(data, ...)

correlation(data, ...)

# S3 method for cont_table covariance(data, ...)

# S3 method for cont_table correlation(data, ...)

# S3 method for cont_table anova(object, x, ...)

# S3 method for anova.cont_table summary(object, ...)

regline(formula, data)

Arguments

data, object

a cont_table object,

...

further arguments.

x

the series for which the analyse of variance should be computed,

formula

symbolic description of the model,

Value

a numeric or a tibble

Examples

Run this code
# NOT RUN {
# the covariance and the linear correlation coefficient are
# computed using only the `cont_table`
# First reduce the number of bins
wages2 <- wages %>%
          dplyr::mutate(size = cut(as_bin(size), c(20, 50, 100)),
                        wage = cut(as_bin(wage), c(10, 30, 50)))
wages2 %>% cont_table(wage, size) %>% covariance
wages2 %>% cont_table(wage, size) %>% correlation
# For the analyse of variance, one of the two series should be
# indicated
wages2 %>% cont_table(wage, size) %>% anova(wage)
wages2 %>% cont_table(wage, size) %>% anova(wage) %>% summary
# For the regression line, a formula should be provided
wages2 %>% cont_table(wage, size) %>% regline(formula = wage ~ size)
# }

Run the code above in your browser using DataLab