1

I have an unexpected error in my research. Let me show you several code chunks from my research. Hope, you'll help me.

I have two binary variables: alco and smoke that were generated like this:

smoke<- factor(with(df, ifelse((q34<2),1,0)))
alco<-factor(with(df, ifelse((q47==1), 1,0)))
df<- cbind(df, smoke, alco, educ_3, smoke_14)

I tried to analyse a model using zeligverse package

m3<-zelig(cbind(smoke,alco) ~ fem+age+age2+smoke_14+ninc,  model = "blogit", data = df)

that lead to the mistake

Error in eval(process.binomial2.data.VGAM) : response must contains 0's and 1's only

I couldn't get it as variables in cbind are binominal.

mischva11
  • 2,811
  • 3
  • 18
  • 34
  • The error is telling you that the two response variables should be zero and ones - so try not converting them to factor but leaving them as 0/1 – user20650 Jun 09 '18 at 20:40
  • if doing `cbind(smoke,alco)` is valid as a response variable as per your model. then I think `smoke` or `alco` may have NA's. – A. Suliman Jun 09 '18 at 21:06

1 Answers1

0

It would be good to know what you are trying to fit and how your data look like. Here there are some guidelines to ask good questions.

I assume you are trying to run a (binary) logit. If so glm() can estimate such a model

For example:

df = data.frame(x = factor(sample(0:1, 25, replace = TRUE)), 
                y = factor(sample(1:4, 25, replace = TRUE)), 
                z = sample(18:65, 25, replace = TRUE))


summary(glm(x ~ y + z, family = binomial(link = "logit"), 
            data = df))

If you have more than two categories in your outcome variable and they are ordered. clm() from ordinal package can be an option:

 library(ordinal)

 summary(clm(y ~ x + z, data = df, link = "logit")

I hope it helps

Edu
  • 903
  • 6
  • 17
  • Edu ; this seems to be the model the op is fitting http://docs.zeligproject.org/articles/zeligchoice_blogit.html – user20650 Jun 09 '18 at 20:42