###########################
# Logistic regression model
set.seed(123)
n <- 100
p <- 10
X <- matrix(rnorm(n*p), n, p)
b <- 1:2
eta <- b[1] + X[,1] * b[2]
mu <- binomial()$linkinv(eta)
y <- rbinom(n, 1, mu)
fit <- dglars.fit(X, y, family = "binomial")
## the BIC criterion is used to select the best model
summary(fit, k= "BIC",complexity = "df")
## the AIC criterion is used to select the best model
summary(fit, k= "AIC",complexity = "df")
tbl <- make_summary_table(fit, k=log(n), complexity = "df")
str(tbl)
summary(fit, complexity = "gdf")
tbl <- make_summary_table(fit, k=log(n), complexity = "gdf")
str(tbl)
##########################
# Poisson regression model
n <- 100
p <- 10
X <- matrix(rnorm(n*p), n, p)
b <- 1:2
eta <- b[1] + X[,1] * b[2]
mu <- poisson()$linkinv(eta)
y <- rpois(n, mu)
fit <- dglars.fit(X, y, family = "poisson")
## the BIC criterion is used to select the best model
summary(fit, k= "BIC",complexity = "df")
## the AIC criterion is used to select the best model
summary(fit, k= "AIC",complexity = "df")
tbl <- make_summary_table(fit, k=log(n), complexity = "df")
str(tbl)
summary(fit, k=log(n), complexity = "gdf")Run the code above in your browser using DataLab