philchalmers / mirt

Multidimensional item response theory
https://philchalmers.github.io/mirt/
200 stars 75 forks source link

Code sharing for model report on journal #87

Closed seonghobae closed 8 years ago

seonghobae commented 8 years ago

Hi, Phil.

I short short code for report on my journal paper. So, I decided share code on here for convenience to another person.

Seongho

      MirtModelParmsReport <- function(MirtModel){
        testValues <- mod2values(MirtModel)

        testParms <- unique(testValues$name)
        testNames <- unique(testValues$item)

        testParms <- as.character(testParms[-c(grep("^MEAN", testParms), grep("^GROUP", testParms), grep("^COV", testParms))])
        testNames <- as.character(testNames[-c(grep("^GROUP", testNames))])
        testParmValue <- round(testValues$value[testValues$item %in% testNames], 2)

        testParmMatrix <- matrix(nrow = length(testNames), ncol = length(testParms))
        colnames(testParmMatrix) <- testParms
        rownames(testParmMatrix) <- testNames

        testParmMatrix[testNames,] <- t(testParmValue)

        return(as.data.frame(testParmMatrix))
      }
>       MirtModelParmsReport(firstTime_GDS_FIPC$oldFormModel) # return Parameter Linking model coefficients matrix
         a1     d
GDS1  -0.63  0.25
GDS2  -2.27 -0.17
GDS4   0.32  0.54
GDS5  -0.30 -0.64
GDS6   0.36  0.31
GDS7  -0.29 -0.90
GDS8  -0.65 -0.73
GDS9  -2.44 -2.77
GDS10  0.33  0.09
GDS11 -0.32 -0.23
GDS12 -0.74 -0.72
GDS13 -2.67 -3.05
GDS14  0.13  0.35
GDS15 -0.63 -0.80
GDS16 -0.70  0.19
GDS17 -2.43 -0.82
GDS18  0.36  0.43
GDS19 -0.25 -0.52
GDS20  0.42  0.41
GDS21 -0.51 -0.39
GDS23  1.34 -0.60
GDS24 -0.58 -2.12
GDS25  0.34  1.27
GDS26 -0.57 -0.51
GDS27  0.33 -0.43
GDS28 -0.28 -1.93
GDS29 -0.40 -0.42
GDS30 -1.99 -1.82
philchalmers commented 8 years ago

Not and appropriate location. Try opening a Github gist which is associated with your account. I have a few examples on my account as well: https://gist.github.com/philchalmers/4614a7dfd764b4eb65a1

seonghobae commented 8 years ago

Oh, I see it.