This document introduces how to use the three functions in package "zouhw2". Please make sure to install packages "askpass" and "sys" in advance and enter "3" when installing this package. For the definition of each parameter in the functions, please refer to the documentations via help() function.
library(devtools) #install.packages("askpass") #install.packages("sys") install_github("xyzou685/STSCI6520_HW2") library(zouhw2)
set A to be a 1010 square matrix, entries drawn IID from standard normal distribution, $v=1_{10}$. b is a 101 vector and $Av=b$. When using this function with other input, need to make sure that column number of A=row number of b. Method must be either "GS" or "Jacobi". Now we use different approach to approximate v. You can change number of cores or number of iteration as you want.
n=10 L <- diag(0, n) L[(row(L) - col(L)) == 1] <- -1 U <- diag(0, n) U[(row(U) - col(U)) == -1] <- -1 D <- diag(2, n) a <- L+D+U v <- as.vector(rep(1,10)) b=a%*%v #Gauss-Seidel solve_ols(a,b,method = "GS",iteration=100) #Sequential Jacobi solve_ols(a,b,cores=1,method = "Jacobi",iteration=100) #Parallel Jacobi solve_ols(a,b,cores=2,method = "Jacobi",iteration=100)
xi can be a n1 vector or a np matrix, yi is a n1 vector. xi's row number(data size) must match yi's row number. r can be set as any integer between 1 and yi's length. In the tet code, we set xi to be a 1005 matrix, yi to be a 100*1 vector, and $y_i=-x_i+\epsilon_i$.
x <- matrix(rnorm(500),100,5) y <- x%*%rep(-1,5)+rnorm(100) algo_leverage(x,y)
same test setting as algo_leverage() function, but you can determine more parameters: $\alpha \in [0,1], \lambda$ can be any real number, maxiteration can be any positive integer. The returned $\beta$ value is expected to be smaller as $\lambda$ increases.
x <- matrix(rnorm(500),100,5) y <- x%*%rep(-1,5)+rnorm(100) elnet_coord(x,y,a=0.5,lambda=0.7)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.