Выполняется следующий код:
> mod1b <- lrm(dependent_variable ~ merged_dataset$Lag4_CPI, data = merged_dataset, na.action="na.delete")
> print(mod1b)
Logistic Regression Model
lrm(formula = dependent_variable ~ merged_dataset$Lag4_CPI, data = merged_dataset,
na.action = "na.delete")
Model Likelihood Discrimination Rank Discrim.
Ratio Test Indexes Indexes
Obs 19209 LR chi2 1305.57 R2 0.105 C 0.685
0 15465 d.f. 1 g 0.690 Dxy 0.369
1 3744 Pr(> chi2) <0.0001 gr 1.994 gamma 0.378
max |deriv| 4e-11 gp 0.112 tau-a 0.116
Brier 0.146
Coef S.E. Wald Z Pr(>|Z|)
Intercept -1.6305 0.0210 -77.82 <0.0001
merged_dataset 0.2809 0.0079 35.77 <0.0001
при сбое следующих действий:
> mod1b <- lrm(dependent_variable ~ merged_dataset$Lag4_CPI + quarterYear.x, data = merged_dataset, na.action="na.delete")
singular information matrix in lrm.fit (rank= 39 ). Offending variable(s):
quarterYear.x=2017 4
Warning message:
In lrm(dependent_variable ~ merged_dataset$Lag4_CPI + quarterYear.x, :
Unable to fit model using “lrm.fit”
> print(mod1b)
Error in 1:ns : argument of length 0
, а также при выполнении этой модели
> mod1b <- lrm(dependent_variable ~ quarterYear.x, data = merged_dataset, na.action="na.delete")
> print(mod1b)
Logistic Regression Model
lrm(formula = dependent_variable ~ quarterYear.x, data = merged_dataset,
na.action = "na.delete")
Model Likelihood Discrimination Rank Discrim.
Ratio Test Indexes Indexes
Obs 19209 LR chi2 2821.65 R2 0.218 C 0.746
0 15465 d.f. 38 g 0.947 Dxy 0.492
1 3744 Pr(> chi2) <0.0001 gr 2.579 gamma 0.503
max |deriv| 3e-10 gp 0.154 tau-a 0.154
Brier 0.130
Coef S.E. Wald Z Pr(>|Z|)
Intercept -1.4663 0.1601 -9.16 <0.0001
quarterYear.x=2008 3 -0.0657 0.2225 -0.30 0.7678
quarterYear.x=2008 4 0.1500 0.2068 0.73 0.4683
quarterYear.x=2009 1 -0.0208 0.2506 -0.08 0.9340
quarterYear.x=2009 2 -0.0681 0.2437 -0.28 0.7798
quarterYear.x=2009 3 -0.2177 0.2528 -0.86 0.3891
quarterYear.x=2009 4 -0.1368 0.2514 -0.54 0.5862
quarterYear.x=2010 1 1.7921 0.1906 9.40 <0.0001
quarterYear.x=2010 2 1.7773 0.1893 9.39 <0.0001
quarterYear.x=2010 3 1.5728 0.1906 8.25 <0.0001
quarterYear.x=2010 4 1.6011 0.1861 8.60 <0.0001
quarterYear.x=2011 1 1.8365 0.1979 9.28 <0.0001
quarterYear.x=2011 2 1.6809 0.1916 8.77 <0.0001
quarterYear.x=2011 3 1.5499 0.1884 8.23 <0.0001
quarterYear.x=2011 4 1.5944 0.1932 8.25 <0.0001
quarterYear.x=2012 1 0.7949 0.2047 3.88 0.0001
quarterYear.x=2012 2 0.6866 0.2029 3.38 0.0007
quarterYear.x=2012 3 0.4700 0.2113 2.22 0.0261
quarterYear.x=2012 4 0.1778 0.2251 0.79 0.4295
quarterYear.x=2013 1 -0.5261 0.2296 -2.29 0.0219
quarterYear.x=2013 2 -0.5155 0.2283 -2.26 0.0239
quarterYear.x=2013 3 -0.3346 0.2173 -1.54 0.1236
quarterYear.x=2013 4 0.0757 0.1908 0.40 0.6914
quarterYear.x=2014 1 -0.3843 0.1970 -1.95 0.0511
quarterYear.x=2014 2 -0.2848 0.1960 -1.45 0.1462
quarterYear.x=2014 3 -0.3608 0.1971 -1.83 0.0671
quarterYear.x=2014 4 -0.5849 0.2033 -2.88 0.0040
quarterYear.x=2015 1 -0.3867 0.1945 -1.99 0.0468
quarterYear.x=2015 2 -0.7632 0.2031 -3.76 0.0002
quarterYear.x=2015 3 -0.7042 0.2007 -3.51 0.0005
quarterYear.x=2015 4 -0.6335 0.1971 -3.21 0.0013
quarterYear.x=2016 1 -0.5354 0.1949 -2.75 0.0060
quarterYear.x=2016 2 -0.6899 0.1977 -3.49 0.0005
quarterYear.x=2016 3 -1.2847 0.2197 -5.85 <0.0001
quarterYear.x=2016 4 -0.9774 0.2065 -4.73 <0.0001
quarterYear.x=2017 1 -0.9550 0.2035 -4.69 <0.0001
quarterYear.x=2017 2 -1.1674 0.2133 -5.47 <0.0001
quarterYear.x=2017 3 -0.9355 0.2036 -4.60 <0.0001
quarterYear.x=2017 4 -0.8023 0.2098 -3.82 0.0001
ивыполняется с помощью glm:
> mod1b <- glm(dependent_variable ~ Lag4_CPI + quarterYear.x, data = merged_dataset, na.action="na.delete")
> print(mod1b)
Call: glm(formula = dependent_variable ~ Lag4_CPI + quarterYear.x,
data = merged_dataset, na.action = "na.delete")
Coefficients:
(Intercept) Lag4_CPI quarterYear.x2008 3 quarterYear.x2008 4
0.107586 0.030795 -0.011729 -0.008175
quarterYear.x2009 1 quarterYear.x2009 2 quarterYear.x2009 3 quarterYear.x2009 4
-0.054277 -0.076580 -0.096677 -0.029427
quarterYear.x2010 1 quarterYear.x2010 2 quarterYear.x2010 3 quarterYear.x2010 4
0.425475 0.449203 0.397895 0.365963
quarterYear.x2011 1 quarterYear.x2011 2 quarterYear.x2011 3 quarterYear.x2011 4
0.390587 0.286830 0.242882 0.267349
quarterYear.x2012 1 quarterYear.x2012 2 quarterYear.x2012 3 quarterYear.x2012 4
0.086013 0.098457 0.088850 0.022890
quarterYear.x2013 1 quarterYear.x2013 2 quarterYear.x2013 3 quarterYear.x2013 4
-0.050055 -0.033645 -0.006617 0.056816
quarterYear.x2014 1 quarterYear.x2014 2 quarterYear.x2014 3 quarterYear.x2014 4
0.027560 0.054966 0.062687 0.073598
quarterYear.x2015 1 quarterYear.x2015 2 quarterYear.x2015 3 quarterYear.x2015 4
0.068696 0.034706 0.013563 0.058336
quarterYear.x2016 1 quarterYear.x2016 2 quarterYear.x2016 3 quarterYear.x2016 4
0.084714 0.061984 0.007989 -0.008914
quarterYear.x2017 1 quarterYear.x2017 2 quarterYear.x2017 3 quarterYear.x2017 4
0.002342 -0.011443 0.005842 NA
Degrees of Freedom: 19208 Total (i.e. Null); 19170 Residual
Null Deviance: 3014
Residual Deviance: 2503 AIC: 15450
Есть идеи, почему это происходит и как это исправить?