x <- array(list(1818
,279055
,73
,504
,95
,3
,96
,42
,159
,130
,140824
,32033
,186099
,165
,165
,1439
,212450
,76
,513
,68
,4
,75
,38
,149
,143
,110459
,20654
,113854
,135
,132
,2059
,233939
,83
,710
,64
,16
,70
,46
,178
,118
,105079
,16346
,99776
,121
,121
,2733
,222117
,106
,1154
,139
,2
,134
,42
,164
,146
,112098
,35926
,106194
,148
,145
,1399
,189911
,56
,415
,51
,1
,83
,30
,100
,73
,43929
,10621
,100792
,73
,71
,631
,70849
,28
,179
,46
,3
,8
,35
,129
,89
,76173
,10024
,47552
,49
,47
,5460
,605767
,135
,2563
,118
,0
,173
,40
,156
,146
,187326
,43068
,250931
,185
,177
,381
,33186
,19
,111
,46
,0
,1
,18
,67
,22
,22807
,1271
,6853
,5
,5
,2150
,227332
,62
,763
,79
,7
,88
,38
,148
,132
,144408
,34416
,115466
,125
,124
,2042
,267925
,49
,661
,76
,0
,104
,37
,132
,92
,66485
,20318
,110896
,93
,92
,2541
,372083
,123
,983
,82
,0
,114
,46
,169
,147
,79089
,24409
,169351
,154
,149
,2449
,279589
,133
,754
,66
,7
,132
,60
,230
,203
,81625
,20648
,94853
,98
,93
,2100
,212638
,87
,785
,60
,10
,57
,37
,122
,113
,68788
,12347
,72591
,70
,70
,3020
,368577
,85
,1186
,117
,4
,139
,55
,191
,171
,103297
,21857
,101345
,148
,148
,2265
,269455
,88
,724
,50
,10
,87
,44
,162
,87
,69446
,11034
,113713
,100
,100
,5169
,402600
,197
,1783
,133
,0
,176
,63
,237
,208
,114948
,33433
,165354
,150
,142
,2375
,335735
,78
,850
,63
,8
,114
,40
,156
,153
,167949
,35902
,164263
,197
,194
,3564
,432711
,173
,1390
,100
,4
,121
,43
,157
,97
,125081
,22355
,135213
,114
,113
,1516
,185822
,59
,527
,44
,3
,103
,32
,123
,95
,125818
,31219
,111669
,169
,162
,2398
,267365
,89
,692
,65
,8
,135
,52
,203
,197
,136588
,21983
,134163
,200
,186
,2551
,279452
,74
,849
,103
,0
,123
,49
,187
,160
,112431
,40085
,140303
,148
,147
,3253
,527853
,112
,1443
,103
,1
,110
,41
,152
,148
,103037
,18507
,150773
,140
,137
,1761
,227252
,50
,587
,62
,5
,84
,25
,89
,84
,82317
,16278
,111848
,74
,71
,1787
,200004
,58
,636
,70
,9
,103
,57
,227
,227
,118906
,24662
,102509
,128
,123
,3796
,257239
,134
,1371
,159
,1
,158
,45
,165
,154
,83515
,31452
,96785
,140
,134
,3113
,271341
,139
,1094
,78
,0
,116
,42
,162
,151
,104581
,32580
,116136
,116
,115
,3230
,324969
,134
,1201
,101
,5
,114
,45
,174
,142
,103129
,22883
,158376
,147
,138
,2494
,349753
,93
,795
,73
,0
,181
,43
,154
,148
,83243
,27652
,153990
,132
,125
,1856
,200723
,63
,674
,58
,0
,76
,36
,129
,110
,37110
,9845
,64057
,70
,66
,3257
,399591
,80
,1230
,147
,0
,155
,45
,174
,149
,113344
,20190
,230054
,144
,137
,2692
,327660
,89
,1111
,54
,3
,143
,50
,195
,179
,139165
,46201
,184531
,155
,152
,2187
,269239
,83
,758
,84
,6
,50
,50
,186
,149
,86652
,10971
,114198
,165
,159
,2593
,397689
,107
,911
,56
,1
,145
,51
,197
,187
,112302
,34811
,198299
,161
,159
,1293
,130446
,49
,456
,45
,4
,56
,42
,157
,153
,69652
,3029
,33750
,31
,31
,3567
,430118
,104
,1293
,87
,4
,141
,44
,168
,163
,119442
,38941
,189723
,199
,185
,2764
,273950
,56
,1186
,87
,0
,83
,42
,159
,127
,69867
,4958
,100826
,78
,78
,3766
,429837
,129
,1353
,77
,0
,112
,44
,161
,151
,101629
,32344
,188355
,121
,117
,2075
,254312
,93
,695
,72
,2
,79
,40
,153
,100
,70168
,19433
,104470
,112
,109
,995
,120351
,35
,306
,36
,1
,33
,17
,55
,46
,31081
,12558
,58391
,41
,41
,3750
,395658
,212
,1319
,51
,2
,152
,43
,166
,156
,103925
,36524
,164808
,158
,149
,3437
,349119
,87
,1582
,44
,10
,126
,41
,151
,128
,92622
,26041
,134097
,123
,123
,2071
,220517
,86
,788
,75
,10
,97
,41
,148
,111
,79011
,16637
,80238
,104
,103
,2038
,234780
,85
,768
,87
,5
,84
,40
,129
,119
,93487
,28395
,133252
,94
,87
,1841
,191784
,71
,491
,97
,6
,68
,49
,181
,148
,64520
,16747
,54518
,73
,71
,2964
,186112
,94
,1211
,90
,1
,64
,52
,93
,65
,93473
,9105
,121850
,52
,51
,5578
,459665
,158
,2091
,860
,2
,101
,42
,150
,134
,114360
,11941
,79367
,71
,70
,918
,78800
,42
,330
,57
,2
,20
,26
,82
,66
,33032
,7935
,56968
,21
,21
,2704
,259887
,87
,770
,99
,1
,107
,59
,229
,201
,96125
,19499
,106314
,155
,155
,4145
,368086
,123
,1410
,120
,10
,150
,50
,193
,177
,151911
,22938
,191889
,174
,172
,2841
,230299
,70
,1187
,76
,3
,129
,50
,176
,156
,89256
,25314
,104864
,136
,133
,2222
,256033
,82
,706
,56
,0
,102
,47
,179
,158
,95676
,28527
,160792
,128
,125
,496
,24188
,24
,218
,20
,0
,8
,4
,12
,7
,5950
,2694
,15049
,7
,7
,2699
,400109
,334
,865
,94
,8
,88
,51
,181
,175
,149695
,20867
,191179
,165
,158
,744
,65029
,17
,255
,21
,5
,21
,18
,67
,61
,32551
,3597
,25109
,21
,21
,1161
,101097
,64
,454
,70
,3
,30
,14
,52
,41
,31701
,5296
,45824
,35
,35
,3405
,319020
,68
,1245
,133
,1
,106
,41
,148
,133
,100087
,32982
,129711
,137
,133
,2970
,375638
,91
,790
,86
,5
,166
,61
,230
,228
,169707
,38975
,210012
,174
,169
,4002
,375011
,207
,1233
,224
,6
,132
,40
,148
,140
,150491
,42721
,194679
,257
,256
,2919
,387748
,156
,1118
,65
,0
,161
,44
,160
,155
,120192
,41455
,197680
,207
,190
,2399
,280106
,90
,919
,86
,12
,90
,40
,155
,141
,95893
,23923
,81180
,103
,100
,4121
,400971
,153
,1352
,70
,10
,160
,51
,198
,181
,151715
,26719
,197765
,171
,171
,3330
,322780
,124
,1212
,148
,12
,139
,29
,104
,75
,176225
,53405
,214738
,279
,267
,3132
,291391
,124
,1257
,72
,11
,104
,43
,169
,97
,59900
,12526
,96252
,83
,80
,2868
,295075
,93
,1030
,59
,8
,103
,42
,163
,142
,104767
,26584
,124527
,130
,126
,1778
,280018
,81
,669
,67
,3
,66
,41
,151
,136
,114799
,37062
,153242
,131
,132
,2109
,267432
,71
,542
,58
,0
,163
,30
,116
,87
,72128
,25696
,145707
,126
,121
,2148
,217181
,141
,652
,60
,6
,93
,39
,153
,140
,143592
,24634
,113963
,158
,156
,3009
,258166
,159
,894
,105
,10
,85
,51
,195
,169
,89626
,27269
,134904
,138
,133
,2624
,277891
,90
,935
,84
,2
,159
,40
,149
,129
,131072
,25270
,114268
,200
,199
,1781
,192894
,74
,659
,63
,5
,146
,29
,106
,92
,126817
,24634
,94333
,104
,98
,2735
,271853
,75
,917
,67
,13
,122
,47
,179
,160
,81351
,17828
,102204
,111
,109
,893
,73566
,32
,385
,39
,6
,22
,23
,88
,67
,22618
,3007
,23824
,26
,25
,2411
,276269
,96
,789
,60
,7
,85
,48
,185
,179
,88977
,20065
,111563
,115
,113
,2291
,242619
,64
,949
,94
,2
,105
,38
,133
,90
,92059
,24648
,91313
,127
,126
,2235
,230030
,71
,784
,67
,5
,131
,42
,164
,144
,81897
,21588
,89770
,140
,137
,2370
,371391
,91
,1001
,96
,4
,140
,46
,169
,144
,108146
,25217
,100125
,121
,121
,3242
,398698
,107
,1268
,54
,3
,156
,40
,153
,144
,126372
,30927
,165278
,183
,178
,2080
,243355
,114
,616
,54
,6
,89
,45
,166
,134
,249771
,18487
,181712
,68
,63
,2537
,233519
,73
,775
,62
,2
,137
,42
,164
,146
,71154
,18050
,80906
,112
,109
,2149
,219936
,74
,746
,71
,0
,102
,41
,146
,121
,71571
,17696
,75881
,103
,101
,2150
,206169
,54
,795
,50
,1
,74
,37
,141
,112
,55918
,17326
,83963
,63
,61
,4232
,483429
,133
,1273
,117
,3
,161
,47
,183
,145
,160141
,39361
,175721
,166
,157
,1380
,146100
,72
,657
,45
,5
,30
,26
,99
,99
,38692
,9648
,68580
,38
,38
,2449
,295224
,109
,703
,61
,2
,120
,48
,134
,96
,102812
,26759
,136323
,163
,159
,870
,80953
,25
,437
,31
,0
,49
,8
,28
,27
,56622
,7905
,55792
,59
,58
,2700
,217384
,63
,1060
,175
,0
,121
,27
,101
,77
,15986
,4527
,25157
,27
,27
,1574
,179344
,62
,459
,70
,6
,76
,38
,139
,137
,123534
,41517
,100922
,108
,108
,4055
,416097
,223
,1591
,284
,1
,85
,41
,159
,151
,108535
,21261
,118845
,88
,83
,3327
,395041
,131
,1102
,95
,4
,152
,61
,222
,126
,93879
,36099
,170492
,92
,88
,3098
,180679
,106
,1051
,72
,1
,165
,45
,171
,159
,144551
,39039
,81716
,170
,164
,2673
,311447
,105
,850
,63
,1
,89
,41
,154
,101
,56750
,13841
,115750
,98
,96
,2404
,292260
,84
,732
,75
,3
,168
,42
,154
,144
,127654
,23841
,105590
,205
,192
,1932
,199481
,68
,632
,90
,10
,48
,35
,129
,102
,65594
,8589
,92795
,96
,94
,3147
,282361
,78
,1128
,89
,1
,149
,36
,140
,135
,59938
,15049
,82390
,107
,107
,2598
,329281
,89
,971
,138
,4
,75
,40
,156
,147
,146975
,39038
,135599
,150
,144
,2108
,234577
,48
,711
,68
,5
,107
,40
,156
,155
,165904
,36774
,127667
,138
,136
,2240
,310685
,68
,750
,80
,7
,121
,38
,138
,138
,169265
,40076
,163073
,177
,171
,2506
,352078
,91
,904
,65
,0
,184
,43
,153
,113
,183500
,43840
,211381
,213
,210
,4198
,416463
,163
,1369
,130
,12
,155
,65
,251
,248
,165986
,43146
,189944
,208
,193
,4165
,429565
,120
,1538
,85
,13
,165
,33
,126
,116
,184923
,50099
,226168
,307
,297
,2842
,297080
,142
,893
,83
,9
,121
,51
,198
,176
,140358
,40312
,117495
,125
,125
,2562
,331792
,71
,926
,89
,0
,176
,45
,168
,140
,149959
,32616
,195894
,208
,204
,2564
,242507
,205
,833
,116
,0
,92
,36
,138
,59
,57224
,11338
,80684
,73
,70
,602
,43287
,14
,214
,43
,4
,13
,19
,71
,64
,43750
,7409
,19630
,49
,49
,2579
,238089
,87
,833
,87
,4
,120
,25
,90
,40
,48029
,18213
,88634
,82
,82
,2665
,285479
,164
,931
,80
,0
,124
,44
,167
,98
,104978
,45873
,139292
,206
,205
,3004
,310383
,63
,1304
,132
,0
,133
,45
,172
,139
,100046
,39844
,128602
,112
,111
,2786
,321797
,95
,1079
,59
,0
,169
,44
,162
,135
,101047
,28317
,135848
,139
,135
,1477
,193926
,96
,490
,50
,0
,39
,35
,129
,97
,197426
,24797
,178377
,60
,59
,3358
,175737
,106
,992
,87
,0
,126
,46
,179
,142
,160902
,7471
,106330
,70
,70
,2107
,354041
,78
,677
,62
,5
,82
,44
,163
,155
,147172
,27259
,178303
,112
,108
,2338
,303566
,92
,698
,70
,1
,148
,45
,164
,115
,109432
,23201
,116938
,142
,141
,400
,23668
,13
,156
,9
,0
,12
,1
,0
,0
,1168
,238
,5841
,11
,11
,2233
,196743
,79
,785
,54
,0
,146
,40
,155
,103
,83248
,28830
,106020
,130
,130
,530
,61857
,25
,192
,25
,4
,23
,11
,32
,30
,25162
,3913
,24610
,31
,28
,2033
,217543
,54
,641
,113
,0
,87
,51
,189
,130
,45724
,9935
,74151
,132
,101
,3246
,440711
,128
,1251
,63
,1
,164
,38
,140
,102
,110529
,27738
,232241
,219
,216
,387
,21054
,16
,146
,2
,0
,4
,0
,0
,0
,855
,338
,6622
,4
,4
,2137
,252805
,52
,866
,67
,5
,81
,30
,111
,77
,101382
,13326
,127097
,102
,97
,492
,31961
,22
,200
,22
,0
,18
,8
,25
,9
,14116
,3988
,13155
,39
,39
,3838
,360436
,125
,1351
,157
,3
,118
,43
,159
,150
,89506
,24347
,160501
,125
,119
,2193
,251948
,77
,740
,79
,7
,76
,48
,183
,163
,135356
,27111
,91502
,121
,118
,1796
,187320
,97
,524
,113
,14
,55
,49
,184
,148
,116066
,3938
,24469
,42
,41
,1907
,180842
,58
,724
,50
,3
,62
,32
,119
,94
,144244
,17416
,88229
,111
,107
,568
,38214
,34
,276
,52
,0
,16
,8
,27
,21
,8773
,1888
,13983
,16
,16
,2647
,289296
,58
,869
,113
,3
,98
,43
,163
,151
,102153
,18700
,80716
,70
,69
,2819
,358276
,84
,1031
,115
,0
,137
,52
,198
,187
,117440
,36809
,157384
,162
,160
,1464
,211775
,67
,511
,78
,0
,50
,53
,205
,171
,104128
,24959
,122975
,173
,158
,3946
,447335
,90
,1716
,135
,4
,152
,49
,191
,170
,134238
,37343
,191469
,171
,161
,2554
,348017
,99
,884
,120
,0
,163
,48
,187
,145
,134047
,21849
,231257
,172
,165
,3506
,441946
,133
,1201
,122
,3
,142
,56
,210
,198
,279488
,49809
,258287
,254
,246
,1552
,215177
,43
,575
,54
,0
,80
,45
,166
,152
,79756
,21654
,122531
,90
,89
,1476
,140328
,48
,507
,63
,0
,65
,40
,145
,112
,66089
,8728
,61394
,50
,49
,3105
,318092
,366
,1033
,162
,4
,94
,48
,187
,173
,102070
,20920
,86480
,113
,107
,4541
,466139
,198
,1574
,162
,5
,128
,50
,186
,177
,146760
,27195
,195791
,187
,182
,1876
,162406
,63
,576
,107
,16
,63
,43
,164
,153
,154771
,1037
,18284
,16
,16
,4469
,417354
,142
,1834
,146
,6
,127
,46
,172
,161
,165933
,42570
,147581
,175
,173
,2113
,178322
,86
,790
,77
,5
,60
,40
,147
,115
,64593
,17672
,72558
,90
,90
,2046
,292443
,54
,668
,87
,2
,118
,45
,167
,147
,92280
,34245
,147341
,140
,140
,2564
,283913
,100
,905
,192
,1
,110
,46
,158
,124
,67150
,16786
,114651
,145
,142
,2209
,253950
,131
,723
,75
,2
,48
,37
,144
,57
,128692
,20954
,100187
,141
,126
,4123
,389698
,126
,1619
,131
,9
,96
,45
,169
,144
,124089
,16378
,130332
,125
,123
,2340
,246963
,93
,811
,67
,1
,128
,39
,145
,126
,125386
,31852
,134218
,241
,239
,2035
,173260
,63
,716
,37
,3
,41
,21
,79
,78
,37238
,2805
,10901
,16
,15
,3241
,346748
,108
,1034
,61
,11
,146
,50
,194
,153
,140015
,38086
,145758
,175
,170
,2056
,188437
,62
,782
,127
,5
,147
,55
,212
,196
,150047
,21166
,75767
,132
,123
,2872
,279125
,98
,1103
,58
,2
,121
,40
,148
,130
,154451
,34672
,134969
,154
,151
,2749
,314070
,113
,852
,71
,1
,185
,48
,171
,159
,156349
,36171
,169216
,198
,194
,2
,1
,0
,0
,0
,9
,0
,0
,0
,0
,0
,0
,0
,0
,0
,207
,14688
,10
,85
,0
,0
,4
,0
,0
,0
,6023
,2065
,7953
,5
,5
,5
,98
,1
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,8
,455
,2
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,1
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,2449
,291847
,95
,816
,72
,2
,85
,46
,141
,94
,84601
,19354
,105406
,125
,122
,3497
,415839
,170
,1145
,123
,3
,164
,52
,204
,129
,68946
,22124
,174586
,174
,173
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,4
,203
,4
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,151
,7199
,5
,74
,0
,0
,7
,0
,0
,0
,1644
,556
,4245
,6
,6
,475
,46660
,21
,259
,7
,0
,12
,5
,15
,13
,6179
,2089
,21509
,13
,13
,141
,17547
,5
,69
,3
,0
,0
,1
,4
,4
,3926
,2658
,7670
,3
,3
,1145
,121550
,46
,309
,106
,0
,37
,48
,172
,89
,52789
,1813
,15673
,35
,35
,29
,969
,2
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,0
,2080
,242774
,75
,695
,53
,2
,62
,34
,125
,71
,100350
,17372
,75882
,80
,72)
,dim=c(15
,164)
,dimnames=list(c('Pageviews'
,'TimeRFC'
,'Logins'
,'CCviews'
,'PR'
,'Shared'
,'BloggedC'
,'ReviewedC'
,'Feedbackm'
,'+120C'
,'#Characters'
,'#Revisions'
,'#secondsC'
,'Hyperlinks'
,'Blogs')
,1:164))
 y <- array(NA,dim=c(15,164),dimnames=list(c('Pageviews','TimeRFC','Logins','CCviews','PR','Shared','BloggedC','ReviewedC','Feedbackm','+120C','#Characters','#Revisions','#secondsC','Hyperlinks','Blogs'),1:164))
 for (i in 1:dim(x)[1])
 {
 	for (j in 1:dim(x)[2])
 	{
 		y[i,j] <- as.numeric(x[i,j])
 	}
 }
