问题描述
我是 R 的初学者,目前正在使用 R 的贝叶斯网络分析结果。我有这段代码,将结果作为概率及其 95% 的凭证间隔。
这是我使用的代码示例,用于在给定吸烟状况和社会阶层的情况下预测当前哮喘。我想要的是一种将我从两个查询中得到的结果组织到一个表中的方法。我有大约 48 个查询,复制和粘贴所有查询的结果既乏味又耗时。有什么帮助吗?
## probability of current asthma among non smoker in social class 1##
> cpquery(fitted.simpler_mice_hc,event = (c_asthma == 1),evidence = (smoking_status == 0 & sei_class==1),n=100000)
[1] 0.09212951
> run_1<- replicate(100,cpquery(fitted.simpler_mice_hc,n=100000))
>
> # to get the sampling quantile interval
> quantile(run_1,c(0.05,0.975))
5% 97.5%
0.08218354 0.09254333
> ### non smokers in sei2,age,gender,diabtets,dust and hypertension###
> cpquery(fitted.simpler_mice_hc,evidence = (smoking_status == 0 & sei_class==2),n=100000)
[1] 0.08623836
>
> run_2 <- replicate(100,n=100000))
>
> # to get the sampling quantile interval
> quantile(run_2,0.975))
5% 97.5%
0.08279396 0.09144179
在第一个查询中,0.09212951 是概率,0.08218354 0.09254333 是区间上下限,如何将这些查询组织成表格或易于使用 excel 处理的内容,而不是复制和粘贴每个?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)