효과 패키지를 사용하여 로지스틱 회귀 모델의 예상 확률을 보여주는 일부 확률 그래프를 작성합니다. 그러나 이상한 오류 메시지가 표시되고 문제점을 알지 못합니다 입니다.효과 패키지를 사용할 때 "첨자가 범위를 벗어남"
플롯을 생성하려고하면 다음 오류가 발생합니다. 경고는 문제가 아니며 오류 메시지가 무엇을 말하고 있는지 이해할 수 없습니다.
library(effects)
dat$won_ping = as.factor(dat$won_ping)
mod2 = glm(won_ping ~ our_bid +
age_of_oldest_driver2 +
credit_type2 +
coverage_type2 +
home_owner2 +
vehicle_driver_score +
currently_insured2 +
zipcode2,
data=dat, family=binomial(link="logit"))
> plot(effect("our_bid*vehicle_driver_score", mod2), rescale.axis=FALSE, multiline=TRUE)
Warning message:
In analyze.model(term, mod, xlevels, default.levels) :
our_bid:vehicle_driver_score does not appear in the model
Error in plot(effect("our_bid*vehicle_driver_score", mod2), rescale.axis = FALSE, :
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
여기 내 데이터에 대한 정보가 그리고 내 GLM 명령 :
> str(dat)
'data.frame': 85240 obs. of 71 variables:
$ our_bid : num 155 123 183 98 108 159 98 123 98 200 ...
$ won_ping : Factor w/ 2 levels "0","1": 1 1 2 1 1 1 1 1 1 1 ...
$ zipcode2 : Factor w/ 4 levels "1:6999","10000:14849",..: 4 3 2 1 3 2 3 1 2 2 ...
$ age_of_oldest_driver2 : Factor w/ 4 levels "18 to 21","22 to 25",..: NA 3 NA NA NA NA 3 NA 3 NA ...
$ currently_insured2 : Factor w/ 2 levels "0","1": 2 1 2 2 1 1 2 2 1 1 ...
$ credit_type2 : Ord.factor w/ 4 levels "POOR"<"FAIR"<..: 2 3 2 3 2 2 1 3 3 2 ...
$ coverage_type2 : Factor w/ 4 levels "BASIC","MINIMUM",..: 4 3 3 3 3 3 3 3 4 3 ...
$ home_owner2 : Factor w/ 2 levels "0","1": 1 2 2 2 2 2 2 2 2 2 ...
$ vehicle_driver_score : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
을 그리고 마지막으로, 여기에 몇 가지 유용한 정보가 될 수 있습니다
> sessionInfo()
R version 2.14.0 (2011-10-31)
Platform: x86_64-pc-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] effects_2.2-1 colorspace_1.1-1 nnet_7.3-1 MASS_7.3-16 lattice_0.20-0 foreign_0.8-46
loaded via a namespace (and not attached):
[1] tools_2.14.0
도와주세요! 오류 메시지의 의미는 무엇입니까? 일반적으로 "첨자가 범위를 벗어났습니다"라는 것은 해당 데이터 구조의 범위를 벗어나는 것을 선택한다는 것을 의미하지만 단순히 발생하지는 않습니다.
는 편집 : 제가 위에서 말했듯이
이
을 @Rowland하려면, 경고 및 오류 메시지는 별도의와 관련이 없습니다. 이 전 zipcode2을 꺼내 GLM을 실행한다고 가정 해 봅시다 :
이mod2 = glm(won_ping ~ our_bid +
age_of_oldest_driver2 +
credit_type2 +
coverage_type2 +
home_owner2 +
vehicle_driver_score +
currently_insured2,
data=dat, family=binomial(link="logit"))
> plot(effect("our_bid*home_owner2", mod2), rescale.axis=FALSE, multiline=TRUE)
Warning message:
In analyze.model(term, mod, xlevels, default.levels) :
our_bid:home_owner2 does not appear in the model
이 내가 원하는 결과를 얻을로 괜찮 바로 경고를 생성합니다. 따라서 ":"이 모델에 나타나지 않는다는 것은 문제가 아니며 오류 메시지가 나타나지 않습니다.
맞습니다. 경고에서 직접 오류가 발생하지 않습니다. 그러나, 나는 여전히 그들이 관련 될 수 있다고 생각합니다. 상호 작용을 포함 시키면 GLM에 맞출 수 있습니까? – Roland
그래, 상호 작용을 추가하면 잘 실행됩니다. – ATMathew