0

I am conducting a multidimensional item response theory analysis using (mirt) package.

df.mirt <- mirt(data = df, model = 1, itemtype = "gpcm")

after that, I used the summary function to get the loading for each item

summary.df <- summary(df.mirt)

The summary results showed that I have items with really bad loading. Now, I would like to drop these items from my df without the need to drop each item one-by-one by using the loading values from the summary function.

The loading values are stored in summary.df$rotF, the criteria is to drop any item with loading less than the absolute value of 0.4, this is what I tried:

New.df <- SelectVar[, summary.df$rotF > abs(0.4)]

Another one:

df2 <- if (summary.df$rofF < abs(0.4), SelectVar)
My.vars <- names(df.mirt) %in% names(df2)
New.df <- df.mirt[!My.vars]

Clearly, it is a beginner question, but I am still learning R. I do appreciate your help.

mischva11
  • 2,811
  • 3
  • 18
  • 34
Tamimi
  • 37
  • 1
  • 5

1 Answers1

0

It is very hard to address your question without knowing about your data and context. Assuming that your df.mirt and summary.df$rotF have the same length and order, this may do the job:

df <- df.mirt[abs(summary.df$rotF) > 0.4, ]

Data:

df.mirt <- data.frame(
  var1 = rnorm(10),
  var2 = rnorm(10),
  var3 = rnorm(10)
)

summary.df <- data.frame(
  rotF = rnorm(10)
)

df <- df.mirt[abs(summary.df$rotF) > 0.4, ]

Please try to make your questions reproducible so that the community can help you easily.

OzanStats
  • 2,756
  • 1
  • 13
  • 26