# Scoring GSED

## D-score and DAZ

Suppose you have administered GSED SF, GSED LF (World Health Organization (WHO) 2023; McCray et al. 2023) or GSED HF to one or more children. The next step is calculating each child’s developmental score (D-score) and age-adjusted equivalent (DAZ). This step is known as scoring. The present section provides recipes for calculating the D-score and DAZ. We may pick one of the following two methods:

1. Online calculator. The online app D-score calculator is a convenient option for users not familiar with `R`. The app contains online documentation and instructions and will not be further discussed here.
2. `R` package `dscore`. The `R` package `dscore` at https://CRAN.R-project.org/package=dscore is a flexible option with all the tools needed to calculate the D-score. It is an excellent choice for users familiar with `R` and users who like to incorporate D-score calculations into a workflow.

## Preliminaries

- We use the `R` language. If you are new to `R` consult the R for Data Science book by Hadley Wickham and Garrett Grolemund;
- You need to install the `R` package `dscore` on your local machine;
- The child data need to be stored as a `data.frame`, a standard `R` tabular structure;
- You need to run the `dscore()` function to calculate the D-score and DAZ. The function returns a table with six columns with the estimates with the same number of rows as your data.

## Install the `dscore` package

The `dscore` package contains tools to

- Map your item names to the GSED convention
- Calculate D-scores from item level responses
- Transform the D-scores into DAZ, age-standardised Z-scores

The required input consists of item level responses on milestones collected using instruments for measuring child development, including the GSED LF, GSED SF and GSED HF.

There are two versions of the `dscore` package. For daily use, we recommend the curated and published version on CRAN. In `R`, install the `dscore` package as

    install.packages("dscore")

In some cases, you might need a more recent version that includes extensions and bug fixes not yet available on CRAN. You can install the development version from GitHub by:

    install.packages("remotes")
    remotes::install_github("d-score/dscore")

The development version requires a local C++ compiler for building the package from source.

## GSED 9-position item names

The `dscore()` function accepts item names that follow the GSED 9-position schema. A name with a length of nine characters identifies every milestone. The following table shows the construction of names.

Position | Description | Example
--- | --- | ---
1-3 | instrument | `by3`
4-5 | developmental domain | `cg`
6 | administration mode | `d`
7-9 | item number | `018`

Thus, item `by3cgd018` refers to the 18th item in the cognitive scale of the Bayley-III. The label of the item can be obtained by

    library(dscore)
    get_labels("by3cgd018")

    ##           by3cgd018
    ## "Inspects own hand"

The `dscore` package maintains a list of items names.

## Response data format

Rows: One measurement, i.e., one test administration for a child at a given age, occupies a row in the data set. Thus, if a child is measured three times at different ages, there will be three rows for that child in the dataset.

Columns: There should be at least two columns in the data set:

- One column with the age of the child. The age column may have any name, and may be measured in decimal age, months, or days since birth. Do not truncate age. Make the value as a continuous as possible, for example by calculating age in days by the difference between measurement date and birth date.
- One column for each item, appropriately named by the 9-position GSED item name. Normally, the items come from the same instrument, but they may also come from multiple instruments. The data from any recognised item name will contribute to the D-score. Do not duplicate names in the data. A PASS is coded as `1`, a FAIL as `0`. If there is no answer or if the item was not administered use the missing value code `NA`. Items that are never administered may be coded as all `NA` or deleted.

The dataset may contain additional columns, e.g., the child number or health information. These are ignored by the D-score calculation.

The most important steps is preparing the data for the D-score calculations are:

- rename your original variable names into the 9-position GSED item names;
- recode all item response as `0`, `1` or `NA`

## GSED Instruments

The table below lists the five available GSED instruments:

