可视化分层病例对照研究图(使用R语言)

可视化分层病例对照研究图(使用R语言)

研究者经常使用可视化工具来展示分层病例对照研究的结果。R语言是一种功能强大的统计分析和可视化工具,提供了丰富的包和函数来创建各种类型的图表。本文将介绍如何使用R语言来创建分层病例对照研究图。

首先,我们需要准备数据。假设我们有一个分层病例对照研究,其中包含了两个变量:病例/对照状态(case/control)和分层变量(stratum)。我们将使用以下代码生成一个示例数据集:

# 创建示例数据集
set.seed(1)
n <- 100
data <- data.frame(
  case_control = sample(c("Case", "Control"), n, replace = TRUE),
  stratum = sample(c("Stratum1", "Stratum2", "Stratum3"), n, replace = TRUE)
)

现在,我们可以开始创建可视化图表了。下面是一些常见的分层病例对照研究图的示例:

  1. 分层柱状图
library(ggplot2)

# 创建分层柱状图
plot <- ggplot(data, aes(x = stratum, fill = case_control)) +
  geom_bar(position = "fill") +
  labs(title = "分层病例对照研究分层柱状图", x = "分层变量", y = "比例") +
  theme_minimal()

#
【R语言实战】病例对照研究中的年龄性别频数匹配:从数据分层到样本精准挑选 本文详细介绍了在R语言中实现病例对照研究中的年龄性别频数匹配方法,从数据分层到样本精准挑选的全流程。通过实际代码示例和案例分析,帮助研究者掌握如何有效控制混杂变量,确保病例组和对照组在关键变量上的分布一致,为流行病学研究提供可靠的数据基础。 阅读详情

相关推荐

R语言dplyr包和tidyr包创建交叉表(列联表、crosstab)实战

R语言dplyr包和tidyr包创建交叉表(列联表、crosstab)实战 目录 R语言dplyr包和tidyr包创建交叉表(列联表、crosstab)实战 #dplyr包和tidyr包创建交叉表(列联表、crosstab)的语法 #仿真数据 #dplyr包和tidyr包创建交叉表(列联表、crosstab) #dplyr包和tidyr包创建交叉表(列联表、crosstab)交换行和列 #dplyr包和tidyr包创建交叉表(列联表、crosstab)的语法 df %>%

data+scenario+science+insight 2193

R语言两个时间序列数据的滞后相关性可视化:使用forecast包的ccf函数绘制交叉相关函数,根据可视化结果分析滞后相关性

R语言两个时间序列数据的滞后相关性可视化:使用forecast包的ccf函数绘制交叉相关函数,根据可视化结果分析滞后相关性

statistics+insight+vista+power 2501

可视化分组层次线图 R 语言

分组层次线图,又称阶梯线图,适用于展示不同组别之间的分布情况,并凸显各组别之间的差异。除了基础的分组层次线图外,ggplot2 还提供了丰富的绘图功能和主题样式的定制选项,可以根据需要进行进一步调整和美化。在这个例子中,我们将标题设为 “销售额分组层次线图”,x 轴标签设为 “月份”,y 轴标签设为 “销售额”。假设我们有一个数据集,其中包含了三个不同地区(A、B 和 C)的销售额数据,每个地区有五个月份的数据。运行上述代码,我们就能够得到一个美观的分组层次线图,展示了三个地区五个月份的销售额数据。

DevCharm的博客 303

R语言使用epiDisplay包的mhor函数检验两个分类变量在调整(控制)第三个变量的情况下是否独立、计算优势比、可视化分层病例对照研究图(Cochran-Mantel-Haenszel检验)

R语言使用epiDisplay包的mhor函数检验两个分类变量在调整(控制)第三个变量的情况下是否独立、计算优势比(odds ratio)、可视化分层病例对照研究图(Cochran-Mantel-Haenszel检验)

statistics+insight+vista+power 581

R语言使用table函数计算列联表(三维维频数表)、使用epiDisplay包的mhor函数检验两个分类变量在调整(控制)第三个变量的情况下是否独立、计算优势比、可视化分层病例对照研究图(CMH检验)

R语言使用table函数计算列联表(三维维频数表)、使用epiDisplay包的mhor函数检验两个分类变量在调整(控制)第三个变量的情况下是否独立、计算优势比、可视化分层病例对照研究图(Cochran-Mantel-Haenszel检验)

statistics+insight+vista+power 837

R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用stress.labels参数在可视化图像中为强调线添加标签信息

R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用stress.labels参数在可视化图像中为强调线添加标签信息

statistics+insight+vista+power 387

R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用stress参数指定用于绘制强调线的id子集

R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用stress参数指定用于绘制强调线的id子集

statistics+insight+vista+power 395

R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图

R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图

statistics+insight+vista+power 254

R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用n.of.lines参数指定显示的病例数

R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用n.of.lines参数指定显示的病例数

statistics+insight+vista+power 360

R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用by参数指定不同分组(治疗方案)曲线使用不同的颜色

R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用by参数指定不同分组(治疗方案)曲线使用不同的颜色

statistics+insight+vista+power 359

R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、自定义设置line.col参数为multicolor指定多条可视化曲线的颜色渐变

R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、自定义设置line.col参数为multicolor指定多条可视化曲线的颜色渐变

statistics+insight+vista+power 288

R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用stress.col参数指定强调线的id子集的颜色(色彩)

