Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Christopher, what you are asking for appears, after some consideration and examination of <code>sparse.model.matrix</code> etc, to be somewhat involved. You haven't explain <em>why</em> you do not want to form the full sparse model matrix for <code>X_test</code> so it is difficult to advise a way forward other than the two options below.</p> <p>If you have a large number of observations in <code>X_test</code> and hence do not want to produce the full sparse matrix for use in <code>predict()</code> for computational reasons, it might be more expedient to split <code>X_test</code> into two or more chunks of samples and form the sparse model matrices for each one in turn, discarding it after after use.</p> <p>Failing that, you will need to study code from the Matrix package in detail. Start with <code>sparse.model.matrix</code> and note that it then calls <code>Matrix:::model.spmatrix</code> and locate calls to <code>Matrix:::fac2Sparse</code> in that function. You will probably need to co-opt code from these functions but use a modified <code>fac2Sparse</code> to achieve what you want to achieve.</p> <p>Sorry I cannot provide an off-the-shelf script to do this, but that is a substantial coding task. If you go down that route, check out the <em>Sparse Model Matrices</em> vignette in the Matrix package and get the package sources (from CRAN) to see if the functions I mention are better documented in the source code (there are no Rd files for <code>fac2Sparse</code> for example). You can also ask the authors of Matrix (Martin Maechler and Doug Bates) for advice, although note that both of these chaps have had a particularly heavy teaching load this term.</p> <p>Good luck!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload