forked from feste/generics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
speaker2C.r
218 lines (212 loc) · 10.7 KB
/
speaker2C.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
library("ggplot2")
library("bear")
library("plyr")
df = read.table("speaker2C.tsv", sep="\t", header=T)
df = df[,c("workerid", "trial_number",
"trial_type", "sentence_type", "species", "genus",
"feature", "target_proportion", "distractor_proportion",
"response", "incorrect_clicks", "incorrect_labels",
"language", "enjoyment", "age",
"sex", "assess", "education")]
familiarization = subset(df, trial_type == "familiarization")
familiarization$response = as.character(familiarization$response)
sentences = subset(df, trial_type == "sentences")
sentences$response = as.numeric(as.character(sentences$response))
sentences$sentence_type = factor(sentences$sentence_type, levels=c("generic", "usually", "negation", "sometimes", "always"))
ggplot(sentences, aes(x=distractor_proportion, y=response)) +
geom_point(aes(colour=factor(target_proportion)), stat="identity", size=point_size, alpha=1/5) +
ggtitle("Individual Unnormalized Speaker Measure Responses") +
facet_grid(~ sentence_type) +
theme_bw(18) +
theme(
plot.background = element_blank()
,panel.grid.minor = element_blank()
)
ggsave(file="2C_individual.pdf", width=20, height=5, title="Individual Unnormalized Speaker Measure Responses")
graph_title = "2C Mean Endorsement of Generic and Frequencies Sentences"
sentences_summary = summarySE(sentences, measurevar="response", groupvars=c("target_proportion", "distractor_proportion", "sentence_type"))
ggplot(sentences_summary, aes(x=distractor_proportion, y=response)) +
geom_point(aes(colour=factor(target_proportion)), stat="identity", size=point_size) +
geom_errorbar(aes(ymin=response-ci, ymax=response+ci, colour=factor(target_proportion)), width=.03) +
ggtitle(graph_title) +
facet_grid(~sentence_type) +
theme_bw(18) +
theme(
plot.background = element_blank()
,panel.grid.minor = element_blank()
)
ggsave(file="2C_mean.pdf", width=20, height=5, title=graph_title)
# generic = subset(df, trial_type == "generic")
# generic$response = as.numeric(as.character(generic$response))
#
# graph_title = "Individual Endorsement of Generic"
# ggplot(generic, aes(x=distractor_proportion, y=response, colour=factor(target_proportion))) +
# geom_point(stat="identity", size=3) +
# ggtitle(graph_title) +
# theme_bw(18) +
# theme(
# plot.background = element_blank()
# ,panel.grid.minor = element_blank()
# )
# ggsave(file="speaker2B-generic-individuals.pdf", width=10, height=6, title=graph_title)
#
# graph_title = "Mean Endorsement of Generic"
# generic_summary = summarySE(generic, measurevar="response", groupvars=c("target_proportion", "distractor_proportion"))
# ggplot(generic_summary, aes(x=distractor_proportion, y=response, colour=factor(target_proportion))) +
# geom_point(stat="identity", size=3) +
# ggtitle(graph_title) +
# geom_errorbar(aes(ymin=response-ci, ymax=response+ci), width=.03) +
# theme_bw(18) +
# theme(
# plot.background = element_blank()
# ,panel.grid.minor = element_blank()
# )
# ggsave(file="speaker2B-generic-means.pdf", width=10, height=6, title=graph_title)
# # #
# # # # better x and y axis choices for cleaner graph with mean of normalized data
# # # normed_sentence_summary = summarySE(individuals, measurevar="normed_response", groupvars=c("numeric_context", "sentence_type", "category"))
# # # ggplot(normed_sentence_summary, aes(x=numeric_context, y=normed_response)) +
# # # geom_point(aes(colour=factor(sentence_type)), stat="identity", size=point_size) +
# # # ggtitle("mean of normalized endorsement per sentence ") +
# # # geom_errorbar(aes(ymin=normed_response-ci, ymax=normed_response+ci, colour=sentence_type), width=1) +
# # # facet_grid(category ~ sentence_type) +
# # # theme_bw(18) +
# # # theme(
# # # plot.background = element_blank()
# # # #,panel.grid.major = element_blank()
# # # ,panel.grid.minor = element_blank()
# # # )
# # # ggsave(file="normed_mean_responses.pdf", width=20, height=10, title="normed_mean_responses")
# #
#
#
# # #df = subset(df, context != "a_bit_lower")
# # # df = subset(df, reminder_target == "True")
# # # df = subset(df, reminder_context_category0 == "True")
# # # df = subset(df, reminder_context_category1 == "True")
# #
# # df$category = as.character(df$category_type)
# # df$category[df$category == "context_category0"] = "context"
# # df$category[df$category == "context_category1"] = "context"
# # df$category = as.factor(df$category)
# #
# # df$category = factor(df$category, levels=c("target", "context"), labels=c("target (percent positive=50%)", "distractor (percent positive=context)"))
# # df$context = factor(df$context, levels=c("lower", "a_bit_lower", "same", "higher"), labels=c("10", "30", "50", "90"))
# # df$numeric_context = as.numeric(as.character(df$context))
# #
# # ###### name check: how did Ss echo back the names of the creatures
# #
# # name_check = subset(df, trial_type=="name_attention_check")
# # name_check$response = as.character(name_check$response)
# #
# # ###### trial type: sentence ratings (speaker dependent measure)
# #
# # point_size = 5
# #
# # speaker_measure = subset(df, trial_type == "speaker_ratings")
# # speaker_measure$response = as.numeric(as.character(speaker_measure$response))
# # speaker_measure = ddply(speaker_measure, .(workerid, category_type), transform, normed_response = response / sum(response))
# # speaker_measure$sentence_type = factor(speaker_measure$sentence_type, levels=c("generic", "usually", "negation", "sometimes", "always"))
# #
# # # # better x and y axis choices for messy graph with normalized individual data
# # # ggplot(individuals, aes(x=numeric_context, y=normed_response)) +
# # # geom_point(aes(colour=factor(sentence_type)), stat="identity", size=point_size, alpha=1/4) +
# # # ggtitle("normalized individual subject endorsement per sentence") +
# # # facet_grid(category ~ sentence_type) +
# # # theme_bw(18) +
# # # theme(
# # # plot.background = element_blank()
# # # #,panel.grid.major = element_blank()
# # # ,panel.grid.minor = element_blank()
# # # )
# # # ggsave(file="normed_individuals.pdf", width=20, height=10, title="normed_individuals")
# # #
# # # # better x and y axis choices for cleaner graph with mean of normalized data
# # # normed_sentence_summary = summarySE(individuals, measurevar="normed_response", groupvars=c("numeric_context", "sentence_type", "category"))
# # # ggplot(normed_sentence_summary, aes(x=numeric_context, y=normed_response)) +
# # # geom_point(aes(colour=factor(sentence_type)), stat="identity", size=point_size) +
# # # ggtitle("mean of normalized endorsement per sentence ") +
# # # geom_errorbar(aes(ymin=normed_response-ci, ymax=normed_response+ci, colour=sentence_type), width=1) +
# # # facet_grid(category ~ sentence_type) +
# # # theme_bw(18) +
# # # theme(
# # # plot.background = element_blank()
# # # #,panel.grid.major = element_blank()
# # # ,panel.grid.minor = element_blank()
# # # )
# # # ggsave(file="normed_mean_responses.pdf", width=20, height=10, title="normed_mean_responses")
# #
# # # messy graph of individual data
# # ggplot(speaker_measure, aes(x=numeric_context, y=response)) +
# # geom_point(aes(colour=factor(sentence_type)), stat="identity", size=point_size, alpha=1/4) +
# # ggtitle("Individual Unnormalized Speaker Measure Responses") +
# # facet_grid(category ~ sentence_type) +
# # theme_bw(18) +
# # theme(
# # plot.background = element_blank()
# # #,panel.grid.major = element_blank()
# # ,panel.grid.minor = element_blank()
# # )
# # ggsave(file="speaker_individual.pdf", width=20, height=10, title="Individual Unnormalized Speaker Measure Responses")
# #
# # # messy graph of individual data, keeping track of individuals
# # ggplot(speaker_measure, aes(x=sentence_type, y=response)) +
# # geom_line(aes(x=sentence_type, y=response, group=category), colour="black",
# # alpha=1/5) +
# # # + geom_point(colour="black", size = 4.5) +
# # # geom_point(colour="pink", size = 4) +
# # # geom_point(aes(shape = factor(cyl)))
# # geom_point(aes(shape=sentence_type, colour=context, solid=category),
# # stat="identity",
# # size=3) +
# # ggtitle("Individual Unnormalized Speaker Measure Responses") +
# # facet_wrap(~ workerid) +
# # theme(
# # plot.background = element_blank()
# # #,panel.grid.major = element_blank()
# # ,panel.grid.minor = element_blank()
# # #,legend.position="none"
# # )
# # ggsave(file="speaker_by_subject.pdf", width=20, height=10, title="Individual Unnormalized Speaker Measure Responses")
# #
# # # cleaner of mean data
# # sentence_summary = summarySE(speaker_measure, measurevar="response", groupvars=c("numeric_context", "sentence_type", "category"))
# # ggplot(sentence_summary, aes(x=numeric_context, y=response)) +
# # geom_point(aes(colour=factor(sentence_type)), stat="identity", size=point_size) +
# # ggtitle("mean of unnormalized endorsement per sentence ") +
# # geom_errorbar(aes(ymin=response-ci, ymax=response+ci, colour=sentence_type), width=1) +
# # facet_grid(category ~ sentence_type) +
# # theme_bw(18) +
# # theme(
# # plot.background = element_blank()
# # #,panel.grid.major = element_blank()
# # ,panel.grid.minor = element_blank()
# # )
# # ggsave(file="speaker_mean.pdf", width=20, height=10, title="Means of Unnormalized Speaker Measure Responses")
# #
# # ###### trial type: posterior predictive measure
# #
# # posterior_measure = subset(df, trial_type == "posterior_predictive")
# # posterior_measure$response = as.numeric(as.character(posterior_measure$response))
# #
# # ggplot(posterior_measure, aes(x=numeric_context, y=response)) +
# # geom_point(aes(colour=factor(numeric_context)), stat="identity", size=point_size, alpha=1/2) +
# # ggtitle("given 'wugs have fur', how likely is the next wug to have fur?") +
# # facet_wrap(~ category) +
# # theme_bw(18) +
# # theme(
# # plot.background = element_blank(),
# # panel.grid.minor = element_blank())
# # ggsave(file="posterior_individual.pdf", width=16, height=8, title="Individual Posterior Measure Responses")
# #
# # posterior_summary = summarySE(posterior_measure, measurevar="response", groupvars=c("numeric_context", "category"))
# # ggplot(posterior_summary, aes(x=numeric_context, y=response)) +
# # geom_point(aes(colour=factor(numeric_context)), stat="identity", size=point_size) +
# # ggtitle("given 'wugs have fur', how likely is the next wug to have fur?") +
# # geom_errorbar(aes(ymin=response-ci, ymax=response+ci, colour=factor(numeric_context)), width=1) +
# # facet_wrap(~ category) +
# # theme_bw(18) +
# # theme(
# # plot.background = element_blank(),
# # panel.grid.minor = element_blank())
# # ggsave(file="posterior_mean.pdf", width=16, height=8, title="Means of Posterior Measure Responses")