Issue with graphing subjects and items growth curve model vs subjects-only in ggplot










0















I have been having trouble graphing growth curve model results that have been calculated over both subjects and items (both included as random effects), while models calculated over a dataset that is averaged over items, so that subjects are the only random effect, seems to work fine. I cannot seem to figure out why this would be or how to fix it.



Graph of Subject Only Model



Graph of Subjects and Items Model



Summary DF Subj Items



Summary DF Subj Only



> dput(head(new.df.subjitems, 20))
structure(list(Item.No = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1),
Subject_No = c(330, 322, 141, 330, 330,
330, 137, 330, 330, 330, 137, 330, 137, 330, 330, 137, 137, 330,
137, 141),
Bin.No = c(35, 17, 19, 44, 42, 34, 31, 23, 36, 32,
33, 28, 23, 33, 37, 7, 4, 30, 28, 31),
TargetFix = c(1, 1, 1,
0, 0.02, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0),
Condition.E = structure(c(5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L), .Label = c("First", "Second", "Max Entropy, Unrelated",
"Third", "Fourth", "Max Entropy, Competitive"), class = "factor"),


ot1 = c(-0.00489995957550024, 0.220498180897511, -0.171498585142509,
0.142098827689507, 0.210698261746511, -0.20089834259551,
-0.0538995553305028, -0.151898746840508, -0.112699070236506,
-0.230298100048512, 0.0146998787265008, -0.161698665991508,
-0.151898746840508, 0.0146998787265008, -0.122498989387506,
0.0538995553305028, 0.181298504293509, -0.0440996361795023,
-0.161698665991508, -0.0538995553305028),
ot2 = c(-0.158018948215706,
0.226392531578272, 0.0744512352170155, 0.00151941296361255,
0.192965446378795, 0.161057774142931, -0.135227753761518,
0.024310607417801, -0.0577376926172773, 0.26133902974136,
-0.156499535252094, 0.0486212148356019, 0.024310607417801,
-0.156499535252094, -0.0395047370539266, -0.135227753761518,
0.101800668562042, -0.142824818579581, 0.0486212148356019,
-0.135227753761518),
ot3 = c(0.0112384799617412, 0.177762495548696,
0.0718614343707494, -0.14311051566666, 0.113069194230467,
-0.05612035827049, 0.113717568074414, 0.12506411034348, 0.167352493276442,
-0.250560469916257, -0.0335353360396831, 0.101434485808536,
0.12506411034348, -0.0335353360396831, 0.16389449944206,
-0.113717568074414, -0.035984748339037, 0.0957432042894495,
0.101434485808536, 0.113717568074414),
ot4 = c(0.158779933129858,
0.0903598052498265, -0.175158477576023, -0.166766788637329,
-0.00086703192354873, -0.0706803112875428, 0.0864589810947309,
-0.178854426512889, -0.0950686572656207, 0.205524262921174,
0.153690832709029, -0.182263550144233, -0.178854426512889,
0.153690832709029, -0.123325047363878, 0.0864589810947308,
-0.15558879673071, 0.109609880754701, -0.182263550144233,
0.0864589810947309)),
.Names = c("Item.No", "Subject_No",
"Bin.No", "TargetFix", "Condition.E", "ot1", "ot2", "ot3", "ot4"
), row.names = c(1L, 5L, 8L, 22L, 29L, 59L, 61L, 74L, 78L, 86L,
90L, 98L, 101L, 111L, 115L, 120L, 126L, 133L, 140L, 145L), class = "data.frame")


> dput(head(df.subjonly, 20))
structure(list(Subject_No = c(103, 103, 103, 103, 103, 103, 103,
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103
),
Bin.No = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20),
TargetFix = c(0.16667, 0.16667, 0.16667,
0.16667, 0.32667, 0.39, 0.5, 0.5, 0.5, 0.5, 0.62667, 0.59, 0.66667,
0.66667, 0.76667, 0.76333, 0.66667, 0.40667, 0.33333, 0.48333
),
Condition.E = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("First",
"Second", "Max Entropy, Unrelated", "NaN, Unrelated", "Third",
"Fourth", "Max Entropy, Competitive", "NaN, Competitive", "Low Entropy, NaN",
"High Entropy, NaN", "Max Entropy, NaN", "NaN, NaN"), class = "factor"),

