boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 求教一道google的面试题,关于multicollinearity的
相关主题
突然对直线拟合的R不明白起来了
关于R的Simplex的错误信息
rw一个关于保存simple logistic分析结果的问题
问个logistic regression的问题。
【R】保留matrix中某些值
I have a question about logistic regression model
How to interprate parameter estimate in Proc GENMOD fit Gamma Distribution example?
请教:关于covariance matrix
求用R做bootstrap的example script
请教一个ARIMA-GARCH在SAS中实现的问题
相关话题的讨论汇总
话题: x1话题: x2话题: test
进入Statistics版参与讨论
1 (共1页)
u*****o
发帖数: 1224
1
在glassdoor上看到的,不太确定自己的思路对不对,希望牛人们帮我看看
题目是
If each of the two coefficient estimates in a regression model is
statistically significant, do you expect the test of both together is still
significant
我觉得是不是应该从两个variable是不是correlated(high or perfect
multicollinearity)的角度讨论。如果是highly correlated, 那么remove one
variable does not lose explanatory power, 所以用F-test测试 b1=b2=0的时候,应
该是significant的,因为两个b至少有一个应该不是0,我们就应该reject H0,
conclude significance..
第二种情况是没有correlation, independent variables, 那么也应该是significant
的,因为observing two unlikely independent events is "more unlikely" than
observing them alone..
所以结论是significant for both cases.. 我说的是不是很扯呀。。
y******6
发帖数: 61
2
我同意你的观点,
我肤浅的理解就是,significance for a single parameter means adding in this
predictor can bring in additional
prediction power than the old model.
If single predictor alone can even have better prediction power. Then we
have two predictors both
in the model , assuming least square is clever learner in terms of how to
use the information provided by these
two predictors, then it must have better prediction power. For instance, A
learner ( not OLS) with one estimate 0 for one input variable, the other
estimate is the same as OLS will be as good as including one single variable
alone. The OLS should be better than this linear learner since it is
optimal linear learner in terms of reducing MSE and minimax risk.
有没有大牛从理论上解释一下呀。。。。我跑了一些simulation,没有找到反面例子


still

【在 u*****o 的大作中提到】
: 在glassdoor上看到的,不太确定自己的思路对不对,希望牛人们帮我看看
: 题目是
: If each of the two coefficient estimates in a regression model is
: statistically significant, do you expect the test of both together is still
: significant
: 我觉得是不是应该从两个variable是不是correlated(high or perfect
: multicollinearity)的角度讨论。如果是highly correlated, 那么remove one
: variable does not lose explanatory power, 所以用F-test测试 b1=b2=0的时候,应
: 该是significant的,因为两个b至少有一个应该不是0,我们就应该reject H0,
: conclude significance..

z******n
发帖数: 397
3
如果局限到linear reg的score test,大致可以有一个比较全面的回答。欢迎指正
假设y x1 x2都已经中心化和标准化
y=b1*x1+ b2*x2 + e
记T1^2为 y=c1*x1 + e的score statistic (数值上大致等于Wald stat的平方)
T_2^2 为 y=c2*x2 + e的score statistic
简单计算表明H0: b1=b2=0的score statistic有形式
T= (T1^2 - 2*r*T1*T2 + T2^2)/(1-r^2)
r是correlation(x1, x2)
所以对于绝大部分情况,给定T1^ 和 T2^2充分大,且 r < 0时,你的回答应该是对的
。如果r > 0,则不一定,因为r对于分子分母的影响是同向的。这也是为什么对于两个
负相关的因子,联合起来考虑通常能提高power;对于正相关的情形,则未必,因为检
验统计量的增大(甚至减小)未必能抵消df增大的影响。
对于独立的情形,r=0,这时候T=T1^2 + T2^2 ~ chisq(df=2),大概也是对的,要看具
体的significant threshold。
z******n
发帖数: 397
4
对于另外一种类似的情况也可以同样分析
假定题目是说模型 y=b1*x1+ b2*x2 + e 中b1 b2各自的两个wald test都显著(而不是
像上面那样说两个简单模型中的c1 c2显著)
则用和上面同样的记号,两个wald stat(出去一个常数因子var(e))大致是
(T1-r * T2)^2/(1-r^2)
(r * T1 - T2)^2/(1-r^2)
对于两个参数的联合检验仍然有统计量
T= (T1^2 - 2*r*T1*T2 + T2^2)/(1-r^2)
具体的结论就不分析了,应该大致相同
t*******2
发帖数: 384
5
好像不对吧,如果correlation(x1, x2)>0, 那么correlation(x1, -x2)<0, 难道这样
结果就可能相反?
z******n
发帖数: 397
6
T1 T2 是有符号的。另外你说的也对,最好是限定b1 b2的符号,再讨论相关性的符号
问题。

