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
8
votes
3 answers

Model runs with glm but not bigglm

I was trying to run a logistic regression on 320,000 rows of data (6 variables). Stepwise model selection on a sample of the data (10000) gives a rather complex model with 5 interaction terms: Y~X1+ X2*X3+ X2*X4+ X2*X5+ X3*X6+ X4*X5. The glm()…
ybeybe
  • 149
  • 1
  • 12
8
votes
3 answers

Predict.glm not predicting missing values in response

For some reason, when I specify glms (and lm's too, it turns out), R is not predicting missing values of the data. Here is an example: y = round(runif(50)) y = c(y,rep(NA,50)) x = rnorm(100) m = glm(y~x, family=binomial(link="logit")) p =…
generic_user
  • 3,430
  • 3
  • 32
  • 56
8
votes
3 answers

How to obtain a LM object from regsubsets

Let's imagine we want to model the US State Public-School Expenditures (education) using income, young, urban and region as regressors. For more info: ?Anscombe Model: education ~ (income+young+urban)*region library(car) library(leaps) #Loading…
Emer
  • 3,734
  • 2
  • 33
  • 47
7
votes
1 answer

R: modeling on residuals

I have heard people talk about "modeling on the residuals" when they want to calculate some effect after an a-priori model has been made. For example, if they know that two variables, var_1 and var_2 are correlated, we first make a model with var_1…
Helen
  • 533
  • 12
  • 37
7
votes
1 answer

R geepack: unreasonably large estimates using GEE

I am using geepack for R to estimate logistic marginal model by geeglm(). But I am getting garbage estimates. They about 16 orders of magnitude too large. However the p-values seems to similar to what I expected. This means that the response…
Mikkel Rev
  • 863
  • 3
  • 12
  • 31
7
votes
0 answers

Custom link function in scikitlearn

R has the option to define and use custom link function in the following way (binomial can be replaced with poisson, etc): link <- function() { define link, linkinv, d(linkinv)/d(eta) ... } model <- glm(y~x, family=binomial(link=link)) Is there an…
Naveen Mathew
  • 362
  • 2
  • 14
7
votes
3 answers

ggplot GLM fitted curve without interaction

I want to add the fitted function from GLM on a ggplot. By default, it automatically create the plot with interaction. I am wondering, if I can plot the fitted function from the model without interaction. For example, dta <-…
TheRimalaya
  • 4,232
  • 2
  • 31
  • 37
7
votes
2 answers

ggplot smooth line glm model with given vector of weights

I have data as below: numbers <- structure(list(density = c(1L, 4L, 10L, 22L, 55L, 121L, 210L, 444L), females = c(1L, 3L, 7L, 18L, 22L, 41L, 52L, 79L), males = c(0L, 1L, 3L, 4L, 33L, 80L, 158L, 365L), maleProp = c(0, 0.25, 0.3, 0.181818181818182,…
TheRimalaya
  • 4,232
  • 2
  • 31
  • 37
7
votes
1 answer

Confint() with glm {stats} very, very slow

I have a problem with calculating OR confidence intervals from a glm in the latest version of R, but I have not had this issue before. With any glm where family="binomial", no matter how simple the model is, it will easily allow me to extract the…
user4575913
  • 507
  • 1
  • 7
  • 16
7
votes
1 answer

Error: please supply starting values

I am conducting a log binomial regression in R. I want to control for covariates in the model (age and BMI- both continuous variables) whereas the dependent variable is Outcome(Yes or No) and independent variable is Group (1 or 2).…
Tina
  • 71
  • 1
  • 4
7
votes
1 answer

How to predict random and fixed effect models?

I just recently made a change from STATA to R and have some troubles implementing the R equivalent of the STATA commands xtlogit,fe or reand predict. May I ask for some assistance to adjust the following scenario: data <-…
Googme
  • 914
  • 7
  • 27
7
votes
3 answers

Why can't pass only 1 coulmn to glmnet when it is possible in glm function in R?

Why there is no possibility to pass only 1 explanatory variable to model in glmnet function from glmnet package when it is possible in glm function from base? Code and error are below: > modelX<-glm( ifelse(train$cliks <1,0,1)~(sparseYY[,40]),…
Marcin
  • 7,834
  • 8
  • 52
  • 99
7
votes
1 answer

Dummy Variables in Julia

In R there is nice functionality for running a regression with dummy variables for each level of a categorical variable. e.g. Automatically expanding an R factor into a collection of 1/0 indicator variables for every factor level Is there an…
Rob Donnelly
  • 2,256
  • 2
  • 20
  • 29
7
votes
3 answers

Anova test for GLM in python

I am trying to get the F-statistic and p-value for each of the covariates in GLM. In Python I am using the stats mode.formula.api to conduct the GLM. formula = 'PropNo_Pred ~ Geography + log10BMI + Cat_OpCavity + CatLes_neles + CatRural_urban + \ …
DKangeyan
  • 533
  • 6
  • 14
7
votes
3 answers

predict() with arbitrary coefficients in r

I've got some coefficients for a logit model set by a non-r user. I'd like to import those coefficients into r and generate some goodness of fit estimates on the same dataset (ROC and confusion matrix) vs my own model. My first thought was to coerce…
Stencil
  • 125
  • 1
  • 1
  • 7