R version 2.6.0 (2007-10-03) Copyright (C) 2007 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > y <- c(103.1,100.6,103.1,95.5,90.5,90.9,88.8,90.7,94.3,104.6,111.1,110.8,107.2,99,99,91,96.2,96.9,96.2,100.1,99,115.4,106.9,107.1,99.3,99.2,108.3,105.6,99.5,107.4,93.1,88.1,110.7,113.1,99.6,93.6,98.6,99.6,114.3,107.8,101.2,112.5,100.5,93.9,116.2,112,106.4,95.7,96,95.8,103,102.2,98.4,111.4,86.6,91.3,107.9,101.8,104.4,93.4,100.1,98.5,112.9,101.4,107.1,110.8,90.3,95.5,111.4,113,107.5,95.9,106.3,105.2,117.2,106.9,108.2,110,96.1,100.6) > x <- c(98.1,101.1,111.1,93.3,100,108,70.4,75.4,105.5,112.3,102.5,93.5,86.7,95.2,103.8,97,95.5,101,67.5,64,106.7,100.6,101.2,93.1,84.2,85.8,91.8,92.4,80.3,79.7,62.5,57.1,100.8,100.7,86.2,83.2,71.7,77.5,89.8,80.3,78.7,93.8,57.6,60.6,91,85.3,77.4,77.3,68.3,69.9,81.7,75.1,69.9,84,54.3,60,89.9,77,85.3,77.6,69.2,75.5,85.7,72.2,79.9,85.3,52.2,61.2,82.4,85.4,78.2,70.2,70.2,69.3,77.5,66.1,69,75.3,58.2,59.7) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: Wessa P., (2007), Box-Cox Linearity Plot (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_boxcoxlin.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description > n <- length(x) > c <- array(NA,dim=c(401)) > l <- array(NA,dim=c(401)) > mx <- 0 > mxli <- -999 > for (i in 1:401) + { + l[i] <- (i-201)/100 + if (l[i] != 0) + { + x1 <- (x^l[i] - 1) / l[i] + } else { + x1 <- log(x) + } + c[i] <- cor(x1,y) + if (mx < abs(c[i])) + { + mx <- abs(c[i]) + mxli <- l[i] + } + } > c [1] 0.4295763 0.4293510 0.4291248 0.4288979 0.4286703 0.4284418 0.4282127 [8] 0.4279828 0.4277521 0.4275207 0.4272885 0.4270556 0.4268219 0.4265875 [15] 0.4263523 0.4261164 0.4258797 0.4256423 0.4254041 0.4251652 0.4249256 [22] 0.4246851 0.4244440 0.4242021 0.4239595 0.4237161 0.4234720 0.4232271 [29] 0.4229815 0.4227352 0.4224881 0.4222403 0.4219918 0.4217425 0.4214925 [36] 0.4212418 0.4209903 0.4207381 0.4204851 0.4202314 0.4199770 0.4197219 [43] 0.4194661 0.4192095 0.4189522 0.4186941 0.4184354 0.4181759 0.4179157 [50] 0.4176548 0.4173931 0.4171307 0.4168677 0.4166039 0.4163394 0.4160741 [57] 0.4158082 0.4155415 0.4152742 0.4150061 0.4147373 0.4144678 0.4141976 [64] 0.4139267 0.4136551 0.4133828 0.4131098 0.4128360 0.4125616 0.4122865 [71] 0.4120107 0.4117342 0.4114570 0.4111791 0.4109005 0.4106212 0.4103412 [78] 0.4100605 0.4097792 0.4094971 0.4092144 0.4089310 0.4086469 0.4083621 [85] 0.4080767 0.4077906 0.4075037 0.4072163 0.4069281 0.4066393 0.4063497 [92] 0.4060596 0.4057687 0.4054772 0.4051850 0.4048922 0.4045987 0.4043045 [99] 0.4040097 0.4037142 0.4034180 0.4031212 0.4028237 0.4025256 0.4022269 [106] 0.4019274 0.4016274 0.4013267 0.4010253 0.4007233 0.4004207 0.4001174 [113] 0.3998134 0.3995089 0.3992037 0.3988978 0.3985914 0.3982843 0.3979765 [120] 0.3976682 0.3973592 0.3970496 0.3967393 0.3964285 0.3961170 0.3958049 [127] 0.3954922 0.3951789 0.3948649 0.3945504 0.3942352 0.3939195 0.3936031 [134] 0.3932861 0.3929685 0.3926503 0.3923316 0.3920122 0.3916922 0.3913716 [141] 0.3910505 0.3907287 0.3904064 0.3900834 0.3897599 0.3894358 0.3891111 [148] 0.3887859 0.3884600 0.3881336 0.3878066 0.3874791 0.3871509 0.3868222 [155] 0.3864930 0.3861631 0.3858327 0.3855018 0.3851703 0.3848382 0.3845056 [162] 0.3841724 0.3838387 0.3835044 0.3831696 0.3828342 0.3824983 0.3821618 [169] 0.3818248 0.3814873 0.3811492 0.3808106 0.3804715 0.3801318 0.3797916 [176] 0.3794509 0.3791097 0.3787679 0.3784256 0.3780828 0.3777395 0.3773957 [183] 0.3770513 0.3767065 0.3763611 0.3760153 0.3756689 0.3753220 0.3749747 [190] 0.3746268 0.3742785 0.3739296 0.3735803 0.3732304 0.3728801 0.3725293 [197] 0.3721780 0.3718263 0.3714741 0.3711213 0.3707682 0.3704145 0.3700604 [204] 0.3697058 0.3693507 0.3689952 0.3686392 0.3682828 0.3679259 0.3675685 [211] 0.3672107 0.3668525 0.3664938 0.3661346 0.3657751 0.3654150 0.3650546 [218] 0.3646937 0.3643323 0.3639706 0.3636084 0.3632457 0.3628827 0.3625192 [225] 0.3621553 0.3617910 0.3614263 0.3610611 0.3606956 0.3603296 0.3599633 [232] 0.3595965 0.3592293 0.3588617 0.3584937 0.3581254 0.3577566 0.3573874 [239] 0.3570179 0.3566480 0.3562776 0.3559069 0.3555359 0.3551644 0.3547926 [246] 0.3544204 0.3540478 0.3536748 0.3533015 0.3529278 0.3525538 0.3521794 [253] 0.3518046 0.3514295 0.3510541 0.3506783 0.3503021 0.3499256 0.3495487 [260] 0.3491715 0.3487940 0.3484162 0.3480380 0.3476594 0.3472806 0.3469014 [267] 0.3465219 0.3461420 0.3457619 0.3453814 0.3450006 0.3446195 0.3442381 [274] 0.3438564 0.3434744 0.3430920 0.3427094 0.3423265 0.3419432 0.3415597 [281] 0.3411759 0.3407918 0.3404074 0.3400228 0.3396378 0.3392526 0.3388670 [288] 0.3384813 0.3380952 0.3377089 0.3373222 0.3369354 0.3365482 0.3361608 [295] 0.3357732 0.3353853 0.3349971 0.3346087 0.3342200 0.3338311 0.3334419 [302] 0.3330525 0.3326629 0.3322730 0.3318829 0.3314925 0.3311019 0.3307111 [309] 0.3303201 0.3299288 0.3295373 0.3291456 0.3287537 0.3283616 0.3279692 [316] 0.3275766 0.3271839 0.3267909 0.3263977 0.3260043 0.3256108 0.3252170 [323] 0.3248230 0.3244288 0.3240345 0.3236399 0.3232452 0.3228503 0.3224552 [330] 0.3220599 0.3216645 0.3212689 0.3208731 0.3204771 0.3200810 0.3196847 [337] 0.3192883 0.3188917 0.3184949 0.3180980 0.3177009 0.3173037 0.3169063 [344] 0.3165087 0.3161111 0.3157133 0.3153153 0.3149172 0.3145190 0.3141207 [351] 0.3137222 0.3133236 0.3129248 0.3125259 0.3121270 0.3117279 0.3113286 [358] 0.3109293 0.3105298 0.3101303 0.3097306 0.3093308 0.3089310 0.3085310 [365] 0.3081309 0.3077307 0.3073304 0.3069301 0.3065296 0.3061291 0.3057284 [372] 0.3053277 0.3049269 0.3045261 0.3041251 0.3037241 0.3033230 0.3029218 [379] 0.3025205 0.3021192 0.3017178 0.3013164 0.3009149 0.3005133 0.3001117 [386] 0.2997101 0.2993083 0.2989066 0.2985048 0.2981029 0.2977010 0.2972990 [393] 0.2968970 0.2964950 0.2960930 0.2956909 0.2952887 0.2948866 0.2944844 [400] 0.2940822 0.2936800 > mx [1] 0.4295763 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > r<-lm(y~x) > se <- sqrt(var(r$residuals)) > r1 <- lm(y~x1) > se1 <- sqrt(var(r1$residuals)) > postscript(file="/var/www/html/rcomp/tmp/1l8fl1194694806.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(l,c,main='Box-Cox Linearity Plot',xlab='Lambda',ylab='correlation') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/2reza1194694806.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x,y,main='Linear Fit of Original Data',xlab='x',ylab='y') > abline(r) > grid() > mtext(paste('Residual Standard Deviation = ',se)) > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/3dnm31194694807.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x1,y,main='Linear Fit of Transformed Data',xlab='x',ylab='y') > abline(r1) > grid() > mtext(paste('Residual Standard Deviation = ',se1)) > dev.off() null device 1 > load(file='/var/www/html/rcomp/createtable') > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Box-Cox Linearity Plot',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'# observations x',header=TRUE) > a<-table.element(a,n) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'maximum correlation',header=TRUE) > a<-table.element(a,mx) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'optimal lambda(x)',header=TRUE) > a<-table.element(a,mxli) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Residual SD (orginial)',header=TRUE) > a<-table.element(a,se) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Residual SD (transformed)',header=TRUE) > a<-table.element(a,se1) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/447og1194694807.tab") > > system("convert tmp/1l8fl1194694806.ps tmp/1l8fl1194694806.png") > system("convert tmp/2reza1194694806.ps tmp/2reza1194694806.png") > system("convert tmp/3dnm31194694807.ps tmp/3dnm31194694807.png") > > > proc.time() user system elapsed 1.857 0.833 1.994