#object: 元分析中的回归模型 #writer: mike1 #time: 2020,11,16 data <- read.csv("C:\Users\mike1\Desktop\大三人格与幸福感\dataOfTotal.csv",header = T,sep=",") print(colnames(data)) #返回整体数据的缺失值的坐标 print(sum(is.na(data[,'内外倾']))) #返回某一列数据的缺失值的坐标,这里没有纵坐标 print(which(is.na(data[,"内外倾"]),arr.ind = T)) #这是建立了一个副本,并且只有一列 data2 <- na.omit(data[,"内外倾"]) head(data2) #删除一行数据,负数后面只能用数字表示,不能用字符串表示 data3 <- data[-15,] print(rownames(data3)) library("meta") #查看是否有缺失值 print(sum(is.na(data3[,"样本特征"]))) #查看数据的长度 length(data3[,"内外倾"]) #执行具体的函数,在这里变量不能有引号 res <- metacor(n=被试数,cor=内外倾,sm="ZCOR",data=data3) print(res) #进行回归分析,这里不用加上data,因为,上一个结果中已经有了数据集 regression <- metareg(res,回归变量) print(regression) #画出回归图形 bubble(regression) #画出关于调节变量的回归系数的图 pdf(file="C:\users\mike1\desktop\forest3.pdf", width = 20, height = 20) forest(res) dev.off()
产生的结果是:
Mixed-Effects Model (k = 40; tau^2 estimator: DL)
tau^2 (estimated amount of residual heterogeneity): 0.0179 (SE = 0.0057)
tau (square root of estimated tau^2 value): 0.1336
I^2 (residual heterogeneity / unaccounted variability): 87.74%
H^2 (unaccounted variability / sampling variability): 8.15
R^2 (amount of heterogeneity accounted for): 0.00%
Test for Residual Heterogeneity:
QE(df = 38) = 309.8582, p-val < .0001
Test of Moderators (coefficient 2):
QM(df = 1) = 0.0068, p-val = 0.9342 这两个异质性检验是什么意思?
Model Results:
estimate se zval pval ci.lb ci.ub
intrcpt 0.3432 0.0262 13.1090 <.0001 0.2919 0.3945 ***
回归变量 -0.0000 0.0001 -0.0826 0.9342 -0.0002 0.0002
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
有结果可以看出,回归系数是不显著的, 估计值 几乎为0
图形的结果为: