SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.regression.linear.glm
Class IWLS

java.lang.Object
  extended by com.numericalmethod.suanshu.stats.regression.linear.glm.IWLS
All Implemented Interfaces:
Fitting

public class IWLS
extends java.lang.Object
implements Fitting

We estimate parameters ß in a GLM model using the Iteratively Re-weighted Least Squares algorithm. The idea is that, at each iteration, we regress the adjusted, weighted, dependent variables on the same design matrix.

The R equivalent function is glm.fit.

See Also:

Field Summary
 int maxIterations
          the maximum number of iterations
 double threshold
          the convergence threshold
 
Constructor Summary
IWLS(double threshold, int maxIterations)
          Construct an instance to run the Iteratively Re-weighted Least Squares algorithm.
 
Method Summary
 ImmutableVector betaHat()
          Get the estimates of β, β^, as in E(Y) = μ = g-1(Xβ)
 void fit(GlmProblem probelm, Vector beta0Initial)
          Fit a Generalized Linear Model.
 double logLikelihood()
           
 ImmutableVector mu()
          Get μ as in E(Y) = μ = g-1(Xβ)
 ImmutableVector weights()
          Get the weights to the observations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

threshold

public final double threshold
the convergence threshold


maxIterations

public final int maxIterations
the maximum number of iterations

Constructor Detail

IWLS

public IWLS(double threshold,
            int maxIterations)
Construct an instance to run the Iteratively Re-weighted Least Squares algorithm.

Parameters:
threshold - the convergence threshold
maxIterations - maximum number of iterations
Method Detail

fit

public void fit(GlmProblem probelm,
                Vector beta0Initial)
Description copied from interface: Fitting
Fit a Generalized Linear Model.

This method must be called before the three get methods.

Specified by:
fit in interface Fitting
Parameters:
probelm - the generalized linear regression problem to be solved
beta0Initial - initial guess for betaHat

mu

public ImmutableVector mu()
Description copied from interface: Fitting
Get μ as in
 E(Y) = μ = g-1(Xβ)
 

Specified by:
mu in interface Fitting
Returns:
μ

betaHat

public ImmutableVector betaHat()
Description copied from interface: Fitting
Get the estimates of β, β^, as in
 E(Y) = μ = g-1(Xβ)
 

Specified by:
betaHat in interface Fitting
Returns:
β^

weights

public ImmutableVector weights()
Description copied from interface: Fitting
Get the weights to the observations.

Specified by:
weights in interface Fitting
Returns:
the weights

logLikelihood

public double logLikelihood()
Specified by:
logLikelihood in interface Fitting

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.