Questions tagged [glm]

For questions relating to generalized linear models. For the GLM math library, see the [glm-math] tag.

Generalized linear models are a class that encompasses a variety of standard statistical models, including ordinary least squares (a.k.a. linear models, OLS) regression, probit, logistic regression, Poisson regression, and other methods that can be expressed in the standard GLM form.

Consider whether your question is better suited to Cross Validated, the Stack Exchange site for statistics and machine learning. Questions on Stack Overflow should be about programming issues arising from fitting models to data.

In scientific software for statistical computing and graphics, a GLM can be estimated by the function glm.

2019 questions
0
votes
1 answer

How to get “95%CI for a Binomial Proportion” using glm in R

I refer to the site Interval Estimation for a Binomial Proportion Using glm in R, getting the ”asymptotic” 95%CI. I think binomial link doesn’t have “identity”, but the following program got the answer. Why? If you know that, please give me some…
51sep
  • 479
  • 1
  • 4
  • 10
0
votes
0 answers

Negative binomial regression effects on mean and dispersion parameter

My dependent variable is over-dispersed. Therefore, I want to apply a generalized negative binomial regression on my data. In addition, I want to examine the effects of the indicators on the mean and dispersion parameter, like in these two…
Nils_Denter
  • 488
  • 1
  • 6
  • 18
0
votes
0 answers

regression line and confidence interval in R: GLMM with several fixed effects

Somehow as a follow up on the question Creating confidence intervals for regression curve in GLMM using Bootstrapping, I am interested in getting the correct values of a regression curve and the associated confidence interval curves. Consider a case…
yenats
  • 531
  • 1
  • 3
  • 16
0
votes
1 answer

Plot a GLM, R squared and p-value in R base plot

I have data on the monthly number of people varying with a variable (a count) over a period of 30 years, 1987-2018. I have divided this period in three shorter periods to check whether the correlation is approximately the same then and now, fitting…
Dag
  • 569
  • 2
  • 5
  • 20
0
votes
0 answers

Odd's Ratio Plot Produced by the plot_model() function in the sjPlot package is too large for the plotting window in R

Problem: I have produced an odds ratio plot (below) from the data frame called FID (below) using the plot_model() function in the sjPlot package, but the figure is too large for the plotting window. I have two models involving: (1) FID_Model_1 (see…
Alice Hobbs
  • 1,021
  • 1
  • 15
  • 31
0
votes
0 answers

How to correct zero cell counts for odds ratio calculations when variable has >2 categories

I am using R to calculate odds ratios for several univariate models with a binomial outcome. The problem is, for some of my variables, I am getting the following error glm.fit: fitted probabilities numerically 0 or 1 occurred. I have found that…
Jenny
  • 59
  • 4
0
votes
0 answers

Issues with likelihood computation from grouped binomial glm using cbind

Is there an issue with the likelihood computation of the binomial model fit with glm when using cbind or am I missing something. See below for reproducible example: set.seed(123) n <- 100 sze <- 5 x <- rnorm(n, 0, 1) p <- binomial()$linkinv(x) y <-…
user2506086
  • 503
  • 2
  • 10
0
votes
1 answer

Predict error for GLMs in R with number of rows

I am trying to get a prediction curve for a logistic glm in R. I create a new data frame but do not understand why I keep getting this error. Thank you for your help! glm1 <- glm(dataset_presence$presence ~ dataset_presence$Int_Bk, data =…
0
votes
0 answers

Nested models with mutate and formula

I am trying to run multiple models on nested datafraames. The formula is running as null and the models don't seem to be working. When I test it individually it works fine. Any thoughts? library(tidyverse) library(MASS) df<-mtcars getmodelaic <-…
Stat.Enthus
  • 335
  • 1
  • 12
0
votes
1 answer

Plotting prediction from averaged GLM model: Error in eval(predvars, data, env) : object 'x3' not found

I have produced an averaged GLM model (to find the habitat preference of a species), and I want to graph the shape of the relationship for each of the most important variables, “x1” and “x3” (understorey cover and canopy cover), against my response…
hm777
  • 3
  • 1
0
votes
1 answer

How does fixest handle negative values of the demeaned dependent variable in poisson estimations?

I need to perform glm (poisson) estimations with fixed-effects (say merely unit FE) and several regressors (RHS variables). I have an unbalanced panel dataset where most (~90%) observations have missing values (NA) for some but not all…
0
votes
0 answers

Poisson GLM: formula representation of the interaction

I have a question about Poisson GLM and formula representation: Considering a data set: p <- read.csv("https://raw.githubusercontent.com/Leprechault/PEN-533/master/bradysia-greenhouse.csv") Without considering the interaction: m1 <-…
Isabel
  • 323
  • 1
  • 11
0
votes
1 answer

Estimating the average marginal effect of binary and continuous coefficients in logit model R

Using data from the National Health Interview Survey, I am hoping to analyze the average marginal effect a variety of demographic factors have on the predicted probability of having hypertension using a logistic regression. To clarify, by average…
juliah0494
  • 175
  • 11
0
votes
0 answers

GLMs in R - large data sets/complex model formulae

I use R to fit a lot of GLMs on medium-large data sets. Typically 500k-1M rows and up to 50 factors in my models (prior to simplification - banding or dropping factors that aren't predictive, etc. Base R's glm() doesn't seem to cope well with this…
Alan
  • 619
  • 6
  • 19
0
votes
2 answers

R - passing object to function based on the NAME of the object

Suppose in R I have multiple GLM objects from multiple glm() function calls. glm_01 glm_02 ... glm_nn ...and suppose that I want to do all possible pairwise comparisons using a chi-squared or F ANOVA test. anova(glm_01, glm_02, test =…
Alan
  • 619
  • 6
  • 19