ot1 = c(-0.240098019199512, -0.230298100048512, -0.220498180897511,
-0.210698261746511, -0.20089834259551, -0.19109842344451,
-0.181298504293509, -0.171498585142509, -0.161698665991508,
-0.151898746840508, -0.142098827689507, -0.132298908538507,
-0.122498989387506, -0.112699070236506, -0.102899151085505,
-0.0930992319345048, -0.0832993127835043, -0.0734993936325038,
-0.0636994744815033, -0.0538995553305028),
ot2 = c(0.297804940868062,
0.26133902974136, 0.226392531578271, 0.192965446378795, 0.161057774142931,
0.13066951487068, 0.101800668562042, 0.0744512352170154,
0.0486212148356019, 0.0243106074178009, 0.0015194129636125,
-0.0197523685269634, -0.0395047370539266, -0.0577376926172774,
-0.0744512352170155, -0.0896453648531411, -0.103320081525654,
-0.115475385234555, -0.126111275979843, -0.135227753761518
),
ot3 = c(-0.331823325024233, -0.250560469916256, -0.177762495548696,
-0.113069194230468, -0.0561203582704902, -0.00655577997768254,
0.0359847483390369, 0.0718614343707493, 0.101434485808536,
0.12506411034348, 0.14311051566666, 0.15593390946916, 0.16389449944206,
0.167352493276442, 0.166668098663387, 0.162201523293977,
0.154312974859294, 0.143362661050417, 0.12971078955843, 0.113717568074414
),
ot4 = c(0.347265133901292, 0.205524262921176, 0.0903598052498273,
-0.000867031923547791, -0.0706803112875423, -0.121489365408538,
-0.15558879673071, -0.175158477576023, -0.182263550144233,
-0.178854426512889, -0.16676678863733, -0.147721588350685,
-0.123325047363878, -0.0950686572656211, -0.0643291795224186,
-0.0323686454785664, -0.000334356356151326, 0.0307411167449481,
0.0599399328470624, 0.0864589810947308)), .Names = c("Subject_No",
"Bin.No", "TargetFix", "Condition.E", "ot1", "ot2", "ot3", "ot4"
), row.names = 3:22, class = "data.frame")
>

# create 4th-order polynormial in the range of Bin.no
t <- poly ((unique(new.df.subjitems$Bin.No)), 4)
# create variables ot1, ot2, ot3, ot4 corresponding to the orthogonal
polynomial time terms and populate their values
# with the Bin.No-appropriate orthogonal polynomial values:
new.df.subjitems[,paste("ot", 1:4, sep="")] <- t[new.df.subjitems$Bin.No, 1:4]
Model.subjitems.2 <- lmer(TargetFix ~ (ot1+ot2+ot3+ot4)*Condition.E +
(1+ot1+ot2+ot3+ot4|Subject_No) +(1+ot1+ot2+ot3+ot4|Item.No),
control = lmerControl(optimizer="bobyqa"),
data=new.df.subjitems, REML=F)

# create 4th-order polynormial in the range of Bin.no
t <- poly ((unique(df.subjonly$Bin.No)), 4)
# create variables ot1, ot2, ot3, ot4 corresponding to the orthogonal
polynomial time terms and populate their values
# with the Bin.No-appropriate orthogonal polynomial values:
df.subjonly[,paste("ot", 1:4, sep="")] <- t[df.subjonly$Bin.No, 1:4]
Model.subj.2 <- lmer(TargetFix ~ (ot1+ot2+ot3+ot4)*Condition.E +
(1+ot1+ot2+ot3+ot4|Subject_No),
control = lmerControl(optimizer="bobyqa"), data=df.subjonly,
REML=F)

# Graph Subject Items
ggplot(data=new.df.subjitems, aes(Bin.No, TargetFix, color=Condition.E,
lty=Condition.E, shape=Condition.E)) +
stat_summary(fun.data=mean_se,geom="ribbon",linetype=0,alpha=0.25) +
stat_summary(fun.data=mean_se,geom="point",size=1,alpha=0.40)
+stat_summary(aes(y=fitted(Model.subjitems.2)),
fun.y=mean,geom="line",size=2.0,alpha=0.9) +
theme_bw(base_size=10) +
labs(y="Fixation Proportion", x="Bins") +
ggtitle("Subjects and Items, Target Fixations") +
theme(text=element_text(color = "black", size=20, family = "Georgia")) +
theme(axis.text = element_text(color = "black", size=10, family = "Georgia"))
+
scale_color_viridis(begin=0, end = .8, discrete=TRUE) +
scale_shape_manual(values=c(3,2,16,7)) + #16,3,2
theme(legend.key.width=unit(4,"line")) +
ggsave("Testing_SubjectItems_v3.png",width=10,height=5)

# Graph Subject Only
ggplot(data=df.subjonly, aes(Bin.No, TargetFix, color=Condition.E,
lty=Condition.E, shape=Condition.E)) +
stat_summary(fun.data=mean_se,geom="ribbon",linetype=0,alpha=0.25) +
stat_summary(fun.data=mean_se,geom="point",size=1,alpha=0.40) +
stat_summary(aes(y=fitted(Model.subj.2)),
fun.y=mean,geom="line",size=2.0,alpha=0.9) +
theme_bw(base_size=10) +
labs(y="Fixation Proportion", x="Bins") +
ggtitle("Subj Only, Target Fixations") +
theme(text=element_text(color = "black", size=20, family = "Georgia")) +
theme(axis.text = element_text(color = "black", size=10, family = "Georgia"))
+
scale_color_viridis(begin=0, end = .8, discrete=TRUE) +
scale_shape_manual(values=c(3,2,16,7)) + #16,3,2
theme(legend.key.width=unit(4,"line")) +
ggsave("Testing_SubjectOnly_v3.png",width=10,height=5)









share|improve this question
























  • Can you post sample data? Please edit the question with the output of dput(new.df.subjitems). Or, if it is too big with the output of dput(head(new.df.subjitems, 20)).

    – Rui Barradas
    Nov 13 '18 at 15:24











  • I have now done so, I think. Thank you.

    – N.Dab
    Nov 13 '18 at 16:48















0















I have been having trouble graphing growth curve model results that have been calculated over both subjects and items (both included as random effects), while models calculated over a dataset that is averaged over items, so that subjects are the only random effect, seems to work fine. I cannot seem to figure out why this would be or how to fix it.



