Description Usage Arguments Details Value See Also Examples
Classify time series. Run as part of cep.lda
, and can be run seperatly after running cep.lda
.
1 2 |
object |
Object of class "ceplda". |
newdata |
Data frame of cases to be classified. Data frame can be obtained by |
... |
argument based from or to other methods. |
This function is a method for the generic function predict()
for class "ceplda".
It can be invoked by calling predict(x)
for an object x of the appropriate class,
or directly by calling predict.lda(x)
regardless of the class of the object. Details usage of this function
is similar to predict.lda(MASS)
.
List with components
class |
Classification result (a factor). |
posterior |
Posterior class probabilities. |
x |
Scores from test data. |
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 | ## See cep.lda for predicting new data simultaneously while fitting a model to training data.
## Below is predicting new data after fitting a model to the training data.
## Simulate training data
nj = 50 #number of series in training data
N = 500 #length of time series
traindata1 <- r.cond.ar2(N=N,nj=nj,r.phi1=c(.01,.7),r.phi2=c(-.12,-.06),r.sig2=c(.3,3))
traindata2 <- r.cond.ar2(N=N,nj=nj,r.phi1=c(.5,1.2),r.phi2=c(-.36,-.25),r.sig2=c(.3,3))
traindata3 <- r.cond.ar2(N=N,nj=nj,r.phi1=c(.9,1.5),r.phi2=c(-.56,-.75),r.sig2=c(.3,3))
train <- cbind(traindata1$X,traindata2$X,traindata3$X)
y <- c(rep(1,nj),rep(2,nj),rep(3,nj))
## Fit the discriminant analysis
fit <- cep.lda(y,train)
## Simulate test data
testdata1 <- r.cond.ar2(N=N,nj=nj,r.phi1=c(.01,.7),r.phi2=c(-.12,-.06),r.sig2=c(.3,3))
testdata2 <- r.cond.ar2(N=N,nj=nj,r.phi1=c(.5,1.2),r.phi2=c(-.36,-.25),r.sig2=c(.3,3))
testdata3 <- r.cond.ar2(N=N,nj=nj,r.phi1=c(.9,1.5),r.phi2=c(-.56,-.75),r.sig2=c(.3,3))
test <- cbind(testdata1$X,testdata2$X,testdata3$X)
yTest <- c(rep(1,nj),rep(2,nj),rep(3,nj))
## Classifty new data
pre <- predict(fit,cep.get(yTest,test))
mean(pre$class == yTest)
table(yTest,pre$class)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.