lr: Logistic Regression

View source: R/LogisticRegression.R

lrR Documentation

Logistic Regression

Description

lr is used to fit a logistic regression model for a binary response variable.

Usage

lr(formula, data, init = NULL)

Arguments

formula

an object of class formula, a symbolic description of the model to be fitted. The specified names need to also be in data.

data

a required data frame containing the variables in the model

init

optional initial conditions to be passed to optimisation of the log-likelihood

Details

The form of the formula argument will be of the form response ~ predictor1 + predictor2 + ..., with predictor1 and predictor2 being named columns of the data frame in data.

The log-likelihood (from loglik_lr) is maximised using irls.lr with initial estimates given by init. If no initial values are supplied, this uses a vector of zeros instead.

Value

An S3 object of class 'lr', which is a list containing

coefficients

a vector of coefficients corresponding to covariates specified in formula

data

the data input to the function

formula

the formula input to the function

X

the model matrix X

val

value of the final log-likelihood at the values of coefficients, given by loglik_lr

its

number of iterations performed to retrieve the maximised log-likelihood

Examples

y = sample(0:1, 50, replace=TRUE)
d = data.frame(y = y, x = rnorm(10*y + 15))
fit = lr(y ~ x, data = d)

dannyjameswilliams/danielR documentation built on Aug. 20, 2023, 3:25 a.m.