Graph of Subject Only Model



Graph of Subjects and Items Model



Summary DF Subj Items



Summary DF Subj Only



> dput(head(new.df.subjitems, 20))
structure(list(Item.No = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1),
Subject_No = c(330, 322, 141, 330, 330,
330, 137, 330, 330, 330, 137, 330, 137, 330, 330, 137, 137, 330,
137, 141),
Bin.No = c(35, 17, 19, 44, 42, 34, 31, 23, 36, 32,
33, 28, 23, 33, 37, 7, 4, 30, 28, 31),
TargetFix = c(1, 1, 1,
0, 0.02, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0),
Condition.E = structure(c(5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L), .Label = c("First", "Second", "Max Entropy, Unrelated",
"Third", "Fourth", "Max Entropy, Competitive"), class = "factor"),


ot1 = c(-0.00489995957550024, 0.220498180897511, -0.171498585142509,
0.142098827689507, 0.210698261746511, -0.20089834259551,
-0.0538995553305028, -0.151898746840508, -0.112699070236506,
-0.230298100048512, 0.0146998787265008, -0.161698665991508,
-0.151898746840508, 0.0146998787265008, -0.122498989387506,
0.0538995553305028, 0.181298504293509, -0.0440996361795023,
-0.161698665991508, -0.0538995553305028),
ot2 = c(-0.158018948215706,
0.226392531578272, 0.0744512352170155, 0.00151941296361255,
0.192965446378795, 0.161057774142931, -0.135227753761518,
0.024310607417801, -0.0577376926172773, 0.26133902974136,
-0.156499535252094, 0.0486212148356019, 0.024310607417801,
-0.156499535252094, -0.0395047370539266, -0.135227753761518,
0.101800668562042, -0.142824818579581, 0.0486212148356019,
-0.135227753761518),
ot3 = c(0.0112384799617412, 0.177762495548696,
0.0718614343707494, -0.14311051566666, 0.113069194230467,
-0.05612035827049, 0.113717568074414, 0.12506411034348, 0.167352493276442,
-0.250560469916257, -0.0335353360396831, 0.101434485808536,
0.12506411034348, -0.0335353360396831, 0.16389449944206,
-0.113717568074414, -0.035984748339037, 0.0957432042894495,
0.101434485808536, 0.113717568074414),
ot4 = c(0.158779933129858,
0.0903598052498265, -0.175158477576023, -0.166766788637329,
-0.00086703192354873, -0.0706803112875428, 0.0864589810947309,
-0.178854426512889, -0.0950686572656207, 0.205524262921174,
0.153690832709029, -0.182263550144233, -0.178854426512889,
0.153690832709029, -0.123325047363878, 0.0864589810947308,
-0.15558879673071, 0.109609880754701, -0.182263550144233,
0.0864589810947309)),
.Names = c("Item.No", "Subject_No",
"Bin.No", "TargetFix", "Condition.E", "ot1", "ot2", "ot3", "ot4"
), row.names = c(1L, 5L, 8L, 22L, 29L, 59L, 61L, 74L, 78L, 86L,
90L, 98L, 101L, 111L, 115L, 120L, 126L, 133L, 140L, 145L), class = "data.frame")


> dput(head(df.subjonly, 20))
structure(list(Subject_No = c(103, 103, 103, 103, 103, 103, 103,
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103
),
Bin.No = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20),
TargetFix = c(0.16667, 0.16667, 0.16667,
0.16667, 0.32667, 0.39, 0.5, 0.5, 0.5, 0.5, 0.62667, 0.59, 0.66667,
0.66667, 0.76667, 0.76333, 0.66667, 0.40667, 0.33333, 0.48333
),
Condition.E = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("First",
"Second", "Max Entropy, Unrelated", "NaN, Unrelated", "Third",
"Fourth", "Max Entropy, Competitive", "NaN, Competitive", "Low Entropy, NaN",
"High Entropy, NaN", "Max Entropy, NaN", "NaN, NaN"), class = "factor"),

ot1 = c(-0.240098019199512, -0.230298100048512, -0.220498180897511,
-0.210698261746511, -0.20089834259551, -0.19109842344451,
-0.181298504293509, -0.171498585142509, -0.161698665991508,
-0.151898746840508, -0.142098827689507, -0.132298908538507,
-0.122498989387506, -0.112699070236506, -0.102899151085505,
-0.0930992319345048, -0.0832993127835043, -0.0734993936325038,
-0.0636994744815033, -0.0538995553305028),
ot2 = c(0.297804940868062,
0.26133902974136, 0.226392531578271, 0.192965446378795, 0.161057774142931,
0.13066951487068, 0.101800668562042, 0.0744512352170154,
0.0486212148356019, 0.0243106074178009, 0.0015194129636125,
-0.0197523685269634, -0.0395047370539266, -0.0577376926172774,
-0.0744512352170155, -0.0896453648531411, -0.103320081525654,
-0.115475385234555, -0.126111275979843, -0.135227753761518
),
ot3 = c(-0.331823325024233, -0.250560469916256, -0.177762495548696,
-0.113069194230468, -0.0561203582704902, -0.00655577997768254,
0.0359847483390369, 0.0718614343707493, 0.101434485808536,
0.12506411034348, 0.14311051566666, 0.15593390946916, 0.16389449944206,
0.167352493276442, 0.166668098663387, 0.162201523293977,
0.154312974859294, 0.143362661050417, 0.12971078955843, 0.113717568074414
),
ot4 = c(0.347265133901292, 0.205524262921176, 0.0903598052498273,
-0.000867031923547791, -0.0706803112875423, -0.121489365408538,
-0.15558879673071, -0.175158477576023, -0.182263550144233,
-0.178854426512889, -0.16676678863733, -0.147721588350685,
-0.123325047363878, -0.0950686572656211, -0.0643291795224186,
-0.0323686454785664, -0.000334356356151326, 0.0307411167449481,
0.0599399328470624, 0.0864589810947308)), .Names = c("Subject_No",
"Bin.No", "TargetFix", "Condition.E", "ot1", "ot2", "ot3", "ot4"
), row.names = 3:22, class = "data.frame")
>

