I'm getting system is computationally singular
error even after drop variables with high autocorrelation in a Panel Var regression.
I'm using public crop insurance data. The objective of the model is to verify how the number of insured farmers, the number of insured policies, and the insurance premium by state are related to the planted area and the productivity within the states.
Hence, the states are the cross-section units of my dataset (25 in this sample) and the data covers the period from 2006 to 2018. The data can be accessed in this link
First, I tried to run a model using productivity as an exogenous variable:
library(dplyr)
library(tidyverse)
library(panelvar)
df <- read.csv('data2reg_200618.csv')
selected_cols = c('productivity','insurance_policy', 'insured_farmers', 'insured_valued' )
reg_psr <-
pvargmm(
dependent_vars = selected_cols[2:length(selected_cols)],
lags = 1,
exog_vars = selected_cols[1],
transformation = "fd",
data = df,
panel_identifier = c("id", "year"),
steps = c("twostep"),
system_instruments = TRUE,
max_instr_dependent_vars = 99,
min_instr_dependent_vars = 2L,
collapse = FALSE
)
but I got the error Error in solve.default(as.matrix(sum_Lambda_vec)) :system is computationally ingular: reciprocal condition number = 4.47744e-28"
Then I checked the correlation matrix and noticed that, in fact, there is a lot of autocorrelation between the variables:
df %>% select(selected_cols)%>% cor()
productivity insurance_policy insured_farmers insured_valued
productivity 1.0000000 0.4127050 0.4337136 0.4276021
insurance_policy 0.4127050 1.0000000 0.9883224 0.9630020
insured_farmers 0.4337136 0.9883224 1.0000000 0.9562334
insured_valued 0.4276021 0.9630020 0.9562334 1.0000000
However, removing the variables with high autocorrelation led me to the same problem, since:
selected_cols = c('productivity','insured_farmers' )
reg_psr <-
pvargmm(
dependent_vars = selected_cols[2],
lags = 1,
exog_vars = selected_cols[1],
transformation = "fd",
data = df,
panel_identifier = c("id", "year"),
steps = c("twostep"),
system_instruments = TRUE,
max_instr_dependent_vars = 99,
min_instr_dependent_vars = 2L,
collapse = FALSE
)
also gives me a similar error: Error in solve.default(as.matrix(sum_Lambda_vec)) : system is computationally singular: reciprocal condition number = 1.71156e-17
What is happening here? How can I run a Panel Var using this dataset?