我想计算,多元线性回归分析中各个变量的重要程度,就是贡献率"lmg", 其中Package ‘relaimpo’ 可以解决这个问题,包的解释已上传附件,里面有示例 代码install.packages('relaimpo')install.packages('MASS')
install.packages('boot')
install.packages('survey')
install.packages('grid')
install.packages('Matrix')
install.packages('survival')
install.packages('survival')
install.packages('mitools')
#需要安装的所有包
data(swiss)
# bootstrapping(引导)
bootswiss <- boot.relimp(swiss, b = 100,
type = c("lmg", "last", "first", "pratt"),
rank = TRUE, diff = TRUE, rela = TRUE)
# for demonstration purposes only 100 bootstrap replications
#alternatively, use formula interface
bootsub <- boot.relimp(Fertility~Education+Catholic+Infant.Mortality, swiss,
subset=Catholic>40, b = 100, type = c("lmg", "last", "first", "pratt"),
rank = TRUE, diff = TRUE)
# for demonstration purposes only 100 bootstrap replications
#default output (percentily intervals, as of Version 2 of the package)
booteval.relimp(bootswiss)
plot(booteval.relimp(bootswiss))
#sorted printout, chosen confidence levels, chosen interval method
#store as object
result <- booteval.relimp(bootsub, bty="bca",
sort = TRUE, level=c(0.8,0.9))
#because of only 100 bootstrap replications,
#default bca intervals produce warnings
#output driven by print method
result
#result plotting with default settings
#(largest confidence level, names abbreviated to length 4)
plot(result)
#result plotting with modified settings (chosen confidence level,
#names abbreviated to chosen length)
plot(result, level=0.8,names.abbrev=5)
#result plotting with longer names shown vertically
par(las=2)
plot(result, level=0.9,names.abbrev=6)
#plot does react to options set with par()
#exceptions: mfrow, mar and oma are set within the plot routine itself
#示例代码,其中数据(swiss)是R语言自带数据文件 (瑞典地区不同因素对出生率的影响) 把以上的包安装好,把代码全部复制粘贴就可以得到lmg
我现在的问题是,想把自己的数据带入这个代码中替换瑞典的数据,但是总是出错
我的数据已上传附件, 求其他变量对第一列数据RPR的影响程度 ,求大神帮我把我的数据带进去得出“lmg“
附件列表