# create 4th-order polynormial in the range of Bin.no
t <- poly ((unique(new.df.subjitems$Bin.No)), 4)
# create variables ot1, ot2, ot3, ot4 corresponding to the orthogonal
polynomial time terms and populate their values
# with the Bin.No-appropriate orthogonal polynomial values:
new.df.subjitems[,paste("ot", 1:4, sep="")] <- t[new.df.subjitems$Bin.No, 1:4]
Model.subjitems.2 <- lmer(TargetFix ~ (ot1+ot2+ot3+ot4)*Condition.E +
(1+ot1+ot2+ot3+ot4|Subject_No) +(1+ot1+ot2+ot3+ot4|Item.No),
control = lmerControl(optimizer="bobyqa"),
data=new.df.subjitems, REML=F)

# create 4th-order polynormial in the range of Bin.no
t <- poly ((unique(df.subjonly$Bin.No)), 4)
# create variables ot1, ot2, ot3, ot4 corresponding to the orthogonal
polynomial time terms and populate their values
# with the Bin.No-appropriate orthogonal polynomial values:
df.subjonly[,paste("ot", 1:4, sep="")] <- t[df.subjonly$Bin.No, 1:4]
Model.subj.2 <- lmer(TargetFix ~ (ot1+ot2+ot3+ot4)*Condition.E +
(1+ot1+ot2+ot3+ot4|Subject_No),
control = lmerControl(optimizer="bobyqa"), data=df.subjonly,
REML=F)

# Graph Subject Items
ggplot(data=new.df.subjitems, aes(Bin.No, TargetFix, color=Condition.E,
lty=Condition.E, shape=Condition.E)) +
stat_summary(fun.data=mean_se,geom="ribbon",linetype=0,alpha=0.25) +
stat_summary(fun.data=mean_se,geom="point",size=1,alpha=0.40)
+stat_summary(aes(y=fitted(Model.subjitems.2)),
fun.y=mean,geom="line",size=2.0,alpha=0.9) +
theme_bw(base_size=10) +
labs(y="Fixation Proportion", x="Bins") +
ggtitle("Subjects and Items, Target Fixations") +
theme(text=element_text(color = "black", size=20, family = "Georgia")) +
theme(axis.text = element_text(color = "black", size=10, family = "Georgia"))
+
scale_color_viridis(begin=0, end = .8, discrete=TRUE) +
scale_shape_manual(values=c(3,2,16,7)) + #16,3,2
theme(legend.key.width=unit(4,"line")) +
ggsave("Testing_SubjectItems_v3.png",width=10,height=5)

# Graph Subject Only
ggplot(data=df.subjonly, aes(Bin.No, TargetFix, color=Condition.E,
lty=Condition.E, shape=Condition.E)) +
stat_summary(fun.data=mean_se,geom="ribbon",linetype=0,alpha=0.25) +
stat_summary(fun.data=mean_se,geom="point",size=1,alpha=0.40) +
stat_summary(aes(y=fitted(Model.subj.2)),
fun.y=mean,geom="line",size=2.0,alpha=0.9) +
theme_bw(base_size=10) +
labs(y="Fixation Proportion", x="Bins") +
ggtitle("Subj Only, Target Fixations") +
theme(text=element_text(color = "black", size=20, family = "Georgia")) +
theme(axis.text = element_text(color = "black", size=10, family = "Georgia"))
+
scale_color_viridis(begin=0, end = .8, discrete=TRUE) +
scale_shape_manual(values=c(3,2,16,7)) + #16,3,2
theme(legend.key.width=unit(4,"line")) +
ggsave("Testing_SubjectOnly_v3.png",width=10,height=5)









share|improve this question
























  • Can you post sample data? Please edit the question with the output of dput(new.df.subjitems). Or, if it is too big with the output of dput(head(new.df.subjitems, 20)).

    – Rui Barradas
    Nov 13 '18 at 15:24











  • I have now done so, I think. Thank you.

    – N.Dab
    Nov 13 '18 at 16:48













0












0








0








I have been having trouble graphing growth curve model results that have been calculated over both subjects and items (both included as random effects), while models calculated over a dataset that is averaged over items, so that subjects are the only random effect, seems to work fine. I cannot seem to figure out why this would be or how to fix it.



Graph of Subject Only Model



Graph of Subjects and Items Model



Summary DF Subj Items



Summary DF Subj Only



