iwls.bnreg: Iterative Weighted Least Squares for logistic models

Description Usage Arguments Details Value Author(s) References Examples

Description

Performs logisitc regressions for bionomial data.

Usage

1
iwls.bnreg (y, X, n = NULL, intercept = FALSE, tol = 1e-07, max.iter = 1000)

Arguments

y

response vector of observed proportions.

X

model matrix of p covariates.

n

the vector of binomial denominators. When NULL n is equal to a 1s vector.

intercept

a logic value to indicate whether the intercept will be added directly by the function to the model matrix or not. The default value is FALSE i.e. add a vector of 1s to X.

tol

the convergence tolerance criterion.

max.iter

Maximum of iteration to be the limit if convergence is not attained. The default valueis 1000 iterations.

Details

The function performs the IWLS algorithm applied to binomial logistic regression (Fox, 2002)

Value

Returns a list including the following:

estimates

the maximum likelihood estimates of the coefficients.

var

the covariance matrix of coeeficients.

n.iter

the number of iterations at convergence.

Author(s)

Sewanou Honfo <honfosewanou@gmail.com> and Romain Glèlè Kakaï <glele.romain@gmail.com>/ LABEF_07_2019

References

Fox John (2002). An R and S-Plus companion to applied regression. Sage Publications.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Example on Mroz data from the package car
## Load packages and data
library(car)
data(Mroz)
str(Mroz)

## Convert non numeric variables to numeric
Mroz$lfp <- recode(Mroz$lfp, "'yes' = 1; 'no'= 0", as.factor = F)
Mroz$wc <- recode(Mroz$wc, "'yes' = 1; 'no'= 0", as.factor = F)
Mroz$hc <- recode(Mroz$hc, "'yes' = 1; 'no'= 0", as.factor = F)

## Run the binary logistic regression using the iterative weighted least squares estimation methods
attach(Mroz)
m.log <- iwls.bnreg(y = lfp, X = cbind(k5, k618, age, wc, hc, lwg, inc), n = NULL, intercept = FALSE, tol = 1e-07, max.iter = 1000)

## View the result
m.log$estimates
m.log$var
m.log$n.iter

Sewanou/ProjectSC2019 documentation built on Oct. 30, 2019, 11:52 p.m.