« Oct. 2, 2008 | Main | Oct. 9, 2008 »

Oct. 7, 2008

R version 2.7.2 (2008-08-25)
Copyright (C) 2008 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.

Natural language support but running in an English locale

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.

> ###NOTE: standardization makes scores across differing scales comparable###
> football<- read.table("Football.dat",headers = TRUE)
Error in read.table("Football.dat", headers = TRUE) :
unused argument(s) (headers = TRUE)
> football<- read.table("Football.dat",header = TRUE)
> attach(football)
> utils:::menuInstallPkgs()
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://www.ibiblio.org/pub/languages/R/CRAN/bin/windows/contrib/2.7/RColorBrewer_1.0-2.zip'
Content type 'application/zip' length 40465 bytes (39 Kb)
opened URL
downloaded 39 Kb

package 'RColorBrewer' successfully unpacked and MD5 sums checked

The downloaded packages are in
C:\Documents and Settings\install\Local Settings\Temp\Rtmp7VVMMa\downloaded_packages
updating HTML package descriptions
> ######################################################################################
> ##### Create a plot that helps readers interpret the results of the analysis. Note
> ##### that two functions from the RColorBrewer library are used to obtain an
> ##### appropriate color palette. The code is further commented below.
> ######################################################################################
>
> library(RColorBrewer)
> display.brewer.pal(3,"Paired") # This will plot the colors from the Paired palette.
> brewer.pal(3,"Paired")# This gives the hexadecimal values for the colors.
[1] "#A6CEE3" "#1F78B4" "#B2DF8A"
> # see http://www.colorbrewer.org or the RColorBrewer documentation.
>
>
> plot(WGR, ylim=c(0,.05), xlim=c(0,110), ,type="n", ylab="Density", xlab="White Graduation Rate")# This creates an empty plot for us to fill.
> rect(xleft = 55.20, ybottom = -1, xright = 63.12, ytop = 1, border=NA, col="#B2DF8A")# This adds the confidence region.
> box()# The previous command shaded over the outline of the plot,
> # so we re-draw it.
> lines(density(WGR, kernel="e"), lwd=1.5)# Add the density plot with a thicker line.
> rug(WGR, col="#1F78B4")# Add a rug plot.
> arrows(55.20,.005, 63.12, .005, code=3, length=.1)# Add an arrow
> arrows(55.20,.045, 63.12, .045, code=3, length=.1)# Add the second arrow.
> abline(v=76, lty="dashed", lwd = 2, col="#1F78B4")# Add the vertical line for the hypothesized value.
> text(59.16, .025, "95% Confidence Interval", cex = 1.5, srt = 90)# Add the vertical text.
>
>
> plot(BGR, ylim=c(0,.05), xlim=c(0,110), ,type="n", ylab="Density", xlab="Black Graduation Rate")
> rect(xleft = 40.10, ybottom = -1, xright = 47.98, ytop = 1, border=NA, col="#B2DF8A")
> box()
> lines(density(BGR, kernel="e"), lwd=1.5)
> rug(BGR, col="#1F78B4")
> arrows(40.10,.005, 47.98, .005, code=3, length=.1)
> arrows(40.10,.045, 47.98, .045, code=3, length=.1)
> abline(v=49, lty="dashed", lwd = 2, col="#1F78B4")
> text(44.04, .025, "95% Confidence Interval", cex = 1.5, srt = 90)
> ###
> ###
> ###
> ###
> ###

How different is our sample mean different from our hypothesized value?


> ###The absolute value of mu-hat minus mu-NULL
> Confidence interval for the mean answers how confident we are.
Error: unexpected '<' in "<"
> ###Confidence interval for the mean answers how confident we are that the mean is to the population mean.###
> ###(effect size is what is the possible variation in our mean based on the sample size.###
> ###

Cohen's d


> ###If you want to standardise something you divide by standard deviation.###
> ###Cohen's d says takes unstandardized effect size |mu.hat - mu.null| and divide by standard deviation.
> ###because we don't know the actual population mean and SD we must assume it and d becomes d.hat
> sd(BGR)
[1] 13.86813
> Cohen says standardized efect size .2 = small, .5 = moderate, .8 = large
Error: unexpected '<' in "<"
> ###Cohen says standardized efect size .2 = small, .5 = moderate, .8 = large###
> ###These have somehow become the law, but they are relative. His estimates were for psychological data only. My guess is they probably don't really apply, but these things have been locked in.
> ###Remeber to know your field to determine what is a large or small effect size.###
> mean(BGR)
[1] 44.04
> (44.04-49)/13.87
[1] -0.3576063
> |(44.04-49)|
Error: unexpected '|' in "|"
> ###How to find standardised effect size in R###
> library(MBESS)
Error in library(MBESS) : there is no package called 'MBESS'
> utils:::menuInstallPkgs()
also installing the dependency ‘gsl’

trying URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.7/gsl_1.8-11.zip'
Content type 'application/zip' length 582918 bytes (569 Kb)
opened URL
downloaded 569 Kb

trying URL 'http://www.ibiblio.org/pub/languages/R/CRAN/bin/windows/contrib/2.7/MBESS_1.0.1.zip'
Content type 'application/zip' length 658354 bytes (642 Kb)
opened URL
downloaded 642 Kb

package 'gsl' successfully unpacked and MD5 sums checked
package 'MBESS' successfully unpacked and MD5 sums checked

The downloaded packages are in
C:\Documents and Settings\install\Local Settings\Temp\Rtmp7VVMMa\downloaded_packages
updating HTML package descriptions
> ### you need to download MBESS library###
> library(MBESS)
> smd(Mean.1=mean(BGR),Mean.2=49,s-sd(BGR))
Error in smd(Mean.1 = mean(BGR), Mean.2 = 49, s - sd(BGR)) :
object "s" not found
> smd(Mean.1=mean(BGR),Mean.2=49,s=sd(BGR))
[1] -0.3576547
> ###If you are doing a 2-sided test, you have to remember to take the absolute value of your standardized effect size because you are not interestedin directionality.###
>

Confidence Interval for d


Error: unexpected '<' in "<"
> ###

Confidence Interval for d

###
> ###NOTE: At this point APA is going to require an interval estimate of effect size.###
> ###Lucky for us R has a function to figure out the d.hat confidence interval.###
> ###NOTE: With small effect sizes we often get very wide effect size confidence intervals.
>

ci.sm()


Error: unexpected '<' in "<"
> ###

ci.sm()

###
> ###-Used to calculate the standardized effect size confidence interval.###
> ###ci.sm(sm = standardized effect, N = n)###
> ci.sm(sm=smd(Mean.1=mean(BGR),Mean.2=49,s=sd(BGR)),N=50)
[1] "The 0.95 confidence limits for the standardized mean are given as:"
$Lower.Conf.Limit.Standardized.Mean
[1] -0.6419787

$Standardized.Mean
[1] -0.3576547

$Upper.Conf.Limit.Standardized.Mean
[1] -0.06990362

>