Skip to content

Commit 0f58b2e

Browse files
committed
Add model 2
1 parent ebc8113 commit 0f58b2e

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

code/analysisWordLevelPrePostRevisedReadAloudBeta.R

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,49 @@ interact_plot(model = hesitation_adjacent_misproduction_model_1_logistic_wordfre
9595
# then we stack the two sets of rows on top of each other
9696

9797
revisedDatLookBackwards <- revisedDatNoNAs
98-
revisedDatLookBackwards$hesitation_position_predictor <- if_else(
98+
revisedDatLookBackwards$hesitation_position <- if_else(
9999
as.logical(revisedDatLookBackwards$any_prior_hesitation_outcome),
100100
true = -1, # meaning before the syllable in question
101101
false = NA)
102102

103-
revisedDatLookBackwards$hesitation_position_predictor
103+
revisedDatLookBackwards$hesitation_position
104104

105105

106106
revisedDatLookForwards <- revisedDatNoNAs
107-
revisedDatLookForwards$hesitation_position_predictor <- if_else(
107+
revisedDatLookForwards$hesitation_position <- if_else(
108108
as.logical(revisedDatLookForwards$any_upcoming_hesitation_outcome),
109109
true = 1, # meaning after the syllable in question
110110
false = NA)
111-
revisedDatLookForwards$hesitation_position_predictor
111+
revisedDatLookForwards$hesitation_position
112112

113113
revisedDatWithPosition <- rbind(revisedDatLookBackwards, revisedDatLookForwards)
114114

115+
revisedDatWithPosition <-
116+
differentiate_predictor_and_outcome(revisedDatWithPosition, "hesitation_position")
117+
revisedDatWithPosition$hesitation_position_outcome <- NULL # because unused
115118

119+
# set up model 2
120+
hesitation_adjacent_misproduction_model_2_logistic_wordfreq_with_absents_as_median_no_psg <- # starting sans passage because prior model with fewer predictors still did not initially converge
121+
glmer(misprod_outcome ~ any_adjacent_hesitation_predictor * hesitation_position_predictor * log10frequency_with_absents_as_median_z * scaaredSoc_z + (1|id) + (1|word),
122+
data=revisedDatWithPosition, family = "binomial")
123+
# fails, try again without the earlier predictor, because it is already encompassed by the new positional predictor
124+
125+
hesitation_adjacent_misproduction_model_3_logistic_wordfreq_with_absents_as_median_no_psg <- # starting sans passage because prior model with fewer predictors still did not initially converge
126+
glmer(misprod_outcome ~ hesitation_position_predictor * log10frequency_with_absents_as_median_z * scaaredSoc_z + (1|id) + (1|word),
127+
data=revisedDatWithPosition, family = "binomial")
128+
129+
# raise # of iterations
130+
hesitation_adjacent_misproduction_model_3_logistic_wordfreq_with_absents_as_median_no_psg_bobyqa <-
131+
update(hesitation_adjacent_misproduction_model_3_logistic_wordfreq_with_absents_as_median_no_psg,
132+
control = glmerControl(optimizer="bobyqa", optCtrl = list(maxfun = 1e9)))
133+
134+
# now plot
135+
interact_plot(model = hesitation_adjacent_misproduction_model_3_logistic_wordfreq_with_absents_as_median_no_psg_bobyqa,
136+
pred = log10frequency_with_absents_as_median_z,
137+
modx = hesitation_position_predictor,
138+
interval = TRUE,
139+
#fixme x.label = "SCAARED-Social score\n(z-scored)",
140+
y.label = expression(
141+
atop("Probability of misproduction",
142+
"(word-level)")),
143+
)

0 commit comments

Comments
 (0)