mv.correction: Estimate the unrestricted covariance matrix using the...

Description Usage Arguments Author(s) References Examples

View source: R/mv.correction.R

Description

Estimate the unrestricted covariance matrix using the Pearson-Lawley's Multivariate Correction

Usage

1
mv.correction(data, p, v.pp)

Arguments

data

Either a data matrix containing the restricted dataset, or a variance covariance matrix of the selected covariances. The variables used for selected (the Xs) must be in the first p columns, while the "incidental" variables are in the last n-p:p columns

p

the number of columns used for selection

v.pp

The variance-covariance matrix of the population selection variables

Author(s)

Dustin Fife

References

Birnbaum, Z. W., Paulson, E., & Andrews, F. C. (1950). On the effect of selection performed on some coordinates of a multi-dimensional population. Psychometrika, 15(2), 191-204.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# do a simulation to demonstrate unbiasedness of it
#### specify population correlation matrix
cor.mat = matrix(c(
	1, .2, .4, .5,
	.2, 1, .3, .6,
	.4, .3, 1, .4,
	.5, .6, .4, 1), ncol=4)

	#### sample from that matrix
d = data.frame(mvrnorm(100000, mu=rep(0, times=ncol(cor.mat)), Sigma=cor.mat)	)
names(d) = c("X1", "X2", "Y1", "Y2")

	#### restrict the data according to X1 and X2
d.r = d[which((d$X1)>0 & d$X2>0),]

cor.mat.corrected = mv.correction(data=d.r, p=2, v.pp = cor.mat[1:2, 1:2])

# compare the two estimates
cor.mat
round(cor.mat.corrected, digits=4)
# use example I in Birnbaum, Paulson, and Andrews (1950)
## input population correlation matrix
cor = matrix(c(1, .703, .527, .499, .777,
			.703, 1, .404, .555, .679,
			.527, .404, 1, .253, .578,
			.499, .555, .253, 1, .427,
			.777, .679, .578, .427, 1), nrow=5)
require(fifer) ### for cor2cov function
v = cor2cov(cor, sd=c(9.93, 9.39, 8.80, 7.19, 8.05))
### change order so selection variables occur first
ord = c(5,1,2,3,4)
v = v[ord, ord]

# input observed correlation matrix
v.star = matrix(c(
	43, 37.65, 37.24, 25.59, 14.46,
	37.65, 72.24, 48.95, 29.04, 23.90,
	37.24, 48.95, 82.60, 20.10, 31.24,
	25.59, 29.04, 20.10, 68.04, 4.71,
	14.46, 23.90, 31.24, 4.71, 48.31), ncol=5)
mv.correction(v.star, p=2, v.pp = v[1:2, 1:2])

Example output

Loading required package: norm
Loading required package: fifer
Loading required package: MASS
     [,1] [,2] [,3] [,4]
[1,]  1.0  0.2  0.4  0.5
[2,]  0.2  1.0  0.3  0.6
[3,]  0.4  0.3  1.0  0.4
[4,]  0.5  0.6  0.4  1.0
       [,1]   [,2]   [,3]   [,4]
[1,] 1.0000 0.2000 0.3928 0.4923
[2,] 0.2000 1.0000 0.2823 0.5984
[3,] 0.3928 0.2823 0.9904 0.3790
[4,] 0.4923 0.5984 0.3790 0.9936
         [,1]     [,2]      [,3]     [,4]     [,5]
[1,] 64.80250 62.11066  58.35694 39.47221 23.32868
[2,] 62.11066 98.60490  72.19293 44.43264 33.54146
[3,] 58.35694 72.19293 102.86627 33.46993 39.70144
[4,] 39.47221 44.43264  33.46993 76.84840 10.30481
[5,] 23.32868 33.54146  39.70144 10.30481 51.82926

selection documentation built on May 30, 2017, 5:27 a.m.