> dput(head(new.df.subjitems, 20))
structure(list(Item.No = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1),
Subject_No = c(330, 322, 141, 330, 330,
330, 137, 330, 330, 330, 137, 330, 137, 330, 330, 137, 137, 330,
137, 141),
Bin.No = c(35, 17, 19, 44, 42, 34, 31, 23, 36, 32,
33, 28, 23, 33, 37, 7, 4, 30, 28, 31),
TargetFix = c(1, 1, 1,
0, 0.02, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0),
Condition.E = structure(c(5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L), .Label = c("First", "Second", "Max Entropy, Unrelated",
"Third", "Fourth", "Max Entropy, Competitive"), class = "factor"),


ot1 = c(-0.00489995957550024, 0.220498180897511, -0.171498585142509,
0.142098827689507, 0.210698261746511, -0.20089834259551,
-0.0538995553305028, -0.151898746840508, -0.112699070236506,
-0.230298100048512, 0.0146998787265008, -0.161698665991508,
-0.151898746840508, 0.0146998787265008, -0.122498989387506,
0.0538995553305028, 0.181298504293509, -0.0440996361795023,
-0.161698665991508, -0.0538995553305028),
ot2 = c(-0.158018948215706,
0.226392531578272, 0.0744512352170155, 0.00151941296361255,
0.192965446378795, 0.161057774142931, -0.135227753761518,
0.024310607417801, -0.0577376926172773, 0.26133902974136,
-0.156499535252094, 0.0486212148356019, 0.024310607417801,
-0.156499535252094, -0.0395047370539266, -0.135227753761518,
0.101800668562042, -0.142824818579581, 0.0486212148356019,
-0.135227753761518),
ot3 = c(0.0112384799617412, 0.177762495548696,
0.0718614343707494, -0.14311051566666, 0.113069194230467,
-0.05612035827049, 0.113717568074414, 0.12506411034348, 0.167352493276442,
-0.250560469916257, -0.0335353360396831, 0.101434485808536,
0.12506411034348, -0.0335353360396831, 0.16389449944206,
-0.113717568074414, -0.035984748339037, 0.0957432042894495,
0.101434485808536, 0.113717568074414),
ot4 = c(0.158779933129858,
0.0903598052498265, -0.175158477576023, -0.166766788637329,
-0.00086703192354873, -0.0706803112875428, 0.0864589810947309,
-0.178854426512889, -0.0950686572656207, 0.205524262921174,
0.153690832709029, -0.182263550144233, -0.178854426512889,
0.153690832709029, -0.123325047363878, 0.0864589810947308,
-0.15558879673071, 0.109609880754701, -0.182263550144233,
0.0864589810947309)),
.Names = c("Item.No", "Subject_No",
"Bin.No", "TargetFix", "Condition.E", "ot1", "ot2", "ot3", "ot4"
), row.names = c(1L, 5L, 8L, 22L, 29L, 59L, 61L, 74L, 78L, 86L,
90L, 98L, 101L, 111L, 115L, 120L, 126L, 133L, 140L, 145L), class = "data.frame")


> dput(head(df.subjonly, 20))
structure(list(Subject_No = c(103, 103, 103, 103, 103, 103, 103,
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103
),
Bin.No = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20),
TargetFix = c(0.16667, 0.16667, 0.16667,
0.16667, 0.32667, 0.39, 0.5, 0.5, 0.5, 0.5, 0.62667, 0.59, 0.66667,
0.66667, 0.76667, 0.76333, 0.66667, 0.40667, 0.33333, 0.48333
),
Condition.E = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("First",
"Second", "Max Entropy, Unrelated", "NaN, Unrelated", "Third",
"Fourth", "Max Entropy, Competitive", "NaN, Competitive", "Low Entropy, NaN",
"High Entropy, NaN", "Max Entropy, NaN", "NaN, NaN"), class = "factor"),

ot1 = c(-0.240098019199512, -0.230298100048512, -0.220498180897511,
-0.210698261746511, -0.20089834259551, -0.19109842344451,
-0.181298504293509, -0.171498585142509, -0.161698665991508,
-0.151898746840508, -0.142098827689507, -0.132298908538507,
-0.122498989387506, -0.112699070236506, -0.102899151085505,
-0.0930992319345048, -0.0832993127835043, -0.0734993936325038,
-0.0636994744815033, -0.0538995553305028),
ot2 = c(0.297804940868062,
0.26133902974136, 0.226392531578271, 0.192965446378795, 0.161057774142931,
0.13066951487068, 0.101800668562042, 0.0744512352170154,
0.0486212148356019, 0.0243106074178009, 0.0015194129636125,
-0.0197523685269634, -0.0395047370539266, -0.0577376926172774,
-0.0744512352170155, -0.0896453648531411, -0.103320081525654,
-0.115475385234555, -0.126111275979843, -0.135227753761518
),
ot3 = c(-0.331823325024233, -0.250560469916256, -0.177762495548696,
-0.113069194230468, -0.0561203582704902, -0.00655577997768254,
0.0359847483390369, 0.0718614343707493, 0.101434485808536,
0.12506411034348, 0.14311051566666, 0.15593390946916, 0.16389449944206,
0.167352493276442, 0.166668098663387, 0.162201523293977,
0.154312974859294, 0.143362661050417, 0.12971078955843, 0.113717568074414
),
ot4 = c(0.347265133901292, 0.205524262921176, 0.0903598052498273,
-0.000867031923547791, -0.0706803112875423, -0.121489365408538,
-0.15558879673071, -0.175158477576023, -0.182263550144233,
-0.178854426512889, -0.16676678863733, -0.147721588350685,
-0.123325047363878, -0.0950686572656211, -0.0643291795224186,
-0.0323686454785664, -0.000334356356151326, 0.0307411167449481,
0.0599399328470624, 0.0864589810947308)), .Names = c("Subject_No",
"Bin.No", "TargetFix", "Condition.E", "ot1", "ot2", "ot3", "ot4"
), row.names = 3:22, class = "data.frame")
>

