Commit a39ec1b8 authored by Armin Rauschenberger's avatar Armin Rauschenberger

remove file

parent 7a51fb57
...@@ -626,13 +626,13 @@ predict.cornet <- function(object,newx,type="probability",...){ ...@@ -626,13 +626,13 @@ predict.cornet <- function(object,newx,type="probability",...){
if(!miss && any(is.na(x))){ if(!miss && any(is.na(x))){
stop(paste0("Argument \"",name,"\" contains missing values."),call.=FALSE) stop(paste0("Argument \"",name,"\" contains missing values."),call.=FALSE)
} }
if(!is.null(min) && any(x<min)){ if(!is.null(min) && any(x<min,na.rm=TRUE)){
stop(paste0("expecting ",name," >= ",min),call.=FALSE) stop(paste0("expecting ",name," >= ",min),call.=FALSE)
} }
if(!is.null(max) && any(x>max)){ if(!is.null(max) && any(x>max,na.rm=TRUE)){
stop(paste0("expecting ",name," <= ",max),call.=FALSE) stop(paste0("expecting ",name," <= ",max),call.=FALSE)
} }
if(!is.null(values) && any(!x %in% values)){ if(!is.null(values) && any(!x %in% values,na.rm=TRUE)){
stop(paste0("Argument \"",name,"\" contains invalid values."),call.=FALSE) stop(paste0("Argument \"",name,"\" contains invalid values."),call.=FALSE)
} }
if(!inf && any(is.infinite(values))){ if(!inf && any(is.infinite(values))){
......
...@@ -107,26 +107,25 @@ ...@@ -107,26 +107,25 @@
<span class="kw pkg">devtools</span><span class="kw ns">::</span><span class="fu"><a href="https://devtools.r-lib.org//reference/remote-reexports.html">install_github</a></span>(<span class="st">"rauschenberger/cornet"</span>)</pre></body></html></div> <span class="kw pkg">devtools</span><span class="kw ns">::</span><span class="fu"><a href="https://devtools.r-lib.org//reference/remote-reexports.html">install_github</a></span>(<span class="st">"rauschenberger/cornet"</span>)</pre></body></html></div>
<p>Then load and attach the package:</p> <p>Then load and attach the package:</p>
<div class="sourceCode" id="cb3"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/r/base/library.html">library</a></span>(<span class="no">cornet</span>)</pre></body></html></div> <div class="sourceCode" id="cb3"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/r/base/library.html">library</a></span>(<span class="no">cornet</span>)</pre></body></html></div>
<pre><code>## Warning: package 'cornet' was built under R version 4.0.2</code></pre>
</div> </div>
<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 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> <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="cb5"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/r/base/Random.html">set.seed</a></span>(<span class="fl">1</span>) <div class="sourceCode" id="cb4"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/r/base/Random.html">set.seed</a></span>(<span class="fl">1</span>)
<span class="no">n</span> <span class="kw">&lt;-</span> <span class="fl">100</span>; <span class="no">p</span> <span class="kw">&lt;-</span> <span class="fl">500</span> <span class="no">n</span> <span class="kw">&lt;-</span> <span class="fl">100</span>; <span class="no">p</span> <span class="kw">&lt;-</span> <span class="fl">500</span>
<span class="no">X</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/matrix.html">matrix</a></span>(<span class="fu"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span>(<span class="no">n</span>*<span class="no">p</span>),<span class="kw">nrow</span><span class="kw">=</span><span class="no">n</span>,<span class="kw">ncol</span><span class="kw">=</span><span class="no">p</span>) <span class="no">X</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/matrix.html">matrix</a></span>(<span class="fu"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span>(<span class="no">n</span>*<span class="no">p</span>),<span class="kw">nrow</span><span class="kw">=</span><span class="no">n</span>,<span class="kw">ncol</span><span class="kw">=</span><span class="no">p</span>)
<span class="no">beta</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/Binomial.html">rbinom</a></span>(<span class="kw">n</span><span class="kw">=</span><span class="no">p</span>,<span class="kw">size</span><span class="kw">=</span><span class="fl">1</span>,<span class="kw">prob</span><span class="kw">=</span><span class="fl">0.05</span>) <span class="no">beta</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/Binomial.html">rbinom</a></span>(<span class="kw">n</span><span class="kw">=</span><span class="no">p</span>,<span class="kw">size</span><span class="kw">=</span><span class="fl">1</span>,<span class="kw">prob</span><span class="kw">=</span><span class="fl">0.05</span>)
<span class="no">y</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span>(<span class="kw">n</span><span class="kw">=</span><span class="no">n</span>,<span class="kw">mean</span><span class="kw">=</span><span class="no">X</span><span class="kw">%*%</span><span class="no">beta</span>)</pre></body></html></div> <span class="no">y</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span>(<span class="kw">n</span><span class="kw">=</span><span class="no">n</span>,<span class="kw">mean</span><span class="kw">=</span><span class="no">X</span><span class="kw">%*%</span><span class="no">beta</span>)</pre></body></html></div>
<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> <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="cb6"><html><body><pre class="r"><span class="no">model</span> <span class="kw">&lt;-</span> <span class="fu"><a href="../reference/cornet.html">cornet</a></span>(<span class="kw">y</span><span class="kw">=</span><span class="no">y</span>,<span class="kw">cutoff</span><span class="kw">=</span><span class="fl">0</span>,<span class="kw">X</span><span class="kw">=</span><span class="no">X</span>) <div class="sourceCode" id="cb5"><html><body><pre class="r"><span class="no">model</span> <span class="kw">&lt;-</span> <span class="fu"><a href="../reference/cornet.html">cornet</a></span>(<span class="kw">y</span><span class="kw">=</span><span class="no">y</span>,<span class="kw">cutoff</span><span class="kw">=</span><span class="fl">0</span>,<span class="kw">X</span><span class="kw">=</span><span class="no">X</span>)
<span class="no">model</span></pre></body></html></div> <span class="no">model</span></pre></body></html></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>
<div class="sourceCode" id="cb7"><html><body><pre class="r"><span class="no">coef</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/coef.html">coef</a></span>(<span class="no">model</span>)</pre></body></html></div> <div class="sourceCode" id="cb6"><html><body><pre class="r"><span class="no">coef</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/coef.html">coef</a></span>(<span class="no">model</span>)</pre></body></html></div>
<p>The function <code>predict</code> returns fitted values for training data, or predicted values for testing data. The argument <code>newx</code> specifies the feature matrix. The output is a matrix with one column for each model.</p> <p>The function <code>predict</code> returns fitted values for training data, or predicted values for testing data. The argument <code>newx</code> specifies the feature matrix. The output is a matrix with one column for each model.</p>
<div class="sourceCode" id="cb8"><html><body><pre class="r"><span class="no">predict</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/predict.html">predict</a></span>(<span class="no">model</span>,<span class="kw">newx</span><span class="kw">=</span><span class="no">X</span>)</pre></body></html></div> <div class="sourceCode" id="cb7"><html><body><pre class="r"><span class="no">predict</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/predict.html">predict</a></span>(<span class="no">model</span>,<span class="kw">newx</span><span class="kw">=</span><span class="no">X</span>)</pre></body></html></div>
<p>The function <code>cv.cornet</code> measures the predictive performance of combined regression by nested cross-validation, in comparison with logistic regression.</p> <p>The function <code>cv.cornet</code> measures the predictive performance of combined regression by nested cross-validation, in comparison with logistic regression.</p>
<div class="sourceCode" id="cb9"><html><body><pre class="r"><span class="fu"><a href="../reference/cv.cornet.html">cv.cornet</a></span>(<span class="kw">y</span><span class="kw">=</span><span class="no">y</span>,<span class="kw">cutoff</span><span class="kw">=</span><span class="fl">0</span>,<span class="kw">X</span><span class="kw">=</span><span class="no">X</span>)</pre></body></html></div> <div class="sourceCode" id="cb8"><html><body><pre class="r"><span class="fu"><a href="../reference/cv.cornet.html">cv.cornet</a></span>(<span class="kw">y</span><span class="kw">=</span><span class="no">y</span>,<span class="kw">cutoff</span><span class="kw">=</span><span class="fl">0</span>,<span class="kw">X</span><span class="kw">=</span><span class="no">X</span>)</pre></body></html></div>
<p>Here we observe that combined regression outperforms logistic regression (lower logistic deviance), and that logistic regression is only slightly better than the intercept-only model.</p> <p>Here we observe that combined regression outperforms logistic regression (lower logistic deviance), and that logistic regression is only slightly better than the intercept-only model.</p>
</div> </div>
<div id="references" class="section level1"> <div id="references" class="section level1">
......
...@@ -6,5 +6,5 @@ articles: ...@@ -6,5 +6,5 @@ articles:
article: article.html article: article.html
simulation: simulation.html simulation: simulation.html
vignette: vignette.html vignette: vignette.html
last_built: 2020-09-07T10:17Z last_built: 2020-10-05T12:04Z
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment