运行npreg时出现错误消息

时间:2015-06-06 10:59:39

标签: r

我正在使用R np包文档中的npreg示例(由T. Hayfield,J。Racine编写),第3.1节“单变量回归”。

library("np")
data("cps71")
model.par = lm(logwage~age + I(age^2),data=cps71)
summary(model.par)
#
attach(cps71)
bw = npregbw(logwage~age) # thislne not in example 3.1
model.np = npreg(logwage~age,regtype="ll", bwmethod="cv.aic",gradients="TRUE",        
+ data=cps71)

这直接从示例中复制,但npreg调用会导致错误消息

 *Rerun with Debug
 Error in npreg.rbandwidth(txdat = txdat, tydat = tydat, bws = bws, ...) : 
  NAs in foreign function call (arg 15)   
In addition: Warning message:
In npreg.rbandwidth(txdat = txdat, tydat = tydat, bws = bws, ...) :
  NAs introduced by coercion*

npreg R文档表明第一个参数应该是BW特定的。我尝试设置bws = 1

model.np = npreg(bws=1,logwage~age,regtype="ll", 
 + bwmethod="cv.aic",gradients="TRUE", data=cps71)

会出现以下错误

*Error in toFrame(xdat) : 
  xdat must be a data frame, matrix, vector, or factor*  

首次使用R中的密度估算。请建议如何解决这些错误。

0 个答案:

没有答案
相关问题