doc du lieu
thuan = read.csv("D:/OneDrive - UMP/00 - 2021 - 2022/00 LVT/23102022THUAN.csv", header=T)
names(thuan)
## [1] "id" "gioi" "nam" "thang" "thamnien" "sinhnam"
## [7] "tuoi" "congviec" "dantoc" "uwes1" "uwes2" "uwes3"
## [13] "uwes4" "uwes5" "uwes6" "uwes7" "uwes8" "uwes9"
## [19] "uwes_tol" "gjs1" "gjs2" "gjs3" "gjs4" "gjs5"
## [25] "gjs6" "gjs7" "gjs8" "gjs9" "gjs10" "gjs_tol"
## [31] "wss1" "wss2" "wss3" "wss4" "wss5" "wss6"
## [37] "wss7" "wss8" "wss_tol" "brcs1" "brcs2" "brcs3"
## [43] "brcs4" "brcs_tol" "brs1" "brs2" "brs3" "brs4"
## [49] "brs5" "brs6" "brs_tol"
Phân tích Bayes các yếu tố nghề nghiệp
attach(thuan)
library(BayesFactor)
## Loading required package: coda
## Loading required package: Matrix
## ************
## Welcome to BayesFactor 0.9.12-4.4. If you have questions, please contact Richard Morey (richarddmorey@gmail.com).
##
## Type BFManual() to open the manual.
## ************
bf = ttestBF(formula = uwes_tol ~ gioi, data=thuan)
bf
## Bayes factor analysis
## --------------
## [1] Alt., r=0.707 : 1.281262 ±0.01%
##
## Against denominator:
## Null, mu1-mu2 = 0
## ---
## Bayes factor type: BFindepSample, JZS
summary(bf)
## Bayes factor analysis
## --------------
## [1] Alt., r=0.707 : 1.281262 ±0.01%
##
## Against denominator:
## Null, mu1-mu2 = 0
## ---
## Bayes factor type: BFindepSample, JZS
Tính mcmc
mcmc = posterior(bf, iter =1000)
summary(mcmc)
##
## Iterations = 1:1000
## Thinning interval = 1
## Number of chains = 1
## Sample size per chain = 1000
##
## 1. Empirical mean and standard deviation for each variable,
## plus standard error of the mean:
##
## Mean SD Naive SE Time-series SE
## mu 37.5596 0.7240 0.02289 0.026340
## beta (1 - 2) 2.9697 1.4360 0.04541 0.051635
## sig2 156.0124 11.8141 0.37359 0.373595
## delta 0.2384 0.1154 0.00365 0.004148
## g 2.0377 10.8137 0.34196 0.341961
##
## 2. Quantiles for each variable:
##
## 2.5% 25% 50% 75% 97.5%
## mu 36.16359 37.0720 37.5474 38.0779 38.9365
## beta (1 - 2) 0.23090 1.9944 2.9437 4.0111 5.7663
## sig2 134.15486 147.9473 155.4785 163.8475 180.6631
## delta 0.01845 0.1606 0.2366 0.3229 0.4655
## g 0.07412 0.2058 0.4349 1.0788 10.8010
Vẽ biểu đồ
plot(mcmc [, 2])

table(mcmc [, 2] <0)
##
## FALSE TRUE
## 985 15
# nam nho hon nu