Serving the Quantitative Finance Community

 
User avatar
countblessings
Topic Author
Posts: 0
Joined: June 7th, 2012, 11:05 am

R Question on persp function

May 27th, 2014, 9:30 am

Hi All - Please see below and advise if you would know the cause for the error "invalid 'z' argument". I have ensured z is the same dimension as 'x', and 'y'. Thanks much.> unique(sort(returns$ABC)) [1] 3.797441 3.799774 3.803247 3.810240 3.813741 3.816694 3.817892 3.830253 [9] 3.831925 3.834632 3.840804 3.840918 3.844687 3.845418 3.846447 3.847197 [17] 3.847941 3.847959 3.850835 3.853354 3.853437 3.855340 3.857322 3.859312 [25] 3.859436 3.859784 3.861996 3.863260 3.865748 3.893238 3.899964 3.901930 [33] 3.904342 3.914072 3.918178 3.920001 3.923059 3.928393 3.928587 3.929148 [41] 3.936047 3.937208 3.939532 3.939833 3.940528 3.944839 3.945068 3.958581 [49] 3.962122 3.962215 3.963068 3.963242 3.968346 3.968727 3.969420 3.969672 [57] 3.976058 3.977803 3.978424 3.980592 3.981944 3.998648 4.028175 4.035569 [65] 4.038265 4.041785 4.042338 4.050577 4.051642 4.051682 4.052925 4.054387 [73] 4.055002 4.055685 4.060776 4.061649 4.063652 4.065851 4.066597 4.066776 [81] 4.068439 4.076675 4.083155 4.083182 4.083943 4.086031 4.090011 4.090803 [89] 4.092659 4.094053 4.097773 4.098674 4.099444 4.102895 4.105761 4.105940 [97] 4.107467 4.108816 4.111324 4.112365 4.112706 4.114066 4.115887 4.119281[105] 4.120303 4.120353 4.122410 4.126879 4.128161 4.133401 4.133904 4.134200[113] 4.135030 4.135330 4.137343 4.137464 4.138053 4.139010 4.146901 4.151760[121] 4.151934 4.152196 4.152219 4.155420 4.156279 4.161443 4.163809 4.171010[129] 4.285857 4.286890 4.288882 4.297404 4.302733 4.303441 4.304059 4.309363[137] 4.312870 4.314272 4.332501 4.339840> unique(sort(returns$DEF)) [1] 8.009089 8.014559 8.014727 8.017862 8.022953 8.023444 8.025575 8.026716 [9] 8.027040 8.034358 8.039206 8.046752 8.052659 8.054409 8.056153 8.058215 [17] 8.058844 8.059320 8.060425 8.060584 8.062793 8.063419 8.064991 8.065621 [25] 8.065769 8.065937 8.067031 8.068444 8.072508 8.094253 8.100334 8.102010 [33] 8.105487 8.108199 8.108348 8.109252 8.111648 8.115245 8.116593 8.117635 [41] 8.120910 8.126098 8.127130 8.128163 8.129635 8.134924 8.138145 8.138726 [49] 8.141204 8.141785 8.142517 8.145413 8.146001 8.149181 8.150048 8.152786 [57] 8.152934 8.153076 8.153365 8.154800 8.168210 8.171458 8.197119 8.213510 [65] 8.220072 8.221470 8.221874 8.223082 8.223568 8.224290 8.225093 8.225492 [73] 8.226834 8.228704 8.228970 8.229236 8.229498 8.229581 8.230040 8.233762 [81] 8.235433 8.240106 8.243349 8.243611 8.245108 8.248517 8.250297 8.251915 [89] 8.257835 8.258229 8.260551 8.264551 8.269173 8.269175 8.269940 8.271095 [97] 8.272504 8.272882 8.274036 8.276201 8.276372 8.277342 8.279374 8.281900[105] 8.284558 8.285869 8.286325 8.286575 8.286705 8.288210 8.288712 8.289339[113] 8.290465 8.290970 8.292476 8.294727 8.295974 8.298833 8.301820 8.302554[121] 8.310582 8.311779 8.311938 8.312800 8.315490 8.316712 8.317445 8.334876[129] 8.432085 8.434150 8.438700 8.439027 8.441080 8.443663 8.445809 8.446354[137] 8.448713 8.456289 8.459144 8.477729> unique(sort(returns$GHI)) [1] 4.252273 4.253354 4.254225 4.258427 4.259970 4.260334 4.261348 4.261840 [9] 4.262250 4.263915 4.265389 4.267696 4.272864 4.276541 4.278934 4.279932 [17] 4.280805 4.282451 4.283374 4.284114 4.284232 4.284401 4.285025 4.285034 [25] 4.286470 4.287052 4.287411 4.288451 4.288782 4.295856 4.296923 4.297826 [33] 4.298914 4.301299 4.302888 4.302934 4.305027 4.305103 4.305802 4.306633 [41] 4.306773 4.307109 4.307745 4.308052 4.308992 4.310062 4.310210 4.310234 [49] 4.312447 4.312891 4.313355 4.314544 4.315325 4.317847 4.317858 4.320886 [57] 4.325496 4.325505 4.325515 4.330970 4.332286 4.338788 4.339169 4.339795 [65] 4.340624 4.341108 4.341692 4.342570 4.347050 4.349598 4.350190 4.352142 [73] 4.354690 4.358524 4.363928 4.366002 4.367096 4.369419 4.369507 4.370167 [81] 4.370409 4.370785 4.371043 4.371541 4.373860 4.374132 4.374649 4.374676 [89] 4.376530 4.378135 4.378297 4.378880 4.379412 4.379581 4.379779 4.380229 [97] 4.381423 4.384481 4.385149 4.385688 4.386779 4.387584 4.388770 4.388847[105] 4.390346 4.391268 4.392438 4.392960 4.393703 4.395858 4.396519 4.397127[113] 4.398971 4.399631 4.401002 4.404109 4.404298 4.404493 4.408388 4.408774[121] 4.410844 4.413465 4.415812 4.418293 4.420801 4.427057 4.430180 4.433600[129] 4.434509 4.438002 4.441285 4.441857 4.443790 4.446019 4.452260 4.458230[137] 4.459305 4.465445 4.469132 4.472145> persp(x=unique(sort(returns$ABC)), y=unique(sort(returns$DEF)), z=((returns$GHI)), xlab="ABC", ylab="DEF", zlab="GHI")Error in persp.default(x = unique(sort(returns$ABC)), y = unique(sort(returns$DEF)), : invalid 'z' argument> persp(x=unique(sort(returns$ABC)), y=unique(sort(returns$DEF)), z=(unique(sort(returns$GHI))), xlab="ABC", ylab="DEF", zlab="GHI")Error in persp.default(x = unique(sort(returns$ABC)), y = unique(sort(returns$DEF)), : invalid 'z' argument
 
User avatar
Hansi
Posts: 41
Joined: January 25th, 2010, 11:47 am

R Question on persp function

May 27th, 2014, 10:13 am

The default use of persp is having x and y as the axis and z as a matrix reflecting the values of the surface/contour. e.g:R> x <- 1:10R> y <- 1:10R> z <- outer(x,y,function(a,b) a*b)R> persp(x=x,y=y,z=z)Which isn't actually related to what you seem to be doing, so the question I'd raise is what do you want to do rather than what do you want persp to do?
 
User avatar
countblessings
Topic Author
Posts: 0
Joined: June 7th, 2012, 11:05 am

R Question on persp function

May 27th, 2014, 10:48 am

Thanks Hansi. All I had wanted to do was what persp was designed to do. Your explanation has cleared it up - thanks.