Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Questions tagged [glm]

For questions relating to generalized linear models. For the GLM math library, see [tag:glm-math].

1
vote
0answers
27 views

C++ - Combing Transforms Without Matrices

This seems like a fairly simple problem, yet somehow I have still failed to get it right. I have sets of transform information, as defined in the following class: class Transform { public: glm::...
9
votes
1answer
8k views

How to debug “contrasts can be applied only to factors with 2 or more levels” error?

Here are all the variables I'm working with: str(ad.train) $ Date : Factor w/ 427 levels "2012-03-24","2012-03-29",..: 4 7 12 14 19 21 24 29 31 34 ... $ Team : Factor w/...
1
vote
1answer
38 views

Bacteria on fingers. Syntax for crossed random effects with random slopes but not intercepts in MASS::glmmPQL

I have non-normal data (bacteria on fingers after touching surfaces with and without gloves) so using glmmPQL from the MASS package. I have one categorical predictor (Gloves), a repeated measurement ...
0
votes
0answers
45 views

Setting up OpenGL in CodeBlocks on Windows

I am having trouble getting the right setings in order to use OpenGl in CodeBlocks. I am following this tutorial: https://www.youtube.com/watch?v=XlMEK58FaGM and I have done everything that guy has ...
0
votes
0answers
9 views

Weights in glmmPQL say variable lengths: R

People are touching surfaces and picking up germs on their fingers. I measure the germs on their fingers after X number of surface contacts (NumberContacts) (fixed effect). This varies by Participant (...
0
votes
0answers
4 views

what is the input format of this gwr package?

I am trying to do the GWR (Geographically Weighted Regression) method on my data. My data is let say from Georgia for 1000 days. The format of the y variable fed to this function is n*1 where n is the ...
0
votes
1answer
71 views

How to plot predicted probabilities from a GLM with 2-column matrix response?

I would like to plot the regression line from a glm model (written below). Ideally I'd like to plot it over the observed data, but I haven't been able to adapt the code I've found elsewhere (e.g. ...
0
votes
1answer
24 views

glmnet multinomial logistic regression prediction result

I'm building a penalized multinomial logistic regression, but I'm having trouble coming up with a easy way to get the prediction accuracy. Here's my code: fit.ridge.cv <- cv.glmnet(train[,-1], ...
2
votes
0answers
26 views

Using LIME for predictions of a logit model in R?

So I am trying to use LIME to understand predictions from a logit model in R. I know I don't 'need' to, but I am trying to illustrate what it does with a model that one can simply understand as a ...
0
votes
1answer
39 views

How to extract AIC and Log Likelihood from pooled GLM?

I've imputed data using the MICE package. Now I would like to present the results of a GLM based on the pooled data. This is how I came up with the data: data.imputed <- mice(data, m=5, maxit = ...
5
votes
2answers
71 views

R predict glm fit on each column in data frame using column index number

Trying to fit BLR model to each column in data frame, and then predict on new data pts. Have a lot of columns, so cannot identify the columns by name, only column number. Having reviewed the several ...
0
votes
0answers
23 views

Analysis residuals glm in R

I'm doing a GEE model to analyze the influence of variable on costs. My distribution follows a gamma law. res.GEE=GEE<-geeglm(tab_model$cout ~ tab_model$sexe + tab_model$clage + tab_model$temps +...
0
votes
1answer
16 views

Julia: Creating a method for a subtype (LinearModel)

I am trying to create a method for the LinearModel subtype of the GLM package. Unfortunately, this doesn't seem to work: using DataFrames, GLM, RDatasets iris = dataset("datasets", "iris") fit = lm(...
0
votes
0answers
67 views

Another attempt on fitting GLM for a large dataset with big factor variables

I have an unbalanced panel data df, which has two time-invariant variables, A and B, and nine time-varying variables - Var1 to Var9. I would like to run a regression that estimates the effect of these ...
1
vote
2answers
36 views

Logistic regression after imputation in R

I tried implementing logistic regression using glm in R for winconsin breast cancer dataset. I analysed the dataset and found that wbc$V7 contained missing values. I imputed the missing values using ...
0
votes
0answers
23 views

0 values in glm binomial family with link=logit => do not treat them correctly [migrated]

I have this model that run well: glm(formula = cbind(Number_F, Nbre_dead) ~ Temperature + Population + Size + Number_I, family = binomial(link = logit), data = marine_data_T2) Number_F (total ...
0
votes
1answer
40 views

glm in R, give all comparisons

Simple logistic regression example. set.seed(1) df <- data.frame(out=c(0,1,0,1,0,1,0,1,0), y=rep(c('A', 'B', 'C'), 3)) result <-glm(out~factor(y), family = 'binomial', data=df) ...
1
vote
0answers
42 views

Predict Probability

I need to use the predict() function in R to try and obtain the probability for a set of values. The dataset is as follows: Loc: Beach, NonBeach Sex: Male, Female Infec: (Response variable) with ...
9
votes
2answers
19k views

Understanding glm$residuals and resid(glm)

Can you tell me what is returned by glm$residuals and resid(glm) where glm is a quasipoisson object. e.g. How would I create them using glm$y and glm$linear.predictors. glm$residuals n ...
3
votes
1answer
724 views

What is the proper way to use glmnet with caret?

I was reading the glmnet documentation and I found this: Note also that the results of cv.glmnet are random, since the folds are selected at random. Users can reduce this randomness by running ...
0
votes
0answers
12 views

glmmTMB in R beta regression or Poisson distribution? [migrated]

I have a data set which is very zero inflated. Zeros are representative of true zeros, meaning that in this case a zero is a legitimate value to have indicating something about the individuals tested (...
1
vote
0answers
17 views

How to know whether it is better to classify a predictor variable as categorical or continuous in a glm?

I am working with glm and built this model : glm(cbind(Number_F,Nbre_dead)~ Temperature*Transect*Elevation + Size + Number_I, data=marine_data, family=binomial(link=logit)) Response variable 'cbind(...
1
vote
0answers
9 views

Coefficients of all Dummy Factor variables in GLM

I am building a Logistic Regression (in R) as follows: glm_hr1 = glm(attrition_value ~ BusinessTravel+Department+Gender, binomial(link="logit"), data=hr1) The X-variables are defined ...
3
votes
1answer
72 views

Analogue of R's simulate function in Julia?

I'm trying to use Julia's GLM package. Based on my experience in R, I have always loved its simulate function simulate(object, nsim = 1, seed = NULL, ...) which draws response from a fitted model. ...
1
vote
1answer
54 views

How to do a GLM when “contrasts can be applied only to factors with 2 or more levels”?

I want to do a regression in R using glm, but is there a way to do it since I get the contrasts error. mydf <- data.frame(Group=c(1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12), ...
0
votes
1answer
18 views

What statistic method to use in multivariate abundance data with random effects?

I am working with multivariate data with random effects. My hypothesis is this: D has an effect on A1 and A2, where A1 and A2 are binary data, and D is a continuous variable. I also have a random ...
0
votes
0answers
8 views

Mixed Model and repeated measures - random effect for both identifier and year of observation

I am self-learning mixed models and trying to fit a model for childhood BMI and physical activity at different ages. This is a longitudinal study and the children have been followed for years with 6 ...
1
vote
0answers
33 views

Edit: Set dispersion parameter in pooled dataset (mids object)

EDIT 2 27/7: I figured out that I must get the correct output if I set the dispersion parameter to 0.64. I tried doing this with summary(fit, dispersion = 0.64) but this doesn't work. Probably ...
0
votes
0answers
10 views

multiple errors when using glmmADMB

I am using glmmADMB to run a zero-inflated binomial model with mixed effects. I run into multiple errors. My code: m_admb <- glmmadmb( breeding.success ~ laying.date.julian.day.zscale + tmean....
0
votes
0answers
11 views

Why does lambda seems to have no influnece on RMSE when using ridge regression?

I'm using glmnet to train a ridge model but the output of my model gives an equal RMSE for every value of lambda. I'm following these instructions. (https://www.youtube.com/watch?v=_3xMSbIde2I&t=...
0
votes
2answers
68 views

Can MICE pool results of ordinal logistic regression run by the function polr()?

I'm running the data set downloaded from UCLA read.dta("https://stats.idre.ucla.edu/stat/data/ologit.dta") and randomly assign some missing values in the independent variables: pared, public, and ...
0
votes
2answers
63 views

Regression in a loop but get “Error in coef(summary(fit))[2, 4] : subscript out of bounds”

When running the following code on a high dimensional dataset I get the error message Error in coef(summary(fit))[2, 4] : subscript out of bounds The vector beta which the p-values of the logistic ...
1
vote
1answer
32 views

issue combining 2 Euler angles with GLM

I have the following code: #define GLM_ENABLE_EXPERIMENTAL #include <iostream> #include <glm/glm.hpp> #include <glm/ext.hpp> // combines 2 XYZ euler angles given in degrees glm::...
1
vote
1answer
46 views

Get number of data in each factor level (as well as interaction) from a fitted lm or glm [R]

I have a logistic regression model in R, where all of the predictor variables are categorical rather than continuous (in addition to the response variable, which is also obviously categorical/binary). ...
1
vote
0answers
2k views

Adding more than one explanatory variable to Logistic Regression (glm) model gives an error?

I've tried to fit the following linear model: ad.glm.all <- glm(WinLoss ~ Score + Margin + Opposition + Venue + Disposals + Marks + Goals + Behinds + Hitouts + Tackles + Rebound50s + Inside50s + ...
0
votes
1answer
29 views

How does H2O select best variables for GLM

I put my predictor variables in the gridsearch below. As far as I understood, this gridsearch selects the best variables that should be used in our model and throws away the others. However, I do not ...
0
votes
1answer
41 views

GLM modeling error

I have data (I will provide head of the data) and wanna model GLM on "accurancy". My R studio keeps freezing all the time I run the final code, the GLM one. I have no clue what to do and I am ...
0
votes
1answer
37 views

Predict(), NewData with two column and differing rows

I am trying to make the prediction of three variables (retweets,media,content) in my dataset (df_22) to choose between Poisson, Negative binomial and Zero-inflated Poisson. One of the three variables ...
0
votes
2answers
3k views

R: GLMM glmer vs glmmPQL

What is the syntax in glmmPQL for multiple random effects? With glmer my code looks like: fit<- glmer(A~B+C+ (1 | D)+ (1 | E), family = gaussian, data=data) how to rewrite the same exact thing ...
1
vote
1answer
170 views

R: Multiple variables in GLM (one polynomial one sinusoidal)

I have some data where power, wind speed and wind direction have been measured. There's a second degree polynomial correlation between power and wind speed, and there's maybe a sinusoidal correlation ...
0
votes
0answers
31 views

How to covert a h2o coefficients table into a model object in R

UPDATE... so I kinda figure out my problem in other way and I will leave my code below..... Another thing is, I'd still like to know if a dataframe(with coefficients in table) can be converted to a ...
0
votes
1answer
9k views

Error messages when running glmer in R

I am attempting to run two similar generalized linear mixed models in R. Both models have the same input variables for predictors, covariates and random factors, however, response variables differ. ...
0
votes
1answer
24 views

Difference between . and 1 in glm

I want to perform a regression and first of all I want to test if my nullmodel is significant. So if not, I wont be able to perform the stepwise introduction according to AIC. So I did the following:...
0
votes
1answer
194 views

Creating confidence intervals for regression curve in GLMM using Bootstrapping

Have created a GLMM model and plotted the predicted probabilities of each factor. However, I cannot fathom how to create confidence intervals using the BootMer function. I keep getting the error ...
0
votes
1answer
24 views

Running GLM with StatsModels in Python

I try to replicate using my own data the example in the documentation: >>> import numpy as np >>> import statsmodels.api as sm >>> data = sm.datasets.longley.load() >>...
0
votes
0answers
21 views

ridge, lasso regression error in cv.glmnet and error in randomForest

I am trying to run a ridge, lasso regression as well as randomForest model on the total replacement cost from a csv file. This is what I did as follows: data$TOTAL_REPLACEMENT_VALUE=log(data$...
2
votes
1answer
218 views

glm - outlier detection and removal in R

I constructed a binary logistic model. The response variable is binary. There are 4 regressors - 2 binary and 2 integers. I want to find the outliers and delete them. For this i have create some plots:...
0
votes
1answer
31 views

Visualizing marginal effect of two-way interaction of binary logistic model in ggplot

Can someone suggest a quick and comprehensible way of how to visualize a two-way interaction of a glm model/ binary logistic regression model, using ggplot? I'm interested in the marginal effect! I ...
0
votes
0answers
41 views

Add regression line to ggplot

I have a dataset that looks like this: From that I built a glm model: library(glm) model<- glm(outcome ~ time + intervention1 + time*intervention1 + group + group*time + group*intervention1 + ...
0
votes
1answer
29 views

Poisson GLM with categorical data

I'm trying to fit a Poisson generalized mixed model using counts of categorical data labeled as s and v. Since the data was collected within sessions that have a different duration (see session_dur_s),...