1
$\begingroup$

I am trying to fit a binary logistic regression model using only one predictor. After consulting a loess plot I decided to use restricted cubic spline to fit the curve (with default 4 knots). Using 'rms' package:

lrm(y ~ rcs(x), data = data)

however I encounter the following problem:

singular information matrix in lrm.fit (rank= 3 ).  Offending variable(s):
x''' x'' 
Error in lrm(y ~ rcs(x), data = data) : 
  Unable to fit model using “lrm.fit”

Why am I getting this issue? and how do I solve it? enter image description here

(N=61829), Min=-29000, 1st Qu.=0 , Median.=300 , Mean=7260 , 3rd Qu.=6190 , Max.=240000

$\endgroup$
  • $\begingroup$ Show us a high-resolution histogram of the distribution of x (e.g., 100 or 200 bins). $\endgroup$ – Frank Harrell Feb 9 '18 at 13:17
  • $\begingroup$ It's the clumping at zero that creates the problem: hard to figure out which knots to use. Override default knots with constants you select, or use a regular polynomial, e.g. pol(x, 2). Or with your extreme skewness, pol(sqrt(x), 2). Also use sqrt(x) inside rcs, or cube root. $\endgroup$ – Frank Harrell Feb 9 '18 at 13:58
  • $\begingroup$ do you need the loes plot also? @FrankHarrell $\endgroup$ – Danny Feb 9 '18 at 13:58
  • $\begingroup$ The relationship is exactly what I expect: maxium at about 0(a bit less than 0) , a rise at 10000 then decay . $\endgroup$ – Danny Feb 9 '18 at 14:12
  • $\begingroup$ any suggestions where to put the knots. $\endgroup$ – Danny Feb 9 '18 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.