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
0 answers

Error summary(glm) in R: cannot coerce class ‘"summary.glm"’ to a data.frame

I am getting an error running the line summary(glm.object) Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : cannot coerce class ‘"summary.glm"’ to a data.frame For example, the following code gives…
Dan Phillips
  • 132
  • 7
0
votes
1 answer

Adding fit line to multiple ggplot outputs

I'm utilizing the following code to plot each regressor in X_train against the response variable won using a logistic model from glm() require(reshape2) require(ggplot2) regressors = melt(X_train[2:16], id.vars='won') ggplot(regressors) + …
Scoops
  • 61
  • 4
0
votes
0 answers

GLMER ; cannot coerce class ‘"mids"’ to a data.frame

I am studying a dichotomous outcome of an intervention. The data comes from multiple clustered data-sets. All datasets have some missing data. I have imputated the data-sets using MICE. My plan is to use a mixed model, log-binomial distribution to…
WielsN
  • 1
0
votes
0 answers

Warnings using glmer: pwrssUpdate did not converge in (maxit) iterations

I'm testing preference over origin (native/ornamental) and flower colour (6 colours) in pollinators. To do so, I'm using a GLMM since data doesn't follow a normal distribution. In the case of origin, everything is perfect, but when I try to run the…
Raúl
  • 3
  • 2
0
votes
1 answer

"Error in Contrasts" message in glm model after confirming that all Factor variables are longer than 2 unique values [R]:

I am not sure why I am still receiving this message when running a base model with all variables in my dataset: My data, with anonymized variables: set.seed(1234) #dput(df) structure(list(outcome_1= structure(c(2L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 2L,…
Walker
  • 63
  • 7
0
votes
1 answer

Pseudo R-squared for glm.cluster object

I have estimated several glms with cluster robust standard errors using the function glm.cluster() from the miceadds package in R. Unfortunately, the function does not automatically calculate a pseudo R-squared. Moreover, I am unable to find a…
0
votes
1 answer

Univariate logistic regression in R

I am trying to do a univariate logistic regression analysis. The input is a data frame with 1 response variable, some demographics (age, gender and ethnicity) and >100 predictor variables. In order to analyse it I have been using: #Function proc_glm…
beanie42
  • 1
  • 2
0
votes
2 answers

How to pass input into a named list within a user-defined function

I am trying to create a user-defined function that outputs odds ratios (95% CIs) from logistic regression models. I am basically stuck on Line 2 where I predict the odds ratio using oddsratio::or_glm() function. I need to pass the predictor input…
Dani
  • 161
  • 9
0
votes
1 answer

Error code: must have identical levels in the same order

When running the MCMCglmm function I get the following error message: fit_mcmc <- MCMCglmm(exchange ~ assocSRI,random=~mm(ID1 + ID2), data=within_dyad) Error in buildZ(rmodel.terms[r], data = data, nginverse = names(ginverse)) : terms involved in…
0
votes
0 answers

Tabulating GLM summaries for each predictor, for multiple GLM fits

All, I am looking for an efficient way to do the following in R. I have a list of R GLM objects G that all use the same model matrix X. Each GLM object just corresponds to a different response variable Y1... Yp. I would like to create a summary list…
mskb
  • 341
  • 3
  • 12
0
votes
1 answer

How to create interplot of negative binomial regression model with interaction effects?

I am trying to plot interaction effects in R for a negative binomial regression model (glm.nb). The dependent variable meetings is numeric. Variable EU is dichotomous and variable "type" is categorical 1/2/3. glmnbmodel <- glm.nb(meetings ~ EU +…
0
votes
0 answers

Finding init.theta value for negative binomial GLM in R

I'm using function glm.nb() from the package MASS in R. How do I find the correct init.theta value? In other questions I've seen on this topic, askers already seemed to have their init.theta. I understand that theta is a dispersion parameter. When I…
Cait
  • 1
0
votes
0 answers

Exponential family distribution where variance is greater than mean in python

Can someone please suggest how to fit a distribution from exponential family with variance greater than mean to build GLM model in python. In R, quasipoisson seemed to work well. But I couldn't find a similar distribution in python. glm_fit1 <-…
0
votes
1 answer

GLM - No R-squared output when running simple linear regression with categorical predictor

I am running a simple linear regression with a numerical response (wellbeing) and a categorical explanatory (education) variable. I know that there are ideas about dealing with the categorical variable as continuous, but in this case I want to keep…
SHW
  • 461
  • 7
  • 26
0
votes
0 answers

Binomial negative distribution

I am learning how to use glms to test hypothesis and to see how variables relate among themselves. I am trying to see if the variable tick prevalence (Parasitized individuals/Assessed individuals)(dependent variable) is influenced by the number of…
RBiology
  • 3
  • 3