Weighted Effect Coding for Observational Data with wec

Weighted effect coding refers to a specific coding matrix to include factor variables in generalised linear regression models. With weighted effect coding, the effect for each category represents the deviation of that category from the weighted mean (which corresponds to the sample mean). This technique has particularly attractive properties when analysing observational data, that commonly are unbalanced. The wec package is introduced, that provides functions to apply weighted effect coding to factor variables, and to interactions between (a.) a factor variable and a continuous variable and between (b.) two factor variables.

Rense Nieuwenhuis , Manfred te Grotenhuis , Ben Pelzer

CRAN packages used


CRAN Task Views implied by cited packages


Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".


For attribution, please cite this work as

Nieuwenhuis, et al., "The R Journal: Weighted Effect Coding for Observational Data with wec", The R Journal, 2017

BibTeX citation

  author = {Nieuwenhuis, Rense and Grotenhuis, Manfred te and Pelzer, Ben},
  title = {The R Journal: Weighted Effect Coding for Observational Data with wec},
  journal = {The R Journal},
  year = {2017},
  note = {https://doi.org/10.32614/RJ-2017-017},
  doi = {10.32614/RJ-2017-017},
  volume = {9},
  issue = {1},
  issn = {2073-4859},
  pages = {477-485}