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

Checking linearity assumption for GLMM

I conducted a generalized linear mixed effects model using R. Now. I want to check if the linearity assumption of my model is violated. First, I tried to create a plot of the residuals using plot(fitted(glmm), residuals(glmm) which gave me this…
0
votes
1 answer

Logistic regression in R using glm() produces error in xy.coords when plotting

I'm trying to do a logistic regression using glm in R. My data sheet measurement.csv is structured like the…
Adrian Mak
  • 137
  • 8
0
votes
1 answer

R Model prediction using GLM for day-ahead forecasts in a for-loop

I have the following data table that I want to use to predict DE prices based on the other variables in the data table with the GLM (= Generalized Linear Model). set.seed(123) dt.data <- data.table(date = seq(as.Date('2019-01-01'), by = '1 day',…
MikiK
  • 398
  • 6
  • 19
0
votes
0 answers

Trying to translate a SAS GLM to R sasLM::GLM

I have a data set like this: X1 Record Plot Row Column Cp Csp Entry Year Location Genotype Trait Value Whole_plot 1 3256 717 566 6 …
R.Merritt
  • 477
  • 5
  • 17
0
votes
0 answers

GLM: Continuous variable with few states as factor or numeric?

I have a basic question. I am running binomial GLMs, with numeric predictors. Some of these predictors have very few unique values - some have 2, some 3 and some have 4. All these predictors are on a clear and interpretable continuous scale - I just…
Alex_H
  • 23
  • 5
0
votes
2 answers

Calculate Probit Estimates for samples via Loop

I have a sample dataset that looks like this: library(dplyr) test_df <- structure(list(test = c(0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L,…
Maximilian
  • 89
  • 1
  • 7
0
votes
0 answers

How can I compare 3 binary variables in R?

I'm looking at debris ingestion in gulls. Each gull is listed by row. Columns contain the sex(0=male, 1=female), if they ate debris (0=no, 1=yes) and if I found any number of other items in their stomach, for this problem I'd like to see if sex and…
0
votes
1 answer

Calculate marginal effects of probit model with categorial data

So my example data looks like this: library(dplyr) library(plm) library(car) library(margins) test <- structure(list(period = c(1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 1, 2, 2, 2, 3,…
Maximilian
  • 89
  • 1
  • 7
0
votes
0 answers

Logistics Regression in r

Trying to perform Logistics Regression: I converted the variable price to a qualitative variable. pricecode = (ifelse(Airbnb$price >= 175, "high", "low")) glm.fits = glm(pricecode["high"] ~ latitude + longitude + number_of_reviews +…
0
votes
0 answers

Very high odds ratios in R glm

I run a glm analysis on a dataset some days ago and obtained some relatively normal ranged (i.e from 0 to 2-3) odds ratios. I wanted to re-run the code because I had forgotten to print it and now I obtain very high and widely ranged odds ratios…
John M.
  • 51
  • 5
0
votes
1 answer

Is it possible to filter data based on its plot/predicted curve?

I had a question regarding excluding/filtering data points. I currently have coded a logistic regression that generates a decision boundary that is wrapped up into a function in which I am able to run over subsets of my data frame. I was wondering,…
LizJu
  • 125
  • 6
0
votes
1 answer

Poisson Model (Binary Response) Evaluation Metrics

I am unsure about the correct evaluation metrics to use in my model, and would appreciate your advice. Model Info: I fitted a GLM Poisson model in Python on a dataset, where each row of data has a different exposure between 0 to 1 and the response…
0
votes
1 answer

Predicting claim number through GLM model

I'm conducting a case study where I have to predict claim number per policy. Since my variable ClaimNb is not binary I can't use logistic Regression but I have to use Poisson. My code for GLM model: import statsmodels.api as sm import…
L200
  • 11
  • 1
  • 5
0
votes
1 answer

Is and Brier Score the right approach to evaluate this binomial glm model?

I want to evaluate a calculator that predicts events by calculating an estimated percentage of the probability that the event will occur based on numerous input variables (in practice it's about patients with risk factors and postoperative…
NR117
  • 25
  • 4
0
votes
2 answers

How to extract standard error from coefficients in stan_glm

I have a model that looks like this: fit <- stan_glm(switch ~ arsenic + dist100, family=binomial(link="logit"), data=wells, refresh=0) with an output that looks like this: stan_glm family: …
Alex Peniz
  • 483
  • 5
  • 14