## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# R CODE FOR UNIVARIATE ADAPTIVE TESTS

```adapt <− function(dataset, complete, reduced, r=2000, seed=1492){

print(testdata)
attach(testdata)
statsu<− teststats(y, complete, reduced)
lambdau <− statsu[l]
fu <− statsu[2]
e <− 0
redu <− lm(as.formula(reduced))
yhat <− predict(redu)
yresidual <− residuals(redu)
set.seed(seed)
for (k in l:r) {
ynew <− yhat+sample(yresidual)```
`statsp <− teststats(ynew, complete, reduced) lambdap <− statsp[1] if( (lambdap <= lambdau) ) e <− e + 1 } p <− (e+1)/(r+1) detach (testdata) cat (“\n”, “ ***************************************”, “ \n ”, “ \n ” ) cat (“ Input : ”, “\n”, “\n”) cat (“ Data set : ”, dataset, “\n”, “\n”) cat (“ Complete model : ”, complete, “\n”, “\n”) cat (“ Reduced model : ”, reduced, “\n”, “\n ”) cat (“ Number of permutations = ”, r, “\n”, “\n”) cat (“ Random seed = ”, seed, “\n”, “\n”, “\n”, “\n”) cat (“ Output from Adaptive Test:”, “\n”, “\n”) cat (“ Unpermuted lambda = ”, round(lambdau, 4), “\n”, “\n”) cat (“ Unpermuted F = ”, round(fu, 4), “\n”, “\n”) cat (“ p-value = ”, round(p, 4), “\n”, “\n”, “\n”) cat (“ Trad. F test p-value = ”, round(tradpvalue, 4), “\n”) cat (“\n”, “ *************************************** ”, “\n”, “\n”) return(p) } teststats <− function(y, complete, reduced) { red <− 1m(as.formula(reduced)) resid <− residuals(red) # compute traditional quantiles q25 <− quantile(resid, 0.25, type=6) q75 <− quantile(resid, 0.75, type=6) ...`

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required