looq2( modelData, formula = NULL, nu = 1, round = 4,
extOut = FALSE, extOutFile = NULL )
cvq2( modelData, formula = NULL, nFold = N, nRun = 1, nu = 1,
round = 4, extOut = FALSE, extOutFile = NULL )
q2( modelData, predictData, formula = NULL, nu = 0, round = 4,
extOut = FALSE, extOutFile = NULL )
modelData
is randomly partitioned into nFold equal sized subsets (test sets) during each run, DEFAULT: N, $2 looq2(),cvq2()
), 0 (else)extOutFile
is not specified, write to stdout()extOut = TRUE
), DEFAULT: NULLq2()
q2
returns an object of class "q2 "
.
It contains information about the model calibration and its prediction performance on the external data set, predictData
.
}
cvq2(), looq2()
cvq2
and looq2
return an object of class "cvq2 "
.
It contains information about the model calibration and its prediction performance as well as data about the cross-validation applied to modelData
.
}modelData
is done with a linear regression.
q2()
qsq()
, qsquare()
The model described by modelData
is used to predict the observations of predictData
. These predictions are used to calculate the predictive squared correlation coefficient, $q^2$.
}
cvq2()
cvqsq()
, cvqsquare()
A cross-validation is performed for modelData
, whereas modelData
(N elements) is split into nFold
disjunct and equal sized test sets.
Each test set consists of k elements:
$$k = \left\lceil\frac{N}{nFold}\right\rceil$$
In case $\frac{N}{nFold}$ is a decimal number, some test sets consist of $k-1$ elements.
The remaining $N-k$ elements are merged together as training set for this test set and describe the model M'.
This model is used to predict the observations in the test set.
Note, that M' is slighlty different to model M, which is a result of the missing k values.
Each observation from modelData
is predicted once.
The difference between the prediction and the observation within the test sets is used to calculate the PREdictive residual Sum of Squares (PRESS).
Furthermore for any training set the mean of the observed values in this training set, $y_{mean}^{N-k,i}$, is calculated.
PRESS and $y_{mean}^{N-k,i}$ are required to calculate the predictive squared correlation coefficient, $q^2_{cv}$.
In case $k > 1$ one can repeat the cross-validation to overcome biasing.
Therefore in each iteration ($\code{nRun} = \lbrace1, 2, \ldots, x\rbrace$) the test sets are compiled individually by random.
Within one iteration, each observation is predicted once.
If $\code{nFold} = N$, one iteration is necessary only. }
looq2()
cvq2()
(see above), but implicit $\code{nFold} = N$ to perform a Leave-One-Out cross-validation.
For Leave-One-Out cross-validation one iteration (nRun = 1
) is necessary only.
}require(methods)
require(stats)
library(cvq2)
data(cvq2.sample.A)
result <- cvq2( cvq2.sample.A )
result
data(cvq2.sample.B)
result <- cvq2( cvq2.sample.B, y ~ x, nFold = 3 )
result
data(cvq2.sample.B)
result <- cvq2( cvq2.sample.B, y ~ x, nFold = 3, nRun = 5 )
result
data(cvq2.sample.A)
result <- looq2( cvq2.sample.A, y ~ x1 + x2 )
result
data(cvq2.sample.A)
data(cvq2.sample.A_pred)
result <- q2( cvq2.sample.A, cvq2.sample.A, y ~ x1 + x2 )
result
Run the code above in your browser using DataLab