Description Usage Arguments Value Examples
Fit binomial logistic regression via unpenalized maximum likelihood. Use tuning-free optimization to get the result.
1 | Logreg(X, y, maxit = 10000)
|
X |
input matrix, of dimension n (sample number) by p (variable number); each row is an observation vector. |
y |
response variable. Since we aim at binomial regression, it should be a vector with two levels (like a vector of 0 & 1, or a & b) |
maxit |
the Maximum number of iterations when we use optimization to estimate the parameeter; default is 10000. And the algorithm will stop according to its stopping criterion. |
A list containing the relevant data of regression result.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ### install and library package (building vignetter may cost 1 minute)
#devtools::install_github("hobbitish1028/Logistic",build_vignettes = TRUE,force = TRUE)
#And if you fail to call help page after this, please type `.rs.restartR()` and run it.
library(Logistic)
### Generate training data
sigma<-4
set.seed(123)
n<-1e4
p<-1e2
mu1<-rnorm(p)
mu2<-rnorm(p)
X1<-matrix(mu1+rnorm(n*p,0,sigma),n,p,byrow = TRUE)
X2<-matrix(mu2+rnorm(n*p,0,sigma),n,p,byrow = TRUE)
### Train data
X<-rbind(X1,X2)
y<-rep(c(1,0),each=n)
### Fit model
fit<-Logreg(X,y)
### accuracy of train data
fit$accuracy
### check the convergence
plot(fit$loss)
### get the prediction of train data
result<-fit$prediction
### get the probability of each sample belonging to two category
result<-fit$P
### get the parameter of the logistic regression (including intercept)
result<-fit$x
browseVignettes("Logistic")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.