I am fairly new to log-linear modelling, so as opposed to trying to fit modells, I am still trying to figure out how it actually works - hence I am looking at the interpretation of parameters. Now it seems most people skip this part and go directly to measuring model fit, so I am finding very few references to actual parameters, and am of course clear on the fact that their choice is irelevant for the actual model fit. But here is my question: loglin uses deviation contrasts, so the coefficients in each term add up to zero. Another option are indicator contrasts, where a reference category is chosen in each term and set to zero, while the others are relative to it. My question is if there is a log-linear command equivalent to loglin that uses this secong "dummy coding" style of constraints (I know e.g. spss genlog does this). I hope this is not to basic a question! And if anyone is up for answeing the wider question of why log-linear parameters are not something to be looked at - which might just be my impression of the literature - feel free to comment! Thanks for your help! Maja edit: this might just be me using the wrong terminology! if idicator and deviation contrasts come by a different name, I would love to know it! tnx -- View this message in context: http://www.nabble.com/indicator-or-deviation-contrasts-in-log-linear-modelling-tp22090104p22090104.html Sent from the R help mailing list archive at Nabble.com.
Charles C. Berry
2009-Feb-19 02:30 UTC
[R] indicator or deviation contrasts in log-linear modelling
On Wed, 18 Feb 2009, maiya wrote:> > I am fairly new to log-linear modelling, so as opposed to trying to fit > modells, I am still trying to figure out how it actually works - hence I am > looking at the interpretation of parameters. Now it seems most people skip > this part and go directly to measuring model fit, so I am finding very few > references to actual parameters, and am of course clear on the fact that > their choice is irelevant for the actual model fit. > > But here is my question: loglin uses deviation contrasts,Depends on what you mean by 'uses'.>From ?loglinQUOTE: Details The Iterative Proportional Fitting algorithm as presented in Haberman (1972) is used for fitting the model. At most iter iterations are performed, convergence is taken to occur when the maximum deviation between observed and fitted margins is less than eps. All internal computations are done in double precision; there is no limit on the number of factors (the dimension of the table) in the model. END QUOTE There are no explicit contrasts in IPF. The $param component returned when 'param=TRUE' is used is derived from the estimated cell frequencies. You can transform these to other basis vectors. If there are no structural zeros, lm( as.vector( loglin(...,fit=TRUE)$fit ) ~ < your favored contrasts > ) will give you estimates under your favored scheme. Then too there is the surrogate Poisson approach, which will do this too. so the> coefficients in each term add up to zero. > Another option are indicator contrasts, where a reference category is chosen > in each term and set to zero, while the others are relative to it. My > question is if there is a log-linear command equivalent to loglin that uses > this secong "dummy coding" style of constraints (I know e.g. spss genlog > does this).Yep, glm(). See McCullagh P. and Nelder, J. A. (1989) Generalized Linear Models. London: Chapman and Hall. for details on surrogate Poisson modelling.> > I hope this is not to basic a question! > > And if anyone is up for answeing the wider question of why log-linear > parameters are not something to be looked at - which might just be my > impression of the literature - feel free to comment! >I can think of three: 1) IPF doesn't need the parameters to do its work and do tests based on loglinear models. The canonical reference is Bishop, Fienberg, and Holland's Discrete Multivariate Analysis, 1975. 2) In many applications, direct inspection of the cell frequencies or their estimates is quite natural. 3) Often there are higher order effects (a four way table with 3 way interactions, say) , so the lower order parameter values are not easily interpreted anyway. HTH, Chuck> Thanks for your help! > > Maja > -- > View this message in context: http://www.nabble.com/indicator-or-deviation-contrasts-in-log-linear-modelling-tp22090104p22090104.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry at tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
Michael Friendly
2009-Feb-19 13:30 UTC
[R] indicator or deviation contrasts in log-linear modelling
Maja, The need to interpret parameters in log-linear models (and therefore, the need to understand how the model is parameterized) often vanishes if you visualize the fitted model or the residuals in a mosaic display. e.g., ucb1 asserts Admit is jointly independent of Gender and Dept --- fits very badly, but the residuals show the *nature* of the association not accounted for. ucb2 - Admit and Gender conditionally independent, given Dept --- fits badly overall, but only in one department. > library(vcd) > ucb1 <- loglm(~Admit + Gender*Dept, data=UCBAdmissions) > ucb1 Call: loglm(formula = ~Admit + Gender * Dept, data = UCBAdmissions) Statistics: X^2 df P(> X^2) Likelihood Ratio 877 11 0 Pearson 798 11 0 > plot(ucb1) > ucb2 <- loglm(~Admit*Dept + Gender*Dept, data=UCBAdmissions) > ucb2 Call: loglm(formula = ~Admit * Dept + Gender * Dept, data = UCBAdmissions) Statistics: X^2 df P(> X^2) Likelihood Ratio 22 6 0.0014 Pearson 20 6 0.0028 > plot(ucb2) maiya wrote:> I am fairly new to log-linear modelling, so as opposed to trying to fit > modells, I am still trying to figure out how it actually works - hence I am > looking at the interpretation of parameters. Now it seems most people skip > this part and go directly to measuring model fit, so I am finding very few > references to actual parameters, and am of course clear on the fact that > their choice is irelevant for the actual model fit. > > But here is my question: loglin uses deviation contrasts, so the > coefficients in each term add up to zero. > Another option are indicator contrasts, where a reference category is chosen > in each term and set to zero, while the others are relative to it. My > question is if there is a log-linear command equivalent to loglin that uses > this secong "dummy coding" style of constraints (I know e.g. spss genlog > does this). > > I hope this is not to basic a question! > > And if anyone is up for answeing the wider question of why log-linear > parameters are not something to be looked at - which might just be my > impression of the literature - feel free to comment! > > Thanks for your help! > > Maja-- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Street http://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA