我有两个数据框,其中包含两项不同调查(不同受访者)的结果:
DF1 <- data.frame(color = factor(c("Blue", "Brown", "Blue", "Brown", "Blue", "Brown", "Blue", "Brown")),
location = factor(c("California", "Nevada", "Nevada", "California", "California", "Arizona", "California", "Nevada")),
DF1respondent = factor(c("R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8")))
DF2 <- data.frame(shape = factor(c("Square", "Square", "Round", "Square", "Round", "Round", "Square", "Round")),
location = factor(c("California", "Nevada", "Nevada", "California", "Arizona", "Nevada", "California", "Nevada")),
DF2respondent = factor(c("A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8")))
我想拟合一个逻辑回归模型,该模型可以估计DF1
个被调查者在特定{{1 }}。
在R中合并两个数据集非常容易,用color
作为控制变量拟合模型也很容易:
DF2
但是,shape
是否符合规定的标准,与location
和location
中的响应相匹配?还是有更好的方法来估计特定DF3 <- dplyr::full_join(DF1, DF2, by=c("location"))
mod.fit <- glm(color ~ shape + location, binomial(logit), DF3)
中mod.fit
对DF1
的影响?