R中两个细胞组差异分析中差异的统计显着性
我正在尝试测试前波和后波期间控制和暴露的 2 个细胞之间的差异。
1 - 以下是电子表格中单元格 1 和单元格 2 的数据列布局:
Pre-wave 暴露的单元格 1 |预波控制单元 1 |波后曝光单元 1 |波后控制单元 1 |预波曝光单元 2 |预波控制单元 2 |波后曝光 Cell 2 |波后控制单元 2
2 - 然后,我计算了每个 KPI 中波前和波后期间每个曝光/控制的样本大小:
N_for_KPI <- c(683,538,2225,1458,294,307,922,781)
N <- c(1951,1564,5683,4507,819,862,2479,2511)
Wave <- factor(c("A","A","B","B","C","C"))
Brand <- factor(c(0,1,0,1,0,1))
data = data.frame(N_for_KPI,N)
Proportion <-N_for_KPI / N
Proportion
fit <- glm(Proportion~Wave*Brand, family=binomial, weights=N)
summary(fit)
3 - R 然后输出结果如下:
> Proportion
[1] 0.3500769 0.3439898 0.3915186 0.3234968 0.3589744 0.3561485 0.3719242
0.3110315
> fit <- glm(Proportion~Wave*Brand, family=binomial, weights=N)
Error in model.frame.default(formula = Proportion ~ Wave * Brand, weights
= N, :
variable lengths differ (found for 'Wave')
> summary(fit)
Call:
glm(formula = Proportion ~ Wave * Brand, family = binomial, weights = N)
Deviance Residuals:
[1] 0 0 0 0
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.9422 0.1047 -28.096 <2e-16 ***
WaveB 0.0394 0.1203 0.328 0.743
Brand1 -0.1574 0.1507 -1.045 0.296
WaveB:Brand1 -0.4487 0.1786 -2.512 0.012 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 4.5383e+01 on 3 degrees of freedom
Residual deviance: -4.9938e-13 on 0 degrees of freedom
AIC: 35.137
Number of Fisher Scoring iterations: 3
4 - 目标是从模型中的比例变量得到显着性结果 >
问题: 1-引用的内容是否正确地描述了问题? 2-我该如何修复错误: model.frame.default 中的错误(公式 = 比例 ~ Wave * 品牌,权重 = N,:可变长度不同(为“Wave”找到)
提前非常感谢!!
I'm trying to test the difference in difference between 2 cells for control and exposed during pre-wave and post-wave.
1 - Here is the column layout of the data in spreadsheet for Cell 1 and Cell 2:
Pre-wave exposed Cell 1 | Pre-wave control Cell 1 | Post-wave exposed Cell 1 | Post-wave control Cell 1 | Pre-wave exposed Cell 2 | Pre-wave control Cell 2 | Post-wave exposed Cell 2 | Post-wave control Cell 2
2 - I then calculated the sample size for each exposed/control during pre-wave and post-wave in each KPI:
N_for_KPI <- c(683,538,2225,1458,294,307,922,781)
N <- c(1951,1564,5683,4507,819,862,2479,2511)
Wave <- factor(c("A","A","B","B","C","C"))
Brand <- factor(c(0,1,0,1,0,1))
data = data.frame(N_for_KPI,N)
Proportion <-N_for_KPI / N
Proportion
fit <- glm(Proportion~Wave*Brand, family=binomial, weights=N)
summary(fit)
3 - R then spit out the results as below:
> Proportion
[1] 0.3500769 0.3439898 0.3915186 0.3234968 0.3589744 0.3561485 0.3719242
0.3110315
> fit <- glm(Proportion~Wave*Brand, family=binomial, weights=N)
Error in model.frame.default(formula = Proportion ~ Wave * Brand, weights
= N, :
variable lengths differ (found for 'Wave')
> summary(fit)
Call:
glm(formula = Proportion ~ Wave * Brand, family = binomial, weights = N)
Deviance Residuals:
[1] 0 0 0 0
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.9422 0.1047 -28.096 <2e-16 ***
WaveB 0.0394 0.1203 0.328 0.743
Brand1 -0.1574 0.1507 -1.045 0.296
WaveB:Brand1 -0.4487 0.1786 -2.512 0.012 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 4.5383e+01 on 3 degrees of freedom
Residual deviance: -4.9938e-13 on 0 degrees of freedom
AIC: 35.137
Number of Fisher Scoring iterations: 3
4 - The goal is to get the significance results from the proportion variable in the model
Question:
1-Is the quote correct to describe the issue?
2-How can i fix the error: Error in model.frame.default(formula = Proportion ~ Wave * Brand, weights = N, : variable lengths differ (found for 'Wave')
Thank you so much in advance!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论