【在 t*******2 的大作中提到】
: 好像不对吧,如果correlation(x1, x2)>0, 那么correlation(x1, -x2)<0, 难道这样
: 结果就可能相反?

D**u
发帖数: 288
7
两个都放进去,如果是有multicollinearity issue,可以是一个significant另一个不
significant吧?
try this R - code: (随便写的啊)
dt = data.frame(matrix(c(1,2,4,8,1,2,4,8,-1,-2,-4,-7),ncol = 3))
summary(lm(X1~X2,data=dt)) sig
summary(lm(X1~X3,data=dt)) sig
summary(lm(X1~X2+X3,data=dt)) one sig one no sig
P****D
发帖数: 11146
8
相当可能啊。不过楼主问的是model 整体的significance,不是单个variable 的。
我对multicolinearity的表现的理解就是:对于“涉案”variable 来说,回归算出来
什么都不能做准了,不管是回归的参数,还是significance。

【在 D**u 的大作中提到】
: 两个都放进去,如果是有multicollinearity issue,可以是一个significant另一个不
: significant吧?
: try this R - code: (随便写的啊)
: dt = data.frame(matrix(c(1,2,4,8,1,2,4,8,-1,-2,-4,-7),ncol = 3))
: summary(lm(X1~X2,data=dt)) sig
: summary(lm(X1~X3,data=dt)) sig
: summary(lm(X1~X2+X3,data=dt)) one sig one no sig

D**u
发帖数: 288
9
两个variable单独都sig,不管有没有collinerity放到一起model必然sig,但是如果有
collinerity issue两个coefficients有可能都sig,都不sig,或者一个sig,一个不sig
i***o
发帖数: 778
10
If correlated, all together significant/non-significant are both possible.
Draw a rejection region then it is easy to see

still
★ 发自iPhone App: ChineseWeb 7.8

【在 u*****o 的大作中提到】
: 在glassdoor上看到的,不太确定自己的思路对不对,希望牛人们帮我看看
: 题目是
: If each of the two coefficient estimates in a regression model is
: statistically significant, do you expect the test of both together is still
: significant
: 我觉得是不是应该从两个variable是不是correlated(high or perfect
: multicollinearity)的角度讨论。如果是highly correlated, 那么remove one
: variable does not lose explanatory power, 所以用F-test测试 b1=b2=0的时候,应
: 该是significant的,因为两个b至少有一个应该不是0,我们就应该reject H0,
: conclude significance..

相关主题
问个logistic regression的问题。
【R】保留matrix中某些值
I have a question about logistic regression model
How to interprate parameter estimate in Proc GENMOD fit Gamma Distribution example?
进入Statistics版参与讨论
d******e
发帖数: 7844
11
我擦,两个放一起变得不显著了是什么情况br />

【在 i***o 的大作中提到】
: If correlated, all together significant/non-significant are both possible.
: Draw a rejection region then it is easy to see
:
: still
: ★ 发自iPhone App: ChineseWeb 7.8

k*******a
发帖数: 772
12
我觉得可以看 Wald statistic
一个的情况,两个的情况
可惜公式不记得了
w********m
发帖数: 1137
13
正解!

sig

【在 D**u 的大作中提到】
: 两个variable单独都sig,不管有没有collinerity放到一起model必然sig,但是如果有
: collinerity issue两个coefficients有可能都sig,都不sig,或者一个sig,一个不sig

