################################### # Straightening Google's Growth # ################################### # read in google data data=read.table("google.txt",header=T,sep="\t",skip=2) attach(data) # the two variables are period and employees # plot growth against employees plot(period, employees) # fit a line -- we use rline in the LearnEDA package library(LearnEDA) # this is LearnEDA_1.01 fit=rline(period, employees) # print the line of the form a + b (x - xC) fit$a fit$b fit$xC # add the line to the graph curve(fit$a+fit$b*(x-fit$xC), add=TRUE) # to see if this line is a suitable fit, we look at the residuals plot(period, fit$residual); abline(h=0) # one way of detecting the curvature is by the half-slope ratio fit$half.slope.ratio # want to straighten the graph # we reexpress data by trying power transformations on the y variable rline(period,sqrt(employees))$half.slope.ratio rline(period,log(employees))$half.slope.ratio rline(period,employees^.25)$half.slope.ratio rline(period,employees^.16)$half.slope.ratio # plot the straightened data and summarize fit=rline(period,employees^.16) plot(period,employees^.16) curve(fit$a+fit$b*(x-fit$xC), add=TRUE) # plot the residuals plot(period,fit$residual); abline(h=0)