Statistics
Workshop

Fall 2012
course
navigation

questions

Anyone in the class can edit this page.
Brownie points for both good questions and good answers.

your question

Ask away.

Here's some code for creating a chart with colored symbols available in R: # Make an empty chart plot(1, 1, xlim=c(1,5.5), ylim=c(0,7), type="n", ann=FALSE) # Plot digits 0-4 with increasing size and color text(1:5, rep(6,5), labels=c(0:4), cex=1:5, col=1:5) # Plot symbols 0-4 with increasing size and color points(1:5, rep(5,5), cex=1:5, col=2:6, pch=0:4) text((1:5)+0.4, rep(5,5), cex=0.6, (0:4)) # Plot symbols 5-9 with labels points(1:5, rep(4,5), cex=2, pch=(5:9), col=3:7) text((1:5)+0.4, rep(4,5), cex=0.6, (5:9)) # Plot symbols 10-14 with labels points(1:5, rep(3,5), cex=2, pch=(10:14), col=4:8) text((1:5)+0.4, rep(3,5), cex=0.6, (10:14)) # Plot symbols 15-19 with labels points(1:5, rep(2,5), cex=2, pch=(15:19), col=5:9) text((1:5)+0.4, rep(2,5), cex=0.6, (15:19)) # Plot symbols 20-25 with labels points((1:6)*0.8+0.2, rep(1,6), cex=2, pch=(20:25), col=5:10) text((1:6)*0.8+0.5, rep(1,6), cex=0.6, (20:25))
Also, here's a journal of negative results-type thing in psychology: http://www.jasnh.com/

Here's how to import data files from different places:
#specify the name and address of the remote file datafilename <- "http://personality-project.org/r/datasets/maps.mixx.epi.bfi.data" #datafilename <- "Desktop/epi.big5.txt" #read from local directory or # datafilename <- file.choose() # use the OS to find the file #in all cases person.data <- read.table(datafilename,header=TRUE) #read the data file #Alternatively, to read in a comma delimited file: #person.data <- read.table(datafilename,header=TRUE,sep=",") names(person.data) #list the names of the variables

Hey all, here are R codes I use for regression plots, residual plots, and log scatterplots (using the data "weights" from Matt's book "Practicing Statistics" in Chapter three. > weight<-read.table(file.choose(), header=TRUE,sep="\t") > head(weight) Species body brain 1 African elephant 6654.000 5712.0 2 African giant pouched rat 1.000 6.6 3 Arctic Fox 3.385 44.5 4 Arctic ground squirrel 0.920 5.7 5 Asian elephant 2547.000 4603.0 6 Baboon 10.550 179.5 > attach(weight) > plot(body,brain) > weight.lm<-lm(body~brain) > summary(weight.lm) Call: lm(formula = body ~ brain) Residuals: Min 1Q Median 3Q Max -1552.25 -8.00 47.36 55.10 1553.42 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -56.85555 42.97805 -1.323 0.191 brain 0.90291 0.04453 20.278 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 323.5 on 60 degrees of freedom Multiple R-squared: 0.8727, Adjusted R-squared: 0.8705 F-statistic: 411.2 on 1 and 60 DF, p-value: < 2.2e-16 > abline( -56.85555,.90291) ##How to find individual residual numbers > residuals<-weight.lm$res > residuals[1] 1 1553.417 ##Now, these are the R codes I used to make a residual plot. > pred.weight<-weight.lm$fitted > residuals<-weight.lm$res > plot(pred.weight,residuals) > abline(0,0) ##Log of Body and Brain weight >plot(log10(body)~log10(brain)) body.log<-lm(log10(body)~log10(brain)) > summary(body.log) Call: lm(formula = log10(body) ~ log10(brain)) Residuals: Min 1Q Median 3Q Max -0.94050 -0.25955 0.04097 0.28572 0.90971 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.08968 0.07995 -13.63 <2e-16 *** log10(brain) 1.22496 0.04638 26.41 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.3849 on 60 degrees of freedom Multiple R-squared: 0.9208, Adjusted R-squared: 0.9195 F-statistic: 697.4 on 1 and 60 DF, p-value: < 2.2e-16 ## Residual plot of the log of body and brain weight > pred.weight<-body.log$fitted > residuals<-body.log$res > plot(pred.weight,residuals) >abline(0,0)

Elias
http://cs.marlboro.edu/ courses/ fall2012/statistics/ wiki/ questions
last modified Tuesday September 18 2012 2:25 am EDT