Kyle Bogdan Grant Brown. Simulated based on known values of parameters (one covariate, ‘dose’)....

19
A (poor) Gibbs Sampling Approach to Logistic Regression Kyle Bogdan Grant Brown

Transcript of Kyle Bogdan Grant Brown. Simulated based on known values of parameters (one covariate, ‘dose’)....

Page 1: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

A (poor) Gibbs Sampling Approach to Logistic Regression

Kyle BogdanGrant Brown

Page 2: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

Data

Simulated based on known values of parameters (one covariate, ‘dose’).

‘rats’ given different dosages of imaginary chemical, 4 dose groups with 25 rats in each group.

Data generated three times under different parameters, three chains used for each data set.

Page 3: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

Gibbs Sampling For Logistic Data?

Traditionally, binomial likelihood, prior on logit.

Full Conditionals have no coherent form.

Attractive, however, because it eliminates the need to reject iterations

Page 4: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

Algorithm

Groenewald and Mokgatlhe, 2005 Create Uniform Latent Variables

Based on Y[i,j] = 0, 1 Draws from joint posterior of Betas

and U[i,j] pi[i] = p(uniform(01) <= logit-

1(Beta*x[i])) Written in R, refined in Python Very inefficient

Draw new parameter for each Y[i,j] at each iteration

Page 5: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

Implementation

• Three datasets• Three chains per set• 1 Million iterations per chain• Last 500k iterations sent to CODA• 9m total iterations, 4.5 m analyzed

Page 6: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

Initial Problems

Page 7: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

Sampler Output/Diagostics

Page 8: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

Sampler Output/Diagnostics

Page 9: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

Sampler Output/Diagnostics

Page 10: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

Sampler Output/Diagnostics

Page 11: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

Sampler Output/Diagnostics

Page 12: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

WinBUGS Model

Y[i,j]’s given binomial (instead of Bernoulli) likelihood

Betas regressed on logit of proportion

Locally uniform priors on beta1 and beta2

Page 13: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

WinBUGS Model

model{for (i in 1:N){ r[i] ~ dbin(p[i], n[i]); logit(p[i]) <- (beta1 + beta2*(x[i] - mean(x[]))); r.hat[i] <- (p[i] * n[i]); }beta1 ~ dflat();beta2 ~ dflat();beta1nocenter <- beta1 - beta2*mean(x[]);}

Page 14: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

WinBUGS Output: Beta0 (1,0)

Page 15: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

WinBUGS Output: Beta0 (1,1)

Page 16: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

WinBUGS Output: Beta0 (1,-2)

Page 17: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

Comparison

Page 18: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

WinBUGS Wins

Uses proportions instead of Individual Y[i,j]’s

Convergence is Better WinBUGS appears more precise

(more trials needed) Also, much faster.

Page 19: Kyle Bogdan Grant Brown.  Simulated based on known values of parameters (one covariate, ‘dose’).  ‘rats’ given different dosages of imaginary chemical,

Resources

Groenewald, Pieter C.N., and Lucky Mokgatlhe. "Bayesian computation for logistic regression.“ Computational Statistics & Data Analysis 48 (2005): 857-68. Science Direct. Elsevier. Web. <http://www.sciencedirect.com/>.

Professor Cowles