Warning: package 'ggplotly' is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
Warning: 'BiocManager' not available. Could not check Bioconductor.
Please use `install.packages('BiocManager')` and then retry.
Warning in p_install(package, character.only = TRUE, ...):
Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
logical.return = TRUE, : there is no package called 'ggplotly'
The downloaded binary packages are in
/var/folders/92/xm82pvms01l67cph1f7lch_80000gn/T//RtmpvAO91F/downloaded_packages
tidytable installed
The downloaded binary packages are in
/var/folders/92/xm82pvms01l67cph1f7lch_80000gn/T//RtmpvAO91F/downloaded_packages
plotly installed
Warning: package 'plotly' was built under R version 4.4.3
Warning in pacman::p_load(tidyverse, conflicted, here, lme4, lmerTest, effects, : Failed to install/load:
ggplotly, tidytable, plotly
conflict_prefer("select", "dplyr")
[conflicted] Will prefer dplyr::select over any other package.
conflict_prefer("rename", "dplyr")
[conflicted] Will prefer dplyr::rename over any other package.
conflict_prefer("lmer", "lmerTest")
[conflicted] Will prefer lmerTest::lmer over any other package.
conflict_prefer("here", "here")
[conflicted] Will prefer here::here over any other package.
conflicted::conflicts_prefer(psych::alpha)
[conflicted] Will prefer psych::alpha over any other package.
conflicts_prefer(dplyr::arrange)
[conflicted] Will prefer dplyr::arrange over any other package.
conflicts_prefer(tidyr::pivot_longer)
[conflicted] Will prefer tidyr::pivot_longer over any other package.
conflicts_prefer(tidyr::pivot_wider)
[conflicted] Will prefer tidyr::pivot_wider over any other package.
conflicts_prefer(tidytable::`%in%`)
[conflicted] Will prefer tidytable::`%in%` over any other package.
conflicts_prefer(dplyr::group_by)
[conflicted] Will prefer dplyr::group_by over any other package.
conflicts_prefer(dplyr::summarize)
[conflicted] Will prefer dplyr::summarize over any other package.
conflicts_prefer(dplyr::mutate)
[conflicted] Will prefer dplyr::mutate over any other package.
conflicts_prefer(dplyr::filter)
[conflicted] Will prefer dplyr::filter over any other package.
conflicts_prefer(dplyr::row_number)
[conflicted] Will prefer dplyr::row_number over any other package.
conflicts_prefer(tidytable::ungroup)
[conflicted] Will prefer tidytable::ungroup over any other package.
conflicts_prefer(dplyr::n)
[conflicted] Will prefer dplyr::n over any other package.
conflicts_prefer(dplyr::case_when)
[conflicted] Will prefer dplyr::case_when over any other package.
Warning: Removed 18 rows containing missing values or values outside the scale range
(`geom_segment()`).
#Fun by activity typeggplot(kid_expt1_main_labeled_wide, aes(x=fun, y=act_type, fill=act_type)) +stat_summary(fun = median)+geom_boxplot() +facet_wrap(~Age_in_years) +theme_minimal() +scale_fill_manual(values =c("mental"="#1f77b4", "physical"="#ff7f0e", "restorative"="#2ca02c"))+labs(title="Fun by Activity",y="Activity",x="Fun")
Warning: Removed 3 rows containing missing values or values outside the scale range
(`geom_segment()`).
Warning: Removed 3 rows containing missing values or values outside the scale range
(`geom_segment()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_segment()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_segment()`).
Kids dont’ generally find restorative activities as energy-restoring, in fact it is similar to mental activities - because they involve similar amount of movement? physical activities are energy-depleting because they involve more movement?
younger kids (3-5): the more difficult, the less energy-depleting/more restorative for all activities (esp mental ones). For mental activities only, the more difficult more fun.
older kids (6-7): Like younger kids, for mental activities, they say the more difficult the less energy-depleting. Like adults (unlike younger kids), they say the less difficult the more fun for mental and physical activities, and the more energy depleting the less fun for restorative activities.
kids below 5 have trouble with difficulty sliders (numbers??)
Modeling
library(lme4)library(lmerTest)#comparing across typeskid_expt1_main_labeled$act_type <-factor(kid_expt1_main_labeled$act_type, levels =c("physical", "mental", "restorative"))
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: response ~ 1 + (1 | subjectID)
Data: filter(phys_energy)
REML criterion at convergence: 2334.2
Scaled residuals:
Min 1Q Median 3Q Max
-1.9466 -0.6818 -0.1220 0.7054 2.2060
Random effects:
Groups Name Variance Std.Dev.
subjectID (Intercept) 316.0 17.78
Residual 956.9 30.93
Number of obs: 236, groups: subjectID, 59
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) -9.309 3.068 58.000 -3.035 0.0036 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ment_energy <- kid_expt1_main_labeled |>filter(act_type=="mental"& task=="energy")summary(lmer(formula = response ~1+ (1|subjectID), data=filter(ment_energy))) # not different from 0
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: response ~ 1 + (1 | subjectID)
Data: filter(ment_energy)
REML criterion at convergence: 2287.9
Scaled residuals:
Min 1Q Median 3Q Max
-2.42225 -0.65831 -0.04397 0.72149 2.18744
Random effects:
Groups Name Variance Std.Dev.
subjectID (Intercept) 314.2 17.72
Residual 760.3 27.57
Number of obs: 236, groups: subjectID, 59
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 3.216 2.923 58.000 1.1 0.276
#plot energy rating by vitalism median splitggplot(kid_expt1_main_fullvital, aes(x = energy, y = act_type, fill = act_type)) +geom_boxplot(outlier.shape =NA, width =0.6) +stat_summary(fun = mean, geom ="point", shape =18, size =3, fill ="black", color ="black",aes(group = act_type)) +# diamond for meanstat_summary(fun.data = mean_cl_normal, geom ="errorbar", width =0.2, color ="black", linewidth =0.8,aes(group = act_type)) +# 95% CIscale_fill_manual(name ="Action Type", values =c("mental"="#1f77b4", "physical"="#ff7f0e", "restorative"="#2ca02c"))+facet_wrap(~vital_median_split) +theme_classic() +scale_x_continuous(breaks =c(-50, -25, 0, 25, 50),labels =c("-50\nExtremely tired", "-25\nSomewhat tired", "0\nNeutral", "25\nSomewhat energetic", "50\nExtremely energetic"))+theme_minimal()+theme(axis.text.x =element_text(angle =15, hjust =1)) +labs(x ="Energy Rating", y ="Action")
possible range -6 ~ 19
actual range 0 ~ 18
#difficulty rating by vitalism median splitggplot(kid_expt1_main_fullvital, aes(x = difficulty, y = act_type, fill = act_type)) +geom_boxplot(outlier.shape =NA, width =0.6) +stat_summary(fun = mean, geom ="point", shape =18, size =3, fill ="black", color ="black",aes(group = act_type)) +# diamond for meanstat_summary(fun.data = mean_cl_normal, geom ="errorbar", width =0.2, color ="black", linewidth =0.8,aes(group = act_type)) +# 95% CIscale_fill_manual(name ="Action Type", values =c("mental"="#1f77b4", "physical"="#ff7f0e", "restorative"="#2ca02c"))+facet_wrap(~vital_median_split) +theme_classic() +scale_x_continuous(breaks =c(0, 25, 50,75,100),labels =c("0\nExtremely easy", "25\nSomewhat easy", "50\nNeutral", "75\nSomewhat hard", "100\nExtremely hard"))+theme_minimal()+theme(axis.text.x =element_text(angle =15, hjust =1)) +labs(x ="Difficulty Rating", y ="Action")
#fun rating by vitalism median splitggplot(kid_expt1_main_fullvital, aes(x = fun, y = act_type, fill = act_type)) +geom_boxplot(outlier.shape =NA, width =0.6) +stat_summary(fun = mean, geom ="point", shape =18, size =3, fill ="black", color ="black",aes(group = act_type)) +# diamond for meanstat_summary(fun.data = mean_cl_normal, geom ="errorbar", width =0.2, color ="black", linewidth =0.8,aes(group = act_type)) +# 95% CIscale_fill_manual(name ="Action Type", values =c("mental"="#1f77b4", "physical"="#ff7f0e", "restorative"="#2ca02c"))+facet_wrap(~vital_median_split) +theme_classic() +scale_x_continuous(breaks =c(0, 25, 50,75,100),labels =c("0\nExtremely boring", "25\nSomewhat boring", "50\nNeutral", "75\nSomewhat fun", "100\nExtremely fun"))+theme_minimal()+theme(axis.text.x =element_text(angle =15, hjust =1)) +labs(x ="Fun Rating", y ="Action")
#plot continuous vitalism score and energy rating, by typeggplot(kid_expt1_main_fullvital, aes(x = vital_total, y = energy, color=vital_median_split)) +facet_wrap(~act_type)+geom_point(alpha=0.5)+geom_smooth(method ="lm", se =TRUE)
We don’t see that much of a difference in two vital groups in how energy, difficulty and fun correlate. For physical actions, high vital group showed less positive correlation for fun and energy (more fun less depleting), and more negative cor for difficulty and energy (more difficult more depleting). For mental actions only high vital group showed neg cor for fun and difficulty. For restorative actions only high vital group showed neg cor for difficulty and energy (the more difficult the less restorative)
Modeling
#vitalism as continuous measurem1.1<-lmer(energy ~ act_type + difficulty + fun + Age + (1|subjectID), data=kid_expt1_main_fullvital)m1.2<-lmer(energy ~ act_type + difficulty + fun + vital_total + (1|subjectID), data=kid_expt1_main_fullvital)m1.5<-lmer(energy ~ act_type + difficulty + fun + Age + vital_total + (1|subjectID), data=kid_expt1_main_fullvital)m1.3<-lmer(energy ~ act_type*Age + difficulty + fun + vital_total + (1|subjectID), data=kid_expt1_main_fullvital)m1.4<-lmer(energy ~ act_type*vital_median_split + difficulty + fun + Age + (1|subjectID), data=kid_expt1_main_fullvital)BIC(m1.1,m1.2,m1.3,m1.4, m1.5) #m1.2 has lowest BIC
The higher the vitalism score, the lower the energy rating, and no difference across action type. Age does not explain energy rating at all. That is, kids who are more vitalistic tend to rate physical, mental, restorative actions as more depleting.
#Lets break down by action type (depleting vs. restorative)mental_phys_fullvital <- kid_expt1_main_fullvital |>filter(act_type!="restorative")restorative_fullvital <- kid_expt1_main_fullvital |>filter(act_type=="restorative")#depletingm3.1<-lmer(energy ~ act_type + difficulty + fun + vital_total + Age + (1|subjectID), data=mental_phys_fullvital)summary(m3.1)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: energy ~ act_type + difficulty + fun + vital_total + Age + (1 |
subjectID)
Data: mental_phys_fullvital
REML criterion at convergence: 4434.2
Scaled residuals:
Min 1Q Median 3Q Max
-2.51240 -0.69299 -0.08143 0.69472 2.47754
Random effects:
Groups Name Variance Std.Dev.
subjectID (Intercept) 177.5 13.32
Residual 884.5 29.74
Number of obs: 456, groups: subjectID, 57
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) -0.07763 13.15314 63.24373 -0.006 0.995310
act_typemental 11.28826 2.81712 396.49487 4.007 7.35e-05 ***
difficulty -0.14164 0.04230 441.71530 -3.348 0.000883 ***
fun 0.14452 0.04062 440.02973 3.558 0.000415 ***
vital_total -1.43913 0.63754 53.59516 -2.257 0.028086 *
Age 0.12212 2.23762 53.06740 0.055 0.956682
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Correlation of Fixed Effects:
(Intr) act_ty dffclt fun vtl_tt
act_typmntl -0.140
difficulty -0.201 0.146
fun -0.223 0.054 0.162
vital_total 0.135 -0.001 -0.025 0.067
Age -0.903 0.002 0.007 0.019 -0.434
plot(allEffects(m3.1))
#restorativem3.2<-lmer(energy ~ difficulty + fun + vital_total + (1|subjectID), data=restorative_fullvital)summary(m3.2)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: energy ~ difficulty + fun + vital_total + (1 | subjectID)
Data: restorative_fullvital
REML criterion at convergence: 2257.4
Scaled residuals:
Min 1Q Median 3Q Max
-2.1353 -0.7151 0.2140 0.7617 1.6208
Random effects:
Groups Name Variance Std.Dev.
subjectID (Intercept) 143.7 11.99
Residual 1055.8 32.49
Number of obs: 228, groups: subjectID, 57
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 16.44473 7.11302 119.07490 2.312 0.0225 *
difficulty -0.07483 0.06886 223.54685 -1.087 0.2783
fun 0.05666 0.06526 220.54278 0.868 0.3862
vital_total -1.22157 0.68655 55.67267 -1.779 0.0807 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Correlation of Fixed Effects:
(Intr) dffclt fun
difficulty -0.324
fun -0.622 -0.004
vital_total -0.674 0.119 0.058
plot(allEffects(m3.2))
For depleting actions (mental and physical), kids with higher vital understanding tend to rate them as more depleting. For restorative actions this effect is marginally present (higher vital understanding leads to lower restoration rating)
#vitalism as categorical level (median split)m2.1<-lmer(energy ~ act_type + vital_median_split + difficulty + fun + (1|subjectID), data=kid_expt1_main_fullvital)summary(m2.1)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: energy ~ act_type + vital_median_split + difficulty + fun + (1 |
subjectID)
Data: kid_expt1_main_fullvital
REML criterion at convergence: 6694.7
Scaled residuals:
Min 1Q Median 3Q Max
-2.71661 -0.72103 -0.04387 0.73006 2.21580
Random effects:
Groups Name Variance Std.Dev.
subjectID (Intercept) 147.2 12.13
Residual 973.4 31.20
Number of obs: 684, groups: subjectID, 57
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) -3.57459 4.52262 223.57933 -0.790 0.430143
act_typemental 11.32210 2.94411 623.69177 3.846 0.000133 ***
act_typerestorative 13.89407 3.12220 634.34769 4.450 1.01e-05 ***
vital_median_split>=6 -7.35608 4.04150 54.72447 -1.820 0.074209 .
difficulty -0.13236 0.03645 676.23624 -3.631 0.000303 ***
fun 0.11989 0.03475 674.42860 3.450 0.000595 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Correlation of Fixed Effects:
(Intr) act_typm act_typr v__>=6 dffclt
act_typmntl -0.390
act_typrstr -0.394 0.498
vtl_mdn_>=6 -0.533 0.003 -0.005
difficulty -0.494 0.119 0.316 0.014
fun -0.467 0.039 -0.118 0.064 0.116
By median split, <6 group rated mental and restorative actions as energy-increasing, and physical actions as not changing energy; >=6 group rated physical actions as energy-decreasing, and mental and restorative actions as not changing energy.