全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
5125 5
2018-06-05
> #####MCAR
> library(simFrame)
Loading required package: Rcpp
Loading required package: lattice
Loading required package: parallel
Warning messages:
1: package ‘simFrame’ was built under R version 3.4.4
2: package ‘Rcpp’ was built under R version 3.4.4
> bar<-rnorm(100,10,1)    #situmlation data
> nc<-NAControl(NArate=0.2)   #set missing rate
> x<-setNA(bar,nc)    #insert into missing data from bar
Error in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function ‘setNA’ for signature ‘"numeric", "NAControl"’

如上,本人想用r中的simFrame包来模拟缺失,完全随机缺失MCAR,到缺失比例这一步还是可以的,可是下面这一句报错,不知道该如何解决?
> x<-setNA(bar,nc)    #insert into missing data from bar
Error in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function ‘setNA’ for signature ‘"numeric", "NAControl"’
本人还处于入门级别的菜鸟,请各位大神多多指教。

或者有没有其他方法可以模拟数据的缺失,MCAR,我的研究是先生成一个完整矩阵,再设置缺失比例,生成缺失矩阵,之后进行分析。
求帮助!



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2018-6-5 19:38:07
I think your NAControl function lacks of a target.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2018-6-6 20:42:42
hifinecon 发表于 2018-6-5 19:38
I think your NAControl function lacks of a target.
谢谢~
我试一下~
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2018-6-6 21:50:06
good luck!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2018-6-8 09:09:57
hifinecon 发表于 2018-6-5 19:38
I think your NAControl function lacks of a target.
bar2<-as.data.frame(bar) 然后x<-setNA(bar2,nc)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2018-6-8 09:10:36
setNA(x, control, ...)

## S4 method for signature 'data.frame,NAControl'
setNA(x, control, i)
Arguments

x       
the data in which missing values should be inserted.
control       
a control object inheriting from the virtual class "VirtualNAControl" or a character string specifying such a control class (the default being "NAControl").
i       
an integer giving the element or row of the slot NArate of control to be used as missing value rate(s).
...       
if control is a character string or missing, the slots of the control object may be supplied as additional arguments. See "NAControl" for details on the slots.

Methods

x = "data.frame", control = "character"
set missing values using a control class specified by the character string control. The slots of the control object may be supplied as additional arguments.

x = "data.frame", control = "missing"
set missing values using a control object of class "NAControl". Its slots may be supplied as additional arguments.

x = "data.frame", control = "NAControl"
set missing values as defined by the control object control.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群