r语言多重插补

r语言多重插补

inputfile<-read.csv(“F:/rstudiospace/2019.3.7.csv”, header = TRUE)
View(inputfile)
is.na(inputfile) # 判断是否存在缺失
n <- sum(is.na(inputfile)) # 输出缺失值个数
n
par(mfrow = c(1, 2))
dotchart(inputfile$ET)

boxplot(inputfile$ET, horizontal = TRUE)

inputfile$ET[38] = NA
fix(inputfile)
library(lattice)
library(MASS)
library(nnet)
library(mice)
imp <- mice(inputfile, m = 4)
fit <- with(imp,lm(ET ~ time, data = inputfile))
pooled <- pool(fit)
summary(pooled)
result4 <- complete(imp, action = 3)

查看结果:
(1)imp i m p imp impET
(2)with对象。利用其他模型
(3)pool对象。summary之后,展示lm系数;
(4)complete对象,完整展现数据集

结果分析:
Estimate Std. Error t value Pr(>|t|)

估值,标准误差,T值,P值

你可能感兴趣的:(r语言多重插补)