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

Limit on the Number of Variables for bestglm Function

I am trying to run the bestglm function in R for subset selection and the run fails immediately if I use more than 15 variables in the function. I attached some sample code below (I know these models have far too many variables for this dataset, I…
eschu
  • 3
  • 2
0
votes
1 answer

Multiple imputation (mice) with glm: "argument to 'which' is not logical"

I should have successfully used mice to do multiple imputation on a data frame. I would now like to run glm on that dataset. My outcome variable is "MI" and my independent variables are "Hypertension" and "Diabetes". I have tried: dat <-…
John M.
  • 51
  • 5
0
votes
0 answers

How do I treat female and male as binary variables when I am working with binomial data?

I am a complete beginner in R/R Studio, coding and statistics in general. In R, I am running a GLM where my Y variable is a no/yes (0/1) category and my X variable is a Sex category (female/male). So I have run the following script: hello <-…
123
  • 1
  • 1
0
votes
1 answer

difference between normal execution of glm.nb and geom_smooth execution of glm.nb for a spline model

I'm trying to fit a negative binomial glm for two different conditions to my data. first, some toy data : value times variable 1 82.21236 0.0000000 B 2 130.69185 0.0000000 A 3 159.10491 1.3131313 B 4 136.94357 …
0
votes
2 answers

How to make loop to contain confounders(covariates) in a binary logistic regression using glm in R?

There are more than 50 exposure variables and a total of 16,000 data. I need to analyze the association between all exposure variables and outcome. I would like to repeat the following formula. example.data <- data.frame(outcome =…
0
votes
1 answer

I need to find all predictors(p-value < 0.05) from my dataset using loops. Is there any way to do it?

I am new to R and I am using glm() function to fit a logistic model. I have 5 columns. I need to find all possible predictors using a loop based on their p-values(less than 0.05). My dataset has 40,000 entries which contains numerical and…
0
votes
1 answer

Predict ignores newdata argument in feglm estimation

After estimating my model train_data <- df_est_hdfe[idx,] test_data <- df_est_hdfe[-idx,] est <- c("NATURAL", "GDPsim", "cap_lab_sim", "cap_lab_sim_sq", "cont") form <- formula(paste0("rta ~ ",paste(est, collapse = " + "), "| exp_ind +…
SimonDude
  • 7
  • 1
  • 4
0
votes
1 answer

R | How to get accuracy from cv.glmnet

I've been using the cv.glmnet function to fit a lasso logistic regression model. I'm using R Here's my code. I'm using the iris dataset. df = iris %>% mutate(Species = as.character(Species)) %>% filter(!(Species =="setosa")) %>% …
Mistakamikaze
  • 446
  • 3
  • 19
0
votes
1 answer

How can I store the each column of the summary of a model in a list in R without using libraries

! Please see the above picture to see the summary I want each element of the summary to be converted into a list. This is the summary data and I want to create separate lists such as predictors = ['Age','WorkClassLocal-gov', ..., HoursWork] z value…
lala
  • 11
  • 5
0
votes
2 answers

How convert contingency tables (counts) to individuals for GLM in R

I have my info as in this photograph: You can download it here: https://drive.google.com/file/d/1pgO51NXtjpVSz-VxQEDNFFuQXVc4jVkt/view?usp=sharing What i want is to transform this data to individuals, For example Will transform into this Another…
0
votes
1 answer

svymultinom in R

I'm using a large dataset and have run several logistic regressions with svyglm(). I am now examining a dependent variable with at least 5 possible outcomes. I discovered svymultinom but I'm having trouble with the code. I get the following…
nerak31
  • 1
  • 1
0
votes
2 answers

permute a column within a level, perform an test on 2 columns, and save the pvalues

I have a data frame > dput(df) structure(list(id = c(1, 2, 3, 4, 1, 2, 3, 4), level = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c("g01", "g02"), class = "factor"), m_col = c(1, 2, 3, 4, 11, 22, 33, 44), u_col = c(11, 12, 13,…
R-MASHup
  • 365
  • 2
  • 9
0
votes
0 answers

Model failed to converge (lme4)

I would like to achieve the following task. Using a linear mixed model, I would like to check whether "Month" (see dat table) has a significant effect on the "Response" variable. As for some of the tanks, data comes from different months, I included…
ABiologist
  • 43
  • 6
0
votes
0 answers

Warning message: All models failed in [fit_resamples()]. See the `.notes` column

I have used recipe()function in tidymodels packages for imputation missing values and fixing imbalanced data. here is my data; mer_df <- mer2 %>% filter(!is.na(laststagestatus2)) %>% select(Id, Age_Range__c, Gender__c, numberoflead,…
Ozgur Alptekın
  • 505
  • 6
  • 19
0
votes
0 answers

predict not working for confidence intervals in R

I am trying to get the confidence intervals with the predict function for a glm in R (so I can then plot them as a geom_ribbon in ggplot). These three options give me exaclty the same answer, i.e. the confidence intervals and prediction intervals…