jMetrik and R and Other Neat Tricks

How can I allocate more memory to jMetrik? (August 6, 2011)
jMetrik is limited to 256MB of memory by default. It will only use this much memory if it is needed. Otherwise it uses much less memory. If you have a really large data file or a need to run many statistical methods, you may want to increase the default memory allocation by starting jMetrik manually. In Windows, start a command prompt by clicking the Start button or Windows button in the lower left corner. Type "cmd" in the search or run box and press enter to start the command prompt. If you are using Windows Vista or 7, you must start the command prompt with elevated priviledges. To invoke elevated priviliedges, type "cmd" (without quotes) in the search box and then type Ctrl + Shift + Enter. This operation will start a command prompt with Administrator rights (note: you must have Administrator priviledges to have these rights).

At the command prompt, navigate to the jMetrik installation by typing, for example (without quotes): "cd C:\Program Files\jmetrik". The Java command for memory allocation is -Xmx. You must combine this command with the call to the Java Archive File (*.jar). For example, to use 500MB of memory, type (without quotes): "java -jar -Xmx500M jmetrik.jar". jMetrik will report the amount of allocated memory in the command prompt window. For another example, type "java -jar -Xmx1G to allocate one gigabyte of memory.

Note that java must be in your PATH for these commands to be recognized. To determine whether Java is in your PATH, type "path" (without quotes) at the command prompt. You should see the path to Java listed somewhere in this output. If it is not there, find the location on your computer where Java is installed. Add the path of this location to your PATH system variable, http://www.java.com/en/download/help/path.xml. That should do it.

How does the jMetrik Mantel-Haenszel DIF analysis compare to the difMH() function in the difR package? (posted January 27, 2010)
jMetrik and difMH() implement similar methods for conducting a differential item functioning analysis. jMetrik uses the Cochran-Mantel-Haenszel statistic for q strata of 2 x c tables. This statistic allows DIF analysis to be performed on binary (i.e. multiple-choice) and polytomous (e.g. Likert scale) items. At the moment, the Cochran-Mantel-Haenszel statistic does not include a correction for continuity. The difMH() function in the difR package uses the Mantel-Haenszel statistic with an optional correction for continuity. Therefore, it is limited to binary items.

jMetrik and difMH() will produce the same results for binary items if you use the correct=FALSE option in difMH() and there is no missing data. A key difference between these two programs is treatment of missing data on the variable that contains DIF group membership. jMetrik will exclude any case that is missing a focal or reference code. The difMH() function will treat missing focal or reference code as reference codes. As such, any focal group member who did not provide, say, their gender or race will be counted as a reference group member.

To compare jMetrik and difMH(), download the dif1.txt example data file (it has no missing data). Save it to you computer and run the following code in R. You will need to change the path to indicate the location of the dif1.txt file on your computer. The code below will eliminate polytomous items prior to conducting the analysis. The analysis is conducted with 1 as the focal code. Anything that is not a 1 is a reference code in difMH(). In jMetrik, you should specify 0 as the reference code.

DIF analysis with difMH()

library(difR)
path<-"C:/" #replace this line
x<-read.csv(file=paste(path, "/", "dif1.txt", sep=""), header=TRUE)
gender<-x[,2]
items<-x[,3:62]
difMH(Data=items, group=gender, focal.name=1, correct=FALSE)

 

Use R to Analyze Your jMetrik Data (Posted: September 3, 2010)
Are you a fan of R? If the answer is yes, then you will be happy to know that you can use R to connect to the jMetrik database. No need to export your data when R can access it directly. You need to install the RJBDC package in R. Here is an example script (I'll provide directions soon on how you can modify the connection to make this work on your computer). Note that this method is potentially destructive. Only use this method to read a jMetrik database. Do not use it to modify the database in anyway.

Using R to Connect to a jMetrik Database

library(RJDBC)

#load the database driver and establish a connection
drv<-JDBC("org.apache.derby.jdbc.EmbeddedDriver", "E:/NetBeansProjects/jmetrik/dist/lib/derby.jar")
conn<-dbConnect(drv, "jdbc:derby:E:/NetBeansProjects/jmetrik/DefaultWorkspace/math")

#create a result set and fecth the first 100 records
rs<-dbSendQuery(conn, "SELECT * FROM TBLFALL2009")
myData<-fetch(rs, n=100)

#compute the mean of a variable
mean(myData$XRAW70X)