Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
PAGE 2005 Introduction to Categorical Data Analysis Adrian Dunne Department of Statistics and Actuarial Science, Roinn na Staitisticí agus na hAchtúreolaíochta University College Dublin An Coláiste Ollscoile Baile Átha Cliath Data Types • Quantitative – Continuous – Discrete Plasma drug conc., BP, Muscle Tension, Time Number of blood cells, Number of heart attacks • Categorical – Nominal – Ordinal – Binary Copyright Adrian Dunne 2005 Religion, Nationality, Gender Social class, Treatment outcome Gender, Dead/Alive 2 Example: Categorical Data Population of patients require a particular analgesic Estimate population proportions in each category – none, some, complete. Copyright Adrian Dunne 2005 Drug administered to sample of patients Each patient is assessed for pain relief – none, some, complete 3 Binary Data • Describe the two categories as “Success” (S) and “Failure” (F). • Code Z = 0 for F Z = 1 for S Copyright Adrian Dunne 2005 4 Binary Data • Proportion of S in population. • Randomly select a member of the population – probability of S. • Proportion = Probability Copyright Adrian Dunne 2005 5 Binary Data • Z has the Bernoulli Distribution Pr (Z = 1 ) = π Prob Pr (Z = 0 ) = 1 − π Pr( Z = r ) = π Copyright Adrian Dunne 2005 r of S Prob of F (1 − π ) ( 1 − r ) r = 0 ,1 6 Estimation: Method of Maximum Likelihood • Likelihood n L(π ) = ∏ π (1 − π ) zi (1− zi ) i =1 • πˆ is the value of π that maximises the likelihood Copyright Adrian Dunne 2005 7 Simple Example 10 observations:- 3S’s 7F’s Simple model with no structure Z ~ Bernoulli (π ) n L(π ) = ∏ π (1 − π ) zi (1− zi ) i =1 Copyright Adrian Dunne 2005 8 Example: Likelihood Copyright Adrian Dunne 2005 9 Data Modelling • Previous example had no structure in the data. • Consider the case where the subjects were administered different doses of drug and the response depends on dose. • Another example would be where response changes with time following drug administration (PK-PD). Copyright Adrian Dunne 2005 10 Data Modelling • Take account of the structure by recording the values of covariates (x’s) for each member of the sample e.g. dose, time. • Then construct a model which describes how the parameters depend on the covariates. Copyright Adrian Dunne 2005 11 Modelling Binary Data • We model π i e.g. • However, π i = f ( xi ,θ ) 0 ≤ πi ≤1 • There is no guarantee that 0 ≤ f ( xi ,θˆ) ≤ 1 Copyright Adrian Dunne 2005 12 Modelling Binary Data Transform πi from (0,1) to (−∞,+∞) and model the transformed value to ensure that model predicted probabilities lie in (0,1). Copyright Adrian Dunne 2005 13 Transformations • Logit πi logit (π i ) = log 1−π i • Probit probit (π i ) = Φ −1 (π i ) • Log-log log(− log(π i )) • Complementary log-log Copyright Adrian Dunne 2005 log(− log(1 − π i )) 14 Probit transformation Normal distribution π Probit Copyright Adrian Dunne 2005 15 Transformations Logit Log-log Comp. Log-log Copyright Adrian Dunne 2005 Probit 16 Logistic Regression Model Now consider a model with structure logit (π i ) = f ( xi ,θ ) Example logit (π i ) = θ1 + θ 2 x1i + θ 3 x2i + ... Copyright Adrian Dunne 2005 17 Example: Bioassay Beetle deaths following dosing with an insecticide Dose 0.0028 0.0056 0.0112 0.0225 0.0450 Copyright Adrian Dunne 2005 # Exposed 40 40 40 40 40 # Dead 5 19 31 34 39 18 Copyright Adrian Dunne 2005 19 Copyright Adrian Dunne 2005 20 Logit Model Linear logistic model with log(dose) zi ~ Bernoulli (π i ) log it (π i ) = θ1 + θ 2 log(dosei ) n L(θ) = ∏ π i (1 − π i ) zi (1− zi ) i =1 Copyright Adrian Dunne 2005 21 Observed & Predicted Values Copyright Adrian Dunne 2005 22 Mixed Effects Modelling • Modelling correlation between responses/variation between groups. – Groups of related items – Repeated measures/Longitudinal data Copyright Adrian Dunne 2005 23 Example: Binary PK-PD response • 10 subjects all received dose of 100 units. • Bolus iv administration. • Binary response (dry mouth) recorded for each subject at times 0.5, 1, 2, 3, 5, 7, 9, 12, 15, 18, 24, 30 hours. Copyright Adrian Dunne 2005 24 Copyright Adrian Dunne 2005 25 PK-PD Model Bolus (D) at t=0 Central Compartment Cp(t) K k1e Effect Compartment Ce(t) keo Eff ( t ) = f ( C e ( t )) Copyright Adrian Dunne 2005 26 PK-PD Model • Linear PD model Eff (t ) = θ1 + θ 2Ce (t ) logit (π (t )) = θ1 + θ 2Ce (t ) Copyright Adrian Dunne 2005 27 Example: Binary Population PK-PD model • Variation between subjects • Longitudinal (repeated measures) data – observations on same subject are correlated • Model intrasubject correlation and intersubject variation using random effects Copyright Adrian Dunne 2005 28 Example: Binary Population PK-PD model logit ( π i ( t j )) = θ 1 + θ 2 C e ( t j ) + η i η i ~ N (0, Ω ) n L(θ, Ω) = ∏ +∞ mi ∫ ∏ π (t ) i j zi (1 − π i (t j )) (1− zi ) f (ηi , φ )dηi i =1 − ∞ j =1 Copyright Adrian Dunne 2005 29 Observed & Predicted Values Copyright Adrian Dunne 2005 30 Latent Variable • Consider again the insecticide bioassay • Assume that each insect has an (unobserved) tolerance ti which varies randomly across the population of insects ti ≤ d i ⇒ zi = 1 ti > d i ⇒ zi = 0 Copyright Adrian Dunne 2005 31 Tolerance distribution π i = Pr(ti ≤ d i ) πi 1−π i di zi = 1 Copyright Adrian Dunne 2005 zi = 0 32 Latent Variables • di is known as the cut-point • Here the latent variable is tolerance Copyright Adrian Dunne 2005 33 π i = Pr(ti ≤ d i ) πi = di ∫ f (ti , β)dti −∞ Copyright Adrian Dunne 2005 34 exp((ti − β 0 ) / β1 ) f(ti , β) = 2 β1 (1 + exp((ti − β 0 ) / β1 ) ) logit (π i ) = θ1 + θ 2 d i Copyright Adrian Dunne 2005 35 exp((log(ti ) − β 0 ) / β1 ) f(ti , β) = 2 ti β1 (1 + exp((log(ti ) − β 0 ) / β1 ) ) logit (π i ) = θ1 + θ 2 log(d i ) Copyright Adrian Dunne 2005 36 exp(−0.5((ti − β 0 ) / β1 ) ) f (ti , β) = 2π β1 2 probit (π i ) = θ1 + θ 2 d i Copyright Adrian Dunne 2005 37 exp(−0.5((log(ti ) − β 0 ) / β1 ) ) f (ti , β) = ti 2π β1 2 probit (π i ) = θ1 + θ 2 log(d i ) Copyright Adrian Dunne 2005 38 f (ti , β) = exp((ti − β0 ) / β1 ) exp(− exp((ti − β0 ) / β1 )) β1 log(-log(1- π i )) = θ1 + θ2di Copyright Adrian Dunne 2005 39 exp((log(ti ) − β0 ) / β1 ) exp(− exp((log(ti ) − β0 ) / β1 )) f (ti , β) = ti β1 log(-log(1- π i )) = θ1 + θ2 log(di ) Copyright Adrian Dunne 2005 40 Ordinal Data • Ordered categories e.g. severity of symptoms, none, mild, moderate, severe. • Ordered categories • Probabilities Copyright Adrian Dunne 2005 Z = 1,2,..., K π 1 , π 2 ,..., π K 41 Latent Variable α1 Z =1 Copyright Adrian Dunne 2005 α2 Z =2 Z =3 42 Cumulative Logits • Cumulative probabilities Fk = π 1 + π 2 + ... + π k • Cumulative Logits Fk Lk = logit ( Fk ) = log 1 − Fk k = 1,2,..., K − 1 • A model for Lk is a logit model for a binary response. • We need K-1 logit models Copyright Adrian Dunne 2005 43 Cumulative Logits Based on K-1 dichotomizations. – – – – (1) and (2 to K) (1 and 2) and (3 to K) (1 to 3) and (4 to K) etc. Copyright Adrian Dunne 2005 44 Proportional Odds Model • Covariate x influences all cumulative logits equally logit ( Fk ) = α k − f ( x, θ ) • Such a model is equivalent to x influencing the location (but not the spread) of the distribution of the latent variable. Copyright Adrian Dunne 2005 45 Proportional Hazards Model • Covariate x influences all cumulative complementary log-logs equally log(− log(1 − Fk )) = α k − f ( x,θ ) • Such a model is equivalent to x influencing the location (but not the spread) of the distribution of the latent variable. Copyright Adrian Dunne 2005 46