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

R Logistic Regression: How to code a zip code fixed effect?

I am looking to model the binary probability of someone to enroll/not enroll in an energy saving program. My data and formula look like this: ID Buildingtype Energyconsumption Enrollment Zip Code 1 Detached 2000 1 …
TvCasteren
  • 449
  • 3
  • 18
0
votes
1 answer

Stratifying Logistic Regression

I’m trying to stratify my glm model by age decades. My main question is: Instead of doing this subsetting within glm could I just make a new column called BYDECADE and run the the code as follows? fit <- glm(COMPLICATION~BYDECADE, …
ComputerNoob
  • 480
  • 6
  • 12
0
votes
1 answer

R: How to simulate from pooled GLM from mice

How can I use the simulate function on a pooled GLM from MICE? I have my MICE-imputed data in the object miceData. On this data i made a model as such: form3 <- survived ~ sex + age * pclass - 1 glm3 <- glm.mids(data=miceData, form3, family =…
Landscape
  • 249
  • 1
  • 2
  • 13
0
votes
1 answer

Do I need to / how can I specify (or retrieve) distribution parameters for GLM model (e.g. lambda for poisson family)?

To fit a generalized linear model (GLM), is it possible and/or necessary, to specify additional parameters (such as lambda for a Poisson distribution)? Currently, I am using R and stats::glm()). Or would glm() try and find the best e.g. lambda - in…
Martin
  • 594
  • 5
  • 16
0
votes
0 answers

Estimate x by defined y value in logit model in R

I have built a logit model in R: model <- glm(as.factor(y) ~ x, family = binomial(link = "logit"), data = data) Using the predicted probabilities from this model, I'd like to solve for x when y = 0.95. I believe the predict() function only solves…
Aliv25
  • 13
  • 2
0
votes
1 answer

glmmLasso function won't finish running

I am trying to build a Mixed Model Lasso model using glmmLasso in RStudio. However, I am looking for some assistance. I have the equation of my model as follows: glmmModel <- glmmLasso(outcome ~ year + married ,list(ID=~1), lambda = 100,…
0
votes
1 answer

fitted probabilities error numerically 0 or 1

I tried to construct a generalized linear model in R. I receive the following output below with the error "fitted probabilities numerically 0 or 1 occurred". I am wondering is this due to complete separation? My intercepts and standard errors are…
irene
  • 17
  • 5
0
votes
1 answer

Adding odds ratios values and different colors in a ggplot graph in R

I am trying to insert the Odds ratio values in the graph. I'm also trying to give different color to the shapes with significant Odds ratio. Significant Odds ratio are those whose confidence intervals does not include a value of 1. Can someone,…
Baptista
  • 15
  • 4
0
votes
0 answers

Errors - bootstrap GLM model - glmmBoot package

I'm trying to run a bootstrap resampling on a GLM model, but I keep running into errors and I can't find any solution online. The first problem in which I ran into is "variable lenght differs" when i try to use a normalized variable (sub.size_z) and…
Fabrizio
  • 13
  • 5
0
votes
1 answer

glmfit in MATLAB vs glm in R.. getting different answers

% A set of car weights\ weight = [0.17. 0.27, 0.44, 0.56, 0.65, 0.79, 0.98, 1.25, 1.56, 2.1, 2.42, 3.02, 3.6, 4.02]'; % The number of cars tested at each weight\ tested = [45 45 45 45 45 45 45 45 45 45 45 45 45 45]'; % The number of cars failing…
0
votes
0 answers

What GLM should I use to try and control for effort?

Probably a very simple question, but I am banging my head against the wall with this. To start with I am not very familiar with r or stats beyond the basics. I work for an NGO with an endangered species, so we have very little in the way of…
Jack
  • 1
  • 1
0
votes
2 answers

Is there a way to set the largest subset as the base in statsmodels glm, and how do you get hold of the base from the params?

I have two questions on statsmodels GLM: Is there a way to tell the glm to automatically set the level with most observations as the base (i.e. parameter 0) for each factor? If not, is there a reason for this? Is there a way to display or extract…
Rob
  • 21
  • 5
0
votes
1 answer

error: 'predictions' contains NA while predict landuse change using glm model (lulcc package) in R

I made a prediction model for land use change using the lulcc package in R. Prediction was done using glm. When I did the glm.pred (the last line), there was an error: 'predictions' contains NA message. I've tried using the na.omit function, but…
Double
  • 1
  • 2
0
votes
0 answers

Extracting regression coefficients from the output in r

I have the following data and the survey design: province <- read.table( text = "id str clu wt ue91 meanz hou85 diffhou85 smplrat 1 1 1 4 4123 2867 26881 -24014 .25 2 1 4 4 760 2867 4896 -2029 .25 3 1 5 4…
student_R123
  • 962
  • 11
  • 30
0
votes
1 answer

graph of half-normal plots residuals in ggplot2

I am trying to make the graph presented below for the residuals in the half-normal plot in ggplot2. However, I am facing an error entitled Error: data must be a data frame, or other object coercible byfortify (), not an S3 object with class…
user55546
  • 37
  • 1
  • 15