【问题标题】:Using Simex Package to Correct for Measurement Error使用 Simex 软件包纠正测量误差
【发布时间】:2019-02-20 00:56:15
【问题描述】:

我正在尝试使用 simex 包 R 中的测量误差模型的 MCSIMEX 算法来纠正潜在类分配中的错误。有 8 个潜在类别,我使用最可能的类别成员的平均潜在类别概率来创建误差矩阵以 simex 分类变量。我使用此 [example][1] 中的适当 R 代码实现了分析。当我运行分析时,我收到以下错误消息:“mcsimex 中的错误(naive,mc.matrix = Data600,SIMEXvariable = “Class”):mc.matrix 可能包含小于 1 的指数的负值”。有人可以帮忙吗这个?我包含了一些虚假数据,让您了解我想要完成的工作。

## Create Data set 
Y = sample(x=30:100, size = 500, replace= TRUE) ## Outcome variable
Class = sample(x=1:8, size=500, replace=TRUE) #Class membership variable
X2 = sample(x=0:100, size=500, replace=TRUE)## Control variable 
Data=cbind(Class, X2, Y)

Data2=as.data.frame(Data)

## Build matrix containing probabilities of most likely class membership
p6 <- matrix(c(0.852086,    0.002081,   0.145126,   0.000000,   0.000000,   0.000706,   0.000000,   0.000002,
               0.016235,    0.983277,   0.000453,   0.000034,   0.000000,   0.000001,   0.000000,   0.000000,
               0.001904,    0.000025,   0.992375,   0.000000,   0.000000,   0.005629,   0.000004,   0.000063,
               0.000010,    0.000001,   0.073121,   0.926070,   0.000002,   0.000001,   0.000793,   0.000001,
               0.000004,    0.000454,   0.005430,   0.025924,   0.926010,   0.040839,   0.000002,   0.001338,
               0.007274,    0.000003,   0.000294,   0.004842,   0.000000,   0.987587,   0.000000,   0.000000,
               0.000839,    0.325729,   0.270084,   0.001621,   0.000001,   0.000115,   0.401590,   0.000022,
               0.000000,    0.000000,   0.000750,   0.000000,   0.000000,   0.000013,   0.000000,   0.999237), 
             nrow = 8, byrow=FALSE)

check.mc.matrix(list(build.mc.matrix(p6)))


dimnames(p6) <- list(levels(Data2$Class),levels(Data2$Class))

## Check Data Structure 
str(Data2)

## Specify Class Variable as factor and other variables as numeric 
Data2$Class=as.factor(Data2$Class)

Data2$X2= as.numeric(Data2$X2)
Data2$Y= as.numeric(Data2$Y)

##Estimate Naive model 
naive=glm(Y ~., family=gaussian, data=Data2, x=T, y=T)

summary(naive)



##Model accounting for classification error
mod.Dis <- mcsimex(naive, mc.matrix = p6, SIMEXvariable = "Class")


  [1]: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.503.9789&rep=rep1&type=pdf

【问题讨论】:

  • 能否请您添加导致错误的代码?
  • @Heidi。我用我使用的代码更新了问题。谢谢。

标签: r measurement


【解决方案1】:

抱歉耽搁了。问题在于您的矩阵:

您使用build.mc.matrix() 来检查您的矩阵,但您使用“朴素”的 mc-matrix 进行估计。

如果你构建了一个修正后的 mc-matrix,一切运行顺利:

new_mc_matrix <- build.mc.matrix(p6)
dimnames(new_mc_matrix) <- list(levels(Data2$Class),levels(Data2$Class))

mod.Dis <- mcsimex(naive, mc.matrix = new_mc_matrix, SIMEXvariable = "Class")

最好的问候

沃尔夫冈

【讨论】:

    猜你喜欢
    • 2016-02-24
    • 2010-09-13
    • 2013-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-12
    • 1970-01-01
    相关资源
    最近更新 更多