EVOLUTION-MANAGER
Edit File: KNex.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Koenker-Ng Example Sparse Model Matrix and Response Vector</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for KNex {Matrix}"><tr><td>KNex {Matrix}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Koenker-Ng Example Sparse Model Matrix and Response Vector</h2> <h3>Description</h3> <p>A model matrix <code>mm</code> and corresponding response vector <code>y</code> used in an example by Koenker and Ng. The matrix <code>mm</code> is a sparse matrix with 1850 rows and 712 columns but only 8758 non-zero entries. It is a <code>"dgCMatrix"</code> object. The vector <code>y</code> is just <code><a href="../../base/html/numeric.html">numeric</a></code> of length 1850. </p> <h3>Usage</h3> <pre>data(KNex)</pre> <h3>References</h3> <p>Roger Koenker and Pin Ng (2003). SparseM: A sparse matrix package for R; <em>J. of Statistical Software</em>, <b>8</b> (6), doi: <a href="http://doi.org/10.18637/jss.v008.i06">10.18637/jss.v008.i06</a> </p> <h3>Examples</h3> <pre> data(KNex) class(KNex$mm) dim(KNex$mm) image(KNex$mm) str(KNex) system.time( # a fraction of a second sparse.sol <- with(KNex, solve(crossprod(mm), crossprod(mm, y)))) head(round(sparse.sol,3)) ## Compare with QR-based solution ("more accurate, but slightly slower"): system.time( sp.sol2 <- with(KNex, qr.coef(qr(mm), y) )) all.equal(sparse.sol, sp.sol2, tolerance = 1e-13) # TRUE </pre> <hr /><div style="text-align: center;">[Package <em>Matrix</em> version 1.2-17 <a href="00Index.html">Index</a>]</div> </body></html>