hirt 0.0.1.0 → 0.0.1.1
raw patch · 7 files changed
+110/−9 lines, 7 filesdep ~containersdep ~hmatrix
Dependency ranges changed: containers, hmatrix
Files
- ChangeLog.md +12/−0
- Driver.hs +2/−1
- Engine.hs +1/−1
- Statistics.hs +2/−2
- Types.hs +1/−1
- demo.sh +85/−0
- hirt.cabal +7/−4
+ ChangeLog.md view
@@ -0,0 +1,12 @@+0.0.1.1+-------++- added simple demo+- renamed statistic TaskCount to Count+- fixed nondescript error message on empty input+- relaxed version bounds on dependencies++0.0.1.0+-------++- initial version
Driver.hs view
@@ -86,6 +86,7 @@ istate = Engine.init responses engine = setupEngine args in do printStats resp responses+ when (length resp > 0) $ do maybeWriteFile oResponses (formatResp oRespFormat responses) putStrLn "Reading initial task parameters..." istate <- maybe return readParams iTaskParams $ istate@@ -96,7 +97,7 @@ thetas results `seq` params results `seq` return () putStrLn "Calculating bayes probabilities..." let (bayesBounds, bayesValues) = calcBayes results in do- putStrLn "Writing bayes probability values..."+ putStrLn "Saving bayes probability values..." maybeWriteFile oBayesPlot . buildTable $ bayesValues putStrLn "Writing task parameters..." let taskBase = tableTaskParams . getTaskParamsList $ results in do
Engine.hs view
@@ -35,7 +35,7 @@ where [dt] = diff (thetas old) (thetas new) dp = diff (params old) (params new)- diff xs ys = (max' . trans . sub xs) ys+ diff xs ys = (max' . trans) (sub xs ys) where max' :: [[Double]] -> [Double] max' = map (maximum . map abs)
Statistics.hs view
@@ -20,7 +20,7 @@ import System.Random.MWC statTheta :: StatisticType -> ContestantsData -> IO Statistic-statTheta TaskCount xs = return . SingleStatistic . map (fromIntegral . V.length . snd) $ xs+statTheta Count xs = return . SingleStatistic . map (fromIntegral . V.length . snd) $ xs statTheta SolvedProp xs = return . SingleStatistic . map (prop . snd) $ xs where prop = mean . V.map (ok . snd)@@ -75,7 +75,7 @@ statTask :: StatisticType -> TasksData -> IO Statistic-statTask TaskCount xs = return . SingleStatistic . map (fromIntegral . V.length . snd) $ xs+statTask Count xs = return . SingleStatistic . map (fromIntegral . V.length . snd) $ xs statTask SolvedProp xs = return . SingleStatistic . map (prop . snd) $ xs where prop = mean . V.map (ok . snd)
Types.hs view
@@ -69,7 +69,7 @@ type TaskParams = UV.Vector TaskParam type Thetas = UV.Vector Theta -data StatisticType = TaskCount | SolvedProp | LogLikelihood+data StatisticType = Count | SolvedProp | LogLikelihood | DLogLikelihood | FisherSEM | Bootstrap deriving (Eq, Show, Data, Typeable)
+ demo.sh view
@@ -0,0 +1,85 @@+#!/bin/sh -v++function find_exe() {+ HIRT=+ [ -z "$HIRT" ] && type hirt 2>/dev/null && HIRT=hirt+ [ -z "$HIRT" ] && [ -x hirt ] && HIRT=./hirt+ [ -z "$HIRT" ] && [ -x dist/build/hirt/hirt ] && HIRT=dist/build/hirt/hirt+}++find_exe++if [ -z "$HIRT" ]; then+ echo "Could not find executable..."+ echo "Perhaps build it with:"+ echo " cabal configure && cabal build"+ echo " or cabal install hirt"+ exit 1+fi >&2+++# a very simple sample+RESPONSES=/tmp/responses+TASKPARAM=/tmp/params+BAYES=/tmp/bayes++cat > "$RESPONSES" << EOF+contestant task result+c1 t1 0+c1 t2 0+c2 t1 0+c2 t2 1+c3 t2 1+c3 t1 1+EOF++# fit model with default options+"$HIRT" "$RESPONSES"++# the differences in loglikehood on this very small example are tiny,+# throwing off the JML estimate, let's try BFGS++"$HIRT" "$RESPONSES" --algo lbfgsb++# Better, but not quite there yet.+# We will increase the precision.++"$HIRT" "$RESPONSES" --algo lbfgsb --prec 1e-30++# Let's save task parameters for later use+# and show contestant ability estimates.++"$HIRT" "$RESPONSES" --algo lbfgsb --prec 1e-30 --otaskparam "$TASKPARAM" --otheta /dev/stdout++# Now, let's use the task parameter estimates+# to estimate contestant abilities.+# We will use one round of JML to leave task parameters fixed.++"$HIRT" "$RESPONSES" --algo jml -n 1 --itaskparam "$TASKPARAM" --otheta /dev/stdout++# Now we will show some statistics++"$HIRT" "$RESPONSES" --algo lbfgsb --prec 1e-30 --otaskparam /dev/stdout --otheta /dev/stdout \+ --taskstats count --taskstats solvedprop --taskstats loglikelihood --taskstats dloglikelihood \+ --thetastats count --thetastats solvedprop --thetastats loglikelihood --thetastats dloglikelihood \+ --thetastats fishersem --thetastats bootstrap++# Finally, we will plot a graph of the bayes expected a posteriori probability++"$HIRT" "$RESPONSES" --algo lbfgsb --prec 1e-30 --otaskparam /dev/stdout --otheta /dev/stdout \+ --obayesplot /tmp/bayes++cat > /tmp/plot.R << EOF+library(ggplot2)++x <- read.table(file="$BAYES", header=T)+p <- ggplot(data=x, aes(x=x, y=p, color=contestant)) ++ geom_line(size=1) ++ scale_color_brewer(palette="Set1",name="") ++ scale_x_continuous(expression(theta)) ++ scale_y_continuous("y")++ggsave(file="/tmp/plot.pdf", w=10, h=7, plot=p)+EOF++Rscript /tmp/plot.R
hirt.cabal view
@@ -1,5 +1,5 @@ Name: hirt-Version: 0.0.1.0+Version: 0.0.1.1 Synopsis: Calculates IRT 2PL and 3PL models Description: Program for fitting Item Response Theory (IRT) two (2PL) and@@ -30,12 +30,15 @@ Build-type: Simple Cabal-version: >=1.6 +Extra-source-files:+ ChangeLog.md+ demo.sh+ Flag PL3 Description: Compile for 3PL model, doesn't support JML yet. Model needs to be selected at compile time. Default: False --- Extra-source-files: Executable hirt Main-is: Main.hs@@ -45,12 +48,12 @@ Build-depends: base >= 4 && < 5, vector >= 0.9 && < 0.10,- containers >= 0.4 && < 0.5,+ containers >= 0.4 && < 0.6, text >= 0.11.1.13 && < 0.12, attoparsec >= 0.10.1 && < 0.11, text-format >= 0.3.0.7 && < 0.4, csv >= 0.1.2 && < 0.2,- hmatrix >= 0.13.1.0 && < 0.14,+ hmatrix >= 0.13.1.0 && < 0.15, numeric-extras >= 0.0.2.2 && < 0.1, cmdargs >= 0.9.3 && < 0.10, random >= 1.0.1.1 && < 1.1,