tags:

views:

298

answers:

1

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')
A: 

Sorry, I'm a novice, so please bear with me.

I've checked length(partisan042) and the lengths of other variables, and they are the same

however dim(data04) gives me NULL

I haven't rerun the model yet, but I don't have my data on this computer.

Abraham
It suggests that `data04` is not a `data.frame`. Check `class(data04)` or even better `str(data04)`. On other hand if your variables are "standalone" vectors in workspace then you don't need a `data` argument in `zelig` (you could try run without it). And it's better to edit your question than add answer with details.
Marek