Instrument | Year | Code | Domains | Mode | Range | Status
--- | --- | --- | --- | --- | --- | ---
GSED SF | 2023 | `gs1` | `cg|lg|li|mo|se` | `c` | `001-139` | Active
GSED LF | 2023 | `gl1` | `gm|lg|fm` | `d` | `001-049|052|054` | Active
GSED HH | 2023 | `gh1` | `cg|lg|li|mo|se` | `c` | `001-055` | Active
GSED SF | 2020 | `gpa` | any | `c` | `001-139` | Retired
GSED LF | 2020 | `gto` | `gm|lg|fm` | `d` | `001-049|052|054` | Retired

Select the section corresponding to your instrument for further instructions.

::: {.panel-tabset group = “GSED”}

### `GSED SF`

The `GSED Short Form (GSED SF)` is a caregiver-reported instrument containing 139 items. It has instrument code `gs1`.

#### Check

Obtain the full list of item name for as

    instrument <- "gs1"
    items <- get_itemnames(instrument = instrument, order = "indm")
    length(items)

    ## [1] 139

    head(items)

    ## [1] "gs1sec001" "gs1moc002" "gs1sec003" "gs1lgc004" "gs1moc005" "gs1cgc006"

The `order` argument is needed to sort items according to sequence number 1 to 139. Check that you have the correct version by comparing the labels of the first few items as:

    labels <- get_labels(items)
    head(cbind(items, substr(labels, 1, 50)))

    ##           items
    ## gs1sec001 "gs1sec001" "SF001 Does your child smile?"
    ## gs1moc002 "gs1moc002" "SF002 When lying on his/her back, does your child "
    ## gs1sec003 "gs1sec003" "SF003 Does your child look at your face when you s"
    ## gs1lgc004 "gs1lgc004" "SF004 Does your child cry when he/she is hungry, w"
    ## gs1moc005 "gs1moc005" "SF005 Does your child grasp your finger if you tou"
    ## gs1cgc006 "gs1cgc006" "SF006 Does your child look at and focus on objects"

#### Renaming example

Suppose that you stored your data with items names `sf001` to `sf139`. For example,

    sf <- dscore::sample_sf
    head(sf[, c(1:2, 101:105)])

    ##   subjid agedays sf099 sf100 sf101 sf102 sf103
    ## 1      1     811     1     1     1     1     1
    ## 2      2     898     1     1     1     1     1
    ## 3      3     203    NA    NA    NA    NA    NA
    ## 4      4     966    NA    NA    NA     1    NA
    ## 5      8     770     1     1     1     0     1
    ## 6      9     306    NA    NA    NA    NA    NA

Make sure that the items are in the correct order. Rename the columns with gsed 9-position item names.

    colnames(sf)[3:141] <- items
    head(sf[, c(1:2, 101:105)])

    ##   subjid agedays gs1lgc099 gs1lgc100 gs1moc101 gs1sec102 gs1lic103
    ## 1      1     811         1         1         1         1         1
    ## 2      2     898         1         1         1         1         1
    ## 3      3     203        NA        NA        NA        NA        NA
    ## 4      4     966        NA        NA        NA         1        NA
    ## 5      8     770         1         1         1         0         1
    ## 6      9     306        NA        NA        NA        NA        NA

The data in `sf` are now ready for the `dscore()` function.

#### Calculate D-score

Once the data are in proper shape, calculation of the D-score is straightforward. The `sf` dataset has properly named columns that identify each item.

    results <- dscore(sf, xname = "agedays", xunit = "days")
    head(results)

    ##        a  n      p     d      sem    daz
    ## 1 2.2204 29 0.7586 67.67 1.658818 -0.043
    ## 2 2.4586 39 0.6923 69.05 1.411819 -0.352
    ## 3 0.5558 48 0.6667 38.97 1.649425  1.058
    ## 4 2.6448 36 0.7500 74.47 1.471799  0.624
    ## 5 2.1081 50 0.5000 66.45 1.244876 -0.033
    ## 6 0.8378 48 0.7083 42.18 1.699459 -0.839

The table below provides the interpretation of the output:

Name | Interpretation
--- | ---
`a` | Decimal age in years
`n` | Number of items used to calculate the D-score
`p` | Proportion of passed milestones
`d` | D-score (posterior mean)
`sem` | Standard error of measurement (posterior standard deviation)
`daz` | D-score corrected for age

The number of rows of `result` is equal to the number of rows of `sf`. We save the result for later processing.

    sf2 <- data.frame(sf, results)

It is possible to calculate D-score for item subsets by setting the `items` argument. We do not advertise this option for practical application, but suppose we are interested in the D-score based on items from `gs1` and `gl1` for domains `mo` or `gm` (motor) only. The “motor” D-score can be calculated as follows:

    items_motor <- get_itemnames(
      instrument = c("gs1", "gl1"),
      domain = c("mo", "gm")
    )
    results <- dscore(sf, items = items_motor, xname = "agedays", xunit = "days")
    head(results)

    ##        a  n      p     d      sem    daz
    ## 1 2.2204  6 0.8333 67.40 3.391252 -0.116
    ## 2 2.4586  8 0.7500 69.16 3.049288 -0.324
    ## 3 0.5558 30 0.7333 39.89 1.946849  1.347
    ## 4 2.6448  5 0.8000 75.78 3.154717  0.981
    ## 5 2.1081 10 0.7000 69.52 2.808620  0.814
    ## 6 0.8378 31 0.7419 42.35 1.983714 -0.790

### `GSED LF`

The `GSED Long Form (GSED LF)` instrument is a directly-observed instrument containing 155 items with instrument code `gl1`.

#### Check

Obtain the full list of item name for as

    instrument <- "gl1"
    items <- get_itemnames(instrument = instrument)
    length(items)

    ## [1] 155

    head(items)

    ## [1] "gl1fmd001" "gl1fmd002" "gl1fmd003" "gl1fmd004" "gl1fmd005" "gl1fmd006"

Reorder item names so that they corresponds to streams A, B and C, respectively.

    items <- items[c(55:155, 1:54)]
    head(items)

    ## [1] "gl1gmd001" "gl1gmd002" "gl1gmd003" "gl1gmd004" "gl1gmd005" "gl1gmd006"

Check that you have the correct version by comparing the labels of the first few items as:

    labels <- get_labels(items)
    head(cbind(items, substr(labels, 1, 50)))

    ##           items
    ## gl1gmd001 "gl1gmd001" "A1  Moves body in reaction to caregiver"
    ## gl1gmd002 "gl1gmd002" "A2  Moves body, kicking legs and moving arms equal"
    ## gl1gmd003 "gl1gmd003" "A3  Pulls to sit - no head lag"
    ## gl1gmd004 "gl1gmd004" "A4  Lifts head in prone 45 degrees (2X)"
    ## gl1gmd005 "gl1gmd005" "A5  Lifts head, shoulders, chest when prone (2X)"
    ## gl1gmd006 "gl1gmd006" "A6  Puts hands together in front of face"

#### Renaming example

Suppose that you stored your data with items names `lf001` to `lf155`. For example,

    lf <- dscore::sample_lf
    head(lf[, c(1:2, 60:64)])

    ##   subjid agedays lf058 lf059 lf060 lf061 lf062
    ## 1      1     811    NA    NA    NA    NA    NA
    ## 2      2     898    NA    NA    NA    NA    NA
    ## 3      3     203     0     0     0    NA    NA
    ## 4      4     966    NA    NA    NA    NA    NA
    ## 5      8     770     0     0     0     0     0
    ## 6      9     306     1     1     0     1     0

Make sure that the items are in the correct order. Rename the columns with gsed 9-position item names.

    colnames(lf)[3:157] <- items
    head(lf[, c(1:2, 60:64)])

    ##   subjid agedays gl1lgd009 gl1lgd010 gl1lgd011 gl1lgd012 gl1lgd013
    ## 1      1     811        NA        NA        NA        NA        NA
    ## 2      2     898        NA        NA        NA        NA        NA
    ## 3      3     203         0         0         0        NA        NA
    ## 4      4     966        NA        NA        NA        NA        NA
    ## 5      8     770         0         0         0         0         0
    ## 6      9     306         1         1         0         1         0