L**M
发帖数: 551
14
牛人。能否搞个图看看

【在 i***o 的大作中提到】
: If correlated, all together significant/non-significant are both possible.
: Draw a rejection region then it is easy to see
:
: still
: ★ 发自iPhone App: ChineseWeb 7.8

k*******a
发帖数: 772
15
我觉得是significant
可以用F-test
假设test significance of x1, F = f1
test significance of x2, F = f2
那么test both x1 and x2 肯定有 f12 > max(f1, f2)
f1 和 f2的degrees of freedom是 (1, n-3)
f12 的 degree of freedom 是 (2, n-3)
rejection region 的话有 qf(0.975, 1, n-3) > qf(0.975, 1, n-3)
如果 f1 和 f2 都reject, 那么f1, f2 > qf(0.975, 1, n-3) > qf(0.975, 2, n-3)
所以 f12 > qf(0.975, 2, n-3) 所以必定reject
z******n
发帖数: 397
16
我想我的看法不大受重视。所以构造了一个数值例子。为了使得结果能够重复,我固定
了随机数种子
set.seed(2)
library("mvtnorm")
n<-100
rho<-.9
bet<-c(.1,.1)
sigma<-matrix(c(1, rho, rho, 1), ncol=2)
x<-rmvnorm(n, sigma=sigma)
e<-rnorm(n,sd=.8)
y<-x%*%bet+e
data<-data.frame(y, x)
colnames(data)<-c("y", "x1", "x2")
mdl0<-lm(y~1, data=data)
mdl1<-lm(y~x1,data=data)
mdl2<-lm(y~x2,data=data)
mdl<-lm(y~x1+x2, data=data)
> anova(mdl0, mdl1, test="Chisq")[2, "Pr(>Chi)"]
[1] 0.03725746
> anova(mdl0, mdl2, test="Chisq")[2, "Pr(>Chi)"]
[1] 0.03311402
> anova(mdl0, mdl, test="Chisq")[2, "Pr(>Chi)"]
[1] 0.09753512
可见marginal p-value 分别是0.037和0.033,但2-df的joint test只有0.098 ...
代码在win R 3.0.1下运行,供各位参考。总的来看,x1 x2的相关系数符号和真参数
beta1 beta2的符号共同决定了结论。楼上的各种误解我就不逐个判断了,希望有帮助。

still

【在 u*****o 的大作中提到】
: 在glassdoor上看到的,不太确定自己的思路对不对,希望牛人们帮我看看
: 题目是
: If each of the two coefficient estimates in a regression model is
: statistically significant, do you expect the test of both together is still
: significant
: 我觉得是不是应该从两个variable是不是correlated(high or perfect
: multicollinearity)的角度讨论。如果是highly correlated, 那么remove one
: variable does not lose explanatory power, 所以用F-test测试 b1=b2=0的时候,应
: 该是significant的,因为两个b至少有一个应该不是0,我们就应该reject H0,
: conclude significance..

g******i
发帖数: 118
17
赞一个!

【在 z******n 的大作中提到】
: 我想我的看法不大受重视。所以构造了一个数值例子。为了使得结果能够重复,我固定
: 了随机数种子
: set.seed(2)
: library("mvtnorm")
: n<-100
: rho<-.9
: bet<-c(.1,.1)
: sigma<-matrix(c(1, rho, rho, 1), ncol=2)
: x<-rmvnorm(n, sigma=sigma)
: e<-rnorm(n,sd=.8)

k*******a
发帖数: 772
18
我觉得你可能理解错题目了
我觉得原题的意思是 同一个model y~x1+x2
里面x1和x2的coefficient都是significant,而不是fit两个single-variable model

【在 z******n 的大作中提到】
: 我想我的看法不大受重视。所以构造了一个数值例子。为了使得结果能够重复,我固定
: 了随机数种子
: set.seed(2)
: library("mvtnorm")
: n<-100
: rho<-.9
: bet<-c(.1,.1)
: sigma<-matrix(c(1, rho, rho, 1), ncol=2)
: x<-rmvnorm(n, sigma=sigma)
: e<-rnorm(n,sd=.8)

