+ - 0:00:00
Notes for current slide
Notes for next slide

CV Lab

Dr. D’Agostino McGowan

1 / 11

RStudio Pro

rstudio.hpc.ar53.wfu.edu:8787

pw: R2D2Star!

2 / 11

Practice getting your lab into RStudio Pro

3 / 11

Now get your lab into RStudio Cloud

4 / 11

Practice pushing and pulling in GitHub

  • So far we have just been pushing to GitHub, but a nice feature is that you can then pull your results at any time.
  • Make a change to your Lab file in RStudio Pro and push this to GitHub (check the GitHub repo to make sure your changes showed up)
  • Check RStudio cloud - did those changes show up?
5 / 11

Practice pushing and pulling in GitHub

  • So far we have just been pushing to GitHub, but a nice feature is that you can then pull your results at any time.
  • Make a change to your Lab file in RStudio Pro and push this to GitHub (check the GitHub repo to make sure your changes showed up)
  • Check RStudio cloud - did those changes show up?
  • Click the pull (down) arrow in RStudio cloud. Do you see the changes now?
5 / 11

Some R functions

sample(10)
## [1] 3 1 8 5 7 2 4 9 6 10
sample(10)
## [1] 8 3 9 1 7 10 4 6 2 5
6 / 11

Some R functions

set.seed(1)
sample(10)
## [1] 3 4 5 7 2 8 9 6 10 1
set.seed(1)
sample(10)
## [1] 3 4 5 7 2 8 9 6 10 1
7 / 11

Use the set.seed() function before performing cross validation so you get consistent (reproducible) answers!

8 / 11

Polynomial regression in R

\(y = \beta_0 + \beta_1 x + \beta_2 x^2 + \beta_3 x^3 + \epsilon\)

lm(y ~ x + I(x^2) + I(x^3), data = data)
##
## Call:
## lm(formula = y ~ x + I(x^2) + I(x^3), data = data)
##
## Coefficients:
## (Intercept) x I(x^2) I(x^3)
## 0.10276 -0.06669 -0.13772 0.02546
9 / 11

Polynomial regression in R

\(y = \beta_0 + \beta_1 x + \beta_2 x^2 + \beta_3 x^3 + \epsilon\)

lm(y ~ x + I(x^2) + I(x^3), data = data)
##
## Call:
## lm(formula = y ~ x + I(x^2) + I(x^3), data = data)
##
## Coefficients:
## (Intercept) x I(x^2) I(x^3)
## 0.10276 -0.06669 -0.13772 0.02546
lm(y ~ poly(x, 3), data = data)
##
## Call:
## lm(formula = y ~ poly(x, 3), data = data)
##
## Coefficients:
## (Intercept) poly(x, 3)1 poly(x, 3)2 poly(x, 3)3
## -0.007264 -0.205147 -1.465710 0.382521
9 / 11

Polynomial regression in R

\(y = \beta_0 + \beta_1 x + \beta_2 x^2 + \beta_3 x^3 + \epsilon\)

model1 <- lm(y ~ x + I(x^2) + I(x^3), data = data)
model2 <- lm(y ~ poly(x, 3), data = data)
all.equal(predict(model1), predict(model2))
## [1] TRUE
10 / 11

When doing polynomial regression, you can use the poly() function in R

11 / 11

RStudio Pro

rstudio.hpc.ar53.wfu.edu:8787

pw: R2D2Star!

2 / 11
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow