Nothing
knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
BranchGLM()
allows fitting of gaussian, binomial, gamma, and poisson GLMs with a variety of links available. grads
argument is for L-BFGS only and it is the number of gradients that are stored at a time and are used to approximate the inverse information. The default value for this is 10, but another common choice is 5.tol
argument controls how strict the convergence criteria are, lower values of this will lead to more accurate results, but may also be slower.method
argument is ignored for linear regression and the OLS solution is
used.init
argument.TRUE
and setting the nthreads
argument to the desired number of threads used.# Loading in BranchGLM library(BranchGLM) # Fitting gaussian regression models for mtcars dataset cars <- mtcars ## Identity link BranchGLM(mpg ~ ., data = cars, family = "gaussian", link = "identity")
MASS::gamma.dispersion()
function.# Fitting gamma regression models for mtcars dataset ## Inverse link GammaFit <- BranchGLM(mpg ~ ., data = cars, family = "gamma", link = "inverse") GammaFit ## Log link GammaFit <- BranchGLM(mpg ~ ., data = cars, family = "gamma", link = "log") GammaFit
# Fitting poisson regression models for warpbreaks dataset warp <- warpbreaks ## Log link BranchGLM(breaks ~ ., data = warp, family = "poisson", link = "log")
# Fitting binomial regression models for toothgrowth dataset Data <- ToothGrowth ## Logit link BranchGLM(supp ~ ., data = Data, family = "binomial", link = "logit") ## Probit link BranchGLM(supp ~ ., data = Data, family = "binomial", link = "probit")
Table()
creates a confusion matrix based on the predicted classes and observed classesROC()
creates an ROC curve which can be plotted with plot()
AUC()
and Cindex()
calculate the area under the ROC curveMultipleROCCurves()
allows for the plotting of multiple ROC curves on the same plot# Fitting logistic regression model for toothgrowth dataset catFit <- BranchGLM(supp ~ ., data = Data, family = "binomial", link = "logit") Table(catFit)
# Creating ROC curve catROC <- ROC(catFit) plot(catROC, main = "ROC Curve", col = "indianred")
# Getting Cindex/AUC Cindex(catFit) AUC(catFit)
# Showing ROC plots for logit, probit, and cloglog probitFit <- BranchGLM(supp ~ . ,data = Data, family = "binomial", link = "probit") cloglogFit <- BranchGLM(supp ~ . ,data = Data, family = "binomial", link = "cloglog") MultipleROCCurves(catROC, ROC(probitFit), ROC(cloglogFit), names = c("Logistic ROC", "Probit ROC", "Cloglog ROC"))
BranchGLM
object.preds <- predict(catFit) Table(preds, Data$supp) AUC(preds, Data$supp) ROC(preds, Data$supp) |> plot(main = "ROC Curve", col = "deepskyblue")
coef()
to extract the coefficientslogLik()
to extract the log likelihoodAIC()
to extract the AICBIC()
to extract the BICpredict()
to obtain predictions from the fitted modelcoefficients
slot of the fitted model# Predict method predict(GammaFit) # Accessing coefficients matrix GammaFit$coefficients
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.