get_cor: Compute the prediction accuracy from Cross Validition

Description Usage Arguments Value See Also Examples

View source: R/clmm.R

Description

Takes a matrix of predictions returned by get_pred, a list of masked phenotypes returned by cCV and the original phenotype vector and returns the correlation between predicted and observed values

Usage

1
get_cor(predictions,cv_pheno,y)

Arguments

predictions

Prediction matrix returned by get_pred

cv_pheno

List of masked phenotypes returned by cCV

y

Original unmasked phenotype vector that has been used in cCV

Value

Numeric scalar - Mean prediction accuracy measured as correlation between predicted and observed phenotypes

See Also

clmm, get_pred, cCV

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
### Running a 4-fold cross-validation with one repetition:
## Not run: 

# generate random data
rand_data(500,5000)

### compute the list of masked phenotype-vectors for CV
y_CV <- cCV(y,fold=4,reps=1)


### Cross Validation using GBLUP
G.A <- cgrm.A(M,lambda=0.01)


### generate the list of design matrices for clmm
Z_list = list(t(chol(G.A)))

### specify options
h2 = 0.3
scale = unlist(lapply(y_CV,function(x)var(x,na.rm=T))) * h2
df = rep(5,length(y_CV))
par_random = list(list(method="ridge",scale=scale,df=df))

### run 
fit <- clmm(y_CV, Z=Z_list, par_random=par_random, niter=5000, burnin=2500)

### inspect results
str(fit)

### obtain predictions
pred <- get_pred(fit)

### prediction accuracy
get_cor(pred,y_CV,y)

## End(Not run)

cpgen documentation built on May 2, 2019, 8:15 a.m.