我正在尝试运行逻辑回归并不断收到“NA”错误。问题是它说有 NA 的列没有 NA 其全部为 0 或 1。我的代码如下:
#V1=race, V2=momcounts of breast cancer, V3=prstatus, V4=erstatus, V5=her2status, V6=triplenegative, V7=menopause, V8=agemenopause, V9=mentype, V10=mensurg, V11=bmi, V12=eversmok, V13=age, V14=breastfeed, V15=breastfeedmonths, V16=pregnum, V17=birthcount, V18=agefirstpreg,
regressiondata <- as.data.frame(cbind((data[,'race']),(data[,'mom_countsofbreastcancer']),(data[,'prstatus']),(data[,'erstatus']),(data[,'her2status']),(data[,'triplenegative']),(data[,'menopause']),(data[,'agemenopause']),(data[,'mentype']),(data[,'mensurg']),(data[,'bmi']),(data[,'eversmok']),(data[,'age']),(data[,'breastfeed']),(data[,'breastfeedmonths']),(data[,'pregnum']),(data[,'birthcount']),(data[,'agefirstpreg'])), stringsAsFactors=F)
dataAA=regressiondata[regressiondata$V1==2,] #AA
glm(V6 ~ V2+V7+V8+V10+V11+V12+V13+V14+V15+V16+V17+V18, family=binomial, data=dataAA)
我也尝试了 lm() ,但仍然出现错误:
lm(formula=V6~V2+V7+V8+V10, data=dataAA)
错误:
Coefficients:
(Intercept) V2 V7 V8 V10 V11
1326.433 -17.262 NA -31.174 -34.108 0.525
V12 V13 V14 V15 V16 V17
2.281 11.060 NA 1.154 -50.258 NA
V18
-12.277
Degrees of Freedom: 12 Total (i.e. Null); 3 Residual
(1474 observations deleted due to missingness)
Null Deviance: 16.05
Residual Deviance: 3.49e-10 AIC: 20
Warning message:
glm.fit: fitted probabilities numerically 0 or 1 occurred