Last updated: 2019-10-31

Checks: 7 0

Knit directory: STA_463_563_Fall2019/

This reproducible R Markdown analysis was created with workflowr (version 1.4.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20190905) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/.DS_Store

Untracked files:
    Untracked:  analysis/lab_hw3_sol.Rmd
    Untracked:  docs/figure/lab_hw3_sol.Rmd/

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the R Markdown and HTML files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view them.

File Version Author Date Message
Rmd b46eac3 dleelab 2019-10-31 size changed
Rmd 724723a dleelab 2019-10-31 title corrected
html 9f77fa8 dleelab 2019-10-18 added
Rmd 41acc1b dleelab 2019-10-18 new

data0120=read.table("http://www.stat.ufl.edu/~rrandles/sta4210/Rclassnotes/data/textdatasets/KutnerData/Chapter%20%201%20Data%20Sets/CH01PR20.txt")
colnames(data0120)=c("minutes","copiers_number")
attach(data0120)
fit=lm(minutes~copiers_number)

2. We Seek a Descriptive measures of How Well the Fitted Model Explains the Observed Response.

2.a. Compute SST, SSR and \(R^2\) using R.

\[SST=\sum_{i=1}^{n}(Y_i-\bar{Y})^2\]

SST=sum((data0120$minutes-mean(data0120$minutes))^2)
SST
[1] 80376.8

\[SSR=\sum_{i=1}^{n}(\hat{Y_i}-\bar{Y})^2\]

SSR=sum((fit$fitted.values-mean(data0120$minutes))^2)
SSR
[1] 76960.42

\[R^2=\frac{SSR}{SST}\]

Rsq=SSR/SST
Rsq
[1] 0.9574955
summary(fit)#compare with the summary(fit)

Call:
lm(formula = minutes ~ copiers_number)

Residuals:
     Min       1Q   Median       3Q      Max 
-22.7723  -3.7371   0.3334   6.3334  15.4039 

Coefficients:
               Estimate Std. Error t value Pr(>|t|)    
(Intercept)     -0.5802     2.8039  -0.207    0.837    
copiers_number  15.0352     0.4831  31.123   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 8.914 on 43 degrees of freedom
Multiple R-squared:  0.9575,    Adjusted R-squared:  0.9565 
F-statistic: 968.7 on 1 and 43 DF,  p-value: < 2.2e-16

Interpretation: 95.75% of the total variation in minutes can be explained by a linear relationship with copiers_number.

2.b. Coefficient of Correlation, \(r=\pm \sqrt{R^2}\).

  • The sign is determined by the slope of the regression equation.
  • \(r\) does not have any particular interpretation in regression. It is simply a measure of the fit of the linear regression model.
  • \[-1\leq r \leq 1\]
  • Relationship between \(b_1\) and \(r\): \(b_1=r\sqrt{\frac{S_{YY}}{S_{XX}}}\).
r=sqrt(Rsq)
r
[1] 0.978517
cor(minutes,copiers_number)
[1] 0.978517

sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] workflowr_1.4.0 Rcpp_1.0.2      digest_0.6.20   rprojroot_1.3-2
 [5] backports_1.1.4 git2r_0.26.1    magrittr_1.5    evaluate_0.14  
 [9] stringi_1.4.3   fs_1.3.1        whisker_0.3-2   rmarkdown_1.15 
[13] tools_3.6.1     stringr_1.4.0   glue_1.3.1      xfun_0.9       
[17] yaml_2.2.0      compiler_3.6.1  htmltools_0.3.6 knitr_1.24