bruceR
bruceR包中函数相对基本函数提供了更多的模型输出参数,如效应值等。
加载bruceR
library(bruceR)
## Warning: package 'bruceR' was built under R version 4.0.5
##
## <U+0001F381> bruceR: BRoadly Useful Convenient and Efficient R functions
##
## Loaded R packages:
## [Data]: rio / dplyr / tidyr / stringr / forcats / data.table
## [Stat]: psych / emmeans / effectsize / performance
## [Plot]: ggplot2 / ggtext / cowplot / see
##
## Frequently used functions in `bruceR`:
## set.wd() / Describe() / Freq() / Corr() / Alpha() / MEAN()
## MANOVA() / EMMEANS() / model_summary() / theme_bruce()
描述统计
Describe(iris,all.as.numeric = F,plot=T,upper.triangle = T,upper.smooth = "lm")
## Descriptive Statistics:
## ────────────────────────────────────────────────────────────────
## N Mean SD | Median Min Max Skewness Kurtosis
## ────────────────────────────────────────────────────────────────
## Sepal.Length 150 5.84 0.83 | 5.80 4.30 7.90 0.31 -0.61
## Sepal.Width 150 3.06 0.44 | 3.00 2.00 4.40 0.31 0.14
## Petal.Length 150 3.76 1.77 | 4.35 1.00 6.90 -0.27 -1.42
## Petal.Width 150 1.20 0.76 | 1.30 0.10 2.50 -0.10 -1.36
## Species* 150 2.00 0.82 | 2.00 1.00 3.00 0.00 -1.52
## ────────────────────────────────────────────────────────────────
## Registered S3 method overwritten by 'GGally':
## method from
## +.gg ggplot2
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
相关分析
iris_cor <- iris %>% select(-Species) %>%
Corr(method="pearson",p.adjust="fdr",plot.palette = c("red", "white", "blue"))
## Correlation matrix is displayed in plot.
## p values ABOVE the diagonal are adjusted using the "fdr" method.
## Pearson's r and 95% confidence intervals:
## p values and 95% CIs are adjusted using the "fdr" method.
## ─────────────────────────────────────────────────────────────
## r [95% CI] p N
## ─────────────────────────────────────────────────────────────
## Sepal.Length-Sepal.Width -0.12 [-0.32, 0.10] .152 150
## Sepal.Length-Petal.Length 0.87 [ 0.81, 0.92] <.001 *** 150
## Sepal.Length-Petal.Width 0.82 [ 0.73, 0.88] <.001 *** 150
## Sepal.Width-Petal.Length -0.43 [-0.59, -0.24] <.001 *** 150
## Sepal.Width-Petal.Width -0.37 [-0.54, -0.16] <.001 *** 150
## Petal.Length-Petal.Width 0.96 [ 0.94, 0.98] <.001 *** 150
## ─────────────────────────────────────────────────────────────
相关系数差异比较
###独立检验 Sepal.Length~Petal.Length vs Petal.Width~Sepal.Width
cor_diff(r1=0.87, n1=150, r2=-0.37, n2=150)
## r1 = 0.870 (N = 150)
## r2 = -0.370 (N = 150)
## Difference of correlation: z = 14.76, p = 3e-49 ***
### 非独立检验Sepal.Length~Petal.Length vs Petal.Width~Petal.Length
cor_diff(r1=0.87, r2=0.96, n=150,rcov=0.82)
## r1 = 0.870
## r2 = 0.960
## (N = 150, r_cov = 0.820)
## Difference of correlation: t(147) = -7.14, p = 4e-11 ***
交叉相关分析
# 用于分析时间序列数据,以发现是否存在时间延迟
ccf_plot(Petal.Length~Sepal.Width,data=iris)
频率分析
Freq(iris$Species)
## Frequency Statistics:
## ───────────────────
## N %
## ───────────────────
## setosa 50 33.3
## versicolor 50 33.3
## virginica 50 33.3
## ───────────────────
## Total N = 150
Freq(iris$Sepal.Length,sort="+")
## Frequency Statistics:
## ───────────
## N %
## ───────────
## 4.3 1 0.7
## 4.5 1 0.7
## 5.3 1 0.7
## 7 1 0.7
## 7.1 1 0.7
## 7.3 1 0.7
## 7.4 1 0.7
## 7.6 1 0.7
## 7.9 1 0.7
## 4.7 2 1.3
## 6.6 2 1.3
## 4.4 3 2.0
## 5.9 3 2.0
## 6.8 3 2.0
## 7.2 3 2.0
## 4.6 4 2.7
## 5.2 4 2.7
## 6.2 4 2.7
## 6.9 4 2.7
## 7.7 4 2.7
## 4.8 5 3.3
## 6.5 5 3.3
## 4.9 6 4.0
## 5.4 6 4.0
## 5.6 6 4.0
## 6 6 4.0
## 6.1 6 4.0
## 5.5 7 4.7
## 5.8 7 4.7
## 6.4 7 4.7
## 5.7 8 5.3
## 6.7 8 5.3
## 5.1 9 6.0
## 6.3 9 6.0
## 5 10 6.7
## ───────────
## Total N = 150
回归分析
mtcars<-as_tibble(mtcars)
mtcars
## # A tibble: 32 x 11
## mpg cyl disp hp drat wt qsec vs am gear carb
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4
## 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4
## 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1
## 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
## 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
## 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1
## 7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4
## 8 24.4 4 147. 62 3.69 3.19 20 1 0 4 2
## 9 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2
## 10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4
## # ... with 22 more rows
简单线性回归
lm(mpg~wt*disp,data=mtcars)%>%
GLM_summary()
## MODEL INFO:
## Model type: General Linear Model (GLM) (OLS Regression)
## Observations: N = 32
##
## MODEL FIT:
## F(3, 28) = 52.95, p = 1e-11 ***
## R2 = 0.85014 (Adjusted R2 = 0.83408)
##
## FIXED EFFECTS:
## Outcome variable: mpg (N = 32)
## ───────────────────────────────────────────────────────────────────
## b S.E. t p [95% CI of b] VIF
## ───────────────────────────────────────────────────────────────────
## (Intercept) 44.082 (3.123) 14.11 <.001 *** [37.685, 50.479]
## wt -6.496 (1.313) -4.95 <.001 *** [-9.186, -3.805] 8.495
## disp -0.056 (0.013) -4.26 <.001 *** [-0.083, -0.029] 13.848
## wt:disp 0.012 (0.003) 3.60 .001 ** [ 0.005, 0.018] 24.294
## ───────────────────────────────────────────────────────────────────
##
## Standardized coefficients: mpg (N = 32)
## ─────────────────────────────────────────────────────────────
## Beta* S.E.* [95% CI of Beta] r.partial r.part
## ─────────────────────────────────────────────────────────────
## wt -1.055 (0.213) *** [-1.491, -0.618] -0.683 -0.362
## disp -1.159 (0.272) *** [-1.717, -0.601] -0.627 -0.311
## wt:disp 1.297 (0.361) ** [ 0.558, 2.035] 0.562 0.263
## ─────────────────────────────────────────────────────────────
lm(mpg~wt*disp,data=mtcars)%>%
model_summary(std_coef=F)
##
## =======================
## (1) mpg
## -----------------------
## (Intercept) 44.082 ***
## (3.123)
## wt -6.496 ***
## (1.313)
## disp -0.056 ***
## (0.013)
## wt:disp 0.012 **
## (0.003)
## -----------------------
## R^2 0.850
## Adj. R^2 0.834
## Num. obs. 32
## =======================
## Note. * p < .05, ** p < .01, *** p < .001.
##
## # Check for Multicollinearity
##
## Moderate Correlation
##
## Term VIF Increased SE Tolerance
## wt 8.49 2.91 0.12
##
## High Correlation
##
## Term VIF Increased SE Tolerance
## disp 13.85 3.72 0.07
## wt:disp 24.29 4.93 0.04
# one step
regress(mpg ~ wt*disp, data=mtcars, robust=F)
## MODEL INFO:
## Model type: General Linear Model (GLM) (OLS Regression)
## Observations: N = 32
##
## MODEL FIT:
## F(3, 28) = 52.95, p = 1e-11 ***
## R2 = 0.85014 (Adjusted R2 = 0.83408)
##
## FIXED EFFECTS:
## Outcome variable: mpg (N = 32)
## ───────────────────────────────────────────────────────────────────
## b S.E. t p [95% CI of b] VIF
## ───────────────────────────────────────────────────────────────────
## (Intercept) 44.082 (3.123) 14.11 <.001 *** [37.685, 50.479]
## wt -6.496 (1.313) -4.95 <.001 *** [-9.186, -3.805] 8.495
## disp -0.056 (0.013) -4.26 <.001 *** [-0.083, -0.029] 13.848
## wt:disp 0.012 (0.003) 3.60 .001 ** [ 0.005, 0.018] 24.294
## ───────────────────────────────────────────────────────────────────
##
## Standardized coefficients: mpg (N = 32)
## ─────────────────────────────────────────────────────────────
## Beta* S.E.* [95% CI of Beta] r.partial r.part
## ─────────────────────────────────────────────────────────────
## wt -1.055 (0.213) *** [-1.491, -0.618] -0.683 -0.362
## disp -1.159 (0.272) *** [-1.717, -0.601] -0.627 -0.311
## wt:disp 1.297 (0.361) ** [ 0.558, 2.035] 0.562 0.263
## ─────────────────────────────────────────────────────────────
# tidy style
lm(mpg~wt*disp,data=mtcars)%>%broom::tidy()
## Registered S3 methods overwritten by 'broom':
## method from
## tidy.glht jtools
## tidy.summary.glht jtools
## # A tibble: 4 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) 44.1 3.12 14.1 2.96e-14
## 2 wt -6.50 1.31 -4.95 3.22e- 5
## 3 disp -0.0564 0.0132 -4.26 2.10e- 4
## 4 wt:disp 0.0117 0.00326 3.60 1.23e- 3
lm(mpg~wt*disp,data=mtcars)%>%broom::glance()
## # A tibble: 1 x 12
## r.squared adj.r.squared sigma statistic p.value df logLik AIC BIC
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0.850 0.834 2.45 52.9 1.16e-11 3 -72.0 154. 161.
## # ... with 3 more variables: deviance <dbl>, df.residual <int>, nobs <int>
混合模型
regress(mpg ~ wt*disp+(1|cyl), data=mtcars, robust=F)
## boundary (singular) fit: see ?isSingular
## MODEL INFO:
## Model type: Linear Mixed Model (LMM)
## = Hierarchical Linear Model (HLM)
## = Multilevel Linear Model (MLM)
##
## Formula: mpg ~ wt * disp + (1 | cyl)
## Level-2 predictors: ''
##
## Variable Type
## (Intercept) Intercept
## wt L1fixed
## disp L1fixed
## wt:disp L1fixed
##
## Level-1 Observations: N = 32
## Level-2 Groups/Clusters: cyl, 3
##
## MODEL FIT:
## AIC = 173.382
## BIC = 182.176
## R_(m)2 = 0.83671 (Marginal R2: fixed effects)
## R_(c)2 = 0.83671 (Conditional R2: fixed + random effects)
## Omega2 = 0.85014 (= 1 - proportion of unexplained variance)
##
## ANOVA table:
## ───────────────────────────────────────────────────
## Sum Sq Mean Sq NumDF DenDF F p
## ───────────────────────────────────────────────────
## wt 147.42 147.42 1 28.00 24.46 <.001 ***
## disp 109.22 109.22 1 28.00 18.12 <.001 ***
## wt:disp 77.93 77.93 1 28.00 12.93 .001 **
## ───────────────────────────────────────────────────
##
## FIXED EFFECTS:
## Outcome variable: mpg
## ─────────────────────────────────────────────────────────────────
## b S.E. t df p [95% CI of b]
## ─────────────────────────────────────────────────────────────────
## (Intercept) 44.082 (3.123) 14.11 28.0 <.001 *** [37.685, 50.479]
## wt -6.496 (1.313) -4.95 28.0 <.001 *** [-9.186, -3.805]
## disp -0.056 (0.013) -4.26 28.0 <.001 *** [-0.083, -0.029]
## wt:disp 0.012 (0.003) 3.60 28.0 .001 ** [ 0.005, 0.018]
## ─────────────────────────────────────────────────────────────────
## 'df' is estimated by Satterthwaite approximation.
##
## Standardized coefficients: mpg
## ────────────────────────────────────────────────────────────
## Beta* S.E.* t* df* p* [95% CI of Beta]
## ────────────────────────────────────────────────────────────
## wt -1.055 (0.213) -4.95 28 <.001 *** [-1.491, -0.618]
## disp -1.159 (0.272) -4.26 28 <.001 *** [-1.717, -0.601]
## wt:disp 1.297 (0.361) 3.60 28 .001 ** [ 0.558, 2.035]
## ────────────────────────────────────────────────────────────
## 'df*' is calculated based on variable types.
##
## RANDOM EFFECTS:
## ──────────────────────────────────────────
## Cluster K Parameter Variance ICC
## ──────────────────────────────────────────
## cyl 3 (Intercept) 0.00000 0.00000
## Residual 6.02673
## ──────────────────────────────────────────
方差分析
单因素组间方差分析 one-way ANOVA
iris %>% MANOVA(dv="Sepal.Width", between=c("Species")) %>%
EMMEANS("Species")
## ====== MANOVA Output (Between-Subjects Design) ======
##
## Descriptive Statistics:
## ────────────────────────
## Species M SD n
## ────────────────────────
## setosa 3.43 0.38 50
## versicolor 2.77 0.31 50
## virginica 2.97 0.32 50
## ────────────────────────
## Total sample size: N = 150
##
## ANOVA Table:
## Dependent variable(s): Sepal.Width
## Between-subjects factor(s): Species
## Within-subjects factor(s): –
## Covariate(s): –
## ────────────────────────────────────────────────────────────
## MS MSE df1 df2 F p η2p [90% CI]
## ────────────────────────────────────────────────────────────
## Species 5.67 0.12 2 147 49.16 <.001 *** .401 [.300, .485]
## ────────────────────────────────────────────────────────────
## MSE = Mean Square Error (an estimate of population variance σ2).
##
## ω2 = omega-squared = (SS - df1 * MSE) / (SST + MSE)
## η2 = eta-squared = SS / SST
## η2G = generalized eta-squared (see Olejnik & Algina, 2003)
## η2p = partial eta-squared = SS / (SS + SSE) = F * df1 / (F * df1 + df2)
## Cohen’s f = sqrt( η2p / (1 - η2p) )
##
## Levene’s Test for Homogeneity of Variance:
## DV = Sepal.Width:
## Levene's F df1 df2 p sig
## Based on Mean 0.60 2 147 .550
## Based on Median 0.59 2 147 .556
##
## ------ EMMEANS Output (effect = "Species") ------
##
## Omnibus Test of "Species":
## ─────────────────────────────────────────────────────
## Effect df1 df2 F p η2p [90% CI]
## ─────────────────────────────────────────────────────
## Species 2 147 49.16 <.001 *** 0.401 [0.300, 0.485]
## ─────────────────────────────────────────────────────
##
## Estimated Marginal Means of "Species":
## Species Mean S.E. [95% CI of Mean]
## setosa 3.43 (0.05) [3.33, 3.52]
## versicolor 2.77 (0.05) [2.68, 2.86]
## virginica 2.97 (0.05) [2.88, 3.07]
##
## Estimated means use an equally weighted average.
##
## Pairwise Comparisons of "Species":
## Contrast b S.E. df t p* Cohen's d [95% CI]
## versicolor - setosa -0.66 (0.07) 147 -9.69 <.001 *** -1.94 [-2.42, -1.45]
## virginica - setosa -0.45 (0.07) 147 -6.68 <.001 *** -1.34 [-1.82, -0.85]
## virginica - versicolor 0.20 (0.07) 147 3.00 .009 ** 0.60 [ 0.12, 1.08]
##
## SD_pooled for computing Cohen’s d: 0.34
## P-value adjustment: Bonferroni method for 3 tests.
## Disclaimer (about Cohen’s d):
## There is considerable disagreement on how to compute Cohen’s d.
## You should not take the above output as the only right results.
## You are completely responsible for setting the "sd.pooled".
二因素方差分析
# 混合分析
MANOVA(data=CO2,
dv="uptake",
between=c("Type","Treatment")) %>%
EMMEANS(c("Type","Treatment"))
## ====== MANOVA Output (Between-Subjects Design) ======
##
## Descriptive Statistics:
## ─────────────────────────────────────
## Type Treatment M SD n
## ─────────────────────────────────────
## Quebec nonchilled 35.33 9.60 21
## Quebec chilled 31.75 9.64 21
## Mississippi nonchilled 25.95 7.40 21
## Mississippi chilled 15.81 4.06 21
## ─────────────────────────────────────
## Total sample size: N = 84
##
## ANOVA Table:
## Dependent variable(s): uptake
## Between-subjects factor(s): Type, Treatment
## Within-subjects factor(s): –
## Covariate(s): –
## ───────────────────────────────────────────────────────────────────────
## MS MSE df1 df2 F p η2p [90% CI]
## ───────────────────────────────────────────────────────────────────────
## Type 3365.53 64.09 1 80 52.51 <.001 *** .396 [.262, .510]
## Treatment 988.11 64.09 1 80 15.42 <.001 *** .162 [.057, .284]
## Type:Treatment 225.73 64.09 1 80 3.52 .064 . .042 [.000, .135]
## ───────────────────────────────────────────────────────────────────────
## MSE = Mean Square Error (an estimate of population variance σ2).
##
## ω2 = omega-squared = (SS - df1 * MSE) / (SST + MSE)
## η2 = eta-squared = SS / SST
## η2G = generalized eta-squared (see Olejnik & Algina, 2003)
## η2p = partial eta-squared = SS / (SS + SSE) = F * df1 / (F * df1 + df2)
## Cohen’s f = sqrt( η2p / (1 - η2p) )
##
## Levene’s Test for Homogeneity of Variance:
## DV = uptake:
## Levene's F df1 df2 p sig
## Based on Mean 3.36 3 80 .023 *
## Based on Median 1.50 3 80 .221
##
## ------ EMMEANS Output (effect = "Type" & "Treatment") ------
##
## Omnibus Test of "Type" & "Treatment":
## ────────────────────────────────────────────────────────────
## Effect df1 df2 F p η2p [90% CI]
## ────────────────────────────────────────────────────────────
## Type 1 80 52.51 <.001 *** 0.396 [0.262, 0.510]
## Treatment 1 80 15.42 <.001 *** 0.162 [0.057, 0.284]
## Type:Treatment 1 80 3.52 .064 . 0.042 [0.000, 0.135]
## ────────────────────────────────────────────────────────────
##
## Estimated Marginal Means of "Type" & "Treatment":
## Type Treatment Mean S.E. [95% CI of Mean]
## Quebec nonchilled 35.33 (1.75) [31.86, 38.81]
## Mississippi nonchilled 25.95 (1.75) [22.48, 29.43]
## Quebec chilled 31.75 (1.75) [28.28, 35.23]
## Mississippi chilled 15.81 (1.75) [12.34, 19.29]
##
## Estimated means use an equally weighted average.
##
## Pairwise Comparisons of "Type" & "Treatment":
## Contrast b S.E. df t p*
## Mississippi nonchilled - Quebec nonchilled -9.38 (2.47) 80 -3.80 .002 **
## Quebec chilled - Quebec nonchilled -3.58 (2.47) 80 -1.45 .907
## Quebec chilled - Mississippi nonchilled 5.80 (2.47) 80 2.35 .128
## Mississippi chilled - Quebec nonchilled -19.52 (2.47) 80 -7.90 <.001 ***
## Mississippi chilled - Mississippi nonchilled -10.14 (2.47) 80 -4.10 <.001 ***
## Mississippi chilled - Quebec chilled -15.94 (2.47) 80 -6.45 <.001 ***
## Cohen's d [95% CI]
## -1.17 [-2.01, -0.34]
## -0.45 [-1.28, 0.39]
## 0.72 [-0.11, 1.56]
## -2.44 [-3.27, -1.60]
## -1.27 [-2.10, -0.43]
## -1.99 [-2.83, -1.16]
##
## SD_pooled for computing Cohen’s d: 8.01
## P-value adjustment: Bonferroni method for 6 tests.
## Disclaimer (about Cohen’s d):
## There is considerable disagreement on how to compute Cohen’s d.
## You should not take the above output as the only right results.
## You are completely responsible for setting the "sd.pooled".
# 分组简单效应分析,by
MANOVA(data=CO2,
dv="uptake",
between=c("Type","Treatment"))%>%
EMMEANS("Type",by="Treatment")
## ====== MANOVA Output (Between-Subjects Design) ======
##
## Descriptive Statistics:
## ─────────────────────────────────────
## Type Treatment M SD n
## ─────────────────────────────────────
## Quebec nonchilled 35.33 9.60 21
## Quebec chilled 31.75 9.64 21
## Mississippi nonchilled 25.95 7.40 21
## Mississippi chilled 15.81 4.06 21
## ─────────────────────────────────────
## Total sample size: N = 84
##
## ANOVA Table:
## Dependent variable(s): uptake
## Between-subjects factor(s): Type, Treatment
## Within-subjects factor(s): –
## Covariate(s): –
## ───────────────────────────────────────────────────────────────────────
## MS MSE df1 df2 F p η2p [90% CI]
## ───────────────────────────────────────────────────────────────────────
## Type 3365.53 64.09 1 80 52.51 <.001 *** .396 [.262, .510]
## Treatment 988.11 64.09 1 80 15.42 <.001 *** .162 [.057, .284]
## Type:Treatment 225.73 64.09 1 80 3.52 .064 . .042 [.000, .135]
## ───────────────────────────────────────────────────────────────────────
## MSE = Mean Square Error (an estimate of population variance σ2).
##
## ω2 = omega-squared = (SS - df1 * MSE) / (SST + MSE)
## η2 = eta-squared = SS / SST
## η2G = generalized eta-squared (see Olejnik & Algina, 2003)
## η2p = partial eta-squared = SS / (SS + SSE) = F * df1 / (F * df1 + df2)
## Cohen’s f = sqrt( η2p / (1 - η2p) )
##
## Levene’s Test for Homogeneity of Variance:
## DV = uptake:
## Levene's F df1 df2 p sig
## Based on Mean 3.36 3 80 .023 *
## Based on Median 1.50 3 80 .221
##
## ------ EMMEANS Output (effect = "Type") ------
##
## Simple Effects of "Type":
## ─────────────────────────────────────────────────────────────────────────────
## Effect (By: Treatment) df1 df2 F p η2p [90% CI]
## ─────────────────────────────────────────────────────────────────────────────
## Type (Treatment = nonchilled) 1 80 14.42 <.001 *** 0.153 [0.051, 0.275]
## Type (Treatment = chilled) 1 80 41.61 <.001 *** 0.342 [0.208, 0.461]
## ─────────────────────────────────────────────────────────────────────────────
##
## Estimated Marginal Means of "Type":
## Treatment = nonchilled:
## Type Mean S.E. [95% CI of Mean]
## Quebec 35.33 (1.75) [31.86, 38.81]
## Mississippi 25.95 (1.75) [22.48, 29.43]
##
## Treatment = chilled:
## Type Mean S.E. [95% CI of Mean]
## Quebec 31.75 (1.75) [28.28, 35.23]
## Mississippi 15.81 (1.75) [12.34, 19.29]
##
## Estimated means use an equally weighted average.
##
## Pairwise Comparisons of "Type":
## Treatment = nonchilled:
## Contrast b S.E. df t p Cohen's d [95% CI]
## Mississippi - Quebec -9.38 (2.47) 80 -3.80 <.001 *** -1.17 [-1.79, -0.56]
##
## Treatment = chilled:
## Contrast b S.E. df t p Cohen's d [95% CI]
## Mississippi - Quebec -15.94 (2.47) 80 -6.45 <.001 *** -1.99 [-2.60, -1.38]
##
## SD_pooled for computing Cohen’s d: 8.01
## No need to adjust p values.
## Disclaimer (about Cohen’s d):
## There is considerable disagreement on how to compute Cohen’s d.
## You should not take the above output as the only right results.
## You are completely responsible for setting the "sd.pooled".
效应值
lm(Sepal.Length~Sepal.Width+Species,data=iris) %>%
effectsize::effectsize()
## # Standardization method: refit
##
## Parameter | Coefficient (std.) | 95% CI
## -------------------------------------------------------
## (Intercept) | -1.37 | [-1.55, -1.20]
## Sepal.Width | 0.42 | [ 0.31, 0.53]
## Speciesversicolor | 1.76 | [ 1.49, 2.03]
## Speciesvirginica | 2.35 | [ 2.11, 2.59]
aov(Sepal.Length~Sepal.Width+Species,data=iris) %>%
effectsize::effectsize()
## Parameter | Eta2 (partial) | 90% CI
## -------------------------------------------
## Sepal.Width | 0.05 | [0.01, 0.12]
## Species | 0.72 | [0.66, 0.77]
cor.test(iris$Sepal.Length,iris$Sepal.Width) %>%
effectsize::effectsize()
## r | 95% CI
## ---------------------
## -0.12 | [-0.27, 0.04]
BayesFactor::correlationBF(iris$Sepal.Length,iris$Sepal.Width) %>%
effectsize(test=NULL)
## Warning in .recacheSubclasses(def@className, def, env): undefined subclass
## "numericVector" of class "Mnumeric"; definition not updated
## Summary of Posterior Distribution
##
## Parameter | Median | 95% CI
## ----------------------------------
## rho | -0.11 | [-0.27, 0.04]
aov(mpg~wt*disp,data=mtcars) %>% effectsize::effectsize()
## Parameter | Eta2 (partial) | 90% CI
## -----------------------------------------
## wt | 0.83 | [0.73, 0.89]
## disp | 0.16 | [0.01, 0.36]
## wt:disp | 0.32 | [0.10, 0.51]
aov(mpg~wt*disp,data=mtcars) %>% broom::tidy()
## # A tibble: 4 x 6
## term df sumsq meansq statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 wt 1 848. 848. 141. 1.96e-12
## 2 disp 1 31.6 31.6 5.25 2.97e- 2
## 3 wt:disp 1 77.9 77.9 12.9 1.23e- 3
## 4 Residuals 28 169. 6.03 NA NA
BayesFactor::anovaBF(Sepal.Length~Species,data=iris)
## Bayes factor analysis
## --------------
## [1] Species : 1.425293e+28 ±0%
##
## Against denominator:
## Intercept only
## ---
## Bayes factor type: BFlinearModel, JZS
BayesFactor::lmBF(Sepal.Length~Petal.Width+Sepal.Width,data=iris)
## Bayes factor analysis
## --------------
## [1] Petal.Width + Sepal.Width : 3.376503e+36 ±0.01%
##
## Against denominator:
## Intercept only
## ---
## Bayes factor type: BFlinearModel, JZS
BayesFactor::regressionBF(Sepal.Length~Petal.Width+Sepal.Width,data=iris)
## Bayes factor analysis
## --------------
## [1] Petal.Width : 6.575863e+33 ±0.01%
## [2] Sepal.Width : 0.4544437 ±0%
## [3] Petal.Width + Sepal.Width : 3.376503e+36 ±0.01%
##
## Against denominator:
## Intercept only
## ---
## Bayes factor type: BFlinearModel, JZS
mtcars %>% tidyBF::bf_oneway_anova(x=cyl,y=mpg) %>%
select(log_e_bf10,r2)
## # A tibble: 6 x 2
## log_e_bf10 r2
## <dbl> <dbl>
## 1 14.9 0.712
## 2 14.9 0.712
## 3 14.9 0.712
## 4 14.9 0.712
## 5 14.9 0.712
## 6 14.9 0.712
颜色
show_colors(colors=viridis::viridis_pal()(10))
show_colors(colors=ggsci::pal_aaas()(10))
show_colors(RColorBrewer::brewer.pal(name="Set2", n=8))
show_colors(RGB(0, 0, 255))
show_colors("#0000FF")