I'm using R to run some generalized linear models (GLM) and I want to interpret the estimates.  If I use a GLM assuming Gaussian distribution with identity link, interpretation is easy: if the estimate for factor $x$ is $y$ then an increase of 1 of factor $x$ (if all other factors remain constant) will be estimated to result in a change in the response variable by $y$ units.  Now, if I run a GLM assuming Poisson distribution with log link, in the example above, will the response variable be expected to change by $y$ units, or by $\exp(y)$ units?  note: I'm getting the estimates from summary(model object)
119289
How can I interpret the main effects (coefficients for dummy-coded factor) in a Poisson regression?  Assume the following example:  treatment     &lt;- factor(rep(c(1, 2), c(43, 41)),                          levels = c(1, 2),                         labels = c("placebo", "treated")) improved      &lt;- factor(rep(c(1, 2, 3, 1, 2, 3), c(29, 7, 7, 13, 7, 21)),                         levels = c(1, 2, 3),                         labels = c("none", "some", "marked"))     numberofdrugs &lt;- rpois(84, 10) + 1     healthvalue   &lt;- rpois(84, 5)    y             &lt;- data.frame(healthvalue, numberofdrugs, treatment, improved) test          &lt;- glm(healthvalue~numberofdrugs+treatment+improved, y, family=poisson) summary(test)   The output is:  Coefficients:                  Estimate Std. Error z value Pr(&gt;|z|)     (Intercept)       1.88955    0.19243   9.819   &lt;2e-16 *** numberofdrugs    -0.02303    0.01624  -1.418    0.156     treatmenttreated -0.01271    0.10861  -0.117    0.907   MAIN EFFECT   improvedsome     -0.13541    0.14674  -0.923    0.356   MAIN EFFECT  improvedmarke    -0.10839    0.12212  -0.888    0.375   MAIN EFFECT  --- Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1    I know that the incident rate for numberofdrugs is exp(-0.023)=0.977. But how do I interpret the main effects for the dummy variables?
119147
I am fitting a binomial family glm in R, and I have a whole troupe of explanatory variables, and I need to find the best (R-squared as a measure is fine). Short of writing a script to loop through random different combinations of the explanatory variables and then recording which performs the best, I really don't know what to do. And the leaps function from package  does not seem to do logistic regression.  Any help or suggestions would be greatly appreciated.
605
If a factor variable (e.g. gender with levels M and F) is used in the glm formula, dummy variable(s) are created, and can be found in the glm model summary along with their associated coefficients (e.g. genderM)  If, instead of relying on R to split up the factor in this way, the factor is encoded in a series of numeric 0/1 variables (e.g. genderM (1 for M, 0 for F), genderF (1 for F, 0 for M) and these variables are then used as numeric variables in the glm formula, would the coefficient result be any different?  Basically the question is: does R use a different coefficient calculation when working with factor variables versus numeric variables?  Follow-up question (possibly answered by the above): besides just the efficiency of letting R create dummy variables, is there any problem with re-coding factors as a series of numeric 0,1 variables and using those in the model instead?
94302
I'm performing a GLM, the response variable is number of individuals, and response variables are    habitat (4 levels) and  season (4 levels).    I need some help since I know the summary() shows p-values but not for the first (alphabetical) level of factor. I mean, I don't know how to interpret that the Intercept has a significant p-value. I can't reach a biological explanation for this model. Hope you can help me ...  Call: glm(formula = individuals ~ habitat + season, family = poisson(link = "log"),  data = data)  Deviance Residuals:   Min        1Q    Median        3Q       Max   -2.85859  -0.51541  -0.08508   0.36497   2.29058    Coefficients:                  Estimate Std. Error z value Pr(&gt;|z|)     (Intercept)            1.6774     0.1624  10.331  &lt; 2e-16 *** habitatDeciduous       0.1340     0.1696   0.790  0.42950     habitatSemiDeciduous   0.2102     0.1675   1.255  0.20933     habitatWetland        -0.1861     0.2039  -0.912  0.36151     seasondry2018         -0.1138     0.1510  -0.753  0.45123     seasonwet2016         -0.2699     0.1576  -1.713  0.08677 .   seasonwet2017         -0.4383     0.1656  -2.647  0.00813 **   Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1  (Dispersion parameter for poisson family taken to be 1)  Null deviance: 78.487  on 63  degrees of freedom Residual deviance: 64.556  on 57  degrees of freedom AIC: 287.77
101995
I'm doing a statistical analysis of a model for college. It's modelling a bear catching fish and I'm asking will the amount of time taken to digest the fish have an effect on the amount of fish caught? (stupid question I know!) So the predictor variable is the amount of fish the bear can eat before it needs to digest and the response variable is the amount of fish it catches. The predictors varies between 1 and 30 in integers and the response is also in integers. I repeated each level of the predictor 5 times creating a sample size of 150 altogether. I was thinking of just using a simple correlation test such as cor.test in R, but I've read online that this is for continuous data. Does that matter or would this test still be appropriate? Thanks a million, Eamon
108266
Suppose we have a response Y and predictors X1,....,Xn. If we were to try to fit Y via a linear model of X1,....,Xn, and it just so happened that the true relationship between Y and X1,...,Xn wasn't linear, we might be able to fix the model by transforming the X's somehow and then fitting the model. Moreover, if it just so happened that the X1,...,XN didn't affect y independent of the other features, we also might be able to improve the model by including interaction terms, x1*x3 or x1*x4*x7 or something of the like. So in the linear case, interaction terms might bring value by fixing non-linearity or independence violations between the response and the features.  However, Random Forests don't really make these assumptions. Is including interaction terms important when fitting a Random Forest? Or will just including the individual terms and choosing appropriate parameters allow Random Forests to capture these relationships?
83116
I have run the following logistic regression:  glm(formula = DecisionasReceiver ~ L1 + L2 + L3,    family = binomial("logit"), data = lue)   where L1 L2 and L3 code for differences in condition of no.GREEN. L1: 1,-1,0,0 : is there a difference in DecisionasReceiver as no.GREEN changes from 1 to 2?  L2: 0,1,-1,0: is there a difference in DecisionasReceiver as no.GREEN changes from 2 to 3?  L2: 0,0,1,-1: is there a difference in DecisionasReceiver as no.GREEN changes from 3 to 4?  And I'm running this regression both for the cases where MessageReceived is BLUE and for MessageReceived RED.   I have the following output:     Coefficients:       Estimate Std. Error z value Pr(&gt;|z|)     (Intercept)  -0.9535     0.3659  -2.606  0.00916 **  L1            2.2753     0.5406   4.209 2.56e-05 *** L2            3.1234     0.7318   4.268 1.97e-05 *** L3            1.9369     0.8134   2.381  0.01726 *     Looking at my graph it seems strange that the coefficients are positive and that the intercept is -0.953. How exactly should I interpret these results in the light of the graph?
16111
I am always struggling with normality testing for quantitative predictors (no factors) and transforming them to normality.    If I am running a GLMM and my predictors are really non-normal, should I  transform them as well to try to make them normally distributed?  I know that this is important for the response variable but what should be done with predictors?   P.S.: I really could not find a similar question.
12261
As explained in , a linear model can be written in the form:  $$ y = \beta_1 x_{1} + \cdots + \beta_p x_{p} + \varepsilon_i,$$  where $y$ is the response variable and  $x_{i}$ is the $i^{th}$ explanatory variable.  Often with the goal of meeting test assumptions, one can transform the response variable. For example we apply the log function on each $y_i$. Transforming a response variable does NOT equate to doing a GLM.  A GLM can be written in the following form (from the )  $$ g(u) = \beta_1 x_{1} + \cdots + \beta_p x_{p} + \varepsilon_i,$$  where $u$ is just another symbol for $y$ as I understand from page 2 in the course handout. $g()$ is called the link function.  I don't really understand the difference between a GLM and LM with transformed variable from the slides in the course. Can you help me with that?
29900
Specifically, I want to know if there is a difference between lm(y ~ x1 + x2) and glm(y ~ x1 + x2, family=gaussian). I think that this particular case of glm is equal to lm. Am I wrong?
103379
I am running glmnet for the first time and I am getting some weird results.   My dataset has n = 139; p = 70 (correlated variables)  I am trying to estimate the effect of each variable for both, inference and prediction. I am running:  &gt; cvfit = cv.glmnet(X, Y,family = c('gaussian'),alpha = 0.5,intercept = T,standardize = T,nlambda=100,type = "mse")  &gt; coef(cvfit, s = "lambda.min")   From all the 70 estimates, two caught my attention:  4           0.5731999  14          5.419356829   What bugs me is the fact that:  &gt; cor(X[,4],Y)  [1,] 0.674714  &gt; cor(X[,14],Y)  [1,] -0.01742419   In addition, if I standardize X myself (using scale(X)) and run it again:  &gt; cvfit = cv.glmnet(scale(X), Y,family = c('gaussian'),alpha = 0.5,intercept = T,standardize = F,nlambda=100,type = "mse")  &gt; coef(cvfit, s = "lambda.min")   I now get that 4 has the highest effect and variable "14" is about 5 times smaller. I couldn't find a good description about the normalization process in glmnet. Any clue as to why this is happening (I don't think its a bug, I just would like to understand why and which one is right)?  PS: I ran this many times, so I know it is not an effect of the sampling during the cross-validation.
72747
What is it mean by the statement  "X and Y explained a greater proportion of variance in Z than X alone "  More generally, what is it meant when the model "explains more variation" in the dependent variable  -- certainly this is not equivalent to "this explains the variable" more?  Thank you for the insight into this basic question.
102727
Could someone advise me on how to interpret the estimates from a logistic regression using a cloglog link?  I have fitted the following model in lme4:  glm(cbind(dead, live) ~ time + factor(temp) * biomass,     data=mussel, family=binomial(link=cloglog))   For example, the estimate of time is 0.015.  Is it correct to say the odds of mortality per unit time is multiplied by exp(0.015) = 1.015113 (~1.5% increase per unit time). In other words are the estimates obtained in a cloglog expressed in log odds as is the case for a logit logistic regression?
104901
I have the following result from running glm function.   How can I interpret the following values:   Null deviance Residual deviance AIC   Do they have something to do with the goodness of fit? Can I calculate some goodness of fit measure from these result such as R-square or any other measure?  Call: glm(formula = tmpData$Y ~ tmpData$X1 + tmpData$X2 + tmpData$X3 +      as.numeric(tmpData$X4) + tmpData$X5 + tmpData$X6 + tmpData$X7)  Deviance Residuals:       Min        1Q    Median        3Q       Max   -0.52628  -0.24781  -0.02916   0.25581   0.48509    Coefficients:                      Estimate Std. Error  t value Pr(&gt;|t|)     (Intercept         -1.305e-01  1.391e-01   -0.938   0.3482     tmpData$X1         -9.999e-01  1.059e-03 -944.580   &lt;2e-16 *** tmpData$X2         -1.001e+00  1.104e-03 -906.787   &lt;2e-16 *** tmpData$X3         -5.500e-03  3.220e-03   -1.708   0.0877 .   tmpData$X4         -1.825e-05  2.716e-05   -0.672   0.5017     tmpData$X5          1.000e+00  5.904e-03  169.423   &lt;2e-16 *** tmpData$X6          1.002e+00  1.452e-03  690.211   &lt;2e-16 *** tmpData$X7          6.128e-04  3.035e-04    2.019   0.0436 *   --- Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1   (Dispersion parameter for gaussian family taken to be 0.08496843)      Null deviance: 109217.71  on 3006  degrees of freedom Residual deviance:    254.82  on 2999  degrees of freedom   (4970 observations deleted due to missingness) AIC: 1129.8  Number of Fisher Scoring iterations: 2
100505
I have a dataset in which the response variable is non normal, but on log transforming, it follows the normal distribution. I constructed a mixed effect model using lme4::lmer() as below (multiple measurements within each region), where A is a continuous variable and there are 7 regions  model&lt;-lmer(log(response)~A + (1|Region), data, REML=FALSE)   My output is   Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's method ['lmerModLmerTest'] Formula: logresponse ~ A + (1 | Region) Data: df[, -c(6)]   AIC      BIC   logLik deviance df.resid  151.8    159.8    -71.9    143.8       51   Scaled residuals:   Min       1Q   Median       3Q      Max  -2.24856 -0.63631  0.02206  0.59999  1.94895   Random effects: Groups   Name        Variance Std.Dev. Region   (Intercept) 0.8611   0.9280   Residual             0.5814   0.7625   Number of obs: 55, groups:  Region, 7  Fixed effects:               Estimate Std. Error        df t value Pr(&gt;|t|)   (Intercept) -1.112047   0.747373 19.651457  -1.488   0.1526    A           0.008585   0.004250 29.157266   2.020   0.0526 .  Correlation of Fixed Effects: (Intr) A -0.871   1) Would I infer that for A effects the response variable and the response increases by exp(0.008585) +/- exp(0.004250) (std error)? Would that be the right interpretation?  2) exp(Intercept) is not equal to the mean(log response). They are close but not equal. Why are they not equal and should I be concerned?   I know that this is a hard question to answer without knowing the dataset. So please suggest how I can improve the question.
6777
I've read that it's bad to do this, but am looking for details as to why.  Suppose we're trying to fit the linear model $Y_i = \beta_0 + \beta_1 X_{1i} + \beta_2 X_{2i} + \epsilon_i$ where $Y$ is continuous and $X$s are categorical with many levels. We don't have any opinion on how the levels should be grouped. We then calculate the average response for each level of the predictors, then collapse levels with similar averages.  How badly does this screw up parameter estimates and inferences on them, and why?
719
I have made a generalised linear model with a single response variable (continuous/normally distributed) and 4 explanatory variables (3 of which are factors and the fourth is an integer). I have used a Gaussian error distribution with an identity link function. I am currently checking that the model satisfies the assumptions of the generalised linear model, which are:   independence of Y correct link function correct scale of measurement of explanatory variables no influential observations   My question is: how can I check that the model satisfies these assumptions? The best starting point would seem to be plotting the response variable against each explanatory variable. However, 3 of the explanatory variables are categorical (with 1-4 levels), so what should I be looking for in the plots?  Also, do I need to check for multicollinearity and interactions amongst explanatory variables? If yes, how do I do this with categorical explanatory variables?