# create 4th-order polynormial in the range of Bin.no
t <- poly ((unique(new.df.subjitems$Bin.No)), 4)
# create variables ot1, ot2, ot3, ot4 corresponding to the orthogonal
polynomial time terms and populate their values
# with the Bin.No-appropriate orthogonal polynomial values:
new.df.subjitems[,paste("ot", 1:4, sep="")] <- t[new.df.subjitems$Bin.No, 1:4]
Model.subjitems.2 <- lmer(TargetFix ~ (ot1+ot2+ot3+ot4)*Condition.E +
(1+ot1+ot2+ot3+ot4|Subject_No) +(1+ot1+ot2+ot3+ot4|Item.No),
control = lmerControl(optimizer="bobyqa"),
data=new.df.subjitems, REML=F)

# create 4th-order polynormial in the range of Bin.no
t <- poly ((unique(df.subjonly$Bin.No)), 4)
# create variables ot1, ot2, ot3, ot4 corresponding to the orthogonal
polynomial time terms and populate their values
# with the Bin.No-appropriate orthogonal polynomial values:
df.subjonly[,paste("ot", 1:4, sep="")] <- t[df.subjonly$Bin.No, 1:4]
Model.subj.2 <- lmer(TargetFix ~ (ot1+ot2+ot3+ot4)*Condition.E +
(1+ot1+ot2+ot3+ot4|Subject_No),
control = lmerControl(optimizer="bobyqa"), data=df.subjonly,
REML=F)

# Graph Subject Items
ggplot(data=new.df.subjitems, aes(Bin.No, TargetFix, color=Condition.E,
lty=Condition.E, shape=Condition.E)) +
stat_summary(fun.data=mean_se,geom="ribbon",linetype=0,alpha=0.25) +
stat_summary(fun.data=mean_se,geom="point",size=1,alpha=0.40)
+stat_summary(aes(y=fitted(Model.subjitems.2)),
fun.y=mean,geom="line",size=2.0,alpha=0.9) +
theme_bw(base_size=10) +
labs(y="Fixation Proportion", x="Bins") +
ggtitle("Subjects and Items, Target Fixations") +
theme(text=element_text(color = "black", size=20, family = "Georgia")) +
theme(axis.text = element_text(color = "black", size=10, family = "Georgia"))
+
scale_color_viridis(begin=0, end = .8, discrete=TRUE) +
scale_shape_manual(values=c(3,2,16,7)) + #16,3,2
theme(legend.key.width=unit(4,"line")) +
ggsave("Testing_SubjectItems_v3.png",width=10,height=5)

# Graph Subject Only
ggplot(data=df.subjonly, aes(Bin.No, TargetFix, color=Condition.E,
lty=Condition.E, shape=Condition.E)) +
stat_summary(fun.data=mean_se,geom="ribbon",linetype=0,alpha=0.25) +
stat_summary(fun.data=mean_se,geom="point",size=1,alpha=0.40) +
stat_summary(aes(y=fitted(Model.subj.2)),
fun.y=mean,geom="line",size=2.0,alpha=0.9) +
theme_bw(base_size=10) +
labs(y="Fixation Proportion", x="Bins") +
ggtitle("Subj Only, Target Fixations") +
theme(text=element_text(color = "black", size=20, family = "Georgia")) +
theme(axis.text = element_text(color = "black", size=10, family = "Georgia"))
+
scale_color_viridis(begin=0, end = .8, discrete=TRUE) +
scale_shape_manual(values=c(3,2,16,7)) + #16,3,2
theme(legend.key.width=unit(4,"line")) +
ggsave("Testing_SubjectOnly_v3.png",width=10,height=5)









share|improve this question
















I have been having trouble graphing growth curve model results that have been calculated over both subjects and items (both included as random effects), while models calculated over a dataset that is averaged over items, so that subjects are the only random effect, seems to work fine. I cannot seem to figure out why this would be or how to fix it.



Graph of Subject Only Model



Graph of Subjects and Items Model



Summary DF Subj Items



Summary DF Subj Only



> dput(head(new.df.subjitems, 20))
structure(list(Item.No = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1),
Subject_No = c(330, 322, 141, 330, 330,
330, 137, 330, 330, 330, 137, 330, 137, 330, 330, 137, 137, 330,
137, 141),
Bin.No = c(35, 17, 19, 44, 42, 34, 31, 23, 36, 32,
33, 28, 23, 33, 37, 7, 4, 30, 28, 31),
TargetFix = c(1, 1, 1,
0, 0.02, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0),
Condition.E = structure(c(5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L), .Label = c("First", "Second", "Max Entropy, Unrelated",
"Third", "Fourth", "Max Entropy, Competitive"), class = "factor"),


ot1 = c(-0.00489995957550024, 0.220498180897511, -0.171498585142509,
0.142098827689507, 0.210698261746511, -0.20089834259551,
-0.0538995553305028, -0.151898746840508, -0.112699070236506,
-0.230298100048512, 0.0146998787265008, -0.161698665991508,
-0.151898746840508, 0.0146998787265008, -0.122498989387506,
0.0538995553305028, 0.181298504293509, -0.0440996361795023,
-0.161698665991508, -0.0538995553305028),
ot2 = c(-0.158018948215706,
0.226392531578272, 0.0744512352170155, 0.00151941296361255,
0.192965446378795, 0.161057774142931, -0.135227753761518,
0.024310607417801, -0.0577376926172773, 0.26133902974136,
-0.156499535252094, 0.0486212148356019, 0.024310607417801,
-0.156499535252094, -0.0395047370539266, -0.135227753761518,
0.101800668562042, -0.142824818579581, 0.0486212148356019,
-0.135227753761518),
ot3 = c(0.0112384799617412, 0.177762495548696,
0.0718614343707494, -0.14311051566666, 0.113069194230467,
-0.05612035827049, 0.113717568074414, 0.12506411034348, 0.167352493276442,
-0.250560469916257, -0.0335353360396831, 0.101434485808536,
0.12506411034348, -0.0335353360396831, 0.16389449944206,
-0.113717568074414, -0.035984748339037, 0.0957432042894495,
0.101434485808536, 0.113717568074414),
ot4 = c(0.158779933129858,
0.0903598052498265, -0.175158477576023, -0.166766788637329,
-0.00086703192354873, -0.0706803112875428, 0.0864589810947309,
-0.178854426512889, -0.0950686572656207, 0.205524262921174,
0.153690832709029, -0.182263550144233, -0.178854426512889,
0.153690832709029, -0.123325047363878, 0.0864589810947308,
-0.15558879673071, 0.109609880754701, -0.182263550144233,
0.0864589810947309)),
.Names = c("Item.No", "Subject_No",
"Bin.No", "TargetFix", "Condition.E", "ot1", "ot2", "ot3", "ot4"
), row.names = c(1L, 5L, 8L, 22L, 29L, 59L, 61L, 74L, 78L, 86L,
90L, 98L, 101L, 111L, 115L, 120L, 126L, 133L, 140L, 145L), class = "data.frame")


> dput(head(df.subjonly, 20))
structure(list(Subject_No = c(103, 103, 103, 103, 103, 103, 103,
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103
),
Bin.No = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20),
TargetFix = c(0.16667, 0.16667, 0.16667,
0.16667, 0.32667, 0.39, 0.5, 0.5, 0.5, 0.5, 0.62667, 0.59, 0.66667,
0.66667, 0.76667, 0.76333, 0.66667, 0.40667, 0.33333, 0.48333
),
Condition.E = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("First",
"Second", "Max Entropy, Unrelated", "NaN, Unrelated", "Third",
"Fourth", "Max Entropy, Competitive", "NaN, Competitive", "Low Entropy, NaN",
"High Entropy, NaN", "Max Entropy, NaN", "NaN, NaN"), class = "factor"),

ot1 = c(-0.240098019199512, -0.230298100048512, -0.220498180897511,
-0.210698261746511, -0.20089834259551, -0.19109842344451,
-0.181298504293509, -0.171498585142509, -0.161698665991508,
-0.151898746840508, -0.142098827689507, -0.132298908538507,
-0.122498989387506, -0.112699070236506, -0.102899151085505,
-0.0930992319345048, -0.0832993127835043, -0.0734993936325038,
-0.0636994744815033, -0.0538995553305028),
ot2 = c(0.297804940868062,
0.26133902974136, 0.226392531578271, 0.192965446378795, 0.161057774142931,
0.13066951487068, 0.101800668562042, 0.0744512352170154,
0.0486212148356019, 0.0243106074178009, 0.0015194129636125,
-0.0197523685269634, -0.0395047370539266, -0.0577376926172774,
-0.0744512352170155, -0.0896453648531411, -0.103320081525654,
-0.115475385234555, -0.126111275979843, -0.135227753761518
),
ot3 = c(-0.331823325024233, -0.250560469916256, -0.177762495548696,
-0.113069194230468, -0.0561203582704902, -0.00655577997768254,
0.0359847483390369, 0.0718614343707493, 0.101434485808536,
0.12506411034348, 0.14311051566666, 0.15593390946916, 0.16389449944206,
0.167352493276442, 0.166668098663387, 0.162201523293977,
0.154312974859294, 0.143362661050417, 0.12971078955843, 0.113717568074414
),
ot4 = c(0.347265133901292, 0.205524262921176, 0.0903598052498273,
-0.000867031923547791, -0.0706803112875423, -0.121489365408538,
-0.15558879673071, -0.175158477576023, -0.182263550144233,
-0.178854426512889, -0.16676678863733, -0.147721588350685,
-0.123325047363878, -0.0950686572656211, -0.0643291795224186,
-0.0323686454785664, -0.000334356356151326, 0.0307411167449481,
0.0599399328470624, 0.0864589810947308)), .Names = c("Subject_No",
"Bin.No", "TargetFix", "Condition.E", "ot1", "ot2", "ot3", "ot4"
), row.names = 3:22, class = "data.frame")
>

