wilksLambdaTest: wilksLambdaTest

Description Usage Arguments Examples

View source: R/calcWilks.R

Description

Performs Wilks likelihood ratio test on the multivariate regression model lm_mod versus the null hypothesis model lm_nullmod. Note that if n_adj=0 (the default) then the return values pval and pvalAdj will be the same. Otherwise, pval will be the unadjusted pvalue (full degrees of freedom), and pvalAdj will be the adjusted pvalue (reduced degrees of freedom).

Usage

1
wilksLambdaTest(lm_mod, lm_nullmod = NULL, n_adj = 0)

Arguments

lm_mod

fitted model (eg: lm(Y~X)) corresponding to the alternative hypothesis.

lm_nullmod

fitted model (eg: lm(Y~1)) corresponding to the null hypothesis, default is lm(Y~1) when lm_nullmod==NULL.

n_adj

default=0, subtracted from the error degrees of freedom (for example, may be used to correct for previous testing done on the data).

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
lam = NULL
pval = NULL
for(i in 1:1000) {
x1 = rnorm(100)
x2 = rnorm(100)
y1 = rnorm(100)
y2 = rnorm(100)
A = cbind(y1,y2)
B = cbind(x1,x2)
wi = wilksLambdaTest(lm(A~B), n_adj=0)
lam = c(lam, wi$lambda)
pval = c(pval, wi$pval)
}

hist(lam, freq=F, breaks=100)
curve(dchisq(x, wi$chisq_df), 0, max(lam), lwd=2, xlab = "", ylab = "", add = T)
hist(pval, freq=F, breaks=100)

lam = NULL
pval = NULL
for(i in 1:1000) {
x1 = rnorm(100)
x2 = rnorm(100)
y1 = rnorm(100)
y2 = rnorm(100)
y3 = rnorm(100)
y4 = rnorm(100)
y5 = rnorm(100)
y6 = rnorm(100)
A = cbind(y1,y2,y3,y4,y5,y6)
B = cbind(x1,x2)
wi = wilksLambdaTest(lm(A~B), n_adj=0)
lam = c(lam, wi$lambda)
pval = c(pval, wi$pval)
}

hist(lam, freq=F, breaks=100)
curve(dchisq(x, wi$chisq_df), 0, max(lam), lwd=2, xlab = "", ylab = "", add = T)
hist(pval, freq=F, breaks=100)

mrparker909/mvregress documentation built on Dec. 27, 2019, 3:40 p.m.