NOT_CRAN <- identical(tolower(Sys.getenv("NOT_CRAN")), "true") knitr::opts_chunk$set( purl = NOT_CRAN, collapse = TRUE, comment = "#>" ) keyring::key_set_with_value( "multilex", "gonzalo.garciadecastro@upf.edu", Sys.getenv("ML_KEY") )
The function ml_norms
computes the proportion of children in the sample that understand or produce each item. This function returns the estimated probability of an average participant to understand or produce each item, and allows to condition this probability to the age, language profile or language dominance of participants. Proportions and accompanying standard errors and confidence intervals are adjusted for zero- and one-inflation following Gelman, Hill, and Vehtari (2020) (see documentation of functions prop_adj
, prop_adj_se
, and prop_adj_ci
).
If argument item
is left NULL (default), proportions are computed for all items (currently nrow(pool)
). This may take time. If you need to compute norms for specific items, you can provide the item identifiers in the item
argument. Available items can be consulted in the pool
data set:
library(multilex) data("pool") head(pool)
This is an example of how to use the ml_norms
function for a specific set of items:
First we log in:
library(multilex) my_email <- "gonzalo.garciadecastro@upf.edu" ml_connect(google_email = my_email)
# get participant information and responses (load last update) p <- ml_participants() r <- ml_responses(p, update = FALSE) my_norms <- ml_norms( participants = p, responses = r, item = c("cat_casa", "cat_abric"), type = "produces", # get data for production age = c(16, 30), # get data for participants aged 15 to 30 months lp = c("Bilingual") # get data for bilinguals (exclude monolinguals and others) ) head(my_norms)
Visualised, these data look like this:
library(ggplot2) library(scales) ggplot(my_norms, aes(age_bin, proportion, colour = item_dominance, fill = item_dominance, shape = item_dominance)) + facet_grid(~item) + geom_line(size = 1) + geom_hline(yintercept = 0.5, linetype = "dashed") + geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper, width = 0.3)) + geom_point(size = 3) + labs(x = "Age (months)", y = "Proportion", colour = "Item dominance", fill = "Item dominance", shape = "Item dominance") + scale_colour_brewer(palette = "Set1") + scale_x_continuous(breaks = seq(16, 30, 2)) + scale_y_continuous(limits = c(0, 1), labels = percent) + theme_minimal() + theme( axis.line = element_line(colour = "black"), legend.position = "top", panel.grid.major.x = element_blank(), panel.grid.minor.x = element_blank() )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.