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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
##
## loop tests for princompRob plots
##
#Global
{
data(wood, package = "robustbase")
princompRob.data <- wood[, 1:5]
T
}
###########################################################
#1 test plot.princompRob
{
#make a princompRob object and start pdf device
temp <- princompRob(data = princompRob.data, control = covRob.control(estim = "donostah"))
pdf("plot.princompRob.pdf")
T
}
{
#try plot.princompRob
class(try(plot(temp))) != "Error"
}
{
#clean up and write to file
rm(temp)
dev.off()
T
}
################################################################
#2 Test plot.fit.models with princompRob comparison
{
require("fit.models")
}
{
#make a fit.models object and start pdf device
temp <- fit.models(list(Robust = "princompRob", Classical = "princomp"), data = princompRob.data, control = covRob.control(estim = "donostah"))
pdf("plot.fit.models.princomp.both.pdf")
T
}
{
#Trellis of Component Scatter Plots: 2 models
class(try(plot(temp, which = 1))) != "Error"
}
{
#Loadings: 2 models
class(try(plot(temp, which = 2))) != "Error"
}
{
#Variances: 2 models
class(try(plot(temp, which = 3))) != "Error"
}
{
#All: 2 models
class(try(plot(temp, which = 1:3))) != "Error"
}
{
#clean up and write to file
dev.off()
rm(temp)
T
}
############################################################
#3 Test plot.fit.models with princompRob only
{
#make a fit.models object and start pdf device
temp <- fit.models(list(Robust = "princompRob"), data = princompRob.data, control = covRob.control(estim = "donostah"))
pdf("plot.fit.models.princompRob.only.pdf")
T
}
{
#Trellis of Component Scatter Plots: Robust model
class(try(plot(temp, which = 1))) != "Error"
}
{
#Loadings: Robust model
class(try(plot(temp, which = 2))) != "Error"
}
{
#Variances: Robust model
class(try(plot(temp, which = 3))) != "Error"
}
{
#All: Robust model
class(try(plot(temp, which = 1:3))) != "Error"
}
{
#clean up and write to file
dev.off()
rm(temp)
T
}
#################################################################
#4 Test plot.fit.models with princomp only
{
#make a fit.models object and start pdf device
temp <- fit.models(list(Classical = "princomp"), data = princompRob.data, control = covRob.control(estim = "donostah"))
pdf("plot.fit.models.princomp.only.pdf")
T
}
{
#Trellis of Component Scatter Plots: Classical model
class(try(plot(temp, which = 1))) != "Error"
}
{
#Loadings: Classical model
class(try(plot(temp, which = 2))) != "Error"
}
{
#Variances: Classical model
class(try(plot(temp, which = 3))) != "Error"
}
{
#All: Classical model
class(try(plot(temp, which = 1:3))) != "Error"
}
{
#clean up and write to file
dev.off()
rm(temp)
T
}
#####################################################
# Remove Globals
{
rm(princompRob.data)
T
}
|