--- title: "A minimal example" author: "Matthew Stephens" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{minimal example} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set(collapse = TRUE,comment = "#",fig.width = 4.5, fig.height = 3,fig.align = "center", fig.cap = " ",dpi = 120) ``` In this short vignette, we fit a sparse linear regression model with up to $L > 0$ non-zero effects. Generally, there is no harm in over-stating $L$ (that is, the method is pretty robust to overfitting), except that computation will grow as $L$ grows. Here is a minimal example: ```{r} library(susieR) set.seed(1) n <- 1000 p <- 1000 beta <- rep(0,p) beta[c(1,2,300,400)] <- 1 X <- matrix(rnorm(n*p),nrow=n,ncol=p) y <- X %*% beta + rnorm(n) res <- susie(X,y,L=10) plot(coef(res)[-1],pch = 20) ``` Plot the ground-truth outcomes vs. the predicted outcomes: ```{r fig.height=3.5, fig.width=3.5} plot(y,predict(res),pch = 20) ``` ## Session information Here are some details about the computing environment, including the versions of R, and the R packages, used to generate these results. ```{r} sessionInfo() ```