data_prep: Introduction of time and section fixed effects and data...

View source: R/data_prep.R

data_prepR Documentation

Introduction of time and section fixed effects and data standardization.

Description

If the data is in the panel form the function assumes it has the following structure

section_1 year_1 y x1 x2 x3 ....
section_2 year_1 y x1 x2 x3 ....
section_3 year_1 y x1 x2 x3 ....
........
section_n year_1 y x1 x2 x3 ....
section_1 year_2 y x1 x2 x3 ....
section_2 year_2 y x1 x2 x3 ....
section_3 year_2 y x1 x2 x3 ....
........
section_n year_2 y x1 x2 x3 ....
........
section_n year_(T-1) y x1 x2 x3 ....
section_1 year_T y x1 x2 x3 ....
section_2 year_T y x1 x2 x3 ....
section_3 year_T y x1 x2 x3 ....
........
section_n year_T y x1 x2 x3 ....

Usage

data_prep(
  data,
  FE = FALSE,
  Time = 0,
  Section = 0,
  Time_FE = 0,
  Section_FE = 0,
  STD = 0
)

Arguments

data

A data file.

FE

Binary variable: TRUE - include fixed effect, FALSE - do not include fixed effects.

Time

The number of time periods - works only if FE=1.

Section

The number of cross-sections - works only if EF=1.

Time_FE

Binary variable: 1 - include time fixed effect, 0 - do not include time fixed effects. Works only if EF=1.

Section_FE

Binary variable: 1 - include cross-section fixed effect, 0 - do not include cross-section fixed effects. Works only if EF=1.

STD

Binary variable: 1 - standardize the data set, 0 - do not standardize the data set. By standardization we mean subtraction of a mean and division by standard deviation of each variable.

Value

Formatted data set.

Examples

y <- matrix(1:20,nrow=20,ncol=1)
x1 <- matrix(21:40,nrow=20,ncol=1)
x2 <- matrix(41:60,nrow=20,ncol=1)
data <- cbind(y,x1,x2)
new_data <- data_prep(data,FE=1,Time=5,Section=4,Time_FE=1,Section_FE=1,STD=0)

y <- rnorm(20, mean = 0, sd = 1)
x1 <- rnorm(20, mean = 0, sd = 1)
x2 <- rnorm(20, mean = 0, sd = 1)
data <- cbind(y,x1,x2)
new_data <- data_prep(data,FE=1,Time=5,Section=4,Time_FE=1,Section_FE=1,STD=1)


rmsBMA documentation built on March 14, 2026, 5:06 p.m.