【问题标题】:Comparing Two Groups with Binary Indicator Variable Showing Each Study Arm, Selecting Only Group with Indicator for Analysis使用显示每个研究组的二元指标变量比较两组,仅选择具有指标的组进行分析
【发布时间】:2015-07-10 09:10:20
【问题描述】:

我有一个数据集:

Count   Group    Time
2       1        123123
1       1         1231231 
45      1          145124
25      2          132451
1       2           434114
52      2            1313

我想在每个分支中运行分析,即。组 = 1 和组 = 2。 所以我需要只分析 group=1 的所有计数变量,然后只分析 group=2。

【问题讨论】:

  • 你想要什么分析?你的输出是什么?
  • goodfit(x, type = c("poisson", "binomial", "nbinomial"), method = c("ML", "MinChisq"), par = NULL)
  • x 可以是计数向量、计数频率的单向表,也可以是数据帧或矩阵,频率在第一列,相应的计数在第二列。
  • @Colonel Beauvel 所以我需要 x 来计算研究中的每个计数......对于何时 group =1 和 when group =2 时间并不重要。

标签: r trial summarization


【解决方案1】:

这样的?

Count <- c(2, 1, 45, 25, 1, 52)
Group <- c(1, 1, 1, 2, 2, 2)
Time  <- c(123123, 1231231, 145124, 132451, 434114, 1313)
df    <- as.data.frame(cbind(Count, Group, Time))

aggregate(c(df$Count), list(df$Group), sum)
aggregate(c(df$Count), list(df$Group), mean)
aggregate(c(df$Time), list(df$Group), sum)
aggregate(c(df$Time), list(df$Group), mean)

glm(Count ~ Time, subset = Group, data = df)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-11
    • 2018-08-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多