par4 = 'no'
par3 = '2'
par2 = 'quantiles'
par1 = '2'
library(party)
library(Hmisc)
par1 <- as.numeric(par1)
par3 <- as.numeric(par3)
x <- data.frame(t(y))
is.data.frame(x)
x <- x[!is.na(x[,par1]),]
k <- length(x[1,])
n <- length(x[,1])
colnames(x)[par1]
x[,par1]
if (par2 == 'kmeans') {
cl <- kmeans(x[,par1], par3)
print(cl)
clm <- matrix(cbind(cl$centers,1:par3),ncol=2)
clm <- clm[sort.list(clm[,1]),]
for (i in 1:par3) {
cl$cluster[cl$cluster==clm[i,2]] <- paste('C',i,sep='')
}
cl$cluster <- as.factor(cl$cluster)
print(cl$cluster)
x[,par1] <- cl$cluster
}
if (par2 == 'quantiles') {
x[,par1] <- cut2(x[,par1],g=par3)
}
if (par2 == 'hclust') {
hc <- hclust(dist(x[,par1])^2, 'cen')
print(hc)
memb <- cutree(hc, k = par3)
dum <- c(mean(x[memb==1,par1]))
for (i in 2:par3) {
dum <- c(dum, mean(x[memb==i,par1]))
}
hcm <- matrix(cbind(dum,1:par3),ncol=2)
hcm <- hcm[sort.list(hcm[,1]),]
for (i in 1:par3) {
memb[memb==hcm[i,2]] <- paste('C',i,sep='')
}
memb <- as.factor(memb)
print(memb)
x[,par1] <- memb
}
if (par2=='equal') {
ed <- cut(as.numeric(x[,par1]),par3,labels=paste('C',1:par3,sep=''))
x[,par1] <- as.factor(ed)
}
table(x[,par1])
colnames(x)
colnames(x)[par1]
x[,par1]
if (par2 == 'none') {
m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x)
}

#Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
load(file="/var/wessaorg/rcomp/createtable")

if (par2 != 'none') {
m <- ctree(as.formula(paste('as.factor(',colnames(x)[par1],') ~ .',sep='')),data = x)
if (par4=='yes') {
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'10-Fold Cross Validation',3+2*par3,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'',1,TRUE)
a<-table.element(a,'Prediction (training)',par3+1,TRUE)
a<-table.element(a,'Prediction (testing)',par3+1,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Actual',1,TRUE)
for (jjj in 1:par3) a<-table.element(a,paste('C',jjj,sep=''),1,TRUE)
a<-table.element(a,'CV',1,TRUE)
for (jjj in 1:par3) a<-table.element(a,paste('C',jjj,sep=''),1,TRUE)
a<-table.element(a,'CV',1,TRUE)
a<-table.row.end(a)
for (i in 1:10) {
ind <- sample(2, nrow(x), replace=T, prob=c(0.9,0.1))
m.ct <- ctree(as.formula(paste('as.factor(',colnames(x)[par1],') ~ .',sep='')),data =x[ind==1,])
if (i==1) {
m.ct.i.pred <- predict(m.ct, newdata=x[ind==1,])
m.ct.i.actu <- x[ind==1,par1]
m.ct.x.pred <- predict(m.ct, newdata=x[ind==2,])
m.ct.x.actu <- x[ind==2,par1]
} else {
m.ct.i.pred <- c(m.ct.i.pred,predict(m.ct, newdata=x[ind==1,]))
m.ct.i.actu <- c(m.ct.i.actu,x[ind==1,par1])
m.ct.x.pred <- c(m.ct.x.pred,predict(m.ct, newdata=x[ind==2,]))
m.ct.x.actu <- c(m.ct.x.actu,x[ind==2,par1])
}
}
print(m.ct.i.tab <- table(m.ct.i.actu,m.ct.i.pred))
numer <- 0
for (i in 1:par3) {
print(m.ct.i.tab[i,i] / sum(m.ct.i.tab[i,]))
numer <- numer + m.ct.i.tab[i,i]
}
print(m.ct.i.cp <- numer / sum(m.ct.i.tab))
print(m.ct.x.tab <- table(m.ct.x.actu,m.ct.x.pred))
numer <- 0
for (i in 1:par3) {
print(m.ct.x.tab[i,i] / sum(m.ct.x.tab[i,]))
numer <- numer + m.ct.x.tab[i,i]
}
print(m.ct.x.cp <- numer / sum(m.ct.x.tab))
for (i in 1:par3) {
a<-table.row.start(a)
a<-table.element(a,paste('C',i,sep=''),1,TRUE)
for (jjj in 1:par3) a<-table.element(a,m.ct.i.tab[i,jjj])
a<-table.element(a,round(m.ct.i.tab[i,i]/sum(m.ct.i.tab[i,]),4))
for (jjj in 1:par3) a<-table.element(a,m.ct.x.tab[i,jjj])
a<-table.element(a,round(m.ct.x.tab[i,i]/sum(m.ct.x.tab[i,]),4))
a<-table.row.end(a)
}
a<-table.row.start(a)
a<-table.element(a,'Overall',1,TRUE)
for (jjj in 1:par3) a<-table.element(a,'-')
a<-table.element(a,round(m.ct.i.cp,4))
for (jjj in 1:par3) a<-table.element(a,'-')
a<-table.element(a,round(m.ct.x.cp,4))
a<-table.row.end(a)
a<-table.end(a)
table.save(a,file="/var/wessaorg/rcomp/tmp/1xlfy1324680293.tab") 
}
}
m
postscript(file="/var/wessaorg/rcomp/tmp/2zp471324680293.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) 
plot(m)
dev.off()
postscript(file="/var/wessaorg/rcomp/tmp/3x07n1324680293.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) 
plot(x[,par1] ~ as.factor(where(m)),main='Response by Terminal Node',xlab='Terminal Node',ylab='Response')
dev.off()
if (par2 == 'none') {
forec <- predict(m)
result <- as.data.frame(cbind(x[,par1],forec,x[,par1]-forec))
colnames(result) <- c('Actuals','Forecasts','Residuals')
print(result)
}
if (par2 != 'none') {
print(cbind(as.factor(x[,par1]),predict(m)))
myt <- table(as.factor(x[,par1]),predict(m))
print(myt)
}
postscript(file="/var/wessaorg/rcomp/tmp/4y86e1324680293.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) 
if(par2=='none') {
op <- par(mfrow=c(2,2))
plot(density(result$Actuals),main='Kernel Density Plot of Actuals')
plot(density(result$Residuals),main='Kernel Density Plot of Residuals')
plot(result$Forecasts,result$Actuals,main='Actuals versus Predictions',xlab='Predictions',ylab='Actuals')
plot(density(result$Forecasts),main='Kernel Density Plot of Predictions')
par(op)
}
if(par2!='none') {
plot(myt,main='Confusion Matrix',xlab='Actual',ylab='Predicted')
}
dev.off()
if (par2 == 'none') {
detcoef <- cor(result$Forecasts,result$Actuals)
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Goodness of Fit',2,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Correlation',1,TRUE)
a<-table.element(a,round(detcoef,4))
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'R-squared',1,TRUE)
a<-table.element(a,round(detcoef*detcoef,4))
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'RMSE',1,TRUE)
a<-table.element(a,round(sqrt(mean((result$Residuals)^2)),4))
a<-table.row.end(a)
a<-table.end(a)
table.save(a,file="/var/wessaorg/rcomp/tmp/5zb7t1324680293.tab") 
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Actuals, Predictions, and Residuals',4,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'#',header=TRUE)
a<-table.element(a,'Actuals',header=TRUE)
a<-table.element(a,'Forecasts',header=TRUE)
a<-table.element(a,'Residuals',header=TRUE)
a<-table.row.end(a)
for (i in 1:length(result$Actuals)) {
a<-table.row.start(a)
a<-table.element(a,i,header=TRUE)
a<-table.element(a,result$Actuals[i])
a<-table.element(a,result$Forecasts[i])
a<-table.element(a,result$Residuals[i])
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file="/var/wessaorg/rcomp/tmp/6rnm11324680293.tab") 
}
if (par2 != 'none') {
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Confusion Matrix (predicted in columns / actuals in rows)',par3+1,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'',1,TRUE)
for (i in 1:par3) {
a<-table.element(a,paste('C',i,sep=''),1,TRUE)
}
a<-table.row.end(a)
for (i in 1:par3) {
a<-table.row.start(a)
a<-table.element(a,paste('C',i,sep=''),1,TRUE)
for (j in 1:par3) {
a<-table.element(a,myt[i,j])
}
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file="/var/wessaorg/rcomp/tmp/7fczy1324680293.tab") 
}

try(system("convert tmp/2zp471324680293.ps tmp/2zp471324680293.png",intern=TRUE))
try(system("convert tmp/3x07n1324680293.ps tmp/3x07n1324680293.png",intern=TRUE))
try(system("convert tmp/4y86e1324680293.ps tmp/4y86e1324680293.png",intern=TRUE))

