Thank you very much! It helps a lot. You are right about the NA´s in the coefficients, the model needs some simplification.
Thank you again. ------------------------------------------------------------------------------------------------------------------------------- Pablo Pita Orduna Grupo de Recursos Marinos y Pesquerías. Universidade de A Coruña. Campus da Zapateira s/n. E-15071. A Coruña, Spain. Tel. +34(981) 167000 ext. 2204 Fax. +34(981) 167065. www.fismare.net/verdeprofundo www.recursosmarinos.net ----- Original Message ----- From: joris meys To: Pablo Pita Orduna Cc: r-help@r-project.org ; jfre...@udc.es ; ppitaord...@gmail.com Sent: Saturday, March 07, 2009 12:28 AM Subject: Re: [R] Interpreting GLM coefficients One thing I notice immediately is a number of NA values for your coefficients. If I were you, I would try a model with less parameters, and use the anova() function to compare models, to see if the extra terms really improve the model. e.g. fit1 <- glm(Y~X1+X2+X3,...) fit2 <- glm(Y~X1+X2+X3+X1:X2,...) anova(fit1, fit2, test="F") If you checked all these, understanding the interaction terms will be most easy if you normalized your numeric data before the analysis. For the interpretations, you just fill in some values to get an idea. For example : given the model : Y= a+b1*X1+b2*X2+b3*X1*X2 Say X1 and X2 are numeric : interpretation of the main term : "Y increases with b2 for an increase of 1 unit in X2, given X1 is average". interpretation of the interaction term : "For an X1 value of n units from the mean, X2 increases with b2+n*b3" (n is negative when value is lower than the mean). In a Y ~ X2 plot, you can make this visible by plotting 3 different functions : one for a low X1 value, one for an average X1 value and one for a high X1 value. This gives you an indication of the effect of X1 on X2. for an interaction between a categorical terms or a categorical and a numerical, you follow exact the same reasoning, but keep in mind that the reference level represents a 0, and the mentioned level represents a 1. Fill in the values in the equation, and you can understand the meaning of the terms. Then again, you can plot a seperate function Y~X1 for every level of a certain factor. This isn't a straight answer on your question, but I'm afraid there is none. I hope this helps you with building your model. Kind regards. Joris On Fri, Mar 6, 2009 at 11:04 PM, Pablo Pita Orduna <pp...@udc.es> wrote: Hi all, I´m fitting GLM´s and I can´t interprete the coefficients when I run a model with interaction terms. When I run the simpliest model there is no problem: Model1<-glm (Fishes ~ Year + I(Year^2) + Kind.Geographic + Kind.Fishers + Zone.2 + Hours + Fishers + Month, family = poisson(log)) # Fishes, Year, Hours, and Fishers are numeric, Kind.Geographic, Kind.Fishers, Zone.2 and Month are factors with 4, 3, 5 and 12 levels respectively. Model1$coefficients (whith Helmert contrasts): (Intercept) Year IYear^2 Kind.Geographic1 Kind.Geographic2 Kind.Geographic3 Kind.Fishers1 Kind.Fishers2 Zone.21 Zone.22 Zone.23 Zone.24 -4.416915e+02 4.758455e-01 -1.270986e-04 -5.436199e-01 -1.068809e-01 -1.498580e-01 2.958462e-01 1.316589e-01 -1.328204e-01 -1.605802e-01 5.281869e-03 7.422885e-02 Hours Fishers Month1 Month2 Month3 Month4 Month5 Month6 Month7 Month8 Month9 Month10 9.772076e-02 -2.709955e-03 -1.586887e-01 -1.887837e-02 -5.183241e-03 5.870942e-02 7.075386e-02 2.061223e-02 7.372268e-03 -1.204835e-02 -5.047994e-03 2.441498e-02 Month11 -5.665261e-03 So I can write, for example: y = -4.416915e+02 + -1.270986e-04*x^2 + 4.758455e-01*x # And add this function to a plot(Year,Fishes). My problem is to understand the coefficients for the model with interaction: Model2<-glm(Fishes ~ Year + I(Year^2) + Kind.Geographic + Kind.Fishers + Zone.2 + Hours + Fishers + Month + Year:Kind.Geographic + Year:Kind.Fishers + Year:Zone.2 + Year:Hours + Year:Fishers + Year:Month + Kind.Geographic:Hours + Kind.Fishers:Hours + Zone.2:Hours + Hours:Fishers + Hours:Month +Kind.Geographic:Fishers + Zone.2:Fishers + Fishers:Month , poisson (log)) Model2$coefficients (with Helmert contrast): (Intercept) Year I(Year^2) Kind.Geographic1 Kind.Geographic2 Kind.Geographic3 Kind.Fishers1 Kind.Fishers2 1.641473e+03 -1.748703e+00 4.664752e-04 -6.721427e+00 1.856033e+01 -3.762727e-02 2.903564e+01 9.022858e+01 Zone.21 Zone.22 Zone.23 Zone.24 Hours Fishers Month1 Month2 8.110814e-02 -1.902803e+01 8.335792e+00 -3.661641e+00 -7.824623e+00 7.088065e-01 2.479387e+03 8.346729e+02 Month3 Month4 Month5 Month6 Month7 Month8 Month9 Month10 4.052680e+02 2.384440e+02 1.570644e+02 1.032445e+02 7.930499e+01 6.487925e+01 5.592869e+01 3.888328e+01 Month11 Year:Kind.Geographic1 Year:Kind.Geographic2 Year:Kind.Geographic3 Year:Kind.Fishers1 Year:Kind.Fishers2 Year:Zone.21 Year:Zone.22 4.801656e+01 3.397984e-03 -9.443234e-03 NA -1.449305e-02 -4.470212e-02 -6.269309e-05 9.421045e-03 Year:Zone.23 Year:Zone.24 Year:Hours Year:Fishers Year:Month1 Year:Month2 Year:Month3 Year:Month4 -4.184866e-03 1.854810e-03 3.257250e-03 -4.103058e-04 -1.264934e+00 -4.255907e-01 -2.069909e-01 -1.216459e-01 Year:Month5 Year:Month6 Year:Month7 Year:Month8 Year:Month9 Year:Month10 Year:Month11 Kind.Geographic1:Hours -8.015823e-02 -5.278291e-02 -4.054404e-02 -3.313487e-02 -2.846036e-02 -1.973118e-02 -2.410902e-02 1.341231e-01 Kind.Geographic2:Hours Kind.Geographic3:Hours Kind.Fishers1:Hours Kind.Fishers2:Hours Zone.21:Hours Zone.22:Hours Zone.23:Hours Zone.24:Hours 5.806418e-02 NA 1.318444e-02 -1.234521e-01 7.961319e-04 1.622411e-02 -5.357266e-04 7.749412e-03 Hours:Fishers Hours:Month1 Hours:Month2 Hours:Month3 Hours:Month4 Hours:Month5 Hours:Month6 Hours:Month7 -6.805803e-03 7.971549e+00 2.627090e+00 1.403430e+00 7.747360e-01 5.163810e-01 3.732549e-01 2.827511e-01 Hours:Month8 Hours:Month9 Hours:Month10 Hours:Month11 Kind.Geographic1:Fishers Kind.Geographic2:Fishers Kind.Geographic3:Fishers Zone.21:Fishers 2.091230e-01 1.057001e-01 1.159929e-01 NA -3.422994e-02 -3.421851e-03 NA -3.802354e-03 Zone.22:Fishers Zone.23:Fishers Zone.24:Fishers Fishers:Month1 Fishers:Month2 Fishers:Month3 Fishers:Month4 Fishers:Month5 1.618358e-05 4.197350e-04 -8.773088e-05 7.806815e-01 2.509529e-01 1.280752e-01 7.520139e-02 5.370220e-02 Fishers:Month6 Fishers:Month7 Fishers:Month8 Fishers:Month9 Fishers:Month10 Fishers:Month11 3.786759e-02 2.936135e-02 2.381810e-02 2.422438e-02 NA NA I would like to know if it is possible to extract the intercepts and the slopes for Year and Year^2 for this Model2. Thank you very much for your help. ________________________________________________________________________________ Pablo Pita Orduna Grupo de Recursos Marinos y Pesquerías. Universidade de A Coruña. Campus da Zapateira s/n. E-15071. A Coruña, Spain. Tel. +34(981) 167000 ext. 2204 Fax. +34(981) 167065. www.fismare.net/verdeprofundo ---------------------------------------------------------------- Correo enviado usando el servicio de Webmail de la UDC. ______________________________________________ R-help@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. [[alternative HTML version deleted]]
______________________________________________ R-help@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.