【发布时间】:2021-07-29 08:02:29
【问题描述】:
我的数据是虚拟变量(1 = 如果公开,0 = 未公开)作为因变量,分类变量(五种行业)作为自变量。
有了这些数据,可以用线性回归模型吗?
我的目标是确定哪些部门披露或不披露。
那么是不是很好用呢?例如:
summary(lm(Disclosed ~ 0 + Sectors, data = df_0))
我在模型中添加“0 +”,使其也返回第一个扇区,消除截距。如果我不添加它,我不知道为什么第一个扇区不返回给我。我很失落。谢谢!
如果我使用二项式逻辑回归,则我通过它所指示的估计符号获得的显着性值将不会被解释。
Call:
glm(formula = Disclosed ~ 0 + Sectors, family = binomial(link = "logit"),
data = df_0)
Deviance Residuals:
Min 1Q Median 3Q Max
-0.96954 -0.32029 -0.00005 -0.00005 2.48638
Coefficients:
Estimate Std. Error z value Pr(>|z|)
SectorsCOMMUNICATION -0.5108 0.5164 -0.989 0.32256
SectorsCONSIMERSTAPLES -20.5661 6268.6324 -0.003 0.99738
SectorsCONSUMERDISCRET -3.0445 1.0235 -2.975 0.00293 **
SectorsENERGY -20.5661 3780.1276 -0.005 0.99566
SectorsFINANCIALS -2.9444 0.7255 -4.059 4.94e-05 ***
SectorsHEALTHCARE -20.5661 5345.9077 -0.004 0.99693
SectorsINDUSTRIALS -20.5661 2803.4176 -0.007 0.99415
SectorsINDUSTRIALS -20.5661 17730.3699 -0.001 0.99907
SectorsINFORMATION -1.0986 0.8165 -1.346 0.17846
SectorsMATERIALS -20.5661 3780.1276 -0.005 0.99566
SectorsREALESTATE -20.5661 8865.1850 -0.002 0.99815
SectorsUTILITIES -20.5661 7238.3932 -0.003 0.99773
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 277.259 on 200 degrees of freedom
Residual deviance: 54.185 on 188 degrees of freedom
AIC: 78.185
Number of Fisher Scoring iterations: 19
这意味着金融和非必需消费品行业的披露最少,对吧?
另一方面,如果我应用 lm,它会返回更一致的结果。传播最多的部门是信息和通信。它们是显着的正估计值
Call:
lm(formula = Disclosed ~ 0 + Sectors, data = df_0)
Residuals:
Min 1Q Median 3Q Max
-0.3750 -0.0500 0.0000 0.0000 0.9546
Coefficients:
Estimate Std. Error t value Pr(>|t|)
SectorsCOMMUNICATION 3.750e-01 5.191e-02 7.224 1.22e-11 ***
SectorsCONSIMERSTAPLES 0.000e+00 7.341e-02 0.000 1.000000
SectorsCONSUMERDISCRET 4.545e-02 4.427e-02 1.027 0.305815
SectorsENERGY 0.000e+00 4.427e-02 0.000 1.000000
SectorsFINANCIALS 5.000e-02 3.283e-02 1.523 0.129426
SectorsHEALTHCARE 0.000e+00 6.260e-02 0.000 1.000000
SectorsINDUSTRIALS 2.194e-18 3.283e-02 0.000 1.000000
SectorsINDUSTRIALS 0.000e+00 2.076e-01 0.000 1.000000
SectorsINFORMATION 2.500e-01 7.341e-02 3.406 0.000807 ***
SectorsMATERIALS 0.000e+00 4.427e-02 0.000 1.000000
SectorsREALESTATE 0.000e+00 1.038e-01 0.000 1.000000
SectorsUTILITIES 1.416e-17 8.476e-02 0.000 1.000000
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.2076 on 188 degrees of freedom
Multiple R-squared: 0.2632, Adjusted R-squared: 0.2162
F-statistic: 5.597 on 12 and 188 DF, p-value: 3.568e-08
【问题讨论】:
-
考虑运行概率模型,例如
logistic regression或probit regression -
您可能想要使用逻辑回归,您可以通过添加
family = "binomial"作为lm的参数来实现。 -
如果我指出它是二项式,它会返回以下错误:
In lm.fit (x, y, offset = offset, singular.ok = singular.ok, ...): The additional argument `` family '' will be ignored.
标签: r statistics linear-regression correlation dummy-variable