Java generalized linear model library
I'm trying to port some R code to Java / Scala and need an equivalent GLM function Is there any Java / Scala library to solve the generalized linear model with quasi Poisson error and logarithmic link function?
So far, I have found that:
>Suanshu, but can't figure out how to get the hat matrix. > This question, but I can't find the glmulti package mentioned. There is only one R package with the same name
I have no knowledge of building my own solver
Update: I should ask for free / open source For a MAC address, Suanshu seems to cost $1500
Solution
It seems that you can get the projection matrix or hat value through this example in Suanshu
Examples/src/com/numericalmethod/suanshu/examples/LinearRegression.java
The following is an overview of the sample code, although it sounds like you might want to build a more specific glmproblem rather than the base class lmproblem created here:
LMProblem problem = new LMProblem( new DenseVector(new double[]{2.32,0.452,4.53,12.34,32.2}),new DenseMatrix(new double[][]{ {1.52,2.23,4.31},{3.22,6.34,3.46},{4.32,12.2,23.1},{10.1034,43.2,22.3},{12.1,2.12,3.27} }),true); OLSRegression regression = new OLSRegression(problem); OLSResiduals residuals = regression.residuals(); ImmutableVector hatValues = residuals.Leverage(); // gets the Leverage (R hatvalues) ImmutableMatrix hHat = residuals.hHat(); // gets the projection matrix,H-hat
I hope it will help
Other possibilities
>Apache common math has a simpleregression class > dream in code simple regression analysis > OJ! Algorithms > JAMA: a Java matrix package > mallet (machine learning for language Toolkit) and grmm (graphical models in mallet) > more general Apache mahout
See also logistic regression in Java