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

Hessian in SAS?

Is there any way to get the Hessian matrix in the proc logistic in SAS? Or which will be an option to calculated it taking from departure the proc logsitic? I have been reading the function documentation but cannot see that there is a way to include…
user1571823
  • 394
  • 5
  • 20
5
votes
1 answer

How can I generate marginal effects for a logit model when using survey weights?

I normally generate logit model marginal effects using the mfx package and the logitmfx function. However, the current survey I am using has weights (which have a large effect on the proportion of the DV in the sample because of oversampling in some…
Jon M
  • 1,157
  • 1
  • 10
  • 16
5
votes
1 answer

Bayes predict, subscript out of bounds

I'm having some problems with the predict function when using bayesglm. I've read some posts that say this problem may arise when the out of sample data has more levels than the in sample data, but I'm using the same data for the fit and predict…
ch-pub
  • 1,664
  • 6
  • 29
  • 52
5
votes
2 answers

glm switches coefficient names for interactions

I use the R code: dat<-data.frame(p1=c(0,1,1,0,0), GAMMA.1=c(1,2,3,4,3), VAR1=c(2,2,1,3,4), GAMMA.2=c(1,1,3,4,1)) form <- p1 ~ GAMMA.1:VAR1 + GAMMA.2:VAR1 mod <- glm(formula=form, data=dat, family=binomial) (coef <- coefficients(mod)) # (Intercept)…
Giuseppe
  • 786
  • 1
  • 7
  • 18
5
votes
2 answers

How to save a glmnet model to a file in R?

When I am using R, how can I save a model built by glmnet to a file, and then read it from the file so as to use it to predict? Is it also the same if I use cv.glmnet to build the model? Thanks!
Kudzu
  • 203
  • 2
  • 5
5
votes
1 answer

benchmarking logistic regression using glm.fit , bigglm, speedglm, glmnet, LiblineaR

I am simulating data and comparing glm.fit , bigglm, speedglm, glmnet, LiblineaR for binary logit model. testGLMResults_and_speed <- function(N, p, chunk=NULL, Ifsample=FALSE, size=NULL, reps=5){ library(LiblineaR) library(speedglm) …
user1971988
  • 845
  • 7
  • 22
5
votes
1 answer

Use variable in GLM quasi specification

I'm fitting a GLM to some data, using a quasi-likelihood approach (family=quasi(...)). I'd like to use a variable, p in the variance specification, like so: family = quasi(link=log, variance=mu^p) This however doesn't work (it no longer…
user2249626
  • 453
  • 2
  • 6
  • 15
5
votes
2 answers

Using ROCR package difficulties

I'm following an analysis of German Credit data and I got an error which I'm failing to rectify because I already installed the ROCR package. Below is the code that uses the ROCR: #load library library(ROCR) #score test data set test$score <-…
user2474671
  • 51
  • 1
  • 1
  • 3
5
votes
1 answer

Difference between svyglm and weighted glm

I would like to know what the difference is between using svyglm or a weighted glm. For example: M1 = glm(formula = yy ~ age + gender + country , family = binomial(link = "probit"), data = P2013, subset = (P2013$E27>=14…
Natuk
  • 57
  • 1
  • 9
5
votes
1 answer

Regression for a Rate variable in R

I was tasked with developing a regression model looking at student enrollment in different programs. This is a very nice, clean data set where the enrollment counts follow a Poisson distribution well. I fit a model in R (using both GLM and Zero…
Noah
  • 567
  • 8
  • 19
5
votes
1 answer

R - Separation issue in binary response models - glm, brglm, logistf

I am encountering some issues with my data and need some help. I am trying to run glm analysis with a presence/absence variable as response variable and several explanatory variable (time, location, presence/absence data, abundance data). First I…
Xochitl C.
  • 201
  • 2
  • 7
5
votes
2 answers

Extracting p-value from lapply list of glm fits

I am using lapply to perform several glm regressions on one dependent variable by one independent variable at a time. Right now I am specifically interested in the Pr(>|z|) of each independent variable. However, I am unsure on how to report just…
nofunsally
  • 2,051
  • 6
  • 35
  • 53
5
votes
2 answers

Multiple glm in for loop

I have an R dataframe, strongly simplified as: id <- rep(1:2, c(6,8)) correct <- sample(0:1,14,TRUE) phase <- c(rep("discr",3),rep("rev",3), rep("discr",4),rep("rev",4)) dat <- data.frame(id,correct,phase) with id as my subjects (in reality I have…
Lucy Vanes
  • 237
  • 2
  • 7
5
votes
2 answers

Offset not working in binomial GLM

I'm trying to fit a logistic regression using glm( family='binomial'). Here is the model: model<-glm(f_ocur~altitud+UTM_X+UTM_Y+j_sin+j_cos+temp_res+pp, offset=(log(1/off)), data=mydata, family='binomial') mydata has 76820…
lpchaparro
  • 129
  • 2
  • 6
5
votes
1 answer

Which function/package for robust linear regression works with glmulti (i.e., behaves like glm)?

Background: Multi-model inference with glmulti glmulti is a R function/package for automated model selection for general linear models that constructs all possible general linear models given a dependent variable and a set of predictors, fits them…
jonlemon
  • 111
  • 5