全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
1423 1
2019-01-05
我想计算,多元线性回归分析中各个变量的重要程度,就是贡献率"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“




附件列表

data.xls

大小:2.93 KB

 马上下载

我的数据,变量对第一列数据RPR的影响程度

relaimpo.pdf

大小:181.13 KB

 马上下载

包 relaimpo的解释及示例

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2019-2-14 12:05:11
楼主可以考虑用R里的pca求贡献率
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群