R error message about variable lengths
Posted
by Abraham
on Stack Overflow
See other posts from Stack Overflow
or by Abraham
Published on 2010-03-23T13:57:05Z
Indexed on
2010/03/23
14:43 UTC
Read the original article
Hit count: 277
Filed under:
r
I ran the following code in order to recode the variable. Unfortunately, when I move to run an logit model (using the Zelig package), I get an error message that the variable length differ for this variable.
## Independent Variable - Partisanship (ANES 2004)
data04$V043114
part <- data04$V043114
attributes(part)
summary(part)
partb < part
partb[part %in% levels(part)[4]] <- NA
partb[part %in% levels(part)[5]] <- NA
partb[part %in% levels(part)[6]] <- NA
partb[part %in% levels(part)[7]] <- NA
partb <- factor(partb)
attributes(partb)
summary(partb)
table(partb)
table(part, partb)
cbind(part, partb)
partisan041 <- partb
partisan042 <- as.numeric(partb)
summary(partisan041)
summary(partisan042)
## Regression Model - ANES 2004 ##
anes04one <- zelig(trade041a ~ age042 + education042 + personal042 + economy042 + partisan042 + employment042 + union042 + home042 + market042 + race042 + income042 + gender042, model="logit", data=data04)
summary(anes04one)
#Error in model.frame.default(formula = trade041a ~ age042 + education042 + :
# variable lengths differ (found for 'partisan042')
© Stack Overflow or respective owner