Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenjw committed Jun 5, 2017
1 parent cb966d6 commit 60511d7
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 58 deletions.
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ If building from source, running `sbt console` should give a Scala REPL with a d

To use the pre-built binary, add the following lines to your `build.sbt`:
```scala
libraryDependencies += "darrenjw" %% "scala-glm" % "0.1"
libraryDependencies += "darrenjw" %% "scala-glm" % "0.2"
resolvers += "Newcastle mvn repo" at "https://www.staff.ncl.ac.uk/d.j.wilkinson/mvn/"
```
The current stable release is "0.1". The latest unstable release is "0.2-SNAPSHOT".
The current stable release is "0.2". The latest unstable release is "0.3-SNAPSHOT".

It's currently only published to my own personal repo. I'll figure out how to push it to Sonatype once it's properly tested.
It's currently only published to my own personal repo. I'll figure out how to push it to Sonatype soon.

If you just want to try it out without setting up a project, you can do so with a session like:
```
$ sbt
> set scalaVersion := "2.12.1"
> set libraryDependencies += "darrenjw" %% "scala-glm" % "0.1"
> set libraryDependencies += "darrenjw" %% "scala-glm" % "0.2"
> set resolvers += "Newcastle mvn repo" at "https://www.staff.ncl.ac.uk/d.j.wilkinson/mvn/"
> console
scala> import scalaglm._
Expand All @@ -48,9 +48,15 @@ val pca = Pca(X, List("V1","V2"))
pca.sdev
pca.loadings
pca.scores
pca.plots
pca.summary
```
The final line prints a readable summary of the PCA to the console.
The final line prints a readable summary of the PCA to the console. Note that there is also a utility function for producing a "scatterplot matrix":

```scala
import scalaglm.Utils.pairs
pairs(X, List("V1", "V2"))
```

## Linear regression

Expand All @@ -63,6 +69,7 @@ val y = DenseVector(1.0,2.0,1.0,1.5)
val X = DenseMatrix((1.0,1.5),(1.5,2.0),(2.0,1.5),(2.0,1.0))
val lm = Lm(y,X,List("V1","V2"))
lm.coefficients
lm.plots
lm.summary
```
The final line produces the following output to the console:
Expand All @@ -78,6 +85,7 @@ Residual standard error: 0.7071 on 1 degrees of freedom
Multiple R-squared: 0.2727, Adjusted R-squared: -1.1818
F-statistic: 0.1875 on 2 and 1 DF, p-value: 0.85280
```
The plots include a plot of studentised residuals against fitted values and a normal Q-Q plot for the studentised residuals.

## Generalised linear models

Expand All @@ -93,6 +101,7 @@ val X = DenseMatrix((1.0,1.5),(1.5,2.0),(2.0,1.5),(2.0,1.0))
val glm = Glm(y,X,List("V1","V2"),LogisticGlm)
glm.coefficients
glm.summary
glm.plots
```

### Poisson regression
Expand All @@ -105,6 +114,7 @@ val X = DenseMatrix((1.0,1.5),(1.5,2.0),(2.0,1.5),(2.0,1.0))
val glm = Glm(y,X,List("V1","V2"),PoissonGlm)
glm.coefficients
glm.summary
glm.plots
```


Expand Down
2 changes: 1 addition & 1 deletion docs/api/index.js

Large diffs are not rendered by default.

17 changes: 0 additions & 17 deletions docs/api/scalaglm/Glm.html
Original file line number Diff line number Diff line change
Expand Up @@ -934,23 +934,6 @@ <h3>Value Members</h3>
</span>)</span>

</dd></dl></div>
</li><li name="scalaglm.Glm#xtwxi" visbl="pub" class="indented0 " data-isabs="false" fullComment="no" group="Ungrouped">
<a id="xtwxi:breeze.linalg.DenseMatrix[Double]"></a><a id="xtwxi:DenseMatrix[Double]"></a>
<span class="permalink">
<a href="../scalaglm/Glm.html#xtwxi:breeze.linalg.DenseMatrix[Double]" title="Permalink">
<i class="material-icons"></i>
</a>
</span>
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">lazy val</span>
</span>
<span class="symbol">
<span class="name">xtwxi</span><span class="result">: <span class="extype" name="breeze.linalg.DenseMatrix">DenseMatrix</span>[<span class="extype" name="scala.Double">Double</span>]</span>
</span>