The data in `lf` are now ready for the `dscore()` function.

#### Calculate D-score

Once the data are in proper shape, calculation of the D-score is straightforward. The `lf` dataset has properly named columns that identify each item.

    results <- dscore(lf, xname = "agedays", xunit = "days")
    head(results)

    ##        a  n      p     d      sem    daz
    ## 1 2.2204 42 0.5476 66.91 1.328849 -0.246
    ## 2 2.4586 49 0.6122 70.69 1.239337  0.082
    ## 3 0.5558 31 0.5484 34.27 1.661074 -0.397
    ## 4 2.6448 52 0.5000 70.11 1.165718 -0.529
    ## 5 2.1081 53 0.1509 40.67 1.820166 -4.554
    ## 6 0.8378 31 0.5806 44.85 1.554783 -0.038

The table below provides the interpretation of the output:

Name | Interpretation
--- | ---
`a` | Decimal age in years
`n` | Number of items used to calculate the D-score
`p` | Proportion of passed milestones
`d` | D-score (posterior mean)
`sem` | Standard error of measurement (posterior standard deviation)
`daz` | D-score corrected for age

The number of rows of `result` is equal to the number of rows of `lf`. We save the result for later processing.

    lf2 <- data.frame(lf, results)

It is possible to calculate D-score for item subsets by setting the `items` argument. We do not advertise this option for practical application, but suppose we are interested in the D-score based on items from `gs1` and `gl1` for domains `mo` or `gm` (motor) only. The “motor” D-score can be calculated as follows:

    items_motor <- get_itemnames(
      instrument = c("gs1", "gl1"),
      domain = c("mo", "gm")
    )
    results <- dscore(lf, items = items_motor, xname = "agedays", xunit = "days")
    head(results)

    ##        a  n      p     d      sem    daz
    ## 1 2.2204 12 0.5833 64.88 2.844278 -0.772
    ## 2 2.4586 17 0.6471 70.62 2.244729  0.063
    ## 3 0.5558 19 0.6842 36.27 2.010557  0.213
    ## 4 2.6448 12 0.4167 65.46 2.707788 -1.626
    ## 5 2.1081 12 0.5000 60.25 2.784830 -1.589
    ## 6 0.8378 14 0.7143 45.20 2.350039  0.070

### `GSED HF`

The `GSED Houshold Form (GSED HF)` instrument contains a subset of 55 items from the GSED SF designed to be used for population surveys. It has instrument code `gh1`.

#### Check

Obtain the full list of item name for as

    instrument <- "gh1"
    items <- get_itemnames(instrument = instrument, order = "indm")
    length(items)

    ## [1] 55

    head(items)

    ## [1] "gh1sec001" "gh1sec002" "gh1lgc003" "gh1cgc004" "gh1moc005" "gh1sec006"

The `order` argument is needed to sort items according to sequence number 1 to 55. Check that you have the correct version by comparing the labels of the first few items as:

    labels <- get_labels(items)
    head(cbind(items, substr(labels, 1, 50)))

    ##           items
    ## gh1sec001 "gh1sec001" "Does your child smile?"
    ## gh1sec002 "gh1sec002" "Does your child look at your face when you speak t"
    ## gh1lgc003 "gh1lgc003" "Does your child cry when he/she is hungry, wet, ti"
    ## gh1cgc004 "gh1cgc004" "Does your child look at and focus on objects in fr"
    ## gh1moc005 "gh1moc005" "Does your child bring his/her hand to his/her mout"
    ## gh1sec006 "gh1sec006" "Does your child smile when you smile or talk with "

#### Renaming example

