MORE ON TRANSFORMS ================== bash$ tcsh login on famine.stat.cmu.edu [linux] from lust.stat.cmu.edu on ttyp1 using dumb [famine]~/classes/707/week01% S S-PLUS : Copyright (c) 1988, 1999 MathSoft, Inc. S : Copyright Lucent Technologies, Inc. Version 5.1 Release 1 for Linux 2.0.31 : 1999 Working data will be in .Data > ls() [1] ".Last.value" ".Random.seed" "X" "Y" "angell" [6] "last.dump" "prestige" "x" "y" > motif() > par(mfrow=c(3,2)) > for (i in 1:6) { + zz _ qqnorm(rnorm(102)) + abline(lmsreg(zz$x,zz$y)) + } > help.start() Starting Netscape. Please wait for the category list to complete initialization before clicking items in the list or sending additional help requests from the command line. > for (i in 1:6) { + qqnorm(rnorm(102)) + + + qqline(qqline(+ qqline(qqline( + + }} Problem: Syntax error: No opening parenthesis before unbalanced ("}") on input line 4 > source("../week02/qqenv.q") > qqenv function(x, ylab = deparse(substitute(x)), lty1 = 1, lty2 = 1, ...) { # # qqenv - draw # * qqnorm plot # * qqline reference line # * pointwise 95\% conf envelope # for data x, where the approximate 95\% envelope uses delta-method # standard errors suggested by Fox, p. 44. # # # # save z,x from qqnorm plot qqpairs <- qqnorm(x, ylab = ylab, ...) z <- qqpairs[[1]] x <- qqpairs[[2]] # # # save intercept and slope from qqline plot coefs <- qqline(x, lty = lty1) mu <- coefs[1] sigma <- coefs[2] # # # N _ 100 # delta _ 0.1 # zz _ seq((min(z)-delta),(max(z)+delta),length=N) zz <- sort(z) N <- length(zz) # # # compute delta-method std error for conf envelope P <- ppoints(N) SE <- (sigma * sqrt((P * (1 - P))/N))/dnorm(zz) # # # plot it! cat("You can safely ignore \"Line out of bounds\" warnings....\n\n") lines(zz, mu + sigma * zz + 2 * SE, lty = lty2) lines(zz, mu + sigma * zz - 2 * SE, lty = lty2) # # # return all the pieces invisible(return(z, x, mu, sigma, zz, P, SE)) } > for (i in 1:6) { qqenv(i) } You can safely ignore "Line out of bounds" warnings.... You can safely ignore "Line out of bounds" warnings.... You can safely ignore "Line out of bounds" warnings.... You can safely ignore "Line out of bounds" warnings.... You can safely ignore "Line out of bounds" warnings.... You can safely ignore "Line out of bounds" warnings.... > args(qqenv) function(x, ylab = deparse(substitute(x)), lty1 = 1, lty2 = 1, ...) NULL > for (i in 1:6) { qqenv(rnorm(100))} You can safely ignore "Line out of bounds" warnings.... Lines out of bounds X= 1.959964 Y= 2.411252 Lines out of bounds X= 2.17009 Y= 2.731523 Lines out of bounds X= 2.57583 Y= 3.47665 Lines out of bounds X= -2.17009 Y= -2.9362 Lines out of bounds X= -1.959964 Y= -2.61593 Lines out of bounds X= -1.81191 Y= -2.407692 You can safely ignore "Line out of bounds" warnings.... Lines out of bounds X= 2.17009 Y= 2.703094 Lines out of bounds X= 2.57583 Y= 3.41958 Lines out of bounds X= -2.17009 Y= -2.746762 Lines out of bounds X= -1.959964 Y= -2.438803 Lines out of bounds X= -1.81191 Y= -2.23857 You can safely ignore "Line out of bounds" warnings.... Lines out of bounds X= -2.17009 Y= -2.55677 You can safely ignore "Line out of bounds" warnings.... Lines out of bounds X= 2.57583 Y= 3.88049 Lines out of bounds X= -2.17009 Y= -2.920375 Lines out of bounds X= -1.959964 Y= -2.580727 Lines out of bounds X= -1.81191 Y= -2.35989 Lines out of bounds X= -1.695398 Y= -2.194466 Lines out of bounds X= -1.598193 Y= -2.061158 You can safely ignore "Line out of bounds" warnings.... Lines out of bounds X= 2.57583 Y= 2.50414 Lines out of bounds X= -2.17009 Y= -2.199471 You can safely ignore "Line out of bounds" warnings.... Lines out of bounds X= 2.57583 Y= 3.85853 Lines out of bounds X= -2.17009 Y= -2.769524 Lines out of bounds X= -1.959964 Y= -2.438506 >names(prestige) [1] "education" "income" "pct.female" "occ.prestige" "occ.code" [6] "occ.type" > lapply(mode,prestige) Problem in getFunction(farg): couldn't find function definition for "prestige" Use traceback() to see the call stack > lapply(prestige,mode) $education: [1] "numeric" $income: [1] "numeric" $pct.female: [1] "numeric" $occ.prestige: [1] "numeric" $occ.code: [1] "numeric" $occ.type: [1] "numeric" > prestige[1:10,] education income pct.female occ.prestige occ.code occ.type GOV_ADMINISTRATORS 13.11 12351 11.16 68.8 1113 prof GENERAL_MANAGERS 12.26 25879 4.02 69.1 1130 prof ACCOUNTANTS 12.77 9271 15.70 63.4 1171 prof PURCHASING_OFFICERS 11.42 8865 9.11 56.8 1175 prof CHEMISTS 14.62 8403 11.68 73.5 2111 prof PHYSICISTS 15.64 11030 5.13 77.6 2113 prof BIOLOGISTS 15.09 8258 25.65 72.6 2133 prof ARCHITECTS 15.44 14163 2.69 78.1 2141 prof CIVIL_ENGINEERS 14.52 11377 1.03 73.1 2143 prof MINING_ENGINEERS 14.64 11023 0.94 68.8 2153 prof > par(mfrow=c(2,2)) > for (i in names(prestige)[1:4]) qqenv(prestige[,i]) You can safely ignore "Line out of bounds" warnings.... Lines out of bounds X= -2.177923 Y= 5.75593 Lines out of bounds X= -1.96842 Y= 6.0735 Lines out of bounds X= 1.524231 Y= 16.50162 Lines out of bounds X= 1.607964 Y= 16.82793 Lines out of bounds X= 1.70478 Y= 17.21525 Lines out of bounds X= 1.820865 Y= 17.696 Lines out of bounds X= 1.96842 Y= 18.33802 Lines out of bounds X= 2.177923 Y= 19.32577 Lines out of bounds X= 2.58267 Y= 21.62494 Lines out of bounds X= -2.177923 Y= 1.766727 Lines out of bounds X= -1.96842 Y= 2.754482 Lines out of bounds X= -1.820865 Y= 3.39649 Lines out of bounds X= -1.70478 Y= 3.87725 Lines out of bounds X= -1.607964 Y= 4.26457 Lines out of bounds X= -1.524231 Y= 4.590877 Lines out of bounds X= -1.449999 Y= 4.87421 Lines out of bounds X= -1.382994 Y= 5.12562 Lines out of bounds X= -1.32168 Y= 5.35239 Lines out of bounds X= -1.264969 Y= 5.55956 Lines out of bounds X= -1.212058 Y= 5.75077 Lines out of bounds X= -1.162338 Y= 5.92873 Lines out of bounds X= -1.115337 Y= 6.095536 You can safely ignore "Line out of bounds" warnings.... Lines out of bounds X= -2.177923 Y= -2379.592 Lines out of bounds X= -1.96842 Y= -1420.336 Lines out of bounds X= -1.820865 Y= -796.852 Lines out of bounds X= -1.70478 Y= -329.9622 You can safely ignore "Line out of bounds" warnings.... Lines out of bounds X= -2.177923 Y= -27.5118 Lines out of bounds X= -1.96842 Y= -23.83843 Lines out of bounds X= -1.820865 Y= -20.63017 Lines out of bounds X= -1.70478 Y= -17.82503 Lines out of bounds X= -1.607964 Y= -15.32756 Lines out of bounds X= -1.524231 Y= -13.06741 Lines out of bounds X= -1.449999 Y= -10.99481 Lines out of bounds X= -1.382994 Y= -9.07388 Lines out of bounds X= -1.32168 Y= -7.27809 Lines out of bounds X= -1.264969 Y= -5.587245 Lines out of bounds X= -1.212058 Y= -3.985676 Lines out of bounds X= -1.162338 Y= -2.460943 Lines out of bounds X= 1.70478 Y= 105.0373 Lines out of bounds X= 1.820865 Y= 110.5983 Lines out of bounds X= 1.96842 Y= 118.0243 Lines out of bounds X= 2.177923 Y= 129.4496 Lines out of bounds X= 2.58267 Y= 156.0439 Lines out of bounds X= -2.177923 Y= -73.6546 Lines out of bounds X= -1.96842 Y= -62.2293 Lines out of bounds X= -1.820865 Y= -54.80325 Lines out of bounds X= -1.70478 Y= -49.2423 Lines out of bounds X= -1.607964 Y= -44.76224 Lines out of bounds X= -1.524231 Y= -40.98785 Lines out of bounds X= -1.449999 Y= -37.7106 Lines out of bounds X= -1.382994 Y= -34.80252 Lines out of bounds X= -1.32168 Y= -32.1795 Lines out of bounds X= -1.264969 Y= -29.7832 Lines out of bounds X= -1.212058 Y= -27.57149 Lines out of bounds X= -1.162338 Y= -25.51296 Lines out of bounds X= -1.115337 Y= -23.58357 Lines out of bounds X= -1.070679 Y= -21.76445 Lines out of bounds X= -1.02806 Y= -20.04055 Lines out of bounds X= -0.987231 Y= -18.39967 Lines out of bounds X= -0.947985 Y= -16.83175 Lines out of bounds X= -0.910147 Y= -15.32841 Lines out of bounds X= -0.873569 Y= -13.8826 Lines out of bounds X= -0.838125 Y= -12.48832 Lines out of bounds X= -0.803703 Y= -11.1404 Lines out of bounds X= -0.770208 Y= -9.83439 Lines out of bounds X= -0.737556 Y= -8.56638 Lines out of bounds X= -0.705672 Y= -7.33297 Lines out of bounds X= -0.67449 Y= -6.13114 Lines out of bounds X= -0.64395 Y= -4.95821 Lines out of bounds X= -0.6139995 Y= -3.81178 You can safely ignore "Line out of bounds" warnings.... Lines out of bounds X= 1.96842 Y= 91.8406 Lines out of bounds X= 2.177923 Y= 97.4933 Lines out of bounds X= 2.58267 Y= 110.651 Lines out of bounds X= -2.177923 Y= -2.993313 Lines out of bounds X= -1.96842 Y= 2.659394 Lines out of bounds X= -1.820865 Y= 6.33346 Lines out of bounds X= -1.70478 Y= 9.08475 Lines out of bounds X= -1.607964 Y= 11.30129 Lines out of bounds X= -1.524231 Y= 13.16868 > prestige[1:10,] education income pct.female occ.prestige occ.code occ.type GOV_ADMINISTRATORS 13.11 12351 11.16 68.8 1113 prof GENERAL_MANAGERS 12.26 25879 4.02 69.1 1130 prof ACCOUNTANTS 12.77 9271 15.70 63.4 1171 prof PURCHASING_OFFICERS 11.42 8865 9.11 56.8 1175 prof CHEMISTS 14.62 8403 11.68 73.5 2111 prof PHYSICISTS 15.64 11030 5.13 77.6 2113 prof BIOLOGISTS 15.09 8258 25.65 72.6 2133 prof ARCHITECTS 15.44 14163 2.69 78.1 2141 prof CIVIL_ENGINEERS 14.52 11377 1.03 73.1 2143 prof MINING_ENGINEERS 14.64 11023 0.94 68.8 2153 prof > pairs(prestige[,1:4]) > plot(income,occ.prestige) Problem: Object "income" not found Use traceback() to see the call stack > attach(prestige) > plot(income,occ.prestige) > plot(log(income),occ.prestige) > plot(log(income),occ.prestige) > plot(log(income),occ.prestige) > plot(income,occ.prestige) > plot(lm(income,occ.prestige) + ) Problem in switch(data.class(object),: invalid formula Use traceback() to see the call stack > pploints Problem: Object "pploints" not found > ppoints function(n, a = 0.5) { if(length(n) > 1.) n <- length(n) if(n < 1.) return(integer(0.)) if(a < 0. || a > 1.) stop("a must be between 0 and 1") (seq(n) - a)/(n + 1. - 2. * a) } > help(points) Sending request to help window > help(ppoints) Sending request to help window > plot(lm(occ.prestige~income)) > plot(income,occ.prestige) > par(mfrow=c(2,2)) > plot(income,occ.prestige) > abline(lm(occ.prestige~income)) + ) > par(mfrow=c(3,3)) > par(mfrow=c(2,2)) > plot(income,occ.prestige) > abline(lm(occ.prestige~income)) > plot(log(income),occ.prestige) > abline(lm(occ.prestige ~ log(income))) > abline(lmsreg(sqrt(income),occ.prestige)) > plot(sqrt(income),occ.prestige) > abline(lm(occ.prestige ~ sqrt(income))) > abline(lmsreg(sqrt(income),occ.prestige)) > dim(prestige) [1] 102 6 > par(mfrow=c(3,2)) > plot(density(income),type="l") > points(income,rep(0,102)) > qqenv(income) You can safely ignore "Line out of bounds" warnings.... Lines out of bounds X= -2.177923 Y= -2379.592 Lines out of bounds X= -1.96842 Y= -1420.336 Lines out of bounds X= -1.820865 Y= -796.852 Lines out of bounds X= -1.70478 Y= -329.9622 > plot(density(sqrt(income)),type="l") > points(sqrt(income),rep(0,102)) > qqenv(sqrt(income)) You can safely ignore "Line out of bounds" warnings.... Lines out of bounds X= -2.177923 Y= 22.1136 > plot(density(log(income)),type="l") > points(log(income),rep(0,102)) > qqenv(log(income)) You can safely ignore "Line out of bounds" warnings.... Lines out of bounds X= 2.58267 Y= 10.48475 > pairs(prestige[,1:4]) Problem: Couldn't find a function definition for "pair" > pairs(prestige[,1:4]) > par(mfrow=c(1,1)) > plot(pct.female,income) > abline(lm(income ~ pct.female) + ) > plot(pct.female,log(income)) > abline(lm(log(income) ~ pct.female)) > newpct _ 0.01 + .998*pct.female/100 > logodds _ log(newpct/(1-newpct)) > plot(logodds,log(income)) > abline(lm(log(income) ~ logodds) + ) > par(mfrow=c(2,3)) > plot(lm(log(income) ~ logodds)) >