UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

SPLUS Textbook Examples
Computer-Aided Multivariate Analysis by Afifi and Clark
Chapter 12: Logistic Regression

The SPLUS program for the chapter.

In this chapter we will only be using the depression data set so we choose to use the attach function.

attach(depress)

Table 12.1, p. 286.
Classification of individuals by depression level and sex.

table1 <- table(sex, cases)
print(table1)

    0  1 
1 101 10
2 143 40

Regressing depression level on sex, middle p. 286.
Note: We are using sex01 which is a (0, 1) variable rather than sex which is a (1, 2) variable.

depress$sex01 <- depress$sex - 1
logit1 <- glm(cases ~ sex01, depress, family=binomial)
summary(logit1)

Coefficients:
                Value Std. Error   t value 
(Intercept) -2.312511  0.3304732 -6.997576
      sex01  1.038546  0.3757731  2.763759

Regressing depression levels on age, sex and income, middle p. 287.

logit2 <- glm(cases ~ age+income+sex, depress, family=binomial)
summary(logit2)

Coefficients:
                  Value  Std. Error   t value 
(Intercept) -1.60583693 0.842754515 -1.905462
        age -0.02095667 0.009023527 -2.322447
     income -0.03655542 0.013971982 -2.616337
        sex  0.92934726 0.383808600  2.421382

Regressing depression levels on age and income, top p. 288.

logit3 <- glm(cases ~ age+income, depress, family=binomial)
summary(logit3)

Coefficients:
                  Value  Std. Error     t value 
(Intercept)  0.02790447 0.486489875  0.05735879
        age -0.02016672 0.008888887 -2.26875686
     income -0.04134262 0.013963952 -2.96066780

Regressing depression levels on age, income and sex, bottom p. 297.

logit2 <- glm(cases ~ age+income+sex, depress, family=binomial)
summary(logit2)

Coefficients:
                  Value  Std. Error   t value 
(Intercept) -1.60583693 0.842754515 -1.905462
        age -0.02095667 0.009023527 -2.322447
     income -0.03655542 0.013971982 -2.616337
        sex  0.92934726 0.383808600  2.421382

Unless you plan to work further with the depression data set it will be a good idea to detach it.

detach(depress)


How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California