1

I am analyzing survey data that has dependent variable in the form of a binary variable (0 or 1) with 10 predictors and all are ordinal (scale 1 to 5, Strongly disagree-1, Disagree-2, Neither agree nor disagree-3, Agree-4, Strongly agree-5).

My objective is to find relative importance of these predictors in driving the binary dependent variable. I am using R to achieve this.

I have tried using ‘relaimpo’ package provided by R. Using the function

    model1_raw <- calc.relimp(data, type ="genizi")

Where I have converted my Dependent variable using

    as.factor (data$dependent) 

and have used ordered factors for my independent variables using

    ordered(data$predictor1, levels=1:5)

But I am getting the following error massage (I do not have any NA value in my dataframe)

    Error in cov.wt(y, wt = wt) : 'x' must contain finite values only

Along with following warning massages

Warning messages:
        1: In model.response(mf, "numeric") :
        using type = "numeric" with a factor response will be ignored
        2: In Ops.factor(y, z$residuals) : ‘-’ not meaningful for factors

My question is, Is it possible to get the results using the library ‘relaimpo’. If not what other methods, I can use to get the ‘relative importance of the predictors’

XSCD
  • 23
  • 4
  • I am not sure what type of model you are using, but I suggest you look into discriminant analysis and take a look at this post https://stackoverflow.com/questions/23900932/linear-discriminant-analysis-variable-importance – maarvd Feb 24 '21 at 16:00
  • While using library relaimpo one can pass the dataframe with first column as dependent varable. the object in the argument in the function calc.relimp(object, type = "lmg", groups = NULL, groupnames=NULL, always = NULL, ...) which I have used. – XSCD Feb 24 '21 at 16:58
  • `relaimpo` seems to have some trouble with factor variables as predictors. Take a look at this response: https://stackoverflow.com/questions/75137341/calc-relimp-delivers-an-error-about-finite-values-when-using-a-linear-model/76879246#76879246 for an idea of a workaround – jluchman Aug 10 '23 at 22:47

0 Answers0