z******n
发帖数: 397
19
这种情况我在4楼有讨论,结论仍然是各种情况都可能发生。下面是对应于你提到的情
况的一个数值例子
set.seed(29)
library("mvtnorm")

n<-100
rho<--.9
bet<-c(.1,.1)
sigma<-matrix(c(1, rho, rho, 1), ncol=2)
x<-rmvnorm(n, sigma=sigma)
e<-rnorm(n,sd=.5)
y<-x%*%bet+e

data<-data.frame(y, x)
colnames(data)<-c("y", "x1", "x2")

pv.x1<-summary(mdl)$coefficients["x1", "Pr(>|t|)"]
pv.x2<-summary(mdl)$coefficients["x2", "Pr(>|t|)"]
pv.jnt<-anova(mdl0, mdl, test="Chisq")[2, "Pr(>Chi)"]
> c(pv.x1, pv.x2, pv.jnt)
[1] 0.03195767 0.02085859 0.06284721
可见两个Wald p-value 都显著,但2-df joint test不显著。

【在 k*******a 的大作中提到】
: 我觉得你可能理解错题目了
: 我觉得原题的意思是 同一个model y~x1+x2
: 里面x1和x2的coefficient都是significant,而不是fit两个single-variable model

k*******a
发帖数: 772
20
good, it works
看来highly correlated的时候就会发生这种情况

【在 z******n 的大作中提到】
: 这种情况我在4楼有讨论,结论仍然是各种情况都可能发生。下面是对应于你提到的情
: 况的一个数值例子
: set.seed(29)
: library("mvtnorm")
:
: n<-100
: rho<--.9
: bet<-c(.1,.1)
: sigma<-matrix(c(1, rho, rho, 1), ncol=2)
: x<-rmvnorm(n, sigma=sigma)

相关主题
请教:关于covariance matrix
求用R做bootstrap的example script
请教一个ARIMA-GARCH在SAS中实现的问题
能帮忙化简一个矩阵乘法么?
进入Statistics版参与讨论
z******n
发帖数: 397
21
发生的比例不高,不超过5%

【在 k*******a 的大作中提到】
: good, it works
: 看来highly correlated的时候就会发生这种情况

d******e
发帖数: 7844
22
这个case里,噪声已经超过信号很多。
基本就是在用x1和x2 fit噪声。
随便换了个种子
> c(pv.x1,pv.x2,pv.jnt)
[1] 0.3215142 0.1547054 0.2817467
我觉得实在是意义不大。

【在 z******n 的大作中提到】
: 发生的比例不高,不超过5%
c*****l
发帖数: 1493
23
mark
u*****o
发帖数: 1224
24
这两天准备狗狗的面试也没仔细follow这个帖子,大家给了这么多有用的信息,你们一
个个都是技术流呀,让我这个挫人情何以堪! 周末好好消化一下大家的意见。。。
L**M
发帖数: 551
25
哇!lz拿到onsite了,恭喜。请问是stat 还是 cs的?phd吗?
u*****o
发帖数: 1224
26
我哪有拿到?还在等消息呀, 我是说先发的帖子,看了前几个回复,就去准备第一轮
电面了,面试完再来看这个帖子,回复很多,大家讨论的也很深,觉得很感动,都是学
术帝啊。

【在 L**M 的大作中提到】
: 哇!lz拿到onsite了,恭喜。请问是stat 还是 cs的?phd吗?
1 (共1页)
进入Statistics版参与讨论
相关主题
请教一个ARIMA-GARCH在SAS中实现的问题
能帮忙化简一个矩阵乘法么?
求问一个R apply 函数的问题
菜鸟问一个关于goodness of fit Pearson Chisq 的问题
R 扫描matrix
proc genmod 结果的问题
R: load data 帮忙看看是什么问题
R里面regression 变量选择的package?
Test independence
两组数据,2个variable 的correlation不一样,如果合并起来,他们的correlaton怎么变化
相关话题的讨论汇总
话题: x1话题: x2话题: test