summary.compare_numeric: Summarizing compare_numeric information

summary.compare_numericR Documentation

Summarizing compare_numeric information

Description

print and summary method for "compare_numeric" class.

Usage

## S3 method for class 'compare_numeric'
summary(
  object,
  method = c("all", "correlation", "linear"),
  thres_corr = 0.3,
  thres_rs = 0.1,
  verbose = TRUE,
  ...
)

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

Arguments

object

an object of class "compare_numeric", usually, a result of a call to compare_numeric().

method

character. Select statistics to be aggregated. "correlation" calculates the Pearson's correlation coefficient, and "linear" returns the aggregation of the linear model. "all" returns both information. However, the difference between summary.compare_numeric() and compare_numeric() is that only cases that are greater than the specified threshold are returned. "correlation" returns only cases with a correlation coefficient greater than the thres_corr argument value. "linear" returns only cases with R^2 greater than the thres_rs argument.

thres_corr

numeric. This is the correlation coefficient threshold of the correlation coefficient information to be returned. The default is 0.3.

thres_rs

numeric. R^2 threshold of linear model summaries information to return. The default is 0.1.

verbose

logical. Specifies whether to output additional information during the calculation process. The default is to output information as TRUE. In this case, the function returns the value with invisible(). If FALSE, the value is returned by return().

...

further arguments passed to or from other methods.

x

an object of class "compare_numeric", usually, a result of a call to compare_numeric().

Details

print.compare_numeric() displays only the information compared between the variables included in compare_numeric. When using summary.compare_numeric(), it is advantageous to set the verbose argument to TRUE if the user is only viewing information from the console. It is also advantageous to specify FALSE if you want to manipulate the results.

Value

An object of the class as compare based list. The information to examine the relationship between numerical variables is as follows each components. - correlation component : Pearson's correlation coefficient.

  • var1 : factor. The level of the first variable to compare. 'var1' is the name of the first variable to be compared.

  • var2 : factor. The level of the second variable to compare. 'var2' is the name of the second variable to be compared.

  • coef_corr : double. Pearson's correlation coefficient.

- linear component : linear model summaries

  • var1 : factor. The level of the first variable to compare. 'var1' is the name of the first variable to be compared.

  • var2 : factor. The level of the second variable to compare. 'var2' is the name of the second variable to be compared.

  • r.squared : double. The percent of variance explained by the model.

  • adj.r.squared : double. r.squared adjusted based on the degrees of freedom.

  • sigma : double. The square root of the estimated residual variance.

  • statistic : double. F-statistic.

  • p.value : double. p-value from the F test, describing whether the full regression is significant.

  • df : integer degrees of freedom.

  • logLik : double. the log-likelihood of data under the model.

  • AIC : double. the Akaike Information Criterion.

  • BIC : double. the Bayesian Information Criterion.

  • deviance : double. deviance.

  • df.residual : integer residual degrees of freedom.

See Also

plot.compare_numeric.

Examples


# Generate data for the example
heartfailure2 <- heartfailure[, c("platelets", "creatinine", "sodium")]

library(dplyr)
# Compare the all numerical variables
all_var <- compare_numeric(heartfailure2)

# Print compare_numeric class object
all_var

# Compare the correlation that case of joint the sodium variable
all_var %>% 
  "$"(correlation) %>% 
  filter(var1 == "sodium" | var2 == "sodium") %>% 
  arrange(desc(abs(coef_corr)))
  
# Compare the correlation that case of abs(coef_corr) > 0.1
all_var %>% 
  "$"(correlation) %>% 
  filter(abs(coef_corr) > 0.1)
  
# Compare the linear model that case of joint the sodium variable  
all_var %>% 
  "$"(linear) %>% 
  filter(var1 == "sodium" | var2 == "sodium") %>% 
  arrange(desc(r.squared))
  
# Compare the two numerical variables
two_var <- compare_numeric(heartfailure2, sodium, creatinine)

# Print compare_numeric class objects
two_var
  
# Summary the all case : Return a invisible copy of an object.
stat <- summary(all_var)

# Just correlation
summary(all_var, method = "correlation")

# Just correlation condition by r > 0.1
summary(all_var, method = "correlation", thres_corr = 0.1)

# linear model summaries condition by R^2 > 0.05
summary(all_var, thres_rs = 0.05)

# verbose is FALSE 
summary(all_var, verbose = FALSE)



choonghyunryu/dlookr documentation built on June 11, 2024, 9:12 a.m.