...
 
Commits (2)
...@@ -111,13 +111,13 @@ ...@@ -111,13 +111,13 @@
<div id="example" class="section level2"> <div id="example" class="section level2">
<h2 class="hasAnchor"> <h2 class="hasAnchor">
<a href="#example" class="anchor"></a>Example</h2> <a href="#example" class="anchor"></a>Example</h2>
<p>We simulate data for <span class="math inline">\(n\)</span> samples and <span class="math inline">\(p\)</span> features, in a high-dimensional settting (<span class="math inline">\(p \gg n\)</span>). The matrix <span class="math inline">\(\boldsymbol{X}\)</span> with <span class="math inline">\(n\)</span> rows and <span class="math inline">\(p\)</span> columns represents the features, and the vector <span class="math inline">\(\boldsymbol{y}\)</span> of length <span class="math inline">\(n\)</span> represents the continuous outcome.</p> <p>We simulate data for <span class="math inline">\(n\)</span> samples and <span class="math inline">\(p\)</span> features, in a high-dimensional setting (<span class="math inline">\(p \gg n\)</span>). The matrix <span class="math inline">\(\boldsymbol{X}\)</span> with <span class="math inline">\(n\)</span> rows and <span class="math inline">\(p\)</span> columns represents the features, and the vector <span class="math inline">\(\boldsymbol{y}\)</span> of length <span class="math inline">\(n\)</span> represents the continuous outcome.</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1"><span class="kw"><a href="https://rdrr.io/r/base/Random.html">set.seed</a></span>(<span class="dv">1</span>)</a> <div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1"><span class="kw"><a href="https://rdrr.io/r/base/Random.html">set.seed</a></span>(<span class="dv">1</span>)</a>
<a class="sourceLine" id="cb4-2" title="2">n &lt;-<span class="st"> </span><span class="dv">100</span>; p &lt;-<span class="st"> </span><span class="dv">500</span></a> <a class="sourceLine" id="cb4-2" title="2">n &lt;-<span class="st"> </span><span class="dv">100</span>; p &lt;-<span class="st"> </span><span class="dv">500</span></a>
<a class="sourceLine" id="cb4-3" title="3">X &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/matrix.html">matrix</a></span>(<span class="kw"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span>(n<span class="op">*</span>p),<span class="dt">nrow=</span>n,<span class="dt">ncol=</span>p)</a> <a class="sourceLine" id="cb4-3" title="3">X &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/matrix.html">matrix</a></span>(<span class="kw"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span>(n<span class="op">*</span>p),<span class="dt">nrow=</span>n,<span class="dt">ncol=</span>p)</a>
<a class="sourceLine" id="cb4-4" title="4">beta &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/stats/Binomial.html">rbinom</a></span>(<span class="dt">n=</span>p,<span class="dt">size=</span><span class="dv">1</span>,<span class="dt">prob=</span><span class="fl">0.05</span>)</a> <a class="sourceLine" id="cb4-4" title="4">beta &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/stats/Binomial.html">rbinom</a></span>(<span class="dt">n=</span>p,<span class="dt">size=</span><span class="dv">1</span>,<span class="dt">prob=</span><span class="fl">0.05</span>)</a>
<a class="sourceLine" id="cb4-5" title="5">y &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span>(<span class="dt">n=</span>n,<span class="dt">mean=</span>X<span class="op">%*%</span>beta)</a></code></pre></div> <a class="sourceLine" id="cb4-5" title="5">y &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span>(<span class="dt">n=</span>n,<span class="dt">mean=</span>X<span class="op">%*%</span>beta)</a></code></pre></div>
<p>We use the function <code>cornet</code> for modelling the original continuous outcome and the artifial binary outcome. The argument <code>cutoff</code> splits the samples into two groups, those with an outcome less than or equal to the cutoff, and those with an outcome greater than the cutoff.</p> <p>We use the function <code>cornet</code> for modelling the original continuous outcome and the artificial binary outcome. The argument <code>cutoff</code> splits the samples into two groups, those with an outcome less than or equal to the cutoff, and those with an outcome greater than the cutoff.</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" title="1">model &lt;-<span class="st"> </span><span class="kw"><a href="../reference/cornet.html">cornet</a></span>(<span class="dt">y=</span>y,<span class="dt">cutoff=</span><span class="dv">0</span>,<span class="dt">X=</span>X)</a> <div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" title="1">model &lt;-<span class="st"> </span><span class="kw"><a href="../reference/cornet.html">cornet</a></span>(<span class="dt">y=</span>y,<span class="dt">cutoff=</span><span class="dv">0</span>,<span class="dt">X=</span>X)</a>
<a class="sourceLine" id="cb5-2" title="2">model</a></code></pre></div> <a class="sourceLine" id="cb5-2" title="2">model</a></code></pre></div>
<p>The function <code>coef</code> returns the estimated coefficients. The first column is for the linear model (beta), and the second column is for the logistic model (gamma). The first row includes the estimated intercepts, and the other rows include the estimated slopes.</p> <p>The function <code>coef</code> returns the estimated coefficients. The first column is for the linear model (beta), and the second column is for the logistic model (gamma). The first row includes the estimated intercepts, and the other rows include the estimated slopes.</p>
......
...@@ -40,7 +40,7 @@ library(cornet) ...@@ -40,7 +40,7 @@ library(cornet)
## Example ## Example
We simulate data for $n$ samples and $p$ features, in a high-dimensional settting ($p \gg n$). The matrix $\boldsymbol{X}$ with $n$ rows and $p$ columns represents the features, and the vector $\boldsymbol{y}$ of length $n$ represents the continuous outcome. We simulate data for $n$ samples and $p$ features, in a high-dimensional setting ($p \gg n$). The matrix $\boldsymbol{X}$ with $n$ rows and $p$ columns represents the features, and the vector $\boldsymbol{y}$ of length $n$ represents the continuous outcome.
```{r,eval=FALSE} ```{r,eval=FALSE}
set.seed(1) set.seed(1)
...@@ -50,7 +50,7 @@ beta <- rbinom(n=p,size=1,prob=0.05) ...@@ -50,7 +50,7 @@ beta <- rbinom(n=p,size=1,prob=0.05)
y <- rnorm(n=n,mean=X%*%beta) y <- rnorm(n=n,mean=X%*%beta)
``` ```
We use the function `cornet` for modelling the original continuous outcome and the artifial binary outcome. The argument `cutoff` splits the samples into two groups, those with an outcome less than or equal to the cutoff, and those with an outcome greater than the cutoff. We use the function `cornet` for modelling the original continuous outcome and the artificial binary outcome. The argument `cutoff` splits the samples into two groups, those with an outcome less than or equal to the cutoff, and those with an outcome greater than the cutoff.
```{r,eval=FALSE} ```{r,eval=FALSE}
model <- cornet(y=y,cutoff=0,X=X) model <- cornet(y=y,cutoff=0,X=X)
......