prune_data: Obtain a balanced and possibly imputed and standardized panel...

View source: R/z_utils.R

prune_dataR Documentation

Obtain a balanced and possibly imputed and standardized panel of data

Description

This convenience function allows the user to manipulate the supplied data matrix with respect to

  • the sample span;

  • reordering of the variables;

  • imputation of outliers; and

  • standardization.

Usage

prune_data(
  df,
  int_vars = NULL,
  start_date = NULL,
  end_date = NULL,
  impute = TRUE,
  sdize = TRUE,
  trans_ix = NULL
)

Arguments

df

T x (N+1) data panel with the first column specifying the time stamp, T giving the number of observations and N the number of variables

int_vars

vector of strings specifying the variables of interest, which are ordered first

start_date

ymd object specifying the start date of the sample

end_date

ymd object specifying the end date of the sample

impute

Are the outliers removed and replaced with an imputed value (for the imputation scheme see tw_apc)? Defaults to TRUE

sdize

Are the variables standardized to have zero mean and unit standard deviation? Defaults to FALSE

trans_ix

vector containing the transformation codes of the variables

Value

list of components

df

A T x N data frame corresponding transformed data

date

vector of ymd components giving the sample span

discarded

A list of discarded variables containing missing values

sd_mat

If sdize = TRUE, a matrix containing standard deviations of the variables on the diagonal is also supplied

trans_ix

vector of reordered transformation codes if int_vars is supplied


juhokalle/rmfd4dfm documentation built on July 18, 2024, 10:19 p.m.