0
 W    : +  iОscreen-w|VT 100/ANSI X3.64 virtual terminal with 132 cols                                         џџџџџџџџџџџџџџџџџџџџ @        % ) - џџ8 I K O V џџX d џџh k q u џџџџy {   џџ  џџџџ  Ђ џџЇ Љ Ў џџЗ М Т Ш џџџџџџЫ џџџџџџЯ џџг џџџџџџе џџк џџџџџџџџо т ш ь № є њ  џџџџ %*џџџџџџ.2:џџџџџџџџџџџџџџџџџџџџџџџџџџBџџENW`ir{џџџџџџџџџџџџџџџџџџџџАГОСУЦџџџџџџџџџџџџџџџџџџџџџџџџџџ`џџџџџџџџџџџџdџџџџџџџџџџџџџџџџkџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџpvџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ|џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџІџџџџџџЊД[Z   [%i%p1%d;%p2%dr [3g [H[J [K [J [%i%p1%dG [%i%p1%d;%p2%dH 
 [H [?25l  [34h[?25h [C M [34l [P [M  [5m [1m [?1049h [2m [4h [7m [3m [4m  [m [?1049l [4l [23m [24m g )0 [L  [3~ OB OP [21~ OQ OR OS [15~ [17~ [18~ [19~ [20~ [1~ [2~ OD [6~ [5~ OC OA [?1l> [?1h= E [%p1%dP [%p1%dM [%p1%dB [%p1%d@ [%p1%dS [%p1%dL [%p1%dD [%p1%dC [%p1%dT [%p1%dA c[?1000l[?25h 8 [%i%p1%dd 7 
 M [0%?%p6%t;1%;%?%p1%t;3%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;2%;m%?%p9%t%e%; H 	 ++,,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~ [Z (B)0 [4~ [23~ [24~ [1K [%i%d;%dR [6n [?1;2c [c [39;49m [M [3%p1%dm [4%p1%dm              	  (B (%p1%c AX G0 U8 E0 S0   5   lнm_Jе4в  Ию2%1hпўc~5r4льКд ѓЫюЪСЧ      opar <- par(ask = dev.interactive(orNone = TRUE))
### Reading and quick exploration
data(Oswego)
use(Oswego)
codebook() 
# Same as 'codebook(.data)' and codebook(Oswego)
# since 'use' has created .data as a copy of the data.frame
des()
summ()

# Describe subset of variables
des("c*") # Show all variables starting with 'c'
des("?????") # Show all variables with 5 characters in the name

### Quick graphic exploration
summ(age)
summ(age, by=sex)
dotplot(age)
dotplot(age, by=sex)

### Creating as well as exploring age group
pyramid(age, sex, binwidth=10) -> output
agegr <- output$ageGroup # The above and this line created 'agegr' from the pyramid
summ(agegr)

### Integrate a vector into the default data frame (.data)
# The following line both labels and integrates 'agegr' into '.data'
label.var(agegr, "Age group") 
des()
tab1(agegr)
tabpct(agegr, chocolate) # Note the label of age group
des("age*") # Both 'age' and 'agegr' will be described

### Recoding variable
tab1(chocolate)
recode(chocolate, is.na(chocolate), TRUE)
tab1(chocolate)

### Computing and graphing odds ratio
cc(ill, chocolate)
mhor(ill, chocolate, sex)

### Computing risk difference, relative, NNT for a protective factor
cs(ill, chocolate)

### Computing attributable fraction of a risk factor
cs(ill, vanilla)

### Display of logistic regression results
model1 <- glm(case ~ induced + factor(spontaneous), data=infert, family=binomial)
# Note that 'induced' and 'spontaneous' are both originally continuous variables
logistic.display(model1)
# Having two spontaneous abortions is quite close to being infertile!
# This is actually not a causal relationship

### Likelihood ratio test
model2 <- glm(case ~ factor(spontaneous), data=infert, family=binomial)
logistic.display(model2)
lrtest(model1, model2) 
# Number of induced abortions is associated with increased risk for infertility

#### ROC curve
lroc1 <- lroc(model1, table=TRUE)
lroc1 # Note the returned list
lroc2 <- lroc(model2, add=TRUE, line.col="black")
legend("bottomright",legend=c(lroc1$model.description, lroc2$model.description),
        lty=1, col=c("red","brown"),bg="white")
title(main="Comparison of two logistic regression models")

### ROC from a table of diagnostic test
table1 <- as.table(cbind(c(1,27,56,15,1),c(0,0,10,69,21)))
colnames(table1) <- c("Non-diseas