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
4
votes
1 answer

Defining the Prior in MCMCglmm

I've found this same question posted everywhere, and I can't seem to get any of the solutions to fit to my data, and I'm wondering if I'm trying to fit my data to a model that's just too complex. I'm trying to fit my data to a multinomial logistic…
grifjo06
  • 41
  • 3
4
votes
1 answer

How to fix "Can't differentiate w.r.t. type " error when using autograd in python

I am getting an error "Can't differentiate w.r.t. type " when using the autograd function in python. Basically, I am trying to write code for a generalized linear model (GLM) and I want to use autograd to get a function that describes the…
I. Stone
  • 61
  • 1
  • 3
4
votes
2 answers

How to use map from purrr and mutate from dplyr to produce a glm summary table?

I am using the packages purrr and broom to produce a series of glm's and build a table with information of the models so I can compare them. The code is failing when I call map function from purrr. I think the problem relates to the combination of…
Darius
  • 489
  • 2
  • 6
  • 22
4
votes
1 answer

Python equivalent for poly(x, 2) adds an orthogonal polynomial of degree 2

Here is the R code model1 <- glm(wt82_71 ~ qsmk + sex + race + poly(age, 2, raw = TRUE) + education + poly(smokeintensity, 2, raw = TRUE) + poly(smokeyrs, 2, raw = TRUE) + exercise + active + poly(wt71, 2, raw = TRUE) + qsmk:smokeintensity,data =…
4
votes
1 answer

How to paint a complex function by ggplot2?

I`m trying to colour ribbon of complex functions. However, this does not go well (see the figure below): I want to paint only the lower part of the function. However, in this case, only the part connected by the vertices is painted, and the painted…
LandsEco
  • 43
  • 2
4
votes
2 answers

h2o.glm lambda search not appearing to iterate over all lambdas

Please consider the following basic reproducible example: library(h2o) h2o.init() data("iris") iris.hex = as.h2o(iris, "iris.hex") mod = h2o.glm(y = "Sepal.Length", x = setdiff(colnames(iris), "Sepal.Length"), training_frame =…
jav
  • 1,485
  • 8
  • 11
4
votes
1 answer

H2o GLM interact only certain predictors

I'm interested in creating interaction terms in h2o.glm(). But I do not want to generate all pairwise interactions. For example, in the mtcars dataset...I want to interact 'mpg' with all the other factors such as 'cyl','hp', and 'disp' but I don't…
Raag Agrawal
  • 146
  • 1
  • 9
4
votes
0 answers

Changing stepAIC to accommodate tweedie distributions

So I am trying to do a stepwise regression for a tweedie distribution. However, AIC is returned as NA by glm() if the family is tweedie, and this breaks the stepAIC command. I tried editting the code of the command to change extractAIC to…
J. Gursky
  • 121
  • 1
  • 9
4
votes
0 answers

What's the difference between resid_working, resid_anscombe, and resid_deviance in GLM

What's the difference between resid_working, resid_anscombe, and resid_deviance in statsmodel.GLMResults? Here are some explanation from the source code: Working residuals; the working residuals are defined as resid_response/link'(mu); see links.py…
ZHU
  • 904
  • 1
  • 11
  • 25
4
votes
1 answer

Caret's train() & resamples() reverses sensitivity/specificity for GLM

The documentation for the glm() function states, regarding a factor response variable, that the first level denotes failure and all others success. I assume caret's train() function calls glm() under the hood when using method = 'glm', and…
shaneker
  • 375
  • 2
  • 8
4
votes
1 answer

Expected Fisher information from R's glm routine

I am trying to better understand aspects/implications of the observed versus expected information in the context of maximum likelihood estimation. Part of this involves simulating data. If I generate outcome data from the following logistic…
Ashley Naimi
  • 232
  • 1
  • 9
4
votes
1 answer

How to treat a variable as random factor in GLM in R

I am doing statistical analysis for a dataset using GLM in R. Basically the predictor variables are: "Probe"(types of probes used in the experiment - Factor with 4 levels), "Extraction"(types of extraction used in the experiment - Factor with 2…
Tung Linh
  • 321
  • 1
  • 2
  • 16
4
votes
1 answer

GLM function for Logistic Regression: what is the default predicted outcome?

I am relatively new to R modelling and I came across the GLM functions for modelling. I am interested in Logistic regression using the family 'binomial'. My question is when my dependent variable can take one of two possible outcomes - say…
4
votes
1 answer

Graph GLM in ggplot2 where x variable is categorical

I need to graph the predicted probabilities of a logit regression in ggplot2. Essentially, I am trying to graph a glm by each treatment condition within the same graph. However, I am getting quite confused about how to do this seeing that my treat…
rowbust
  • 451
  • 1
  • 5
  • 14
4
votes
0 answers

R Error in solve.default(V) : 'a' is 0-diml in regTermTest function

I'm trying to use regTermTest function in R survey package to test the significance of each variables for logistic regression. However, I got a solver error for one of my variable, "fun". The error is Error in solve.default(V) : 'a' is 0-diml My…