# Create an Interval-Data object containing the intervals for 899 observations
# on the temperatures by quarter in 60 Chinese meteorological stations.
ChinaT <- IData(ChinaTemp[1:8],VarNames=c("T1","T2","T3","T4"))
#Display the first and last observations
head(ChinaT)
tail(ChinaT)
#Print summary statistics
summary(ChinaT)
#Create a new data set considering only the Winter (1st and 4th) quarter intervals
ChinaWT <- ChinaT[,c(1,4)]
# Estimate normal distributuion parameters by maximum likelihood, assuming
# the classical (unrestricted) covariance configuration Case 1
ChinaWTE.C1 <- mle(ChinaWT,CovCase=1)
cat("Winter temperatures of China -- normal maximum likelhiood estimation results:\n")
print(ChinaWTE.C1)
cat("Standard Errors of Estimators:\n") ; print(stdEr(ChinaWTE.C1))
# Estimate normal distributuion parameters by maximum likelihood,
# assuming that one of the C2, C3 or C4 restricted covariance configuration cases hold
ChinaWTE.C234 <- mle(ChinaWT,CovCase=2:4)
cat("Winter temperatures of China -- normal maximum likelhiood estimation results:\n")
print(ChinaWTE.C234)
cat("Standard Errors of Estimators:\n") ; print(stdEr(ChinaWTE.C234))
# Estimate normal distributuion parameters robustly by fast maximun trimmed likelihood,
# assuming that one of the C2, C3 or C4 restricted covariance configuration cases hold
ChinaWTE.C234 <- fasttle(ChinaWT,CovCase=2:4)
cat("Winter temperatures of China -- normal maximum trimmed likelhiood estimation results:\n")
print(ChinaWTE.C234)
# Estimate skew-normal distributuion parameters
ChinaWTE.SkN <- mle(ChinaWT,Model="SKNormal")
cat("Winter temperatures of China -- Skew-Normal maximum likelhiood estimation results:\n")
print(ChinaWTE.SkN)
cat("Standard Errors of Estimators:\n") ; print(stdEr(ChinaWTE.SkN))
#MANOVA tests assuming that configuration case 1 (unrestricted covariance)
# or 3 (MidPoints independent of Log-Ranges) holds.
ManvChinaWT.C13 <- MANOVA(ChinaWT,ChinaTemp$GeoReg,CovCase=c(1,3))
cat("Winter temperatures of China -- MANOVA by geografical regions results:\n")
print(ManvChinaWT.C13)
#Linear Discriminant Analysis
ChinaWT.lda <- lda(ManvChinaWT.C13)
cat("Winter temperatures of China -- linear discriminant analysis results:\n")
print(ChinaWT.lda)
cat("lda Prediction results:\n")
print(predict(ChinaWT.lda,ChinaWT)$class)
#Estimate error rates by ten-fold cross-validation
CVlda <- DACrossVal(ChinaWT,ChinaTemp$GeoReg,TrainAlg=lda,
CovCase=BestModel(H1res(ManvChinaWT.C13)),CVrep=1)
summary(CVlda[,,"Clerr"])
glberrors <-
apply(CVlda[,,"Nk"]*CVlda[,,"Clerr"],1,sum)/apply(CVlda[,,"Nk"],1,sum)
cat("Average global classification error =",mean(glberrors),"\n")
#Robust Quadratic Discriminant Analysis
ChinaWT.rqda <- Robqda(ChinaWT,ChinaTemp$GeoReg)
cat("Winter temperatures of China -- robust quadratic discriminant analysis results:\n")
print(ChinaWT.rqda)
cat("robust qda prediction results:\n")
print(predict(ChinaWT.rqda,ChinaWT)$class)
# Create an Interval-Data object containing the intervals for characteristics
# of 27 cars models.
Cars <- IData(CarsData[1:8],Seq="MidPLogR_VarbyVar",
VarNames=c("Price","EngineCapacity","TopSpeed","Acceleration"))
#Display the first and last observations
head(Cars)
tail(Cars)
# Estimate normal distributuion parameters
CarsNE <- mle(Cars)
cat("Cars data -- normal maximum likelhiood estimation results:\n")
print(CarsNE)
cat("Standard Errors of Estimators:\n") ; print(stdEr(CarsNE))
# Estimate normal distributuion parameters robustly by full maximum trimmed likelihood,
CarsTE <- fulltle(Cars)
cat("Cars data -- normal maximum trimmed likelhiood estimation results:\n")
print(CarsTE)
# Estimate parameters searching through normal and Skew-Normal distributions.
CarsNSNE <- mle(Cars,Model="NrmandSKN")
cat("Cars data -- Maximum likelhiood estimation results:\n")
print(CarsNSNE)
cat("Standard Errors of Estimators:\n") ; print(stdEr(CarsNSNE))
Run the code above in your browser using DataLab