Download presentation

Presentation is loading. Please wait.

Published byMartin Ridler Modified about 1 year ago

1
Data: Crab mating patterns Data: Typists (Poisson with random effects) (Poisson Regression, ZIP model, Negative Binomial) Data: Challenger (Binomial with random effects) Flu Data: (Binomial with random effects)

2
D.A.D. Mixed (not generalized) Models: Fixed Effects and Random Effects

3 SAS Global Forum 2010 D.A.D. “Generalized” non normal distribution Binary for probabilities: Y=0 or 1 Mean p Pr{Y=j}= p j (1-p) (1-j) Link: L=ln(p/(1-p)) = “Logit” Range (over all L): 0

0

4
SAS Global Forum 2010 D.A.D. Generalized (not mixed) linear models. Use link L = g(E{Y}), e.g. ln(p/(1-p)) = ln(E{Y}/(1-E{Y}) Assume L is linear model in the inputs with fixed effects. Estimate model for L, e.g. L=g(E{Y})= o X Use maximum likelihood Example: L = *dose Dose = 10, L=0.8, p=exp(0.8)/(1+exp(0.8))= inverse link = 0.86

5

6
SAS Global Forum 2010 D.A.D. Challenger was mission 24 From 23 previous launches we have: 6 O-rings per mission Y=0 no damage, Y=1 erosion or blowby p = Pr {Y=1} = f{mission, launch temperature) Features: Random mission effects Logistic link for p proc glimmix data=O_ring; class mission; model fail = temp/dist=binomial s; random mission; run; Generalized Mixed

7
DemoO_rings.sas

8
SAS Global Forum 2010 D.A.D. Estimated G matrix is not positive definite. Covariance Parameter Estimates Cov Standard Parm Estimate Error mission 2.25E-18. Solutions for Fixed Effects Effect Estimate Error DF t Value Pr > |t| Intercept temp

9
Just logistic regression – no mission variance component

10
SAS Global Forum 2010 D.A.D. Flu Data CDC Active Flu Virus Weekly Data % positive data FLU; input fluseasn year t week pos specimens; pct_pos=100*pos/specimens; logit=log(pct_pos/100/(1+(pct_pos/100))); label pos = "# positive specimens"; label pct_pos="% positive specimens"; label t = "Week into flu season (first = week 40)"; label week = "Actual week of year"; label fluseasn = "Year flu season started"; logit pct. pos.

11
DemoGet_Flu.sas

12
“Sinusoids” S(j) = sin(2 jt/52) C(j)=cos(2 jt/52) (1) GLM all effects fixed (harmonic main effects insignificant) PROC GLM DATA=FLU; class fluseasn; model logit = s1 c1 fluseasn*s1 fluseasn*c1 fluseasn*s2 fluseasn*c2 fluseasn*s3 fluseasn*c3 fluseasn*s4 fluseasn*c4; output out=out1 p=p; data out1; set out1; P_hat = exp(p)/(1+exp(p)); label P_hat = "Pr{pos. sample} (est.)"; run; Logit scale

13
DemoFlu_GLM.sas

14
(2) MIXED analysis on logits Random harmonics. Normality assumed PROC MIXED DATA=FLU method=ml; ** reduced model; class fluseasn; model logit = s1 c1 /outp=outp outpm=outpm ddfm=kr; random intercept/subject=fluseasn; random s1 c1/subject=fluseasn type=toep(1); random s2 c2/subject=fluseasn type=toep(1); random s3 c3/subject=fluseasn type=toep(1); random s4 c4/subject=fluseasn type=toep(1); run; Logit scale Probability scale

15
DemoFlu_MIXED.sas

16
(3) GLIMMIX analysis Random harmonics. Binomial assumed (overdispersed – lab effects?) PROC GLIMMIX DATA=FLU; title2 "GLIMMIX Analysis"; class fluseasn; model pos/specimens = s1 c1 ; * s2 c2 s3 c3 s4 c4; random intercept/subject=fluseasn; random s1 c1/subject=fluseasn type=toep(1); random s2 c2/subject=fluseasn; ** Toep(1) - no converge; random s3 c3/subject=fluseasn type=toep(1); random s4 c4/subject=fluseasn type=toep(1); random _residual_; output out=out2 pred(ilink blup)=pblup pred(ilink noblup) overallpearson = p_resid; run; Mean – no BLUPs

17
DemoFlu_GLIMMIX.sas

18
SAS Global Forum 2010 D.A.D. Flu data Binomial random _residual_ does not affect the fit (just standard errors) Could try Beta distribution instead: PROC GLIMMIX DATA=FLU; title2 "GLIMMIX Analysis"; class fluseasn; model f = s1 c1 /dist=beta link=logit s; random intercept/subject=fluseasn; random s1 c1/subject=fluseasn type=toep(1); random s2 c2/subject=fluseasn type=toep(1); random s3 c3/subject=fluseasn type=toep(1); random s4 c4/subject=fluseasn type=toep(1); output out=out3 pred(ilink blup)=pblup pred(ilink noblup)=overall pearson=p_residbeta; run;

19

20

21
SAS Global Forum 2010 D.A.D. Horseshoe Crab study (reference: SAS GLIMMIX course notes): Female nests have “satellite” males Count data – Poisson? Generalized Linear Features (predictors): Carapace Width, Weight, Color, Spine condition Random Effect: Site Mixed Model

22
DemoGet_Horseshoe.sas

23
Histogram # Boxplot 15.5+* 1 0.* * 1 |.* 1 |.** 3 | 9.5+** 3 |.*** 6 |.** 4 | 6.5+******* 13 |.******** ********** 19 | | 3.5+********** 19 | |.***** 9 *--+--*.******** 16 | | 0.5+******************************* * may represent up to 2 counts proc glimmix data=crab; class site; model satellites = weight width / dist=poi solution ddfm=kr; random int / subject=site; output out=overdisp pearson=pearson; run; proc means data=overdisp n mean var; var pearson; run; proc univariate data=crab normal plot; var satellites; run; N Mean Variance Fit Statistics Gener. Chi-Square / DF 2.77 Cov Parm Subject Estimate Intercept site Effect Estimate Pr > |t| Intercept weight width Zero Inflated ?

24
DemoCrabs_OVERDISP.sas

25
SAS Global Forum 2010 D.A.D. Zero Inflated Poisson (ZIP)

26
SAS Global Forum 2010 D.A.D. Zero Inflated Poisson (ZIP) proc nlmixed data=crab; parms b0=0 bwidth=0 bweight=0 c0=-2 c1=0 s2u1=1 s2u2=1; x=c0+c1*width+u1; p0 = exp(x)/(1+exp(x)); eta= b0+bwidth*width +bweight*weight +u2; lambda=exp(eta); if satellites=0 then loglike = log(p0 +(1-p0)*exp(-lambda)); else loglike = log(1-p0)+satellites*log(lambda)-lambda-lgamma(satellites+1); expected=(1-p0)*lambda; id p0 expected lambda; model satellites~general(loglike); Random U1 U2~N([0,0],[s2u1,0,s2u2]) subject=site; predict p0+(1-p0)*exp(-lambda) out=out1; run;

27
SAS Global Forum 2010 D.A.D. Zero Inflated Poisson (ZIP) Parameter Estimates Parameter Estimate t Pr>|t| Lower Upper b bwidth bweight c c s2u s2u

28
DemoCrabs_ZIP.sas

29
SAS Global Forum 2010 D.A.D. From fixed part of model, compute Pr{count=j} and plot (3D) versus Weight, Carapace width

30

31

32

33

34

35

36

37

38

39
SAS Global Forum 2010 D.A.D. Another possibility: Negative binomial Number of failures until k th success ( p=Prob{success} )

40
SAS Global Forum 2010 D.A.D. Crab beer Crab beer 3 trials before first success Negative Binomial Satellites

41
SAS Global Forum 2010 D.A.D. Negative binomial: In SAS, k is our 1/k proc glimmix data=crab; class site; model satellites = weight width / dist=nb solution ddfm=kr; random int / subject=site; run; Fit Statistics -2 Res Log Pseudo-Likelihood Generalized Chi-Square Gener. Chi-Square / DF 1.03 Covariance Parameter Estimates Cov Parm Subject Estimate Std. Error Intercept site Scale Standard Effect Estimate Error DF t Value Pr > |t| Intercept weight width Num Den Effect DF DF F Value Pr > F weight width

42
DemoCrabs_NEGBIN.sas

43
Population average model vs. Individual Specific Model 8 typists Y=Error counts (Poisson distributed) ln( i )= ln(mean of Poisson) = +U i for typist i. conditionally (individual specific) Distributions for Y, U~N(0,1) and =1 =e =e 1 = = mean for “typical” typist

44
SAS Global Forum 2010 D.A.D. Population average model Expectation ||||| | | of individual distributions averaged across population of all typists. Run same simulation for 8000 typists, compute mean of conditional population means, exp( +U). The MEANS Procedure Variable N Mean Std Dev Std Error ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ lambda ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Z=( )/ = !! Population mean is not e Conditional means, +U, are lognormal. Log(Y)~N(1,1) E{Y}=exp( +0.5 ) = e 1.5 =

45
DemoTypists.sas

46
SAS Global Forum 2010 D.A.D. Main points: 1.Generalized linear models with random effects are subject specific models. 2.Subject specific models have fixed effects that represent an individual with random effects 0 (individual at the random effect distributional means). 3.Subject specific models when averaged over the subjects do not give the model fixed effects. 4.Models with only fixed effects do give the fixed effect part of the model when averaged over subjects and are thus called population average models.

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google