Nicole Marie Ford
2012-Mar-10 05:58 UTC
[R] problem with effects : 'subscript out of bounds'
hello. help with effects plots. here's the last bit of code before running the model and then the effects, then the error. nor.dem <- norway$v162 ## nor.dem is my DV & it is continuous. nor.dem <- as.numeric(nor.dem)-5 str(nor.dem) (i had to do a great deal of coding here so i am snipping down to the end) tmp[which(norway$v128 == "trust completely" & norway$v127 == "trust completely")] <- "generalized" tmp <- factor(tmp, levels=c("particular", "generalized", "other")) norway$trust <- tmp nor.trust <- as.factor(norway$trust) #### nor.trust is my IV, a factor as you can see. n.diversity <- norway$v221 ## control n.net <- norway$v228 ##control (there are others but they were coded the same) n.mod1 <- lm(nor.dem ~ nor.trust + n.diversity + n.age + n.sex + n.educ + famecon + n.net) ### linear model. all of these variables already are specific to the dataset which i called 'norway' so there is no need to specify in the model. summary(n.mod1)> plot(effect("nor.trust", n.mod1), multiline=T)Error in plot(effect("nor.trust", n.mod1), multiline = T) : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in apply(mod.matrix[, components], 1, prod) : subscript out of bounds ~~this ran perfectly on my previous dataset so i am unsure of the issue. thanks in advance.
Nicole Marie Ford
2012-Mar-10 06:20 UTC
[R] problem with effects : 'subscript out of bounds'
if that is not specific (or not general) enough: newDV <- dat$DV ## newDV is my DV & it is continuous. newDV <- as.numeric(newDV)-5 str(newDV) (i had to do a great deal of coding here so i am snipping down to the end) tmp[which(dat$v1 == "stuff" & dat$v2 == "more stuff")] <- "lots of stuff" tmp <- factor(tmp, levels=c("la", "la la", "fa la la")) dat$v3 <- tmp newIV <- as.factor(dat$v3) #### newIV is my IV, a factor as you can see. n.var4 <- dat$v4 ## control n.var5 <- dat$v5 ##control (there are others but they were coded the same) n.mod1 <- lm(newDV ~ newIV + v4 + v5 + v6 + v7 + v8 + v9, data=dat) ### linear model. all of these variables already are specific to the dataset which i called 'norway' so there is no need to specify in the model. summary(n.mod1)> plot(effect("newIV", n.mod1), multiline=T)Error in plot(effect("nor.trust", n.mod1), multiline = T) : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in apply(mod.matrix[, components], 1, prod) : subscript out of bounds ~~this ran perfectly on my previous dataset so i am unsure of the issue. thanks in advance. ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.