I am creating a model attempting to predict the probability someone will
reoffend after being caught for a crime.  There are seven total inputs and I
planned on using a logistic regression.  I started with a null deviance of
182.91 and ended up with a residual deviance of 83.40 after accounting for
different interactions and such.  However, I realized after that my code is
different from that in my book.  And I can't figure out what I need to put
in it's place.  Here's my code:

library(foreign)

library(car)

foo = read.table("C:/Documents and
Settings/Chris/Desktop/4330/criminals.dat", header=TRUE)


reoff = foo[ ,1]

race = foo[ ,2]

age = foo[ ,3]

gender = foo[ ,4]

educ = foo[ ,5]

subst = foo[ ,6]

prior = foo[ ,7]

violence = foo[ ,8]

fit1h = glm(reoff ~ factor(subst) + factor(violence) + prior +
factor(violence):factor(subst) + factor(violence):factor(educ) +
factor(violence):factor(age) + factor(violence):factor(prior))

summary(fit1h)


If you noticed, there's no part of my code that looks like:

family=binomial(link="logit"))


If I code like my book has done, it would look like:

fit1i = glm(reoff ~ factor(subst) + factor(violence) + prior +
factor(violence):factor(subst) + factor(violence):factor(educ) +
factor(violence):factor(age) + factor(violence):factor(prior),
family=binomial(link="logit"))

summary(fit1i)




However, when I do this, my null deviance is 1104 and my residual deviance
is 23460.  THIS IS A HUGE DIFFERENCE IN MODEL FIT!  I'm not sure if I have
to redo my model or if my book was simply doing the
"family=binomial(link="logit")" for a specific problem/reason.

So, to my question:
Do I need to include "family=binomial(link="logit")" in my code?  Do I need
to include any type of family?


Thanks for your help,

-chris

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to