Professional Documents
Culture Documents
fisher.test()
fisher.test(x, # a vector or matrix
Sample data set
y = NULL, # a vector, ignored if x is a matrix
simulate.p.value = FALSE,
B = 2000)
Read data and tabulate Frequencies to Percentage
exp(α + β x )
p=
1 + exp( α + β x )
Logistic model
1
or p =
1 + exp( −α − β x )
Logit Model with more than 1 R Script for logistic regression with
Independent Variable more than 1 independent variable
ln(odds ) = b 0 + b1R +b 2 P + b3C
R=1 if using high rate of insecticide, R=0 if using low rate of insecticide
P=1 if past smoker, P=0 if not a past smoker
C=1 if current smoker, C=0 if not a current smoker
From R:
b0=-4.574 b1=0.541 b2=0.335 b3=0.219
ln(odds ) = −4.574 + 0.541R + 0.335P + 0.219C
p
= e − 4.574 e 0.541R e 0.335P e 0.219C
1− p
Test significance of model
p
= e −4.5739e 0.5407 R e 0.3346 Pe 0.2188 C
1− p
p
= ( 0.01032)(1.71721R )(1.39738 P )(1.24482C )
1− p
Indicates that rate of insecticide and past smoking has an effect on
pulmonary ailment. Current smoking has no significant effect on
pulmonary ailment.
p
p = ( 0.01032)(1.71721R )(1.39738 P )(1.24482C )
= ( 0.01032)(1.71721R )(1.39738 P )(1.24482C ) 1− p
1− p
p
Logit model: ln( ) = b 0 + b1T1 + b 2 T2
1− p
Logit model
Test significance of model
A vs control
B vs control
From R Output:
bo=1.735 b1=-2.833 b2=-2.582
Script to compute expected
probabilities
p
ln( ) = 1.735 − 2.833T1 − 2.582T2
1− p
(5.669)(0.0588T1 )(0.0756T2 )
p=
1 + (5.669)(0.0588T1 )(0.0756T2 )
0.5
exp( α + β x )
p=
0.25
1 + exp(α + βx )
0 Estimate α and β using logit
0 1 2 3 4 5 6 7 8 9
Farm Size regression equation:
p
ln( ) = α + βx
1− p
Logit model
Parameter estimates
p
ln( ) = −2.503 + 0.453x
1− p
(0.0818)(1.573x )
p=
1 + (0.0818)(1.573x )
If farm size=5 acres, p=0.44, that is probability
that the farmer is an adopter is 0.44.
Modeling Responses with More than
Two Categories
Re-organize or ignore some of the categories
temporarily, to reduce to a binary response.
Divide categories into a series of binary categories.
Use multinomial logistic regression as an extension
of binary logistic regression. Thank you!
Use log-linear models if all variables are categorical.