<p class="shortcomment cmt">Inverse of the final X'WX matrix
</p>
</li><li name="scalaglm.Glm#y" visbl="pub" class="indented0 " data-isabs="false" fullComment="no" group="Ungrouped">
<a id="y:breeze.linalg.DenseVector[Double]"></a><a id="y:DenseVector[Double]"></a>
<span class="permalink">
Expand Down
67 changes: 50 additions & 17 deletions docs/api/scalaglm/Lm.html
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,23 @@ <h3>Value Members</h3>
</span>

<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef → Any</dd></dl></div>
</li><li name="scalaglm.Lm#h" visbl="pub" class="indented0 " data-isabs="false" fullComment="no" group="Ungrouped">
<a id="h:breeze.linalg.DenseVector[Double]"></a><a id="h:DenseVector[Double]"></a>
<span class="permalink">
<a href="../scalaglm/Lm.html#h:breeze.linalg.DenseVector[Double]" title="Permalink">
<i class="material-icons"></i>
</a>
</span>
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">lazy val</span>
</span>
<span class="symbol">
<span class="name">h</span><span class="result">: <span class="extype" name="breeze.linalg.DenseVector">DenseVector</span>[<span class="extype" name="scala.Double">Double</span>]</span>
</span>

<p class="shortcomment cmt">Vector containing the leverages (diagonal of the hat matrix)
</p>
</li><li name="scala.Any#isInstanceOf" visbl="pub" class="indented0 " data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="isInstanceOf[T0]:Boolean"></a>
<span class="permalink">
Expand Down Expand Up @@ -955,6 +972,23 @@ <h3>Value Members</h3>
</span>

<p class="shortcomment cmt">Standard errors for the regression coefficients
</p>
</li><li name="scalaglm.Lm#sh" visbl="pub" class="indented0 " data-isabs="false" fullComment="no" group="Ungrouped">
<a id="sh:breeze.linalg.DenseVector[Double]"></a><a id="sh:DenseVector[Double]"></a>
<span class="permalink">
<a href="../scalaglm/Lm.html#sh:breeze.linalg.DenseVector[Double]" title="Permalink">
<i class="material-icons"></i>
</a>
</span>
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">lazy val</span>
</span>
<span class="symbol">
<span class="name">sh</span><span class="result">: <span class="extype" name="breeze.linalg.DenseVector">DenseVector</span>[<span class="extype" name="scala.Double">Double</span>]</span>
</span>

<p class="shortcomment cmt">Square root of the leverage vector
</p>
</li><li name="scalaglm.Lm#ssy" visbl="pub" class="indented0 " data-isabs="false" fullComment="no" group="Ungrouped">
<a id="ssy:Double"></a>
Expand All @@ -973,6 +1007,22 @@ <h3>Value Members</h3>

<p class="shortcomment cmt"> The sum-of-squares of the centred observations
</p>
</li><li name="scalaglm.Lm#studentised" visbl="pub" class="indented0 " data-isabs="false" fullComment="no" group="Ungrouped">
<a id="studentised:breeze.linalg.DenseVector[Double]"></a><a id="studentised:DenseVector[Double]"></a>
<span class="permalink">
<a href="../scalaglm/Lm.html#studentised:breeze.linalg.DenseVector[Double]" title="Permalink">
<i class="material-icons"></i>
</a>
</span>
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">lazy val</span>
</span>
<span class="symbol">
<span class="name">studentised</span><span class="result">: <span class="extype" name="breeze.linalg.DenseVector">DenseVector</span>[<span class="extype" name="scala.Double">Double</span>]</span>
</span>


</li><li name="scalaglm.Lm#summary" visbl="pub" class="indented0 " data-isabs="false" fullComment="no" group="Ungrouped">
<a id="summary:Unit"></a>
<span class="permalink">
Expand Down Expand Up @@ -1089,23 +1139,6 @@ <h3>Value Members</h3>
</span>)</span>

