Learn R Programming

normref (version 0.0.0.1)

shape_data: Shape data as input for fb_select()

Description

shape_data() reshapes the response variable into the right format for the specified distribution and removes all cases with missing data on the score or age variable. The result is suitable for use as input to fb_select().

Usage

shape_data(
  data,
  age_name,
  score_name,
  family,
  max_score = NULL,
  verbose = TRUE
)

Value

A data.frame containing the original variables and a new column shaped_score, with the response variable in the correct format for GAMLSS modeling.

Arguments

data

data.frame. Sample on which to fit the distribution; contains the scores and ages.

age_name

string. Name of the age variable.

score_name

string. Name of the score variable.

family

string. For example, "BB", "BCPE", "NO", etc. See gamlss.dist::gamlss.family for more information.

max_score

numeric. Highest possible score in the norm table. Defaults to the maximum observed score in the sample.

verbose

logical. If TRUE, messages are printed whenever a transformation is applied.

Details

The function checks whether the response values are valid for the specified GAMLSS distribution family. If not, transformations are applied to ensure compatibility. Messages are printed (if verbose = TRUE) to describe each transformation.

Unexpected transformations should prompt inspection of the original data. Note that the function does not assess whether the chosen family is appropriate for the data—it only ensures compatibility.

Compatible with all gamlss distributions, with the exception of distributions in the multinomial family (gamlss::.gamlss.multin.list). This includes user-defined distributions, such as truncated distributions.

References

voncken2019modelnormref

See Also

fb_select()

Examples

Run this code
invisible(data("ids_data"))
mydata_BB <- shape_data(ids_data, age_name = "age", score_name = "y14", family = "BB")
mydata_BCPE <- shape_data(ids_data, age_name = "age", score_name = "y14", family = "BCPE")

Run the code above in your browser using DataLab