library(dplyr)
library(tidyLPA)
inertia_data <- KEELY_FYP_copy %>%
select(
INERTIA_RB,
INERTIA_NB1,
INERTIA_NB2,
INERTIA_POS1,
INERTIA_NEG1,
INERTIA_POS2,
INERTIA_NEG2
)
inertia_models <- inertia_data %>%
estimate_profiles(1:5)
get_fit(inertia_models)
Lowest BIC: -7389 -> 5 classes, -7388 –> 4 classes Entropy: All above 0.8 Class Sizes: All above 0.1 besides 5 classes
So 4 CLASSES IS IDEAL
inertia_profile <- get_data(inertia_models[[4]])
KEELY_FYP_copy$inertia_profile <- inertia_profile$Class
library(dplyr)
profile_means <- KEELY_FYP_copy %>%
group_by(inertia_profile) %>%
summarise(
RB = mean(INERTIA_RB, na.rm=TRUE),
NB1 = mean(INERTIA_NB1, na.rm=TRUE),
NB2 = mean(INERTIA_NB2, na.rm=TRUE),
POS1 = mean(INERTIA_POS1, na.rm=TRUE),
NEG1 = mean(INERTIA_NEG1, na.rm=TRUE),
POS2 = mean(INERTIA_POS2, na.rm=TRUE),
NEG2 = mean(INERTIA_NEG2, na.rm=TRUE)
)
profile_means
profile_scores <- profile_means %>%
mutate(
adaptiveness_score =
RB + NB1 + NB2 -
POS1 - NEG1 - POS2 - NEG2
)
profile_scores <- profile_scores %>%
arrange(desc(adaptiveness_score)) %>%
mutate(
inertia_label = c(
"Most adaptive",
"Moderately adaptive",
"Moderately maladaptive",
"Least adaptive"
)
)
KEELY_FYP_copy <- KEELY_FYP_copy %>%
left_join(
profile_scores %>% select(inertia_profile, inertia_label),
by = "inertia_profile"
)
table(KEELY_FYP_copy$inertia_label)
Least adaptive Moderately adaptive Moderately maladaptive Most adaptive
26 51 26 32
anova_model <- aov(ADHD_SX ~ inertia_label, data = KEELY_FYP_copy)
summary(anova_model)
Df Sum Sq Mean Sq F value Pr(>F)
inertia_label 3 48 16.04 0.472 0.703
Residuals 131 4454 34.00
library(dplyr)
KEELY_FYP_copy <- KEELY_FYP_copy %>%
mutate(
least_vs_others_inertia = ifelse(inertia_label == "Least adaptive", 1, 0)
)
# ADHD diagnosis
table(KEELY_FYP_copy$least_vs_others_inertia, KEELY_FYP_copy$ADHDYN)
0 1
0 52 57
1 14 12
chisq.test(KEELY_FYP_copy$least_vs_others_inertia, KEELY_FYP_copy$ADHDYN)
Pearson's Chi-squared test with Yates' continuity correction
data: KEELY_FYP_copy$least_vs_others_inertia and KEELY_FYP_copy$ADHDYN
X-squared = 0.11864, df = 1, p-value = 0.7305
# Sex
table(KEELY_FYP_copy$least_vs_others_inertia, KEELY_FYP_copy$SEX)
1 2
0 55 54
1 10 16
chisq.test(KEELY_FYP_copy$least_vs_others_inertia, KEELY_FYP_copy$SEX)
Pearson's Chi-squared test with Yates' continuity correction
data: KEELY_FYP_copy$least_vs_others_inertia and KEELY_FYP_copy$SEX
X-squared = 0.77742, df = 1, p-value = 0.3779
# Race
table(KEELY_FYP_copy$least_vs_others_inertia, KEELY_FYP_copy$W_POC)
0 1
0 29 80
1 11 15
chisq.test(KEELY_FYP_copy$least_vs_others_inertia, KEELY_FYP_copy$W_POC)
Pearson's Chi-squared test with Yates' continuity correction
data: KEELY_FYP_copy$least_vs_others_inertia and KEELY_FYP_copy$W_POC
X-squared = 1.7864, df = 1, p-value = 0.1814
No significant differences on ADHD Status, Sex or White vs. POC
t.test(INCOME_TO_NEEDS ~ least_vs_others_inertia, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: INCOME_TO_NEEDS by least_vs_others_inertia
t = -1.7015, df = 32.639, p-value = 0.09835
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-1.7032077 0.1521565
sample estimates:
mean in group 0 mean in group 1
3.898671 4.674197
t.test(dept ~ least_vs_others_inertia, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: dept by least_vs_others_inertia
t = -0.58324, df = 39.444, p-value = 0.5631
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-4.306230 2.378121
sample estimates:
mean in group 0 mean in group 1
56.42056 57.38462
t.test(internat ~ least_vs_others_inertia, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: internat by least_vs_others_inertia
t = -0.84622, df = 39.158, p-value = 0.4026
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-6.784799 2.781923
sample estimates:
mean in group 0 mean in group 1
54.38318 56.38462
t.test(ACES ~ least_vs_others_inertia, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: ACES by least_vs_others_inertia
t = 1.1892, df = 48.031, p-value = 0.2402
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-0.2381235 0.9276083
sample estimates:
mean in group 0 mean in group 1
1.2293578 0.8846154
t.test(ADHD_SX ~ least_vs_others_inertia, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: ADHD_SX by least_vs_others_inertia
t = -0.11636, df = 39.403, p-value = 0.908
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-2.626275 2.340460
sample estimates:
mean in group 0 mean in group 1
6.972477 7.115385
t.test(CHAOS_SUM ~ least_vs_others_inertia, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: CHAOS_SUM by least_vs_others_inertia
t = -0.62213, df = 36.51, p-value = 0.5377
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-1.5927529 0.8446936
sample estimates:
mean in group 0 mean in group 1
2.779817 3.153846
No significant differences in t-tests for income to needs, depression t-scores, internalizing t-scores, ACES, ADHD symptoms, choas sum
library(dplyr)
KEELY_FYP_copy %>%
group_by(least_vs_others_inertia) %>%
summarise(
income_mean = mean(INCOME_TO_NEEDS, na.rm=TRUE),
depression_mean = mean(dept, na.rm=TRUE),
internalizing_mean = mean(internat, na.rm=TRUE),
aces_mean = mean(ACES, na.rm=TRUE),
adhd_sx_mean = mean(ADHD_SX, na.rm=TRUE),
chaos_mean = mean(CHAOS_SUM, na.rm=TRUE)
)
model_dep = lm(dept ~ least_vs_others_inertia + SEX + W_POC + INCOME_TO_NEEDS,
data = KEELY_FYP_copy)
summary(model_dep)
Call:
lm(formula = dept ~ least_vs_others_inertia + SEX + W_POC + INCOME_TO_NEEDS,
data = KEELY_FYP_copy)
Residuals:
Min 1Q Median 3Q Max
-9.074 -5.919 -2.865 4.586 27.109
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 58.677084 1.986109 29.544 <2e-16 ***
least_vs_others_inertia 1.409360 1.763346 0.799 0.426
SEX2 0.414302 1.363839 0.304 0.762
W_POC1 -0.009988 1.562541 -0.006 0.995
INCOME_TO_NEEDS -0.631343 0.392322 -1.609 0.110
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 7.779 on 128 degrees of freedom
(2 observations deleted due to missingness)
Multiple R-squared: 0.02489, Adjusted R-squared: -0.005582
F-statistic: 0.8168 on 4 and 128 DF, p-value: 0.5167
model_adhd = lm(ADHD_SX ~ least_vs_others_inertia + SEX + W_POC + INCOME_TO_NEEDS, data = KEELY_FYP_copy)
summary(model_adhd)
Call:
lm(formula = ADHD_SX ~ least_vs_others_inertia + SEX + W_POC +
INCOME_TO_NEEDS, data = KEELY_FYP_copy)
Residuals:
Min 1Q Median 3Q Max
-9.379 -4.503 -0.921 4.061 13.768
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 10.5089 1.4278 7.360 1.86e-11 ***
least_vs_others_inertia 1.1448 1.2725 0.900 0.37000
SEX2 -1.3774 0.9790 -1.407 0.16180
W_POC1 0.8874 1.1120 0.798 0.42634
INCOME_TO_NEEDS -0.8991 0.2815 -3.194 0.00176 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 5.631 on 130 degrees of freedom
Multiple R-squared: 0.08444, Adjusted R-squared: 0.05627
F-statistic: 2.997 on 4 and 130 DF, p-value: 0.02098
model_adhd_yn <- glm(ADHDYN ~ least_vs_others_inertia + SEX + W_POC + INCOME_TO_NEEDS,
data = KEELY_FYP_copy,
family = binomial)
summary(model_adhd_yn)
Call:
glm(formula = ADHDYN ~ least_vs_others_inertia + SEX + W_POC +
INCOME_TO_NEEDS, family = binomial, data = KEELY_FYP_copy)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.25938 0.54373 2.316 0.02055 *
least_vs_others_inertia 0.09795 0.47269 0.207 0.83584
SEX2 -0.59993 0.36316 -1.652 0.09853 .
W_POC1 0.44866 0.41860 1.072 0.28381
INCOME_TO_NEEDS -0.30734 0.11252 -2.731 0.00631 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 187.08 on 134 degrees of freedom
Residual deviance: 175.77 on 130 degrees of freedom
AIC: 185.77
Number of Fisher Scoring iterations: 4
prediction_inertia = glm(least_vs_others_inertia ~ ADHDYN + SEX + W_POC + INCOME_TO_NEEDS +
dept + internat + ACES + CHAOS_SUM,
data = KEELY_FYP_copy,
family = binomial)
summary(prediction_inertia)
Call:
glm(formula = least_vs_others_inertia ~ ADHDYN + SEX + W_POC +
INCOME_TO_NEEDS + dept + internat + ACES + CHAOS_SUM, family = binomial,
data = KEELY_FYP_copy)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -3.421798 1.901629 -1.799 0.0720 .
ADHDYN -0.182793 0.566179 -0.323 0.7468
SEX2 0.369408 0.477565 0.774 0.4392
W_POC1 -0.946604 0.499812 -1.894 0.0582 .
INCOME_TO_NEEDS 0.276997 0.130312 2.126 0.0335 *
dept 0.001138 0.048282 0.024 0.9812
internat 0.022275 0.038872 0.573 0.5666
ACES -0.126370 0.180313 -0.701 0.4834
CHAOS_SUM 0.057490 0.102464 0.561 0.5747
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 131.43 on 132 degrees of freedom
Residual deviance: 120.59 on 124 degrees of freedom
(2 observations deleted due to missingness)
AIC: 138.59
Number of Fisher Scoring iterations: 4
Income to needs is the only variable that predicts the least adaptive grouping for Inertia
instability_data <- KEELY_FYP_copy %>%
select(
RMSSD_RB,
RMSSD_NB1,
RMSSD_NB2,
RMSSD_POS1,
RMSSD_NEG1,
RMSSD_POS2,
RMSSD_NEG2
)
instability_models <- instability_data %>%
estimate_profiles(1:5)
get_fit(instability_models)
Lowest BIC: 506 (2 classes) Entropy: All over 0.8 N min: 3 classes above 0.1
So 2 CLASSES IS IDEAL for instability
instability_profile <- get_data(instability_models[[2]])
KEELY_FYP_copy$instability_profile <- instability_profile$Class - 1
library(dplyr)
profile_means <- KEELY_FYP_copy %>%
group_by(instability_profile) %>%
summarise(
RB = mean(RMSSD_RB, na.rm=TRUE),
NB1 = mean(RMSSD_NB1, na.rm=TRUE),
NB2 = mean(RMSSD_NB2, na.rm=TRUE),
POS1 = mean(RMSSD_POS1, na.rm=TRUE),
NEG1 = mean(RMSSD_NEG1, na.rm=TRUE),
POS2 = mean(RMSSD_POS2, na.rm=TRUE),
NEG2 = mean(RMSSD_NEG2, na.rm=TRUE)
)
profile_means
profile_scores <- profile_means %>%
mutate(
adaptiveness_score =
- RB - NB1 - NB2 +
POS1 + NEG1 + POS2 + NEG2
)
profile_scores <- profile_scores %>%
arrange(desc(adaptiveness_score)) %>%
mutate(
instability_label = c(
"Most adaptive",
"Least adaptive"
)
)
KEELY_FYP_copy <- KEELY_FYP_copy %>%
left_join(
profile_scores %>% select(instability_profile, instability_label),
by = "instability_profile"
)
table(KEELY_FYP_copy$instability_label)
Least adaptive Most adaptive
99 36
# ADHD diagnosis
table(KEELY_FYP_copy$instability_profile, KEELY_FYP_copy$ADHDYN)
0 1
0 17 19
1 49 50
chisq.test(KEELY_FYP_copy$instability_profile, KEELY_FYP_copy$ADHDYN)
Pearson's Chi-squared test with Yates' continuity correction
data: KEELY_FYP_copy$instability_profile and KEELY_FYP_copy$ADHDYN
X-squared = 0.0015159, df = 1, p-value = 0.9689
# Sex
table(KEELY_FYP_copy$instability_profile, KEELY_FYP_copy$SEX)
1 2
0 21 15
1 44 55
chisq.test(KEELY_FYP_copy$instability_profile, KEELY_FYP_copy$SEX)
Pearson's Chi-squared test with Yates' continuity correction
data: KEELY_FYP_copy$instability_profile and KEELY_FYP_copy$SEX
X-squared = 1.5214, df = 1, p-value = 0.2174
# Race
table(KEELY_FYP_copy$instability_profile, KEELY_FYP_copy$W_POC)
0 1
0 8 28
1 32 67
chisq.test(KEELY_FYP_copy$instability_profile, KEELY_FYP_copy$W_POC)
Pearson's Chi-squared test with Yates' continuity correction
data: KEELY_FYP_copy$instability_profile and KEELY_FYP_copy$W_POC
X-squared = 0.85283, df = 1, p-value = 0.3558
No significant differences for SEX, RACE or ADHD Status
t.test(INCOME_TO_NEEDS ~ instability_profile, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: INCOME_TO_NEEDS by instability_profile
t = -0.49038, df = 77.407, p-value = 0.6253
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-0.7912849 0.4785429
sample estimates:
mean in group 0 mean in group 1
3.933359 4.089730
t.test(dept ~ instability_profile, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: dept by instability_profile
t = -0.41434, df = 67.453, p-value = 0.6799
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-3.528041 2.314983
sample estimates:
mean in group 0 mean in group 1
56.16667 56.77320
t.test(internat ~ instability_profile, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: internat by instability_profile
t = -0.55072, df = 64.208, p-value = 0.5837
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-5.442179 3.089946
sample estimates:
mean in group 0 mean in group 1
53.91667 55.09278
t.test(ACES ~ instability_profile, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: ACES by instability_profile
t = -0.11328, df = 69.626, p-value = 0.9101
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-0.6108780 0.5452215
sample estimates:
mean in group 0 mean in group 1
1.138889 1.171717
t.test(ADHD_SX ~ instability_profile, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: ADHD_SX by instability_profile
t = -0.03391, df = 63.783, p-value = 0.9731
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-2.269599 2.193842
sample estimates:
mean in group 0 mean in group 1
6.972222 7.010101
t.test(CHAOS_SUM ~ instability_profile, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: CHAOS_SUM by instability_profile
t = -0.052374, df = 72.453, p-value = 0.9584
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-0.9863216 0.9358166
sample estimates:
mean in group 0 mean in group 1
2.833333 2.858586
No significant differences
library(dplyr)
KEELY_FYP_copy %>%
group_by(instability_profile) %>%
summarise(
income_mean = mean(INCOME_TO_NEEDS, na.rm=TRUE),
depression_mean = mean(dept, na.rm=TRUE),
internalizing_mean = mean(internat, na.rm=TRUE),
aces_mean = mean(ACES, na.rm=TRUE),
adhd_sx_mean = mean(ADHD_SX, na.rm=TRUE),
chaos_mean = mean(CHAOS_SUM, na.rm=TRUE)
)
model_dep_ins = lm(dept ~ instability_profile + SEX + W_POC + INCOME_TO_NEEDS,
data = KEELY_FYP_copy)
summary(model_dep_ins)
Call:
lm(formula = dept ~ instability_profile + SEX + W_POC + INCOME_TO_NEEDS,
data = KEELY_FYP_copy)
Residuals:
Min 1Q Median 3Q Max
-8.760 -6.120 -2.790 4.531 26.574
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 58.3855 2.2393 26.073 <2e-16 ***
instability_profile 0.6135 1.5430 0.398 0.692
SEX2 0.4284 1.3732 0.312 0.756
W_POC1 -0.1791 1.5463 -0.116 0.908
INCOME_TO_NEEDS -0.5741 0.3848 -1.492 0.138
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 7.794 on 128 degrees of freedom
(2 observations deleted due to missingness)
Multiple R-squared: 0.02123, Adjusted R-squared: -0.009354
F-statistic: 0.6942 on 4 and 128 DF, p-value: 0.5973
model_adhd_ins = lm(ADHD_SX ~ instability_profile + SEX + W_POC + INCOME_TO_NEEDS, data = KEELY_FYP_copy)
summary(model_adhd_ins)
Call:
lm(formula = ADHD_SX ~ instability_profile + SEX + W_POC + INCOME_TO_NEEDS,
data = KEELY_FYP_copy)
Residuals:
Min 1Q Median 3Q Max
-9.1431 -4.5906 -0.7543 4.2894 13.2601
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 10.3004 1.6190 6.362 3.12e-09 ***
instability_profile 0.4348 1.1134 0.390 0.69682
SEX2 -1.3466 0.9844 -1.368 0.17366
W_POC1 0.7569 1.1034 0.686 0.49397
INCOME_TO_NEEDS -0.8532 0.2766 -3.085 0.00249 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 5.645 on 130 degrees of freedom
Multiple R-squared: 0.07982, Adjusted R-squared: 0.05151
F-statistic: 2.819 on 4 and 130 DF, p-value: 0.02775
model_adhd_ins <- glm(ADHDYN ~ instability_profile + SEX + W_POC + INCOME_TO_NEEDS,
data = KEELY_FYP_copy,
family = binomial)
summary(model_adhd_ins)
Call:
glm(formula = ADHDYN ~ instability_profile + SEX + W_POC + INCOME_TO_NEEDS,
family = binomial, data = KEELY_FYP_copy)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.22083 0.61074 1.999 0.0456 *
instability_profile 0.07012 0.40944 0.171 0.8640
SEX2 -0.60082 0.36425 -1.649 0.0991 .
W_POC1 0.43990 0.41373 1.063 0.2877
INCOME_TO_NEEDS -0.30423 0.11093 -2.742 0.0061 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 187.08 on 134 degrees of freedom
Residual deviance: 175.78 on 130 degrees of freedom
AIC: 185.78
Number of Fisher Scoring iterations: 4
prediction_instability = glm(instability_profile ~ ADHDYN + SEX + W_POC + INCOME_TO_NEEDS +
dept + internat + ACES + CHAOS_SUM,
data = KEELY_FYP_copy,
family = binomial)
summary(prediction_instability)
Call:
glm(formula = instability_profile ~ ADHDYN + SEX + W_POC + INCOME_TO_NEEDS +
dept + internat + ACES + CHAOS_SUM, family = binomial, data = KEELY_FYP_copy)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.197226 1.717005 0.115 0.909
ADHDYN 0.024615 0.487797 0.050 0.960
SEX2 0.563457 0.408728 1.379 0.168
W_POC1 -0.518541 0.486194 -1.067 0.286
INCOME_TO_NEEDS 0.092411 0.123327 0.749 0.454
dept -0.001775 0.046415 -0.038 0.970
internat 0.012652 0.035041 0.361 0.718
ACES 0.011993 0.139951 0.086 0.932
CHAOS_SUM -0.031999 0.091083 -0.351 0.725
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 155.33 on 132 degrees of freedom
Residual deviance: 151.11 on 124 degrees of freedom
(2 observations deleted due to missingness)
AIC: 169.11
Number of Fisher Scoring iterations: 4
combined_data <- KEELY_FYP_copy %>%
select(
INERTIA_RB,
INERTIA_NB1,
INERTIA_NB2,
INERTIA_POS1,
INERTIA_NEG1,
INERTIA_POS2,
INERTIA_NEG2,
RMSSD_RB,
RMSSD_NB1,
RMSSD_NB2,
RMSSD_POS1,
RMSSD_NEG1,
RMSSD_POS2,
RMSSD_NEG2
)
combined_models <- combined_data %>%
estimate_profiles(1:5)
get_fit(combined_models)
Lowest BIC: -6788 (3 classes) Entropy: all over 0.8 N min: 3 classes above 0.10
So 3 CLASSES IS IDEAL
combined_profile <- get_data(combined_models[[3]])
KEELY_FYP_copy$combined_profile <- combined_profile$Class
library(dplyr)
# Get profile assignments
combined_profile <- get_data(combined_models[[3]])
KEELY_FYP_copy$combined_profile <- combined_profile$Class
KEELY_FYP_copy <- KEELY_FYP_copy %>%
mutate(
# Inertia (z-scores)
z_IN_RB = scale(INERTIA_RB),
z_IN_NB1 = scale(INERTIA_NB1),
z_IN_NB2 = scale(INERTIA_NB2),
z_IN_POS1 = scale(INERTIA_POS1),
z_IN_NEG1 = scale(INERTIA_NEG1),
z_IN_POS2 = scale(INERTIA_POS2),
z_IN_NEG2 = scale(INERTIA_NEG2),
# Instability (z-scores)
z_RM_RB = scale(RMSSD_RB),
z_RM_NB1 = scale(RMSSD_NB1),
z_RM_NB2 = scale(RMSSD_NB2),
z_RM_POS1 = scale(RMSSD_POS1),
z_RM_NEG1 = scale(RMSSD_NEG1),
z_RM_POS2 = scale(RMSSD_POS2),
z_RM_NEG2 = scale(RMSSD_NEG2)
)
# Calculate means for each profile
profile_means <- KEELY_FYP_copy %>%
group_by(combined_profile) %>%
summarise(
IN_RB = mean(z_IN_RB, na.rm=TRUE),
IN_NB1 = mean(z_IN_NB1, na.rm=TRUE),
IN_NB2 = mean(z_IN_NB2, na.rm=TRUE),
IN_POS1 = mean(z_IN_POS1, na.rm=TRUE),
IN_NEG1 = mean(z_IN_NEG1, na.rm=TRUE),
IN_POS2 = mean(z_IN_POS2, na.rm=TRUE),
IN_NEG2 = mean(z_IN_NEG2, na.rm=TRUE),
RM_RB = mean(z_RM_RB, na.rm=TRUE),
RM_NB1 = mean(z_RM_NB1, na.rm=TRUE),
RM_NB2 = mean(z_RM_NB2, na.rm=TRUE),
RM_POS1 = mean(z_RM_POS1, na.rm=TRUE),
RM_NEG1 = mean(z_RM_NEG1, na.rm=TRUE),
RM_POS2 = mean(z_RM_POS2, na.rm=TRUE),
RM_NEG2 = mean(z_RM_NEG2, na.rm=TRUE)
)
profile_means
profile_scores <- profile_means %>%
mutate(
adaptiveness_score =
# INERTIA
IN_RB + IN_NB1 + IN_NB2 -
IN_POS1 - IN_NEG1 - IN_POS2 - IN_NEG2
# INSTABILITY
- RM_RB - RM_NB1 - RM_NB2 +
RM_POS1 + RM_NEG1 + RM_POS2 + RM_NEG2
)
profile_scores <- profile_scores %>%
arrange(desc(adaptiveness_score)) %>%
mutate(
combined_label = c(
"Most adaptive",
"Moderately adaptive",
"Least adaptive"
))
KEELY_FYP_copy <- KEELY_FYP_copy %>%
left_join(
profile_scores %>% select(combined_profile, combined_label.y),
by = "combined_profile"
)
Error in `select()`:
! Can't select columns that don't exist.
✖ Column `combined_label.y` doesn't exist.
Run `]8;;x-r-run:rlang::last_trace()rlang::last_trace()]8;;` to see where the error occurred.
library(dplyr)
KEELY_FYP_copy <- KEELY_FYP_copy %>%
mutate(
least_vs_others_com= ifelse(combined_label == "Least adaptive", 1, 0)
)
# ADHD diagnosis
table(KEELY_FYP_copy$least_vs_others_com, KEELY_FYP_copy$ADHDYN)
0 1
0 47 49
1 19 20
chisq.test(KEELY_FYP_copy$least_vs_others_com, KEELY_FYP_copy$ADHDYN)
Pearson's Chi-squared test with Yates' continuity correction
data: KEELY_FYP_copy$least_vs_others_com and KEELY_FYP_copy$ADHDYN
X-squared = 5.2617e-31, df = 1, p-value = 1
# Sex
table(KEELY_FYP_copy$least_vs_others_com, KEELY_FYP_copy$SEX)
1 2
0 49 47
1 16 23
chisq.test(KEELY_FYP_copy$least_vs_others_com, KEELY_FYP_copy$SEX)
Pearson's Chi-squared test with Yates' continuity correction
data: KEELY_FYP_copy$least_vs_others_com and KEELY_FYP_copy$SEX
X-squared = 0.74934, df = 1, p-value = 0.3867
# Race
table(KEELY_FYP_copy$least_vs_others_com, KEELY_FYP_copy$W_POC)
0 1
0 26 70
1 14 25
chisq.test(KEELY_FYP_copy$least_vs_others_com, KEELY_FYP_copy$W_POC)
Pearson's Chi-squared test with Yates' continuity correction
data: KEELY_FYP_copy$least_vs_others_com and KEELY_FYP_copy$W_POC
X-squared = 0.65384, df = 1, p-value = 0.4187
t.test(INCOME_TO_NEEDS ~ least_vs_others_com, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: INCOME_TO_NEEDS by least_vs_others_com
t = -0.49006, df = 63.466, p-value = 0.6258
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-0.9050277 0.5485189
sample estimates:
mean in group 0 mean in group 1
3.996536 4.174790
t.test(dept ~ least_vs_others_com, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: dept by least_vs_others_com
t = -0.77064, df = 72.015, p-value = 0.4434
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-4.066163 1.798842
sample estimates:
mean in group 0 mean in group 1
56.27660 57.41026
t.test(internat ~ least_vs_others_com, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: internat by least_vs_others_com
t = -0.75347, df = 74.812, p-value = 0.4535
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-5.657860 2.552568
sample estimates:
mean in group 0 mean in group 1
54.31915 55.87179
t.test(ACES ~ least_vs_others_com, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: ACES by least_vs_others_com
t = 1.4793, df = 82.827, p-value = 0.1428
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-0.1410799 0.9599901
sample estimates:
mean in group 0 mean in group 1
1.2812500 0.8717949
t.test(ADHD_SX ~ least_vs_others_com, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: ADHD_SX by least_vs_others_com
t = -0.74362, df = 75.81, p-value = 0.4594
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-2.918001 1.331462
sample estimates:
mean in group 0 mean in group 1
6.770833 7.564103
t.test(CHAOS_SUM ~ least_vs_others_com, data = KEELY_FYP_copy)
Welch Two Sample t-test
data: CHAOS_SUM by least_vs_others_com
t = -0.8803, df = 65.653, p-value = 0.3819
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-1.5058188 0.5843445
sample estimates:
mean in group 0 mean in group 1
2.718750 3.179487
library(dplyr)
KEELY_FYP_copy %>%
group_by(least_vs_others_com) %>%
summarise(
income_mean = mean(INCOME_TO_NEEDS, na.rm=TRUE),
depression_mean = mean(dept, na.rm=TRUE),
internalizing_mean = mean(internat, na.rm=TRUE),
aces_mean = mean(ACES, na.rm=TRUE),
adhd_sx_mean = mean(ADHD_SX, na.rm=TRUE),
chaos_mean = mean(CHAOS_SUM, na.rm=TRUE)
)
prediction_combined = glm(least_vs_others_com~ ADHDYN + SEX + W_POC + INCOME_TO_NEEDS +
dept + internat + ACES + CHAOS_SUM,
data = KEELY_FYP_copy,
family = binomial)
summary(prediction_combined)
Call:
glm(formula = least_vs_others_com ~ ADHDYN + SEX + W_POC + INCOME_TO_NEEDS +
dept + internat + ACES + CHAOS_SUM, family = binomial, data = KEELY_FYP_copy)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.876788 1.632370 -1.150 0.250
ADHDYN -0.010922 0.483922 -0.023 0.982
SEX2 0.287675 0.403440 0.713 0.476
W_POC1 -0.507334 0.439455 -1.154 0.248
INCOME_TO_NEEDS 0.061851 0.114689 0.539 0.590
dept 0.020014 0.042850 0.467 0.640
internat -0.003868 0.033096 -0.117 0.907
ACES -0.224454 0.154578 -1.452 0.146
CHAOS_SUM 0.087340 0.087689 0.996 0.319
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 160.94 on 132 degrees of freedom
Residual deviance: 154.71 on 124 degrees of freedom
(2 observations deleted due to missingness)
AIC: 172.71
Number of Fisher Scoring iterations: 4