0
$\begingroup$

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?

$\endgroup$

1 Answer 1

0
$\begingroup$

Removing correlated rows will only solve matrix singularity caused by having highly correlated pairs of rows. You can also have singularity by having multiple rows that, combined in a linear combination, make another row in the matrix.

For example, if column c is equal to 2x column a plus 3x column b, you wouldn't necessarily get high correlation of c and a or b, but you'd still have a singular matrix. Is it possible you have columns like that?

$\endgroup$
2
  • $\begingroup$ The data can be accessed in the link post in the question. If anyone is curious, I was able to run this model in Stata using panelvar package $\endgroup$
    – Lucas
    Commented Feb 16, 2022 at 13:41
  • 1
    $\begingroup$ The first part of this answer doesn't look relevant: the problems don't stem from correlation among rows (observations), but among columns (variables). The error message basically says yes, some linear combination of the columns used in the model is zero. $\endgroup$
    – whuber
    Commented Feb 16, 2023 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.