Home » date » 2010 » Dec » 21 »

workshop 10

*The author of this computation has been verified*
R Software Module: /rwasp_regression_trees1.wasp (opens new window with default values)
Title produced by software: Recursive Partitioning (Regression Trees)
Date of computation: Tue, 21 Dec 2010 13:51:36 +0000
 
Cite this page as follows:
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL http://www.freestatistics.org/blog/date/2010/Dec/21/t1292939482306yvsu0hedsul5.htm/, Retrieved Tue, 21 Dec 2010 14:51:26 +0100
 
BibTeX entries for LaTeX users:
@Manual{KEY,
    author = {{YOUR NAME}},
    publisher = {Office for Research Development and Education},
    title = {Statistical Computations at FreeStatistics.org, URL http://www.freestatistics.org/blog/date/2010/Dec/21/t1292939482306yvsu0hedsul5.htm/},
    year = {2010},
}
@Manual{R,
    title = {R: A Language and Environment for Statistical Computing},
    author = {{R Development Core Team}},
    organization = {R Foundation for Statistical Computing},
    address = {Vienna, Austria},
    year = {2010},
    note = {{ISBN} 3-900051-07-0},
    url = {http://www.R-project.org},
}
 
Original text written by user:
 
IsPrivate?
No (this computation is public)
 
User-defined keywords:
 
Dataseries X:
» Textbox « » Textfile « » CSV «
162556 807 213118 6282154 29790 444 81767 4321023 87550 412 153198 4111912 84738 428 -26007 223193 54660 315 126942 1491348 42634 168 157214 1629616 40949 263 129352 1398893 45187 267 234817 1926517 37704 228 60448 983660 16275 129 47818 1443586 25830 104 245546 1073089 12679 122 48020 984885 18014 393 -1710 1405225 43556 190 32648 227132 24811 280 95350 929118 6575 63 151352 1071292 7123 102 288170 638830 21950 265 114337 856956 37597 234 37884 992426 17821 277 122844 444477 12988 73 82340 857217 22330 67 79801 711969 13326 103 165548 702380 16189 290 116384 358589 7146 83 134028 297978 15824 56 63838 585715 27664 236 74996 657954 11920 73 31080 209458 8568 34 32168 786690 14416 139 49857 439798 3369 26 87161 688779 11819 70 106113 574339 6984 40 80570 741409 4519 42 102129 597793 2220 12 301670 644190 18562 211 102313 377934 10327 74 88577 640273 5336 80 112477 697458 2365 83 191778 550608 4069 131 79804 207393 8636 203 128294 301607 13718 56 96448 345783 4525 89 93 etc...
 
Output produced by software:

Enter (or paste) a matrix (table) containing all data (time) series. Every column represents a different variable and must be delimited by a space or Tab. Every row represents a period in time (or category) and must be delimited by hard returns. The easiest way to enter data is to copy and paste a block of spreadsheet cells. Please, do not use commas or spaces to seperate groups of digits!


Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time27 seconds
R Server'Gwilym Jenkins' @ 72.249.127.135


Goodness of Fit
Correlation0.6588
R-squared0.434
RMSE323514.9255


Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
162821541991179.083333334290974.91666667
243210231991179.083333332329843.91666667
341119121991179.083333332120732.91666667
42231931991179.08333333-1767986.08333333
514913481991179.08333333-499831.083333333
616296161991179.08333333-361563.083333333
713988931991179.08333333-592286.083333333
819265171991179.08333333-64662.0833333333
99836601991179.08333333-1007519.08333333
101443586678836.631578947764749.368421053
111073089678836.631578947394252.368421053
12984885678836.631578947306048.368421053
131405225678836.631578947726388.368421053
142271321991179.08333333-1764047.08333333
15929118678836.631578947250281.368421053
161071292436863.25862069634428.74137931
17638830436863.25862069201966.741379310
18856956678836.631578947178119.368421053
199924261991179.08333333-998753.083333333
20444477678836.631578947-234359.631578947
21857217678836.631578947178380.368421053
22711969678836.63157894733132.3684210526
23702380678836.63157894723543.3684210526
24358589678836.631578947-320247.631578947
25297978436863.25862069-138885.258620690
26585715678836.631578947-93121.6315789474
27657954678836.631578947-20882.6315789474
28209458311459.00877193-102001.008771930
29786690311459.00877193475230.99122807
30439798678836.631578947-239038.631578947
31688779436863.25862069251915.74137931
32574339436863.25862069137475.741379310
33741409311459.00877193429949.99122807
34597793436863.25862069160929.741379310
35644190436863.25862069207326.741379310
36377934678836.631578947-300902.631578947
37640273436863.25862069203409.741379310
38697458436863.25862069260594.741379310
39550608436863.25862069113744.741379310
40207393311459.00877193-104066.008771930
41301607436863.25862069-135256.258620690
42345783678836.631578947-333053.631578947
43501749436863.2586206964885.7413793103
44379983436863.25862069-56880.2586206897
45387475311459.0087719376015.9912280702
46377305436863.25862069-59558.2586206897
47370837436863.25862069-66026.2586206897
48430866436863.25862069-5997.25862068968
49469107436863.2586206932243.7413793103
50194493311459.00877193-116966.008771930
51530670436863.2586206993806.7413793103
52518365436863.2586206981501.7413793103
53491303436863.2586206954439.7413793103
54527021436863.2586206990157.7413793103
55233773436863.25862069-203090.258620690
56405972311459.0087719394512.9912280702
57652925311459.00877193341465.99122807
58446211436863.258620699347.74137931032
59341340436863.25862069-95523.2586206897
60387699436863.25862069-49164.2586206897
61493408436863.2586206956544.7413793103
62146494311459.00877193-164965.00877193
63414462436863.25862069-22401.2586206897
64364304311459.0087719352844.9912280702
65355178311459.0087719343718.9912280702
66357760678836.631578947-321076.631578947
67261216311459.00877193-50243.0087719298
68397144436863.25862069-39719.2586206897
69374943436863.25862069-61920.2586206897
70424898436863.25862069-11965.2586206897
71202055311459.00877193-109404.008771930
72378525311459.0087719367065.9912280702
73310768436863.25862069-126095.258620690
74325738311459.0087719314278.9912280702
75394510436863.25862069-42353.2586206897
76247060311459.00877193-64399.0087719298
77368078436863.25862069-68785.2586206897
78236761311459.00877193-74698.0087719298
79312378311459.00877193918.991228070168
80339836436863.25862069-97027.2586206897
81347385311459.0087719335925.9912280702
82426280436863.25862069-10583.2586206897
83352850436863.25862069-84013.2586206897
84301881311459.00877193-9578.00877192983
85377516436863.25862069-59347.2586206897
86357312311459.0087719345852.9912280702
87458343436863.2586206921479.7413793103
88354228436863.25862069-82635.2586206897
89308636436863.25862069-128227.258620690
90386212436863.25862069-50651.2586206897
91393343436863.25862069-43520.2586206897
92378509311459.0087719367049.9912280702
93452469311459.00877193141009.99122807
94364839436863.25862069-72024.2586206897
95358649311459.0087719347189.9912280702
96376641311459.0087719365181.9912280702
97429112436863.25862069-7751.25862068968
98330546311459.0087719319086.9912280702
99403560436863.25862069-33303.2586206897
100317892311459.008771936432.99122807017
101307528311459.00877193-3931.00877192983
102235133436863.25862069-201730.258620690
103299243436863.25862069-137620.258620690
104314073436863.25862069-122790.258620690
105368186311459.0087719356726.9912280702
106269661311459.00877193-41798.0087719298
107125390311459.00877193-186069.008771930
108510834436863.2586206973970.7413793103
109321896436863.25862069-114967.258620690
110249898311459.00877193-61561.0087719298
111408881311459.0087719397421.9912280702
112158492311459.00877193-152967.00877193
113292154311459.00877193-19305.0087719298
114289513311459.00877193-21946.0087719298
115378049311459.0087719366589.9912280702
116343466311459.0087719332006.9912280702
117332743311459.0087719321283.9912280702
118442882436863.258620696018.74137931032
119214215311459.00877193-97244.0087719298
120315688311459.008771934228.99122807017
121375195436863.25862069-61668.2586206897
122334280311459.0087719322820.9912280702
123355864436863.25862069-80999.2586206897
124480382436863.2586206943518.7413793103
125353058311459.0087719341598.9912280702
126217193311459.00877193-94266.0087719298
127315380311459.008771933920.99122807017
128314533311459.008771933073.99122807017
129318056311459.008771936596.99122807017
130315380311459.008771933920.99122807017
131314353311459.008771932893.99122807017
132369448311459.0087719357988.9912280702
133315380311459.008771933920.99122807017
134312846311459.008771931386.99122807017
135312075311459.00877193615.991228070168
136315009311459.008771933549.99122807017
137318903311459.008771937443.99122807017
138314887311459.008771933427.99122807017
139314913311459.008771933453.99122807017
140315380311459.008771933920.99122807017
141325506311459.0087719314046.9912280702
142315380311459.008771933920.99122807017
143298568311459.00877193-12891.0087719298
144315834311459.008771934374.99122807017
145329784311459.0087719318324.9912280702
146312878311459.008771931418.99122807017
147315380311459.008771933920.99122807017
148314987311459.008771933527.99122807017
149325249311459.0087719313789.9912280702
150315877311459.008771934417.99122807017
151291650311459.00877193-19809.0087719298
152305959311459.00877193-5500.00877192983
153315380311459.008771933920.99122807017
154297765311459.00877193-13694.0087719298
155315245311459.008771933785.99122807017
156315380311459.008771933920.99122807017
157315380311459.008771933920.99122807017
158315236311459.008771933776.99122807017
159336425311459.0087719324965.9912280702
160315380311459.008771933920.99122807017
161315380311459.008771933920.99122807017
162315380311459.008771933920.99122807017
163315380311459.008771933920.99122807017
164306268311459.00877193-5191.00877192983
165302187311459.00877193-9272.00877192983
166314882311459.008771933422.99122807017
167315380311459.008771933920.99122807017
168382712311459.0087719371252.9912280702
169341570311459.0087719330110.9912280702
170315380311459.008771933920.99122807017
171315380311459.008771933920.99122807017
172312412311459.00877193952.991228070168
173315380311459.008771933920.99122807017
174309596311459.00877193-1863.00877192983
175315380311459.008771933920.99122807017
176315547311459.008771934087.99122807017
177313267311459.008771931807.99122807017
178316176311459.008771934716.99122807017
179315380311459.008771933920.99122807017
180315380311459.008771933920.99122807017
181359335311459.0087719347875.9912280702
182330068311459.0087719318608.9912280702
183314289311459.008771932829.99122807017
184297413311459.00877193-14046.0087719298
185314806311459.008771933346.99122807017
186333210311459.0087719321750.9912280702
187352108311459.0087719340648.9912280702
188313332311459.008771931872.99122807017
189291787311459.00877193-19672.0087719298
190315380311459.008771933920.99122807017
191318745311459.008771937285.99122807017
192315380311459.008771933920.99122807017
193315366311459.008771933906.99122807017
194315380311459.008771933920.99122807017
195315688311459.008771934228.99122807017
196315380311459.008771933920.99122807017
197409642436863.25862069-27221.2586206897
198315380311459.008771933920.99122807017
199315380311459.008771933920.99122807017
200269587311459.00877193-41872.0087719298
201315380311459.008771933920.99122807017
202315380311459.008771933920.99122807017
203315380311459.008771933920.99122807017
204300962311459.00877193-10497.0087719298
205325479436863.25862069-111384.258620690
206316155311459.008771934695.99122807017
207318574311459.008771937114.99122807017
208315380311459.008771933920.99122807017
209343613311459.0087719332153.9912280702
210306948311459.00877193-4511.00877192983
211315380311459.008771933920.99122807017
212315380311459.008771933920.99122807017
213330059311459.0087719318599.9912280702
214288985311459.00877193-22474.0087719298
215304485311459.00877193-6974.00877192983
216315380311459.008771933920.99122807017
217315688311459.008771934228.99122807017
218317736311459.008771936276.99122807017
219315380311459.008771933920.99122807017
220322331311459.0087719310871.9912280702
221296656311459.00877193-14803.0087719298
222315380311459.008771933920.99122807017
223315354311459.008771933894.99122807017
224312161311459.00877193701.991228070168
225315576311459.008771934116.99122807017
226314922311459.008771933462.99122807017
227314551311459.008771933091.99122807017
228315380311459.008771933920.99122807017
229312339311459.00877193879.991228070168
230315380311459.008771933920.99122807017
231298700311459.00877193-12759.0087719298
232321376311459.008771939916.99122807017
233315380311459.008771933920.99122807017
234303230311459.00877193-8229.00877192983
235315380311459.008771933920.99122807017
236315487311459.008771934027.99122807017
237315380311459.008771933920.99122807017
238315793311459.008771934333.99122807017
239315380311459.008771933920.99122807017
240315380311459.008771933920.99122807017
241315380311459.008771933920.99122807017
242312887311459.008771931427.99122807017
243315380311459.008771933920.99122807017
244315637311459.008771934177.99122807017
245324385311459.0087719312925.9912280702
246315380311459.008771933920.99122807017
247315380311459.008771933920.99122807017
248308989311459.00877193-2470.00877192983
249315380311459.008771933920.99122807017
250315380311459.008771933920.99122807017
251296702311459.00877193-14757.0087719298
252315380311459.008771933920.99122807017
253307322311459.00877193-4137.00877192983
254304376311459.00877193-7083.00877192983
255253588311459.00877193-57871.0087719298
256315380311459.008771933920.99122807017
257309560311459.00877193-1899.00877192983
258298466311459.00877193-12993.0087719298
259315380311459.008771933920.99122807017
260315380311459.008771933920.99122807017
261315380311459.008771933920.99122807017
262315380311459.008771933920.99122807017
263343929311459.0087719332469.9912280702
264331955311459.0087719320495.9912280702
265315380311459.008771933920.99122807017
266315380311459.008771933920.99122807017
267315380311459.008771933920.99122807017
268381180311459.0087719369720.9912280702
269315380311459.008771933920.99122807017
270331420311459.0087719319960.9912280702
271315380311459.008771933920.99122807017
272315380311459.008771933920.99122807017
273315380311459.008771933920.99122807017
274310201311459.00877193-1258.00877192983
275315380311459.008771933920.99122807017
276320016311459.008771938556.99122807017
277320398311459.008771938938.99122807017
278315380311459.008771933920.99122807017
279291841311459.00877193-19618.0087719298
280310670311459.00877193-789.008771929832
281315380311459.008771933920.99122807017
282315380311459.008771933920.99122807017
283313491311459.008771932031.99122807017
284315380311459.008771933920.99122807017
285331323311459.0087719319863.9912280702
286315380311459.008771933920.99122807017
287319210311459.008771937750.99122807017
288318098311459.008771936638.99122807017
289315380311459.008771933920.99122807017
290292754311459.00877193-18705.0087719298
291315380311459.008771933920.99122807017
292325176311459.0087719313716.9912280702
293365959311459.0087719354499.9912280702
294315380311459.008771933920.99122807017
295302409311459.00877193-9050.00877192983
296340968311459.0087719329508.9912280702
297315380311459.008771933920.99122807017
298315380311459.008771933920.99122807017
299315380311459.008771933920.99122807017
300315380311459.008771933920.99122807017
301313164311459.008771931704.99122807017
302301164311459.00877193-10295.0087719298
303315380311459.008771933920.99122807017
304315380311459.008771933920.99122807017
305344425311459.0087719332965.9912280702
306315394311459.008771933934.99122807017
307315380311459.008771933920.99122807017
308316647311459.008771935187.99122807017
309309836311459.00877193-1623.00877192983
310315380311459.008771933920.99122807017
311315380311459.008771933920.99122807017
312346611436863.25862069-90252.2586206897
313315380311459.008771933920.99122807017
314322031311459.0087719310571.9912280702
315315656311459.008771934196.99122807017
316339445311459.0087719327985.9912280702
317314964311459.008771933504.99122807017
318297141311459.00877193-14318.0087719298
319315372311459.008771933912.99122807017
320315380311459.008771933920.99122807017
321315380311459.008771933920.99122807017
322315380311459.008771933920.99122807017
323315380311459.008771933920.99122807017
324315380311459.008771933920.99122807017
325315380311459.008771933920.99122807017
326312502311459.008771931042.99122807017
327315380311459.008771933920.99122807017
328315380311459.008771933920.99122807017
329315380311459.008771933920.99122807017
330315380311459.008771933920.99122807017
331315380311459.008771933920.99122807017
332315380311459.008771933920.99122807017
333315380311459.008771933920.99122807017
334313729311459.008771932269.99122807017
335315388311459.008771933928.99122807017
336315371311459.008771933911.99122807017
337296139311459.00877193-15320.0087719298
338315380311459.008771933920.99122807017
339313880311459.008771932420.99122807017
340317698311459.008771936238.99122807017
341295580311459.00877193-15879.0087719298
342315380311459.008771933920.99122807017
343315380311459.008771933920.99122807017
344315380311459.008771933920.99122807017
345308256311459.00877193-3203.00877192983
346315380311459.008771933920.99122807017
347303677311459.00877193-7782.00877192983
348315380311459.008771933920.99122807017
349315380311459.008771933920.99122807017
350319369311459.008771937909.99122807017
351318690311459.008771937230.99122807017
352314049311459.008771932589.99122807017
353325699311459.0087719314239.9912280702
354314210311459.008771932750.99122807017
355315380311459.008771933920.99122807017
356315380311459.008771933920.99122807017
357322378311459.0087719310918.9912280702
358315380311459.008771933920.99122807017
359315380311459.008771933920.99122807017
360315380311459.008771933920.99122807017
361315398311459.008771933938.99122807017
362315380311459.008771933920.99122807017
363315380311459.008771933920.99122807017
364308336311459.00877193-3123.00877192983
365316386311459.008771934926.99122807017
366315380311459.008771933920.99122807017
367315380311459.008771933920.99122807017
368315380311459.008771933920.99122807017
369315380311459.008771933920.99122807017
370315553311459.008771934093.99122807017
371315380311459.008771933920.99122807017
372323361311459.0087719311901.9912280702
373336639311459.0087719325179.9912280702
374307424311459.00877193-4035.00877192983
375315380311459.008771933920.99122807017
376315380311459.008771933920.99122807017
377295370311459.00877193-16089.0087719298
378322340311459.0087719310880.9912280702
379319864311459.008771938404.99122807017
380315380311459.008771933920.99122807017
381315380311459.008771933920.99122807017
382317291311459.008771935831.99122807017
383280398311459.00877193-31061.0087719298
384315380311459.008771933920.99122807017
385317330311459.008771935870.99122807017
386238125311459.00877193-73334.0087719298
387327071311459.0087719315611.9912280702
388309038311459.00877193-2421.00877192983
389314210311459.008771932750.99122807017
390307930311459.00877193-3529.00877192983
391322327311459.0087719310867.9912280702
392292136311459.00877193-19323.0087719298
393263276311459.00877193-48183.0087719298
394367655311459.0087719356195.9912280702
395283910311459.00877193-27549.0087719298
396283587311459.00877193-27872.0087719298
397243650311459.00877193-67809.0087719298
398438493436863.258620691629.74137931032
399296261311459.00877193-15198.0087719298
400230621311459.00877193-80838.0087719298
401304252311459.00877193-7207.00877192983
402333505311459.0087719322045.9912280702
403296919311459.00877193-14540.0087719298
404278990311459.00877193-32469.0087719298
405276898311459.00877193-34561.0087719298
406327007311459.0087719315547.9912280702
407317046311459.008771935586.99122807017
408304555311459.00877193-6904.00877192983
409298096311459.00877193-13363.0087719298
410231861311459.00877193-79598.0087719298
411309422311459.00877193-2037.00877192983
412286963311459.00877193-24496.0087719298
413269753311459.00877193-41706.0087719298
414448243311459.00877193136783.99122807
415165404311459.00877193-146055.00877193
416204325311459.00877193-107134.008771930
417407159311459.0087719395699.9912280702
418290476311459.00877193-20983.0087719298
419275311311459.00877193-36148.0087719298
420246541311459.00877193-64918.0087719298
421253468311459.00877193-57991.0087719298
422240897311459.00877193-70562.0087719298
423-83265311459.00877193-394724.00877193
424-42143311459.00877193-353602.00877193
425272713311459.00877193-38746.0087719298
426215362311459.00877193-96097.0087719298
42742754311459.00877193-268705.00877193
4283062751991179.08333333-1684904.08333333
429253537311459.00877193-57922.0087719298
430372631678836.631578947-306205.631578947
431-7170678836.631578947-686006.631578947
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2010/Dec/21/t1292939482306yvsu0hedsul5/2da4j1292939468.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/21/t1292939482306yvsu0hedsul5/2da4j1292939468.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/21/t1292939482306yvsu0hedsul5/3da4j1292939468.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/21/t1292939482306yvsu0hedsul5/3da4j1292939468.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/21/t1292939482306yvsu0hedsul5/451l41292939468.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/21/t1292939482306yvsu0hedsul5/451l41292939468.ps (open in new window)


 
Parameters (Session):
par1 = 2 ; par2 = quantiles ; par3 = 2 ; par4 = no ;
 
Parameters (R input):
par1 = 4 ; par2 = none ; par3 = 3 ; par4 = no ;
 
R code (references can be found in the software module):
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)
}
load(file='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='mytable3.tab')
}
}
m
bitmap(file='test1.png')
plot(m)
dev.off()
bitmap(file='test1a.png')
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)
}
bitmap(file='test2.png')
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='mytable1.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='mytable.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='mytable2.tab')
}
 





