data_prep: Perform standardization of variables and prepears fixed...

View source: R/data_preparation.R

data_prepR Documentation

Perform standardization of variables and prepears fixed effects estiamtion

Description

This function performs feature standarization (also known as z-score normalization), i.e. the features are centered around the mean and scaled with standard deviation. Additionally, it allows introduction of cross sectional and time fixed effects through demeaning.

Usage

data_prep(
  df,
  timestamp_col,
  entity_col,
  standardize = TRUE,
  entity_effects = FALSE,
  time_effects = FALSE,
  scale = TRUE
)

Arguments

df

Dataframe with data that should be prepared for LIML estimation

timestamp_col

Column with timestamps (e.g. years)

entity_col

Column with entities (e.g. countries)

standardize

Whether to standardize the data (by mean subtraction)

entity_effects

Whether to introduce time cross-section effects (by time demeaning)

time_effects

Whether to introduce time fixed effects (by cross-sectional demeaning)

scale

Whether to divide by the standard deviation TRUE or not FALSE during standardization. Default is TRUE

Value

A dataframe with standardized variables or/and prepared for fixed effects estimation

Examples

df <- data.frame(
  year = c(2000, 2001, 2002, 2003, 2004),
  country = c("A", "A", "B", "B", "C"),
  gdp = c(1, 2, 3, 4, 5),
  ish = c(2, 3, 4, 5, 6),
  sed = c(3, 4, 5, 6, 7)
)

data_prep(df, year, country, entity_effects = TRUE)


bdsm documentation built on April 4, 2025, 1:06 a.m.