Skip to content

Instantly share code, notes, and snippets.

@hans
Last active August 15, 2022 15:34
Show Gist options
  • Save hans/73553e7eea002b261f639506ed04b8b9 to your computer and use it in GitHub Desktop.
Save hans/73553e7eea002b261f639506ed04b8b9 to your computer and use it in GitHub Desktop.
*.csv
__pycache__
.ipynb_checkpoints
---
title: "R Notebook"
output: html_notebook
---
```{r}
library(tidyverse)
library(lme4)
library(lmerTest)
```
```{r}
SUITE = "number_prep"
```
```{r}
predictions_df <- read_csv(paste0(SUITE, ".predictions.csv"))
glimpse(predictions_df)
```
```{r}
predictions_df = predictions_df %>%
mutate(first_item_number=str_extract(used_item_numbers, "^(\\d+)"))
```
```{r}
lm = glmer(prediction_0 ~ log(prefix_length + 1) + (log(prefix_length + 1) | first_item_number),
family=binomial, data=predictions_df)
summary(lm)
```
```{r}
ranef(lm)
```
```{r}
#region_df = read_csv(paste0(SUITE, ".regions.csv"))
#glimpse(region_df)
region_df = rbind(read_csv("number_prep.regions.csv"), read_csv("number_prep2.regions.csv"))
glimpse(region_df)
```
```{r}
crit_region_data = region_df %>%
left_join(predictions_df %>% select(c(item_number, prefix_length, first_item_number)), by="item_number") %>%
filter(region_number == 7) %>%
mutate(grammatical=!grepl("mismatch", condition),
feature=str_extract(condition, "_(.+)$"))
```
```{r}
contrasts(crit_region_data$grammatical) = c(-1, 1)
lm = lmer(value ~ grammatical * log(prefix_length + 1) + (1 | first_item_number) + (1 | feature), data=crit_region_data,
control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
summary(lm)
```
```{r}
ranef(lm)
```
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment