── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.1.9000 ✔ tibble 3.2.1
✔ lubridate 1.9.4 ✔ tidyr 1.3.1
✔ purrr 1.0.4
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(here)
here() starts at /Users/visuallearninglab/Documents/vedi_survey/vedi
library(knitr)library(cowplot)
Attaching package: 'cowplot'
The following object is masked from 'package:lubridate':
stamp
library(grid)library(ggthemes)
Attaching package: 'ggthemes'
The following object is masked from 'package:cowplot':
theme_map
library(lmerTest)
Loading required package: lme4
Loading required package: Matrix
Attaching package: 'Matrix'
The following objects are masked from 'package:tidyr':
expand, pack, unpack
Attaching package: 'lmerTest'
The following object is masked from 'package:lme4':
lmer
The following object is masked from 'package:stats':
step
library(mirt)
Loading required package: stats4
Loading required package: lattice
Attaching package: 'mirt'
The following object is masked from 'package:lme4':
fixef
#devtools::install_github("mikabr/jglmm"): https://github.com/mikabr/jglmm# TODO: switch to just using lmeroptions(JULIA_HOME ="/Users/visuallearninglab/.juliaup/bin")library(jglmm)
Attaching package: 'jglmm'
The following objects are masked from 'package:lme4':
cbpp, grouseticks, sleepstudy
jglmm_setup()
Julia version 1.11.3 at location /Users/visuallearninglab/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/bin will be used.
Loading setup script for JuliaCall...
Finish loading setup script for JuliaCall.
# TODO: switch to more efficiently using scale(), I did not know that was a function center_vars <-function(data) {return(data |>mutate(visual_frequency_centered =scale(Frequency_numeric_val),total_count_centered =scale(TotalCount_numeric_val),interaction_count_centered =scale(InteractionCount_numeric_val),formats_seen_centered =scale(FormatsSeen_numeric_val),babiness_centered =scale(babiness_mean),age_centered =scale(childAge)))}
Rows: 2351 Columns: 22
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (6): object, globalID, category, childSiblingAges, feedback, age_half
dbl (14): aoa, Frequency_normalized_val, TotalCount_normalized_val, Interac...
dttm (2): startTimestamp, endTimestamp
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 49 Columns: 16
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): object, category
dbl (14): aoa, Frequency_normalized_val, TotalCount_normalized_val, Interact...
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# can't use this directly since there are multiple elements with the same AoA dependent variable value, can't add item-level random effectscentered_vars <- combined_normed |>filter(!is.na(InteractionCount_numeric_val) &!is.na(aoa)) |>center_vars()# can use this but it does not include anything age-related and we are just predicting objectcentered_summarized_vars <- combined_normed_summary |>center_vars()
# loaded from https://github.com/mikabr/aoa-predictionload(here("analysis/main/coef_data/uni_joined.Rdata"))eng_joined <- uni_joined |>filter(language =="English (American)")vedi_for_lm <- centered_vars |>filter(7.5< childAge & childAge <31) |>mutate(rounded_age =round(childAge)) |>select(-globalID) |>summarize(participant_count =n(), across(where(is.numeric), ~mean(.x, na.rm =TRUE)), .by=c("object", "category", "rounded_age")) |>center_vars() |>mutate(babiness_centered =ifelse(is.nan(babiness_centered), NA, babiness_centered)) |>select(-matches("normalized|mean|numeric")) |># joining mean values for each item as fixed item effects left_join(combined_normed_summary |>select("object", "Frequency_numeric_val", "FormatsSeen_numeric_val","TotalCount_numeric_val", "InteractionCount_numeric_val"))
Joining with `by = join_by(object)`
Joining with `by = join_by(object)`
Warning: There was 1 warning in `mutate()`.
ℹ In argument: `across(pred, ~if_else(is.na(.), .fitted, .))`.
Caused by warning:
! Using an external vector in selections was deprecated in tidyselect 1.1.0.
ℹ Please use `all_of()` or `any_of()` instead.
# Was:
data %>% select(pred)
# Now:
data %>% select(all_of(pred))
See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
create_formula <-function(response ="prop", interaction_prefix ="age", predictors_list, random_effect ="(age | object)") {# Construct interaction terms for each list of predictors effects <-paste(interaction_prefix, predictors_list, sep =" * ")# Combine terms into a full formula string formula_str <-glue("{response} ~ {random_effect} + {paste(effects, collapse = ' + ')}")# Return as a formula objectreturn(as.formula(formula_str))}# TODO: use glmer instead of jglmm for reproducibilityfit_group_model <-function(group_data, group_formula, contrasts =NULL) { group <-unique(group_data$group)message(glue("Fitting model for {group}..."))jglmm(formula = group_formula, data = group_data, family ="binomial",weights = group_data$total, contrasts = contrasts)}varying_vedi_predictors <-c("interaction_count_centered", "formats_seen_centered","total_count_centered", "visual_frequency_centered")by_measure_data <- uni_model_data %>%mutate(group =paste(measure)) %>%select(measure, group, object, prop, total, age, !!predictors, varying_vedi_predictors) %>%group_by(measure) %>%nest()
Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0.
ℹ Please use `all_of()` or `any_of()` instead.
# Was:
data %>% select(varying_vedi_predictors)
# Now:
data %>% select(all_of(varying_vedi_predictors))
See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
Warning: The `guide` argument in `scale_*()` cannot be `FALSE`. This was deprecated in
ggplot2 3.3.4.
ℹ Please use "none" instead.
Estimates of coefficients in predicting words’ developmental trajectories for English comprehension and production data. Larger coefficient values indicate a greater effect of the predictor on acquisition: positive main effects indicate that words with higher values of the predictor tend to be understood/produced by more children, while negative main effects indicate that words with lower values of the predictor tend to be understood/produced by more children; positive age interactions indicate that the predictor’s effect increases with age, while negative age interactions indicate the predictor’s effect decreases with age. Line ranges indicates 95% confidence intervals; filled in points indicate coefficients for which \(p < 0.05\).
This isn’t exactly what I expected so I’m going to have to try to re-run this without our predictors too
Warning: `cols` is now required when using `unnest()`.
ℹ Please use `cols = c(results)`.
Adding missing grouping variables: `effect`
Warning: `cols` is now required when using `unnest()`.
ℹ Please use `cols = c(data)`.
Fitting model for produces...
Fitting model for understands...
Warning: `cols` is now required when using `unnest()`.
ℹ Please use `cols = c(results)`.
Adding missing grouping variables: `effect`
Warning: `cols` is now required when using `unnest()`.
ℹ Please use `cols = c(data)`.
Fitting model for produces...
Fitting model for understands...
Warning: `cols` is now required when using `unnest()`.
ℹ Please use `cols = c(results)`.
Adding missing grouping variables: `effect`
Warning: `cols` is now required when using `unnest()`.
ℹ Please use `cols = c(data)`.
Got rid of this code but I was basically able to replicate the original plot with the expected negative MLU correlation, indicating that we might not have enough items to reliably plot our effects. Lack of age-based effects should not be surprising given that each point only had 1 or 2 different values. How do we interpret that the less items that infants interact with look at the faster they learn words?