当前位置:网站首页>R language mice package error in terms Formula (TMP, simplify = true): the model formula in extractvars is incorrect
R language mice package error in terms Formula (TMP, simplify = true): the model formula in extractvars is incorrect
2022-06-11 17:32:00 【High cold charging】
ExtractVars The model formula in is wrong
mice
mice It can perform multiple imputation for packets containing missing values , And this so-called multiple interpolation method , You need to keep fitting , That is to say, we need ——formula, This error is due to formula There's a problem in
Error reason
Look at an example , I thought it was outrageous
library(mice)
A <- as.data.frame(matrix(0, 6, 7))
A[1, 2] <- NA
mice(A, m=5)
There is no problem with the operation at this time , But if you continue to run
colnames(A) <- c(1:7)
mice(A, m=5)
This will be the result
iter imp variable
1 1 1Error in terms.formula(tmp, simplify = TRUE) :
ExtractVars The model formula in is wrong
Yes , Listing is not good , My guess is that the column names composed of numbers are recognized as numeric Type, not character type . But if you are character The column name of the type , It may not run successfully , The reason is —— Column name is too long !!
This is my mistake in doing a big homework , Because I'm doing biometrics , So the list is very long , Among them the first 3 The column name of the column is like this :[1] “cna_ADAMTS19-AS1”, Results run mice The times mistakenly said that they couldn't find cna_ADAMTS19, In the formation of formula I cut off the list of names , I was shocked .
Fast solutions
If there is one now 1000*100 Data packets of data, And unfortunately , Its column names are not mice() Accept , The processing is as follows :
temp <- matrix(0, 1, dim(data)[2])
temp <- data.frame(temp)
# utilize matrix turn data.frame Default column name for : "V1","V2",···
temp <- colnames(temp)
# Keep the original column name , You can take it back after processing
origin_col <- colnames(data)
colnames(data) <- temp
# At this point, we can do mice 了
mice(data, m=5)
边栏推荐
- 有效的括号---2022/02/23
- 字符串转数值
- Arraylist集合、对象数组
- Authing biweekly news: online application market (5.10-5.22)
- What is the minimum change price of PTA futures? How can PTA futures be safe?
- 6-3 读文章(*)
- mysql 大表的拆分方式
- Analyze which should be tested in PMP and ACP with actual cases? Which is more useful?
- Cs0006 C failed to find metadata file "c:\users\... Problem
- Hands on deep learning - multiple input and output channels in the convolution layer
猜你喜欢

What problems are exposed when all Sohu employees are cheated?

【线上问题】Timeout waiting for connection from pool 问题排查

RecyclerView缓存复用解析,源码解读

GUI guess number game, directly open play

【Mysql】redo log,undo log 和binlog详解(四)

Service学习笔记01-启动方式与生命周期

QLineEdit 设置输入掩码

ffmpeg硬件编解码Nvidia GPU

What subclasses inherit, polymorphism, and upward transformation

DFS and BFS notes (I) breadth first search based on C language
随机推荐
What is the minimum change price of PTA futures? How can PTA futures be safe?
7-2 h0107. Pig-Latin
拜登下令强制推行零信任架构
RecyclerView缓存复用解析,源码解读
搜狐全员遭诈骗,暴露哪些问题?
7-1 均是素数
ffmpeg硬件编解码Nvidia GPU
6-3 读文章(*)
Leetcode力扣刷题
tidb-cdc日志tables are not eligible to replicate
合并K个升序链表---2022/02/26
Export data prompt -- solution to the problem of secure file priv option
The use of histogram function in MATLAB
Analyze which should be tested in PMP and ACP with actual cases? Which is more useful?
论文阅读 dyngraph2vec: Capturing Network Dynamics using Dynamic Graph Representation Learning
有效的括号---2022/02/23
04_特征工程—特征选择
tidb-数据误删恢复的几种方式
Use of forcescan in SQL server and precautions
信息安全数学基础 Chapter 3——有限域(二)