我目前正在进行有关投票行为的数据分析:这是我的两个假设:
H1:1999年,年龄在18-25岁之间的SVP选民在2003年消费更多媒体更有可能投票支持SVP。H2:忠诚的SVP选民(1999年和2003年被选为SVP),年龄在18-25岁,消费更多的媒体,可能更多地了解政治人物而不是问题。
我对R来说比较新。
- >如何创建我需要的数据样本:1999年的SVP选民年龄在18-25岁? 我试图在1999年和2003年创建用于投票SVP的虚拟变量,但我不确定如何创建一个限于投票SVP和年龄的样本,以便根据该人群进行分析。
下面你可以找到我到目前为止所尝试的内容:
# Dummy creation age, voting
#age
youngvoter99 <- ifelse(w1age>=18 & w1age<26, 1, 0)
youngvoter03 <- ifelse(w2age>=18 & w2age<30, 1, 0)
mean(w1age>=18 & w1age<26)
#voting
SVP99 <- ifelse(w111800f==4, 1, 0)
SVP03 <- ifelse(w211800f==4, 1, 0)
#Media importance
tvimportance99 <- factor(w112414,
levels = c("Not important at all", "1", "2", "3",
"4", "5", "6", "7", "8", "9", "Very important"))
tvimport99low <- factor(tvimportance99,
levels = c("Not important at all", "1", "2", "3",
"4", "5"))
tvimport99high <- factor(tvimportance99,
levels = c("6", "7", "8", "9", "Very important"))
str(tvimport99low)
str(tvimport99high)
--- I did the same thing for 2003 tvimportance as above
#Categorizing Political Knowledge
politknowhigh99 <- factor(w1soph,
levels = c("Low knowledge", "1", "2"))
politknowlow99 <- factor(w1soph,
levels = c("3", "High knowledge"))
str(politknowhigh99)
str(politknowlow99)
--- I did the same thing for 2003 politknowledge as above
#Categorizing Political Personality interest
impers99 <- factor(w112211,
levels = c("Very important", "Rather important", "Rather
not important", "Not important at all"))
impers99mu <-factor(impers99,
levels = c("Very important", "Rather important"))
impers99low <-factor(impers99,
levels = c("Very important", "Rather important"))
str(impers99low)
str(impers99mu)
--- I did the same thing for 2003 tvimportance as above
- &GT;如何在R中为假设1/2创建适当的回归,尤其是当变量是因子变量时?
我想创建2个线性注册表。并减去它们,但是我坚持创建采样总体并处理因子变量。我尝试使用包“plm”,但它似乎已经过时了更新的R studio版本。