R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用stress.col参数指定强调线的id子集的颜色(色彩)

statistics+insight+vista+power 366

R语言病例对照分析实战:从OR计算到PPT可视化

病例对照研究是流行病学中识别疾病暴露关联的基础设计,其核心在于通过比值比(OR)量化暴露与疾病的统计关联,并借助多因素logistic回归控制混杂偏倚。该方法不直接估计发病率,但具备高效筛选高危因素、支撑病因假设生成的技术价值,广泛应用于临床回顾性数据挖掘、电子病历驱动的病因初筛及队列研究前期设计。实践中,R语言凭借可复现性与epiDisplay等专业包支持,成为实现单因素筛查、多变量调整、森林图可视化及敏感性验证的主流工具。本文聚焦真实项目落地场景,详解数据清洗要点、OR解读陷阱、模型诊断指标及PPT级图

weixin_29053073的博客 255

判断两个多边形是否相交(java实现)

判断两个多边形是否相交 ,当前认为一个点相交也是相交,可针对凹多边形和凸边型等多复杂的多边形进行相交判断,采用java实现,因为网上java实现的比较少,所以这里写下如何实现,适用于碰撞检测,地图等等应用场景

IT_CREATE的博客 5844

AD24-层次原理图的设计

4)在原理图关联对话框中双击需要放置方块图的子图,即激活方块图的放置,单击母图的空白处进行放置。3)设计-Create Sheet From Sheet,进入原理图关联对话框。4)放置-添加图纸入口,放置方块图的内部I/O端口并进行名称更改。2)放置-页面符,放置页面符,并执行Table完成属性设置。5)执行Ctrl+W,端口和内部I/O端口对应连接。1)创建一个工程并完成子图的每页原理图的设计。1)新建项目,创建Main原理图页。3)放置-的端口,放置方块图的端口。以上,就是层次原理图页的设计。

qq_52761962的博客 4921

task5:在本地搭建大模型(ollama 和 LM studio 对比),接入 openclaw

关于大模型,大家千万不要想着在本地部署,根本不可行,没有那个财力。另外大模型迭代快,不可能每周都在下载大模型。再次,还是国外的模型好用,国内的模型真的在 deepresearch 上就有很大问题,你们懂的。所以本篇文章,还是聚焦在探索层面+实操,并不会实战。

这里是 AI 食用指南,持续分享有用的AI 实操和应用! 1968

ESP32-CAM+STM32实战:5步搞定无线图像传输到TFT屏(附完整代码)

本文详细介绍了如何利用ESP32-CAM和STM32实现无线图像传输到TFT屏幕的完整方案。通过5个关键步骤,包括硬件连接、ESP32-CAM配置、STM32数据接收、TFT屏幕驱动及系统优化,开发者可以快速构建高效的图像传输系统。特别介绍了RGB565格式的处理技巧,并提供了完整的代码实现,适用于智能家居、工业监控等多种应用场景。

weixin_30316097的博客 484

操作系统实验四 进程运行轨迹的跟踪与统计(哈工大李治军)

实验4 进程运行轨迹的跟踪与统计 实验目的 掌握 Linux 下的多进程编程技术; 通过对进程运行轨迹的跟踪来形象化进程的概念; 在进程运行轨迹跟踪的基础上进行相应的数据统计,从而能对进程调度算法进行实际的量化评价,更进一步加深对调度和调度算法的理解,获得能在实际操作系统上对调度算法进行实验数据对比的直接经验。 实验内容 进程从创建(Linux 下调用 fork())到结束的整个过程就是进程的生命期,进程在其生命期中的运行轨迹实际上就表现为进程状态的多次切换,如进程创建以后会成为就绪态;当该进程被调度以

leoabcd12的博客 4653

【uni-app】PDA扫码枪获取扫码数据APP(通俗易懂),聚焦频繁弹软键盘输入法等各种坑完美解决方法,附完整代码

uniapp PDA扫码枪获取扫码数据APP(通俗易懂),频繁弹软键盘等各种坑完美解决方法

coderYYY的博客 7418

RT-DETR-R18 上下文信息融合:引入全局特征提升遮挡目标检测

"""轻量化全局特征提取器(2层Transformer编码器)"""# 特征投影层(将多尺度特征统一维度)# 轻量化Transformer编码器(分组卷积优化)# 全局特征池化(输出 [bs, hidden_dim])# local_features: 多尺度特征列表 [C3, C4, C5],各 [bs, c, h, w]# 统一投影至 hidden_dim 并展平为序列# Transformer编码全局上下文# 全局池化得到全局向量。

走向CTO的路上... 495

道路施工检测 (construction) - 基于Mapillary Vistas数据集的YOLOv11目标检测及UI界面实现

目标检测是计算机视觉的重要任务,目标是识别图像中的目标物体类别及其位置(用边界框表示)。两阶段检测器:如Faster R-CNN,准确度高但速度较慢单阶段检测器:如YOLO系列、SSD,速度快且精度相对较好,适合实时场景数据量:约25,000张高分辨率街景图标注类型:语义分割、实例分割、多类别检测类别示例:construction, road, car, person, traffic sign等格式:COCO风格JSON标注。

YOLO 496

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

上一篇: R语言中用于可视化的plot函数提供了多种pch形状选项,每种形状都有对应的编码值
下一篇: 使用R语言构建神经网络回归模型并分析可靠性
普通网友
博客等级 码龄3年 267粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值