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

R How to evaluate a single input variable coefficient in a glm

I have a R glm object and I want to evaluate the coefficient associate to a single input variable of a new data frame. Here is an example: library(statmod) data = tibble(X = c('a', 'b', 'c', 'd', 'e'), Z = c('a', 'c', 'c', 'c', 'a'), W = c(21:25),…
John E.
  • 137
  • 2
  • 10
0
votes
1 answer

R code: Error in model.matrix.default(mt, mf, contrasts) : Variable 1 has no levels

I am trying to build a logistic regression model with a response as diagnosis ( 2 Factor variable: B, M). I am getting an Error on building a logistic regression model: Error in model.matrix.default(mt, mf, contrasts) : variable 1 has no…
Priyanshu M
  • 3
  • 1
  • 2
0
votes
0 answers

How to use the predict() function for a GLMGam model with BSplines (statsmodel api Python)?

I have a dataset of 25544 observations and 7 explanatory variables, that I split in train set and test set. Then I run a GAMGam model with BSplines on the train set. y = dfop[['RATIO_OPENING']] X = dfop.loc[:,…
Lucas Snow
  • 35
  • 4
0
votes
0 answers

r glmmLasso : Error in n %*% s (glmm.rmd#64): requires numeric/complex matrix/vector arguments

I am trying to fit a glmmLasso model using this code: lasso <- glmmLasso(stars ~ ADJRIND + AUC + KAPPA + DICE + ICCORR + JACRD + MUTINF + RNDIND + SURFOVLP + SURFDICE + VOLSMTY + HDRFDST + AVGDIST + MAHLNBS + VARINFO + GCOERR + PROBDST + SNSVTY +…
florian
  • 604
  • 8
  • 31
0
votes
0 answers

Why 95%CI of OR in tbl_regression (and manual 95%CI) is different from 95%CI from logistic.display and does not match p-value?

If I want to perform logistic regression, I can use three different ways: manually : fit1 <- (glm(outcome~A+B,family=binomial,data=database)) summary(fit1) exp(confint(fit1)) exp(coefficients(fit1) function tbl_regression from gtsumary…
B_slash_
  • 309
  • 2
  • 17
0
votes
0 answers

Py4JJavaError: An error occurred while calling o767.fit

I tried to fit a random forest classifier in pyspark but i'm getting this error: Py4JJavaError: An error occurred while calling o767.fit. : org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 30.0 failed 1 times, most…
0
votes
0 answers

How do I specify the dispersion parameter when computing the confidence interval for a GLM?

I have a model of exponential decay in the form Y = exp{a + bX + cW}. In R, I represent this as a generalized linear model (GLM) using a gamma random component with log link function. fitted <- glm(Y ~ X + W, family=Gamma(link='log')) I know from…
ning
  • 1,823
  • 1
  • 19
  • 25
0
votes
1 answer

generalized R squared (Naglekerkes R^2)

does anybody know how to compute Naglekerkes generalized R Squared for GLMs using R? And does it makes any sence to use it for count data regression? References: generalized R^2 "Scroll down at to the bottom of this article!"
user734124
  • 489
  • 8
  • 20
0
votes
0 answers

Logistic regression without any outcome data

I am trying to perform logistic regression on data that contains a binary outcome. However, I do not have access to the outcome data. I've calculated probabilities of a "1" outcome for each subject by assigning "risk points" to certain values of…
Emma
  • 31
  • 5
0
votes
1 answer

how to use for loop on glm

I'd like to use sentiment scores to predict each of the stock's return (stock1, stock2, and stock 3). Please see the sample dataset below. data={"sentiment":[0.9, 0.75, 0.88, 0.23] , "stock1":[0.0015, 0.034, -0.065, 0.015], "stock2":[0.023, -0.001,…
Rockaell
  • 13
  • 2
0
votes
2 answers

How to use logistic regression in R function

I am trying to use r base logistic regression function in my customized r function but my glm() is not able to recognize my variables. I have tried multiple searching keywords in the search engine but all answers are related to fitting a logistic…
Y. Z.
  • 369
  • 2
  • 16
0
votes
1 answer

How to prevent or remove or replace NA values in glm output statistics?

I've made up an example to illustrate my problem. Imagine I have a dataset, and I train a generalized linear model with gamma-distributed residuals. library(MASS) df <- read.csv('test.csv') model <- glm(formula = y ~ method * site + year + 0, …
Galen
  • 1,128
  • 1
  • 14
  • 31
0
votes
1 answer

Using variable to select covariates for glm

I am running a simulation of multiple experiments using random data to create glm models. In each individual experiment I need to select different covariates to build the glm. Is there a way to use variable names to specify which covariates to use…
0
votes
1 answer

GLM output trouble

So, i want to run a repeated measures GLM in RStudio, which I have done...for the most part.... However, Not all dates are showing up in my output (12/1/2015 is missing). Here is part of the output along with my model code so you can see what i…
Christina
  • 11
  • 1
  • 2
0
votes
0 answers

Logistic regression model with continuous and categorical variables

I have a dataset “ex” with categorical and continuous variables. The response variable is A16. I want to build a logistic regression model but I receive a message: glm.fit: fitted probabilities numerically 0 or 1 occurred and I suspect that there…
codeforfun
  • 187
  • 10
1 2 3
99
100