1

I have a following problem. I would like to compute bms in R. My code:

library(MASS)
library(BMA)
library(BMS)

armington = bms(pokus, burn=1e5,iter=3e5, g="UIP", mprior="uniform", nmodel=50000, mcmc="bd", user.int=FALSE)

But I got this error:

Error in chol.default(XtX.start) : 
  the leading minor of order 19 is not positive definite
In addition: Warning message:
In bms(pokus, burn = 1e+05, iter = 3e+05, g = "UIP", mprior = "uniform",  :
  data seems to be rank-deficient: its rank seems to be only  18

My data contains no NA values, all columns are type numeric.

My df pokus looks like:

A tibble: 61 × 21
       T    SE   MAX POP_VAR PER_100k  RAIN INTERCEPT   CPI UNEMPLOYMENT  GINI INCOME POVERTY  RACE RURAL DOWRY   OLS Poisson    FE    RE Samplesize
   <dbl> <dbl> <dbl>   <dbl>    <dbl> <dbl>     <dbl> <dbl>        <dbl> <dbl>  <dbl>   <dbl> <dbl> <dbl> <dbl> <dbl>   <dbl> <dbl> <dbl>      <dbl>
 1 0.016 0.004     0       0        1     1         0     0            0     0      0       0     0     0     0     0       0     1     0     493908
 2 0.023 0.011     0       0        1     1         0     0            0     0      0       0     0     0     0     0       0     1     0     493908
 3 0.014 0.003     0       0        1     1         0     0            0     0      0       0     0     0     0     0       0     1     0     493908
 4 0.05  0.023     0       0        1     1         1     0            0     0      0       0     0     0     0     0       0     1     0       1535
 5 0.014 0.004     0       0        1     0         0     0            0     0      1       0     0     0     0     0       0     1     0     486132
 6 0.016 0.004     0       0        1     0         0     0            0     1      0       0     0     0     0     0       0     1     0     482868
 7 0.021 0.005     0       0        1     0         0     0            0     0      0       0     0     0     0     0       0     1     0     121056
 8 0.016 0.004     0       0        1     0         0     0            0     0      0       0     0     0     0     0       0     1     0     493908
 9 0.012 0.003     0       0        1     0         0     0            0     0      0       0     0     0     0     0       0     1     0     262992
10 0.012 0.003     0       0        1     0         0     0            0     0      0       0     0     0     0     0       0     1     0     262992
# … with 51 more rows, and 1 more variable: reviewed_journal <dbl>

How can I fix this error, please?

vojtam
  • 1,157
  • 9
  • 34
  • 1
    61 rows for almost 20 covariates .. that too many covariates or too few rows to have a good modelisation anyway. What the message say is that your data doesn't respect the prerequisite for this kind of model. I don't know this kind of models, but perhaps you could begin by a study of your covariates : is there colinearity ? are somme covariates constant ? is it possible to reduce the dimension .. ? – MrSmithGoesToWashington Jan 01 '22 at 10:38
  • @vojtam I am afraid I concur with MrSmthGoestoWashington. If you search on your error you'll see it is a common problem. I'd recommend you take a look at the BMS website (http://bms.zeugner.eu/resources/). Can you post your actual data? That may help us resolve or better guide you. You can use 'dputs()' to share the complete dataframe. Ref: https://stackoverflow.com/questions/18746456/simplified-dput-in-r – Technophobe01 Jan 01 '22 at 23:27

0 Answers0