glm

How to get an equation out of glm result

社会主义新天地 提交于 2019-12-11 03:59:00
问题 I've created a logistic regression with the glm function mynewlogit <- glm(is_bad ~ ulmp_s_ratio + plmp_mac_all_60d + plmp_est_mac_all_90d + plmp_c_mac_all_90d + lmp_s_ratio + plmp_c_mac_hrsk_60d + ulmp_c_ycount + pp_usr_lmp_count + l2pp_pp_age_min + lmp_c_ratio + lmp_age_max + lmp_age_avg , data = rajsub, family = "binomial") and I've got this result: Coefficients: (Intercept) ulmp_s_ratio plmp_mac_all_60d plmp_est_mac_all_90d -1.6226917 1.8704011 0.1037387 0.1583566 plmp_c_mac_all_90d lmp_s

fit glm with known coefficients and unknown intercept

安稳与你 提交于 2019-12-11 02:59:06
问题 I am trying to fit a logistic regression model using glm , where I am only interested in the intercept - but I still want the model to be fitted with known coefficients. Example: or beta <- c(24.5,3.6,2.87,7.32) So I want to use model <- glm(y~x_1+x_2+x_3+x_4, family=binomial(link="logit"), data=dt) and in some way incorporate the known betas, so the glm function only fits the alpha. How can I do that? 回答1: With offsets, which add a known term to the linear predictor (RHS of the formula, on

How to plot predictions of binomial GLM that has both continuous and categorical variables

瘦欲@ 提交于 2019-12-11 00:48:42
问题 I have a binomial GLM in R, with several predictors that are both continuous and categorical. The response variable is "Presence", which is binary (0/1). Length is a continuous variable, while all others are categorical. I am trying to plot predictions for each of the variables in the final model, particularly for "length", but I'm having difficulties. My data are the following: MyData<-structure(list(site = structure(c(3L, 1L, 3L, 2L, 1L, 4L, 3L, 4L, 1L, 2L, 4L, 5L, 5L, 1L, 4L, 3L, 2L, 4L,

Add confidence intervals to GLM allEffects plot

梦想与她 提交于 2019-12-10 23:58:54
问题 I need to add 95% confidence intervals on my glm plot. When I do multiline=T (because I need my 2 treatments on the same plot, so I did this), the intervals disappear. How can I get them back? This is what I have now: plot(allEffects(fit1), ylab= "Age of onset of foraging", main="", type="rescale", multiline=T, rescale.axis=F) as data I have -RFID is the technique to identify the honeybees and follow their movements; 2 treatments: control and a pathogen-treatment; "first.trip" - days until

Binomial GLM using caret train

﹥>﹥吖頭↗ 提交于 2019-12-10 21:26:42
问题 I would like to fit a Binomial GLM on a certain dataset. Using glm(...,family=binomial) everything works fine however I would like to do it with the caret train() function. Unfortunately I get an unexpected error which I cannot get rid of. library("marginalmodelplots") library("caret") MissUSA <- MissAmerica08[,c(2,4,6,7,8,10)] formula<-cbind(Top10, 9-Top10)~. glmfit <- glm(formula=formula,data=MissUSA,family=binomial()) trainfit<-train(form=formula,data=MissUSA,trControl=trainControl(method

Why can't pass only 1 coulmn to glmnet when it is possible in glm function in R?

三世轮回 提交于 2019-12-10 20:45:56
问题 Why there is no possibility to pass only 1 explanatory variable to model in glmnet function from glmnet package when it is possible in glm function from base? Code and error are below: > modelX<-glm( ifelse(train$cliks <1,0,1)~(sparseYY[,40]), family="binomial") > summary(modelX) Call: glm(formula = ifelse(train$cliks < 1, 0, 1) ~ (sparseYY[, 40]), family = "binomial") Deviance Residuals: Min 1Q Median 3Q Max -0.2076 -0.2076 -0.2076 -0.2076 2.8641 Coefficients: Estimate Std. Error z value Pr(

H2OGeneralizedLinearEstimator() - Prediction Error

旧巷老猫 提交于 2019-12-10 18:23:21
问题 I am trying to predict test times in a Kaggle comp using the H2OGeneralizedLinearEstimator function. The model trains normally in line 3 and the metrics are all reasonable. However when I come to the predict step I get an error despite the test data frame matching the train data frame. Has anyone seen this error before? h2o_glm = H2OGeneralizedLinearEstimator() h2o_glm.train(training_frame=train_h2o,y='y') h2o_glm_predictions = h2o_glm.predict(test_data=test_h2o).as_data_frame() test_pred =

Multiple glm in for loop

孤街醉人 提交于 2019-12-10 15:34:35
问题 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 a lot more than 2), correct = responses coded as incorrect (0) or correct (1), and the phases Discrimination and Reversal (within-subjects factor). I want to perform a logistic regression in the form of glm(correct~phase, dat, family="binomial")

Is ridge binomial regression available in Python?

心已入冬 提交于 2019-12-10 12:23:35
问题 I am new to Python and I would like to fit a ridge binomial regression. I know that binomial regression is available at: http://statsmodels.sourceforge.net/devel/glm.html I also know that logistic regression with L2 penalty can be fitted with sklearn.linear_model. http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html As binomial is sum of Bernoulli, I could use scikit after transforming my binomial structured data into Bernoulli structure, by changing

Model runs with glm but not bigglm

寵の児 提交于 2019-12-09 17:53:49
问题 I was trying to run a logistic regression on 320,000 rows of data (6 variables). Stepwise model selection on a sample of the data (10000) gives a rather complex model with 5 interaction terms: Y~X1+ X2*X3+ X2*X4+ X2*X5+ X3*X6+ X4*X5 . The glm() function could fit this model with 10000 rows of data, but not with the whole dataset (320,000). Using bigglm to read data chunk by chunk from a SQL server resulted in an error, and I couldn't make sense of the results from traceback() : fit <- bigglm