</dd></dl></div>
</li><li name="scalaglm.Lm#xtxi" visbl="pub" class="indented0 " data-isabs="false" fullComment="no" group="Ungrouped">
<a id="xtxi:breeze.linalg.DenseMatrix[Double]"></a><a id="xtxi:DenseMatrix[Double]"></a>
<span class="permalink">
<a href="../scalaglm/Lm.html#xtxi:breeze.linalg.DenseMatrix[Double]" title="Permalink">
<i class="material-icons"></i>
</a>
</span>
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">lazy val</span>
</span>
<span class="symbol">
<span class="name">xtxi</span><span class="result">: <span class="extype" name="breeze.linalg.DenseMatrix">DenseMatrix</span>[<span class="extype" name="scala.Double">Double</span>]</span>
</span>

<p class="shortcomment cmt">The inverse of X'X (but calculated efficiently)
</p>
</li><li name="scalaglm.Lm#y" visbl="pub" class="indented0 " data-isabs="false" fullComment="no" group="Ungrouped">
<a id="y:breeze.linalg.DenseVector[Double]"></a><a id="y:DenseVector[Double]"></a>
<span class="permalink">
Expand Down
34 changes: 17 additions & 17 deletions docs/api/scalaglm/PredictLm.html
Original file line number Diff line number Diff line change
Expand Up @@ -562,23 +562,6 @@ <h3>Value Members</h3>
</span>

<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef</dd></dl></div>
</li><li name="scalaglm.PredictLm#rtix" visbl="pub" class="indented0 " data-isabs="false" fullComment="no" group="Ungrouped">
<a id="rtix:breeze.linalg.DenseMatrix[Double]"></a><a id="rtix:DenseMatrix[Double]"></a>
<span class="permalink">
<a href="../scalaglm/PredictLm.html#rtix:breeze.linalg.DenseMatrix[Double]" title="Permalink">
<i class="material-icons"></i>
</a>
</span>
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">lazy val</span>
</span>
<span class="symbol">
<span class="name">rtix</span><span class="result">: <span class="extype" name="breeze.linalg.DenseMatrix">DenseMatrix</span>[<span class="extype" name="scala.Double">Double</span>]</span>
</span>

<p class="shortcomment cmt">for internal use (probably should be marked private)
</p>
</li><li name="scalaglm.PredictLm#se" visbl="pub" class="indented0 " data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="se:breeze.linalg.DenseVector[Double]"></a><a id="se:DenseVector[Double]"></a>
<span class="permalink">
Expand Down Expand Up @@ -679,6 +662,23 @@ <h3>Value Members</h3>
</span>)</span>

</dd></dl></div>
</li><li name="scalaglm.PredictLm#xrti" visbl="pub" class="indented0 " data-isabs="false" fullComment="no" group="Ungrouped">
<a id="xrti:breeze.linalg.DenseMatrix[Double]"></a><a id="xrti:DenseMatrix[Double]"></a>
<span class="permalink">
<a href="../scalaglm/PredictLm.html#xrti:breeze.linalg.DenseMatrix[Double]" title="Permalink">
<i class="material-icons"></i>
</a>
</span>
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">lazy val</span>
</span>
<span class="symbol">
<span class="name">xrti</span><span class="result">: <span class="extype" name="breeze.linalg.DenseMatrix">DenseMatrix</span>[<span class="extype" name="scala.Double">Double</span>]</span>
</span>

<p class="shortcomment cmt">for internal use (probably should be marked private)
</p>
</li>
</ol>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/scalaglm/Glm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ case class Glm(y: DenseVector[Double],

import breeze.plot._
def plots: Figure = {
val fig = Figure("Linear regression diagnostics")
val fig = Figure("GLM regression diagnostics")
val p0 = fig.subplot(1,1,0)
p0 += plot(fitted,y,'+')
p0 += plot(fitted,fitted)
Expand Down

0 comments on commit 60511d7

Please sign in to comment.