# [R] find confounder in covariates

From: Young Cho <iidn01_at_yahoo.com>
Date: Fri 22 Jul 2005 - 11:47:09 EST

Hi,

> a = sample( c(1:3), size=10,replace=T)
> X1 = factor( c('A','B','C')[a] )
> X2 = factor( c('Aa','Bb','Cc')[a] )
> Xmat = data.frame(X1,X2,rnorm(10),rnorm(10))
> dimnames(Xmat)[[2]] = c('z1','z2','z3','y')

> f = lm(y~.,data=Xmat)
> summary(f)

Residuals:

Min 1Q Median 3Q Max -1.2853 -0.3708 -0.1224 0.4617 1.2821

Coefficients: (2 not defined because of singularities)

Estimate Std. Error t value Pr(>|t|)

```(Intercept)  0.82141    0.44583   1.842   0.1150
z1B         -1.34167    0.65176  -2.059   0.0852 .
z1C          0.80891    1.07639   0.751   0.4808
z2Bb              NA         NA      NA       NA
z2Cc              NA         NA      NA       NA
z3           0.04231    0.23397   0.181   0.8625
```
```---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.'
0.1 ' ' 1

Residual standard error: 0.971 on 6 degrees of freedom
0.2629
F-statistic:  2.07 on 3 and 6 DF,  p-value: 0.2057

In this case, I can look at data and figure out which
variable is confounded with which. But, if we have
many categorial covariates ( not necessarily same
number of levels ), it is almost impossible to check
it out.

Any help would be greatly appreicated. Thanks.

Young.

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help