panel_correl {panelWranglR}R Documentation

Panel linear combinations

Description

A function to find highly correlated variables in a panel of data, both by cross sections and by time dummies.

Usage

panel_correl(data, cross.section = NULL, time.variable = NULL,
  corr.threshold = 0.7, autocorr.threshold = 0.5,
  cross.threshold = 0.7, select.cross.sections = NULL,
  select.time.periods = NULL)

Arguments

data

The data to use, a data.frame or a data.table.

cross.section

The name of the cross sectional variable.

time.variable

The name of the time variable.

corr.threshold

The correlation threshold for finding significant correlations in the base specification, disregarding time or cross sectional dependencies.

autocorr.threshold

The correlation threshold for autocorrelation (splitting the pooled panel into cross sections).

cross.threshold

The correlation threshold for finding significant correlations in the cross sections.

select.cross.sections

An optional subset of cross sectional units.

select.time.periods

An optional subset of time periods

Examples


   x_1 <- rnorm( 100 )
   x_2 <- rnorm( 100 ) + 0.5 * x_1
   cross_levels <- c( "AT", "DE")
   time <- seq(1:50)
   time <- rep(time, 2)
   geo_list <- list()
   for(i in 1:length(cross_levels))
   {  geo <- rep( cross_levels[i], 50 )
      geo_list[[i]] <- geo }
   geo <- unlist(geo_list)
   geo <- as.data.frame(geo)

   example_data <-  do.call ( cbind, list( time, x_1, x_2))
   example_data <- as.data.frame(example_data)
   example_data <- cbind( geo,
                         example_data)

                         names(example_data) <- c("geo", "time", "x_1",
                                                 "x_2")

   panel_correl( data = example_data,
                 cross.section = "geo",
                 time.variable = "time",
                 corr.threshold = 0.2,
                 autocorr.threshold = 0.5,
                 cross.threshold = 0.1)


[Package panelWranglR version 1.2.13 Index]