# data from Field et al. (2012, Chapter 16 MANOVA)
DFA_Field=DFA(data = data_DFA$Field_2012,
groups = 'Group',
variables = c('Actions','Thoughts'),
predictive = TRUE,
priorprob = 'EQUAL',
covmat_type='within', # altho better to use 'separate' for these data
verbose = TRUE)
# \donttest{
# plots of posterior probabilities by group
# hoping to see correct separations between cases from different groups
# first, display the posterior probabilities
print(cbind(round(DFA_Field$posteriors[1:3],3), DFA_Field$posteriors[4]))
# group NT vs CBT
plot(DFA_Field$posteriors$posterior_NT, DFA_Field$posteriors$posterior_CBT,
pch = 16, col = c('red', 'blue', 'green')[DFA_Field$posteriors$Group],
xlim=c(0,1), ylim=c(0,1),
main = 'DFA Posterior Probabilities by Original Group Memberships',
xlab='Posterior Probability of Being in Group NT',
ylab='Posterior Probability of Being in Group CBT' )
legend(x=.8, y=.99, c('CBT','BT','NT'), cex=1.2, col=c('red', 'blue', 'green'), pch=16, bty='n')
# group NT vs BT
plot(DFA_Field$posteriors$posterior_NT, DFA_Field$posteriors$posterior_BT,
pch = 16, col = c('red', 'blue', 'green')[DFA_Field$posteriors$Group],
xlim=c(0,1), ylim=c(0,1),
main = 'DFA Posterior Probabilities by Group Membership',
xlab='Posterior Probability of Being in Group NT',
ylab='Posterior Probability of Being in Group BT' )
legend(x=.8, y=.99, c('CBT','BT','NT'), cex=1.2,col=c('red', 'blue', 'green'), pch=16, bty='n')
# group CBT vs BT
plot(DFA_Field$posteriors$posterior_CBT, DFA_Field$posteriors$posterior_BT,
pch = 16, col = c('red', 'blue', 'green')[DFA_Field$posteriors$Group],
xlim=c(0,1), ylim=c(0,1),
main = 'DFA Posterior Probabilities by Group Membership',
xlab='Posterior Probability of Being in Group CBT',
ylab='Posterior Probability of Being in Group BT' )
legend(x=.8, y=.99, c('CBT','BT','NT'), cex=1.2, col=c('red', 'blue', 'green'), pch=16, bty='n')
# data from Green & Salkind (2008, Lesson 35)
DFA(data = data_DFA$Green_2008,
groups = 'job_cat',
variables = c('friendly','gpa','job_hist','job_test'),
plot=TRUE,
predictive = TRUE,
priorprob = 'SIZES',
covmat_type='within',
CV=TRUE,
verbose=TRUE)
# data from Ho (2014, Chapter 15)
# with group_1 as numeric
DFA(data = data_DFA$Ho_2014,
groups = 'group_1_num',
variables = c("fast_ris", "disresp", "sen_seek", "danger"),
plot=TRUE,
predictive = TRUE,
priorprob = 'SIZES',
covmat_type='within',
CV=TRUE,
verbose=TRUE)
# data from Ho (2014, Chapter 15)
# with group_1 as a factor
DFA(data = data_DFA$Ho_2014,
groups = 'group_1_fac',
variables = c("fast_ris", "disresp", "sen_seek", "danger"),
plot=TRUE,
predictive = TRUE,
priorprob = 'SIZES',
covmat_type='within',
CV=TRUE,
verbose=TRUE)
# data from Huberty (2006, p 45)
DFA_Huberty=DFA(data = data_DFA$Huberty_2019_p45,
groups = 'treatmnt_S',
variables = c('Y1','Y2'),
predictive = TRUE,
priorprob = 'SIZES',
covmat_type='separate', # altho better to used 'separate' for these data
verbose = TRUE)
# data from Huberty (2006, p 285)
DFA_Huberty=DFA(data = data_DFA$Huberty_2019_p285,
groups = 'Grade',
variables = c('counsum','gainsum','learnsum','qelib','qefac','qestacq',
'qeamt','qewrite','qesci'),
predictive = TRUE,
priorprob = 'EQUAL',
covmat_type='within',
verbose = TRUE)
# data from Norusis (2012, Chaper 15)
DFA_Norusis=DFA(data = data_DFA$Norusis_2012,
groups = 'internet',
variables = c('age','gender','income','kids','suburban','work','yearsed'),
predictive = TRUE,
priorprob = 'EQUAL',
covmat_type='within',
verbose = TRUE)
# data from Rencher (2002, p 170) - rootstock
DFA(data = data_DFA$Rencher_2002_root,
groups = 'rootstock',
variables = c('girth4','ext4','girth15','weight15'),
predictive = TRUE,
priorprob = 'SIZES',
covmat_type='within',
verbose = TRUE)
# data from Rencher (2002, p 280) - football
DFA(data = data_DFA$Rencher_2002_football,
groups = 'grp',
variables = c('WDIM','CIRCUM','FBEYE','EYEHD','EARHD','JAW'),
predictive = TRUE,
priorprob = 'SIZES',
covmat_type='separate',
verbose = TRUE)
# Sherry (2006) - with Group as numeric
DFA_Sherry <- DFA(data = data_DFA$Sherry_2006,
groups = 'Group_num',
variables = c('Neuroticism','Extroversion','Openness',
'Agreeableness','Conscientiousness'),
predictive = TRUE,
priorprob = 'SIZES',
covmat_type='separate',
verbose = TRUE)
# Sherry (2006) - with Group as a factor
DFA_Sherry <- DFA(data = data_DFA$Sherry_2006,
groups = 'Group_fac',
variables = c('Neuroticism','Extroversion','Openness',
'Agreeableness','Conscientiousness'),
predictive = TRUE,
priorprob = 'SIZES',
covmat_type='separate',
verbose = TRUE)
# plots of posterior probabilities by group
# hoping to see correct separations between cases from different groups
# first, display the posterior probabilities
print(cbind(round(DFA_Sherry$posteriors[1:3],3), DFA_Sherry$posteriors[4]))
# group 1 vs 2
plot(DFA_Sherry$posteriors$posterior_1, DFA_Sherry$posteriors$posterior_2,
pch = 16, cex = 1, col = c('red', 'blue', 'green')[DFA_Sherry$posteriors$Group],
xlim=c(0,1), ylim=c(0,1),
main = 'DFA Posterior Probabilities by Original Group Memberships',
xlab='Posterior Probability of Being in Group 1',
ylab='Posterior Probability of Being in Group 2' )
legend(x=.8, y=.99, c('1','2','3'), cex=1.2, col=c('red', 'blue', 'green'), pch=16, bty='n')
# group 1 vs 3
plot(DFA_Sherry$posteriors$posterior_1, DFA_Sherry$posteriors$posterior_3,
pch = 16, col = c('red', 'blue', 'green')[DFA_Sherry$posteriors$Group],
xlim=c(0,1), ylim=c(0,1),
main = 'DFA Posterior Probabilities by Group Membership',
xlab='Posterior Probability of Being in Group 1',
ylab='Posterior Probability of Being in Group 3' )
legend(x=.8, y=.99, c('1','2','3'), cex=1.2,col=c('red', 'blue', 'green'), pch=16, bty='n')
# group 2 vs 3
plot(DFA_Sherry$posteriors$posterior_2, DFA_Sherry$posteriors$posterior_3,
pch = 16, col = c('red', 'blue', 'green')[DFA_Sherry$posteriors$Group],
xlim=c(0,1), ylim=c(0,1),
main = 'DFA Posterior Probabilities by Group Membership',
xlab='Posterior Probability of Being in Group 2',
ylab='Posterior Probability of Being in Group 3' )
legend(x=.8, y=.99, c('1','2','3'), cex=1.2, col=c('red', 'blue', 'green'), pch=16, bty='n')
# Tabachnik & Fiddel (2019, p 307, 311) - small - with group as numeric
DFA(data = data_DFA$TabFid_2019_small,
groups = 'group_num',
variables = c('perf','info','verbexp','age'),
predictive = TRUE,
priorprob = 'SIZES',
covmat_type='within',
verbose = TRUE)
# Tabachnik & Fiddel (2019, p 307, 311) - small - with group as a factor
DFA(data = data_DFA$TabFid_2019_small,
groups = 'group_fac',
variables = c('perf','info','verbexp','age'),
predictive = TRUE,
priorprob = 'SIZES',
covmat_type='within',
verbose = TRUE)
# Tabachnik & Fiddel (2019, p 324) - complete - with WORKSTAT as numeric
DFA(data = data_DFA$TabFid_2019_complete,
groups = 'WORKSTAT_num',
variables = c('CONTROL','ATTMAR','ATTROLE','ATTHOUSE'),
plot=TRUE,
predictive = TRUE,
priorprob = 'SIZES',
covmat_type='within',
CV=TRUE,
verbose=TRUE)
# Tabachnik & Fiddel (2019, p 324) - complete - with WORKSTAT as a factor
DFA(data = data_DFA$TabFid_2019_complete,
groups = 'WORKSTAT_fac',
variables = c('CONTROL','ATTMAR','ATTROLE','ATTHOUSE'),
plot=TRUE,
predictive = TRUE,
priorprob = 'SIZES',
covmat_type='within',
CV=TRUE,
verbose=TRUE)
# }
Run the code above in your browser using DataLab