next up previous index
Next: Graphics and Splus - Up: Projects Previous: Graphics and Splus Lab.   Index

Graphics and Splus - Lab. 2

  1. Logging into a workstation at the Theory Center
    To log into the silicon workstation in front of you, type in your tc account userid and passwd.

    Click on the console window if it's not already open and type: \fbox{{\tt xhost +}}

    Then open an xterm window on the theory center computer by:
    \fbox
{\tt
xterm -e telnet splogin.tc
}

    You may have to specify your DISPLAY variable with :
    \fbox{\tt setenv DISPLAY yourtree:0.0}
    (typed into the xterm window opened on tc).

  2. Start a Splus session by: Splus at the tc unix prompt.
  3. Online help in Splus:
    >options(gui='motif')
    >help.start()
    
  4. Using graphical displays under Splus
    Remember you must open a device, Splus does not do this automatically for you.
    >motif()        %starts a motif screen
    
  5. Attach MY data sets and programs to yours:
    >attach('/afs/theory.cornell.edu/user/user2/sholmes/public/.Data')
    
  6. Attach the MASS data sets and programs to yours:
    >attach('/afs/theory.cornell.edu/user/user2/sholmes/public/MASS/.Data')
    
  7. After you have done this you can try using some of the data sets and programs as suggested in the next page.
  8. To quit Splus you must type :
    q() at the prompt.

  1. Some graphical programs:
    help(xgobi)
    help(brush)
    help(spin)
    help(pairs)
    help(image)
    
    Some data :
    help(painters)
    help(crabs)
    help(shuttle)
    help(birthwt)
    help(rock)
    

    Looking at multivariate data graphically:

    >xgobi(crabm)        %Now try using the brush facility
    >xgobi(crabm, glyphs = crab[, 1], color =col.poss[crab[, 2]])
    >xgobi(crabm,glyphs=gly.poss[crab[,1]],color =col.poss[crab[, 2]])
    >xgobi(paintm,color=col.poss[codes(School)])
    >xgobi()
    

    Try using the Brush menu to change the colors persistently for each of the 4 groups created by combination of the 2 grouping variables.

    Try recording the bitmaps at the optimums of the Friedman Tukey index along the graphic.

    Find manually which 2-d projection separates out the groups best.

    Save the coefficients of that projection to compare with our latter discriminating algorithms.

    (The help facility in xgobi now works with a click on the right button)

  2. Building a distance matrix from variables:
    help(dist)
    dist(paintm)
    round(dist2full(dist(paintm[1:10,])))
    
  3. Minimum Spanning Tree:
     ir_rbind(iris[,,1], iris[,,2], iris[,,3])
     tree <- mstree(i) 
     plot(tree, type="n")
     text(tree, label=c(rep(1, 50), rep(2, 50), rep(3, 50)))
                    # get the absolute value stress e
           distp <- dist(i)
           dist2 <- dist(cbind(tree$x, tree$y))
           e <- sum(abs(distp - dist2))/sum(distp)
    
  4. Hierarchical Methods:
    help(hclust)
    sums <- apply(author.count,1,sum)
    adjusted <- sweep(author.count,1,sums,"/")
    par(mar=c(18,4,4,1))
    plclust(hclust(dist(adjusted)),label=dimnames(author.count)[[1]])
    title("Clustering of Books Based on Letter Frequency")
    h<-hclust(dist(paintm))
    plclust(h,labels=School.lab)
     x <- hclust(dist(paintm),method='ave')
    plclust(x, label = FALSE)   # plot without labels
    xy <- plclust(x, plot = FALSE)
    identify(xy,labels=dimnames(painters)[[1]])
    
    Note: To stop identifying you have to click on the middle button.
  5. Partitionning Methods:
    irismean <- t(apply(iris, c(2, 3), 'mean'))
           x <- rbind(iris[,,1], iris[,,2], iris[,,3])
           km <- kmeans(x, irismean)
    wrong <- km$cluster!=rep(1:3, c(50, 50, 50))
    spin(x, highlight=wrong)
     plot(x[,2], x[,3], type="n")
           text(x[!wrong, 2], x[!wrong, 3], km$cluster)
              # identify cluster membership that is correct
           points(x[wrong, 2], x[wrong, 3], pch=15)
              # boxes for points in error
           title(main="K-Means Clustering of the Iris Data")
    

  6. Discriminating pre-classified data:
    help(lda)
    tr <- sample(1:50,25)
           train <- rbind(iris[tr,,1],iris[tr,,2],iris[tr,,3])
           test <- rbind(iris[-tr,,1],iris[-tr,,2],iris[-tr,,3])
           cl <- factor(c(rep("s",25),rep("c",25), rep("v",25)))
           z <- lda(train, cl)
           predict(z,test)$class
    
  7. Using smoothers :
    help(supersmu)
    help(lowess)
    help(spline)
    help(smooth)
    pairs(vinm[,1:5],panel=function(x,y){ points(x,y); lines(lowess(x,y))})
    


next up previous index
Next: Graphics and Splus - Up: Projects Previous: Graphics and Splus Lab.   Index
Susan Holmes 2002-01-12