# create 4th-order polynormial in the range of Bin.no
t <- poly ((unique(new.df.subjitems$Bin.No)), 4)
# create variables ot1, ot2, ot3, ot4 corresponding to the orthogonal
polynomial time terms and populate their values
# with the Bin.No-appropriate orthogonal polynomial values:
new.df.subjitems[,paste("ot", 1:4, sep="")] <- t[new.df.subjitems$Bin.No, 1:4]
Model.subjitems.2 <- lmer(TargetFix ~ (ot1+ot2+ot3+ot4)*Condition.E +
(1+ot1+ot2+ot3+ot4|Subject_No) +(1+ot1+ot2+ot3+ot4|Item.No),
control = lmerControl(optimizer="bobyqa"),
data=new.df.subjitems, REML=F)

# create 4th-order polynormial in the range of Bin.no
t <- poly ((unique(df.subjonly$Bin.No)), 4)
# create variables ot1, ot2, ot3, ot4 corresponding to the orthogonal
polynomial time terms and populate their values
# with the Bin.No-appropriate orthogonal polynomial values:
df.subjonly[,paste("ot", 1:4, sep="")] <- t[df.subjonly$Bin.No, 1:4]
Model.subj.2 <- lmer(TargetFix ~ (ot1+ot2+ot3+ot4)*Condition.E +
(1+ot1+ot2+ot3+ot4|Subject_No),
control = lmerControl(optimizer="bobyqa"), data=df.subjonly,
REML=F)

# Graph Subject Items
ggplot(data=new.df.subjitems, aes(Bin.No, TargetFix, color=Condition.E,
lty=Condition.E, shape=Condition.E)) +
stat_summary(fun.data=mean_se,geom="ribbon",linetype=0,alpha=0.25) +
stat_summary(fun.data=mean_se,geom="point",size=1,alpha=0.40)
+stat_summary(aes(y=fitted(Model.subjitems.2)),
fun.y=mean,geom="line",size=2.0,alpha=0.9) +
theme_bw(base_size=10) +
labs(y="Fixation Proportion", x="Bins") +
ggtitle("Subjects and Items, Target Fixations") +
theme(text=element_text(color = "black", size=20, family = "Georgia")) +
theme(axis.text = element_text(color = "black", size=10, family = "Georgia"))
+
scale_color_viridis(begin=0, end = .8, discrete=TRUE) +
scale_shape_manual(values=c(3,2,16,7)) + #16,3,2
theme(legend.key.width=unit(4,"line")) +
ggsave("Testing_SubjectItems_v3.png",width=10,height=5)

# Graph Subject Only
ggplot(data=df.subjonly, aes(Bin.No, TargetFix, color=Condition.E,
lty=Condition.E, shape=Condition.E)) +
stat_summary(fun.data=mean_se,geom="ribbon",linetype=0,alpha=0.25) +
stat_summary(fun.data=mean_se,geom="point",size=1,alpha=0.40) +
stat_summary(aes(y=fitted(Model.subj.2)),
fun.y=mean,geom="line",size=2.0,alpha=0.9) +
theme_bw(base_size=10) +
labs(y="Fixation Proportion", x="Bins") +
ggtitle("Subj Only, Target Fixations") +
theme(text=element_text(color = "black", size=20, family = "Georgia")) +
theme(axis.text = element_text(color = "black", size=10, family = "Georgia"))
+
scale_color_viridis(begin=0, end = .8, discrete=TRUE) +
scale_shape_manual(values=c(3,2,16,7)) + #16,3,2
theme(legend.key.width=unit(4,"line")) +
ggsave("Testing_SubjectOnly_v3.png",width=10,height=5)






r ggplot2 lme4






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 15:40







N.Dab

















asked Nov 13 '18 at 15:15









N.DabN.Dab

62




62












  • Can you post sample data? Please edit the question with the output of dput(new.df.subjitems). Or, if it is too big with the output of dput(head(new.df.subjitems, 20)).

    – Rui Barradas
    Nov 13 '18 at 15:24











  • I have now done so, I think. Thank you.

    – N.Dab
    Nov 13 '18 at 16:48

















  • Can you post sample data? Please edit the question with the output of dput(new.df.subjitems). Or, if it is too big with the output of dput(head(new.df.subjitems, 20)).

    – Rui Barradas
    Nov 13 '18 at 15:24











  • I have now done so, I think. Thank you.

    – N.Dab
    Nov 13 '18 at 16:48
















Can you post sample data? Please edit the question with the output of dput(new.df.subjitems). Or, if it is too big with the output of dput(head(new.df.subjitems, 20)).

– Rui Barradas
Nov 13 '18 at 15:24





Can you post sample data? Please edit the question with the output of dput(new.df.subjitems). Or, if it is too big with the output of dput(head(new.df.subjitems, 20)).

– Rui Barradas
Nov 13 '18 at 15:24













I have now done so, I think. Thank you.

– N.Dab
Nov 13 '18 at 16:48





I have now done so, I think. Thank you.

– N.Dab
Nov 13 '18 at 16:48












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284072%2fissue-with-graphing-subjects-and-items-growth-curve-model-vs-subjects-only-in-gg%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284072%2fissue-with-graphing-subjects-and-items-growth-curve-model-vs-subjects-only-in-gg%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3