Copyright

Creative Commons License

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.

Software written by Ed van Stee & Patrick Wessa


Disclaimer

Information provided on this web site is provided "AS IS" without warranty of any kind, either express or implied, including, without limitation, warranties of merchantability, fitness for a particular purpose, and noninfringement. We use reasonable efforts to include accurate and timely information and periodically update the information, and software without notice. However, we make no warranties or representations as to the accuracy or completeness of such information (or software), and we assume no liability or responsibility for errors or omissions in the content of this web site, or any software bugs in online applications. Your use of this web site is AT YOUR OWN RISK. Under no circumstances and under no legal theory shall we be liable to you or any other person for any direct, indirect, special, incidental, exemplary, or consequential damages arising from your access to, or use of, this web site.


Privacy Policy

We may request personal information to be submitted to our servers in order to be able to:

  • personalize online software applications according to your needs
  • enforce strict security rules with respect to the data that you upload (e.g. statistical data)
  • manage user sessions of online applications
  • alert you about important changes or upgrades in resources or applications

We NEVER allow other companies to directly offer registered users information about their products and services. Banner references and hyperlinks of third parties NEVER contain any personal data of the visitor.

We do NOT sell, nor transmit by any means, personal information, nor statistical data series uploaded by you to third parties.

We carefully protect your data from loss, misuse, alteration, and destruction. However, at any time, and under any circumstance you are solely responsible for managing your passwords, and keeping them secret.

We store a unique ANONYMOUS USER ID in the form of a small 'Cookie' on your computer. This allows us to track your progress when using this website which is necessary to create state-dependent features. The cookie is used for NO OTHER PURPOSE. At any time you may opt to disallow cookies from this website - this will not affect other features of this website.

We examine cookies that are used by third-parties (banner and online ads) very closely: abuse from third-parties automatically results in termination of the advertising contract without refund. We have very good reason to believe that the cookies that are produced by third parties (banner ads) do NOT cause any privacy or security risk.

FreeStatistics.org is safe. There is no need to download any software to use the applications and services contained in this website. Hence, your system's security is not compromised by their use, and your personal data - other than data you submit in the account application form, and the user-agent information that is transmitted by your browser - is never transmitted to our servers.

As a general rule, we do not log on-line behavior of individuals (other than normal logging of webserver 'hits'). However, in cases of abuse, hacking, unauthorized access, Denial of Service attacks, illegal copying, hotlinking, non-compliance with international webstandards (such as robots.txt), or any other harmful behavior, our system engineers are empowered to log, track, identify, publish, and ban misbehaving individuals - even if this leads to ban entire blocks of IP addresses, or disclosing user's identity.


FreeStatistics.org is powered by