Suppose that you stored your data with items names `hf001` to `hf055`. For example,

    hf <- dscore::sample_hf
    head(hf[, c(1:2, 30:35)])

    ##   subjid agedays hf028 hf029 hf030 hf031 hf032 hf033
    ## 1      1     811    NA    NA    NA    NA    NA    NA
    ## 2      2     898    NA    NA    NA    NA    NA    NA
    ## 3      3     203     1     1     0     1     0     0
    ## 4      4     966    NA    NA    NA    NA    NA    NA
    ## 5      8     770    NA    NA    NA    NA    NA    NA
    ## 6      9     306     1     1     1     1     1     1

Make sure that the items are in the correct order. Rename the columns with gsed 9-position item names.

    colnames(hf)[3:57] <- items
    head(hf[, c(1:2, 30:35)])

    ##   subjid agedays gh1cgc028 gh1moc029 gh1lic030 gh1moc031 gh1moc032 gh1moc033
    ## 1      1     811        NA        NA        NA        NA        NA        NA
    ## 2      2     898        NA        NA        NA        NA        NA        NA
    ## 3      3     203         1         1         0         1         0         0
    ## 4      4     966        NA        NA        NA        NA        NA        NA
    ## 5      8     770        NA        NA        NA        NA        NA        NA
    ## 6      9     306         1         1         1         1         1         1

The data in `hf` are now ready for the `dscore()` function.

#### Calculate D-score

Once the data are in proper shape, calculation of the D-score is straightforward. The `hf` dataset has properly named columns that identify each item.

    results <- dscore(hf, xname = "agedays", xunit = "days", key = "gsed2406")
    head(results)

    ##        a  n      p     d      sem    daz
    ## 1 2.2204  8 0.7500 66.46 3.099626 -0.365
    ## 2 2.4586  8 1.0000 73.55 3.959115  0.862
    ## 3 0.5558 29 0.6207 37.36 2.190590  0.552
    ## 4 2.6448  3 1.0000 74.12 4.231796  0.528
    ## 5 2.1081  7 1.0000 70.72 3.841959  1.149
    ## 6 0.8378 30 0.7000 42.55 2.182150 -0.731

The `key = "gsed2406"` argument is needed here because GSED HH is not yet supported by the default key `"gsed2510"`.

The table below provides the interpretation of the output:

Name | Interpretation
--- | ---
`a` | Decimal age in years
`n` | Number of items used to calculate the D-score
`p` | Proportion of passed milestones
`d` | D-score (posterior mean)
`sem` | Standard error of measurement (posterior standard deviation)
`daz` | D-score corrected for age

The number of rows of `results` is equal to the number of rows of `hf`. We save the result for later processing.

    hf2 <- data.frame(hf, results)

It is possible to calculate D-score for item subsets by setting the `items` argument. We do not advertise this option for practical application, but suppose we are interested in the D-score based on items from `gs1`, `gl1` and `gh1` for domains `mo` or `gm` (motor) only. The “motor” D-score can be calculated as follows:

    items_motor <- get_itemnames(
      instrument = c("gs1", "gl1", "gh1"),
      domain = c("mo", "gm")
    )
    results <- dscore(
      hf,
      items = items_motor,
      xname = "agedays",
      xunit = "days",
      key = "gsed2406"
    )
    head(results)

    ##        a  n      p     d      sem    daz
    ## 1 2.2204  1 1.0000 69.63 4.504147  0.491
    ## 2 2.4586  1 1.0000 71.52 4.583980  0.306
    ## 3 0.5558 18 0.5000 36.65 2.506216  0.331
    ## 4 2.6448  1 1.0000 72.86 4.642396  0.189
    ## 5 2.1081  1 1.0000 68.67 4.467450  0.577
    ## 6 0.8378 18 0.6111 42.29 2.508751 -0.807

:::

### Other GSED instruments`

The `GSED SF` and `GSED LF` 2020 instruments are included only for backward compatibility.

##

### Phase 1 references and DAZ

