Hi,cbw1243, 您好!
最近一直在折腾一份非平衡面板数据的回归分析,有一个错误一直调试不好,特来求助。
我的数据集结构如下:
> str(stockbrcha)
Classes ‘plm.dim’ and ‘data.frame’: 27496 obs. of 25 variables:
$ tic : Factor w/ 2946 levels “A”,”AA”,”AAL”,..: 1 1 1 1 1 1 1 1 1 1 …
$ date : Factor w/ 16871 levels “1/25/09 2:35”,..: 773 808 833 846 869 922 942 957 985 1014 …
$ IS_EFFECTIVE : num 1 1 1 1 1 1 1 1 1 1 …
$ MATERIAL_WEAKNESS : num 1 0 0 0 0 0 0 0 0 0 …
$ SIG_DEFICIENCY : num 0 0 0 0 0 0 0 1 0 0 …
$ NOTEFF_ACC_RULE : int 1 0 0 0 0 0 0 0 0 0 …
$ NOTEFF_FIN_FRAUD : int 0 0 0 0 0 0 0 0 0 0 …
$ NOTEFF_OTHER : int 5 0 0 0 0 0 0 5 0 0 …
$ IC_OP_TYPE : int 1 1 1 1 1 1 1 1 1 1 …
$ AUDITOR_FKEY : int 1 1 1 1 1 1 1 1 1 1 …
$ AUDITOR_AGREES : num 1 1 0 0 0 0 0 0 0 1 …
$ COMBINED_IC_OP : num 0 1 1 0 1 1 1 1 0 1 …
$ IC_IS_EFFECTIVE : num 1 1 1 1 1 1 1 1 1 1 …
$ AUDIT_FEES : num 10730000 7176000 6142000 6647000 5663000 …
$ NON_AUDIT_FEES : int 3761000 5616000 970339 758000 2599000 1037000 820000 390000 1011000 2352000 …
$ BENEFITS_FEES : int 0 0 0 0 0 0 0 0 0 0 …
$ IT_FEES : int 0 0 0 0 0 0 0 0 0 0 …
$ TAX_FEES : int 308000 742000 662039 503000 169000 742000 720000 285000 245000 265000 …
$ AUDIT_RELATED_FEES: int 3443000 4863000 253300 252000 2422000 288000 97000 105000 762000 1695000 …
$ OTHER_FEES : int 10000 11000 55000 3000 8000 7000 3000 0 4000 392000 …
$ mean : num 1176 1176 1176 1176 1176 …
$ sd : num 202 202 202 202 202 …
$ shape : num 16.9 16.9 16.9 16.9 16.9 …
$ rate : num 0.0141 0.0141 0.0141 0.0141 0.0141 …
$ ddate : Factor w/ 16871 levels “1/25/09 2:35”,..: 773 808 833 846 869 922 942 957 985 1014 …
需要执行的命令如下:
> stockbrcha = plm.data(stockbrcha, indexes = NULL) %把数据转化成适合面板分析的数据
> form = stockbrcha$mean ~ stockbrcha$IS_EFFECTIVE+stockbrcha$MATERIAL_WEAKNESS+stockbrcha$SIG_DEFICIENCY+stockbrcha$AUDITOR_AGREES+stockbrcha$COMBINED_IC_OP+stockbrcha$IC_IS_EFFECTIVE+stockbrcha$AUDIT_FEES %回归公式
> ptest = plm(form,data = stockbrcha,effect = “individual”, model = “within”) % 固定效应面板分析
执行错误如下:
series IC_OP_TYPE, IT_FEES are constants and have been removed
Error in names(y) <- namesy :
‘names’ attribute [27496] must be the same length as the vector [0]
我也traceback()了一下,显示:
> traceback()
4: pmodel.response.pFormula(formula, data, model = model, effect = effect,
theta = theta)
3: pmodel.response(formula, data, model = model, effect = effect,
theta = theta)
2: plm.fit(formula, data, model, effect, random.method, random.dfcor,
inst.method)
1: plm(form, data = stockbrcha, effect = “individual”, model = “within”)
BUT我看不懂……
一开始我以为是因为我有的变量缺失值太多,导致各个变量之间长度不一。所以我就把缺失值全都填补了,可是错误仍然存在。也用length()命令查询过所有的变量,长度明明都是27496啊。
我需要用公式里的七个自变量来预测因变量Y,之前我已经执行过类似的公式,当时面板分析是可以做的,没有error,只是R方太低,所以我就换了一个因变量。
google了很多网页,情况都跟我的不同。特发帖求助,先谢过!
Any help will be highly appreciated!
THX!
Lijuan Huang
Xidian University