glm

Interpreting the output of glm for Poisson regression [closed]

风流意气都作罢 提交于 2019-12-12 10:14:21
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Consider the following: foo = 1:10 bar = 2 * foo glm(bar ~ foo, family=poisson) I get results Coefficients: (Intercept) foo 1.1878 0.1929 Degrees of Freedom: 9 Total (i.e. Null); 8 Residual Null Deviance: 33.29 Residual Deviance: 2.399 AIC: 47.06 From the explanation on this page, it seems like the coefficient

define target variable in glm r

China☆狼群 提交于 2019-12-12 04:29:28
问题 I want to be able to define my target variable 'def_target' outside the regression code below: model1 <- glm(def_target~., family=binomial(link='logit'),data=train70) I have tried the following but get an error pop up tv1 <- 'def_target' model1 <- glm(tv1~., family=binomial(link='logit'),data=train70) If anyone could help me that would be great. Thanks 回答1: I think it might tip up cause you tell it in your model1: glm(tv1~., family=binomial(link='logit'),data=train70) . train70 does not have

Error in model.frame.default … variable lengths differ (but no NAs in data)

一世执手 提交于 2019-12-12 03:14:16
问题 On running a glm model I encountered a strange error message which I am unable to understand. The error message was Error in model.frame.default(formula = case ~ MENSTRUALSTATUS + PARITY + : variable lengths differ (found for 'PD') when I run the following code: lr.PD <- glm(case ~ MENSTRUALSTATUS + PARITY + k_BMI + PD, family = "binomial", data = teData.volpara) The dataframe teData.volpara has no NA s in any of the entries. I used the following command to eliminate NA s: teData.volpara <-

using paste() in a for loop with glm

。_饼干妹妹 提交于 2019-12-12 01:28:28
问题 In the code below, df.pts is a dataframe. I'd like to run about dozen glm models using different y variable (only two shown in the code). I'm using a for loop with the paste() function, but I can't seem to get the paste() function to work properly. What am I missing with paste()? SPCA2 = df.pts[,3] CLQU2 = df.pts[,4] df.list = list(SPCA2, CLQU2) for (i in df.list) { qp.mod = glm(paste(i,"~NDVI+ELEV"), family="quasipoisson", data=my.data) print(summary(gp.mod)) } 回答1: Many thanks! The main

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

隐身守侯 提交于 2019-12-12 00:34:15
问题 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/ 18 levels "Adelaide","Brisbane Lions",..: 1 1 1 1 1 1 1 1 1 1 ... $ Season : int 2012 2012 2012 2012 2012 2012 2012 2012 2012 2012 ... $ Round : Factor w/ 28 levels "EF","GF","PF",..: 5 16 21 22 23 24 25 26 27 6 ... $ Score : int 137 82 84 96 110 99 122 124 49 111 ... $ Margin : int 69 18 -56 46 19 5 50 69 -26 29 ... $

R Package segmented with an offset term

眉间皱痕 提交于 2019-12-11 18:04:38
问题 I am using package segmented in R. I first fitted a Poisson glm with a log link function using the glm function that includes an offset term like: M1=glm(Y~X1+X2+X3+offset(log(X)),data=dat.1,family=poisson) M1 is fitted without any error. Next I tried to fit a segmented glm by using the package segmented in R as: library(segmented) seg.1=segmented(M1,seg.Z=~X1,psi=list(X1=c(0.5))) I am having the following error: Error in offset(log(X)) : object 'X' not found Where is my mistake here? Thanks

error glm, NA/NaN/Inf in 'y

不羁的心 提交于 2019-12-11 17:52:13
问题 I am trying to fit a GLM model to my data. The data ( rope_complete ) looks like this: rope.X...Sound rope.directional.change rope.Time.of.the.shark.in.the.video 1 5_min_blank 5 23 2 Snorkeling 11 37 3 Fish1 1 17 4 Fish1 6 46 5 Diving 6 37 Now i wanted to check if I have NA values: table(is.na(rope_complete)) and saw that I have none: FALSE : 3225 Now I did my GLM: directional_turn_fit<-glm(rope_complete$rope.directional.change~ rope_complete$rope.X...Sound +offset( log(rope_complete$rope

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

社会主义新天地 提交于 2019-12-11 14:09:09
问题 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). When calling summary(model_name) , is there a way to include a column representing the number of observations within each factor level? 回答1: I have a logistic regression model in R, where all of the predictor variables are categorical rather than continuous. If all your covariates are factors

MCMCglmm data format difficulties

被刻印的时光 ゝ 提交于 2019-12-11 06:06:20
问题 I want to estimate the heritability of animal traits using an animal model. However, I can't figure out how to properly format my data so that MCMCglmm can create a model. After much trial and error and scouring the internet for advice, I'm stuck. To my knowledge, I've formatted the data as suggested by all available resources that I know of, yet I get the following error message:: Error in MCMCglmm(BWT ~ 1, random = ~animal, pedigree = Ped, data = Data, : some levels of animal do not have a

Loop to implement Leave-One-Out observation and run glm, one variable at a time

你离开我真会死。 提交于 2019-12-11 05:50:11
问题 I have a data frame with 96 observations and 1106 variables. I would like to run logistic regression on the observations by leaving one out , one at a time. (So for the first set of observations there would be 95 total with the first observation removed, the second set of observations there would be 95 total with the second observation removed, and so forth so that there are 95 sets of observations that each have one observation left out.) In addition, I would like to run each set of these