We used the GSED Phase I data to calculate age-conditional reference scores for the D-score. The references are based on about 12,000 administration of the GSED SF and GSED LF from Bangladesh, Pakistan and Tanzania. Extract the references as

    library(dplyr, warn.conflicts = FALSE, quietly = TRUE)
    ref <- builtin_references |>
      filter(population == "phase1") |>
      select(population, age, mu, sigma, nu, tau, SDM2, SD0, SDP2)
    head(ref)

    ##   population    age    mu  sigma     nu    tau     SDM2      SD0     SDP2
    ## 1     phase1 0.0383 13.68 0.2456 1.1731 15.422 6.042690 13.68707 20.71620
    ## 2     phase1 0.0575 14.36 0.2324 1.2062 15.540 6.699401 14.36568 21.30880
    ## 3     phase1 0.0767 15.02 0.2206 1.2375 15.652 7.354450 15.02457 21.88555
    ## 4     phase1 0.0958 15.68 0.2100 1.2670 15.758 8.014796 15.68368 22.47481
    ## 5     phase1 0.1150 16.35 0.2005 1.2951 15.860 8.680976 16.35299 23.09062
    ## 6     phase1 0.1342 17.03 0.1917 1.3218 15.957 9.363085 17.03241 23.72268

The columns `mu`, `sigma`, `nu` and `tau` are the age-varying parameters of a Box-Cox \(t\) (BCT) distribution.

The script below creates a figure with -2SD, 0SD and +2SD centiles plus 20 D-scores (10 LF and 10 SF) for the `lf2` and `sf2` data.

    library(ggplot2)
    library(patchwork)

    r <- builtin_references |>
      filter(population == "phase1" & age <= 3.5) |>
      mutate(m = age * 12)

    lf2$ins <- "lf"
    lf2$m <- lf2$a * 12
    sf2$ins <- "sf"
    sf2$m <- sf2$a * 12
    data <- bind_rows(lf2, sf2)
    g1 <- ggplot(data, aes(x = m, y = d, group = ins, color = ins)) +
      theme_light() +
      annotate(
        "polygon",
        x = c(r$age, rev(r$age)),
        y = c(r$SDM2, rev(r$SDP2)),
        alpha = 0.06,
        fill = "#C5EDDE"
      ) +
      annotate("line", x = r$m, y = r$SDM2, lwd = 0.5, color = "#C5EDDE") +
      annotate("line", x = r$m, y = r$SDP2, lwd = 0.5, color = "#C5EDDE") +
      annotate("line", x = r$m, y = r$SD0, lwd = 1, color = "#C5EDDE") +
      scale_x_continuous(
        "Age (in months)",
        limits = c(0, 42),
        breaks = seq(0, 42, 12)
      ) +
      scale_y_continuous(
        expression(paste(italic(D), "-score", sep = "")),
        breaks = seq(0, 80, 20),
        limits = c(0, 90)
      ) +
      geom_point(size = 2) +
      theme(legend.position = "none")
    g2 <- ggplot(data, aes(x = m, y = daz, group = ins, color = ins)) +
      theme_light() +
      scale_x_continuous(
        "Age (in months)",
        limits = c(0, 42),
        breaks = seq(0, 42, 12)
      ) +
      scale_y_continuous(
        "DAZ",
        breaks = seq(-4, 4, 2),
        limits = c(-5, 5)
      ) +
      geom_point(size = 2) +
      theme(legend.position = "none")
    g1 + g2

## References

McCray, G, D McCoy, P Kariger, M Janus, MM Black, SM Chang, F Tofail, et al. 2023. “The Creation of the Global Scales for Early Development (GSED) for Children Aged 0-3 Years: Combining Subject Matter Expert Judgements with Big Data.” BMJ Glob Health 8 (1).
World Health Organization (WHO). 2023. “Global Scales for Early Development (GSED) V1.0: Technical Report.” Geneva: World Health Organization. https://www.who.int/publications/i/item/WHO-MSD-GSED-package-v1.0-2023.1.