Learn R Programming

QuantPsyc (version 1.5)

ClassLog: Classification for Logistic Regression

Description

Provides a Classification analysis for a logistic regression model. Also provides McFadden's Rsq.

Usage

ClassLog(MOD, resp, cut=.5)

Arguments

MOD
Model of class glm where family is bonomial
resp
response variable from data
cut
Arbitrary cut for the proportion deemed '1' in model

Value

A list containing: /CR
  • rawtab two-way table of classifications as frequencies
  • classtab two-way table of classifications as percentages
  • overall Overall percent classifications that are correct
  • mcFadden McFaddens pseudoRsq; 1 - ModelDeviance / NullDeviance

Warning

This is a primative function. I have a long to do list. For example, it is not yet written to handle missing observations.

See Also

glm

Examples

Run this code
# create some data
x <- rnorm(100)
y <- as.numeric(cut(.5*x + rnorm(100), breaks=2))-1
tdf <- data.frame(x=x, y=y)

# run a logistic regression	
glm1 <- glm(y ~ x, data=tdf, family=binomial)

# Get typical summary of results
summary(glm1)

# Classification Analysis
ClassLog(glm1, tdf$y)

Run the code above in your browser using DataLab