class: center, middle, inverse, title-slide # R (ile) Öğretme: Örnekler ve Kaynaklar ## Why R Turkey konferansı, R eğitimi paneli
bit.ly/dogucu-talks
### Mine Dogucu ### 2022-04-17 --- class: middle center <img src="img/headshot.jpeg" alt="A headshot of a woman with curly, short, ear-length hair with green eyes and red lipstick." style="width:165px; margin-top:20px; border: 3px solid whitesmoke; padding: 10px;"> .large[
] <a href = "http://twitter.com/MineDogucu">MineDogucu</a> .large[
] <a href = "http://github.com/mdogucu">mdogucu</a> .large[
] <a href = "http://minedogucu.com">minedogucu.com</a> --- class: middle <img src="img/uc-map.png" title="California Map with different locations of University of California campuses pinned." alt="California Map with different locations of University of California campuses pinned." width="40%" style="display: block; margin: auto;" /> --- class: middle ## İstatistik ve Veri Bilimi Eğitimcilerinin/Akademisyenlerinin Teknolojik Araç Kullanımı Örneği - Araştırma: R - Öğrenme: Grafik hesap makinesi - Öğretme: Sunum programı <br> [Dogucu & Çetinkaya-Rundel, 2022](https://arxiv.org/abs/2202.09504) --- class: middle ## Benim Teknolojik Araç Kullanımım - Araştırma: R - Öğrenme: ~~Grafik hesap makinesi~~ R - Öğretme: ~~Sunum programı~~ R --- class: middle ## R eğitimi - Öğrenme: R - Öğrenciye R kullanmayı öğretme (örn: Veri Bilimine giriş) - Öğrenciye istatistik öğretirken R'dan faydalanması (örn: İstatistik ve Olasılığa giriş) - Öğretme: R --- class: center middle <span style="font-size:75px;"> Öğrenme için R </span> --- class: center middle <img src="img/ids-logo.png" alt="IDS Course Logo" style="width:215px; align:center; padding: 0px;"> Veri Bilimine Giriş [
](https://github.com/ics80-fa21)[
](https://www.introdata.science) --- class: center middle <img src="img/stats-115-logo.png" alt="Stats 115 Course Logo" style="width:215px; align:center; padding: 0px;"> Bayesyen Veri Analizine Giriş [
](https://github.com/mdogucu/stats115-wi21-website)[
](https://www.stats115.com/) --- class:center <img src="img/bayes-rules-hex.png" title="a hex shaped logo with shiny green-pink disco ball and purple starry background. There is text that says Bayes Rules!" alt="a hex shaped logo with shiny green-pink disco ball and purple starry background. There is text that says Bayes Rules!" width="25%" style="display: block; margin: auto;" /> .pull-left[ <script src="https://use.fontawesome.com/releases/v5.15.1/js/all.js" data-auto-replace-svg="nest"></script> <i class="fas fa-book fa-2x" aria-hidden="true" title="Book icon"></i> [Bayes Rules! An Introduction to Applied Bayesian Modeling](https://bayesrulesbook.com) ] .pull-right[ <i class="fab fa-r-project fa-2x" aria-hidden="true" title="R logo"></i> [{bayesrules}](https://www.github.com/bayes-rules/bayesrules) ] --- class: middle .pull-left[ .center[ <img src="img/alicia.jpg" alt="A headshot of a woman with long blonde hair wearing a brownish yellow tshirt and a red and pink floral silk scarf wrapped around her neck." style="width:165px; margin-top:20px; border: 3px solid whitesmoke; padding: 10px;"> Alicia Johnson .font-20[Macalester College] [
](https://ajohns24.github.io/portfolio) [
](https://github.com/ajohns24) ] ] .pull-right[ .center[ <img src="img/miles.png" alt="A headshot of a man with short dark hair, and a dark moustache. He is wearing a blue button up shirt and dark gray jacket" style="width:165px; margin-top:20px; border: 3px solid whitesmoke; padding: 10px;"> Miles Ott .font-20[Twitter] [
](https://milesott.com/) [
](https://github.com/MilesOtt) [
](https://twitter.com/Miles_Ott) ] ] --- ## Binom Olabilirlik ```r plot_binomial_likelihood(y = 3, n = 10) ``` <img src="index_files/figure-html/unnamed-chunk-4-1.png" title="X axis reads pi with values from 0 to 1. Y axis reads l of pi given capital Y = y). The curve of the graph has a high peak on the y-axis when pi equals to 0.3. The y-values are almost zero when pi is greater than 0.75." alt="X axis reads pi with values from 0 to 1. Y axis reads l of pi given capital Y = y). The curve of the graph has a high peak on the y-axis when pi equals to 0.3. The y-values are almost zero when pi is greater than 0.75." style="display: block; margin: auto;" /> --- ## Önsel Model (Beta Modeli) .pull-left[ ```r plot_beta(alpha = 4, beta = 4) ``` <img src="index_files/figure-html/unnamed-chunk-5-1.png" title="X axis reads pi with values from 0 to 1. Y axis reads f of pi). The curve of the graph has a high peak on the y-axis when pi equals to 0.5. The distribution is symmentric." alt="X axis reads pi with values from 0 to 1. Y axis reads f of pi). The curve of the graph has a high peak on the y-axis when pi equals to 0.5. The distribution is symmentric." style="display: block; margin: auto;" /> ] .pull-right[ ```r plot_beta(alpha = 1, beta = 10) ``` <img src="index_files/figure-html/unnamed-chunk-6-1.png" title="X axis reads pi with values from 0 to 1. Y axis reads f of pi). The curve of the graph has a high peak on the y-axis when pi equals to 0. The curve is a concave one and y is decreasing as pi is increasing." alt="X axis reads pi with values from 0 to 1. Y axis reads f of pi). The curve of the graph has a high peak on the y-axis when pi equals to 0. The curve is a concave one and y is decreasing as pi is increasing." style="display: block; margin: auto;" /> ] --- ## Sonsal Model ```r plot_beta_binomial(alpha = 1, beta = 10, y = 3, n = 10) ``` <img src="index_files/figure-html/unnamed-chunk-7-1.png" title="X axis reads pi with values from 0 to 1. Y axis reads density. Three curves are shown labeled as prior, (scaled) likelihood, and posterior. The prior curve of the graph has a high peak on the y-axis when pi equals to 0. The curve is a concave one and y is decreasing as pi is increasing. The likelihood curve has a high peak on the y-axis when pi equals to 0.3. The y-values are almost zero when pi is greater than 0.75. The posterior sits between the prior and likelihood curves." alt="X axis reads pi with values from 0 to 1. Y axis reads density. Three curves are shown labeled as prior, (scaled) likelihood, and posterior. The prior curve of the graph has a high peak on the y-axis when pi equals to 0. The curve is a concave one and y is decreasing as pi is increasing. The likelihood curve has a high peak on the y-axis when pi equals to 0.3. The y-values are almost zero when pi is greater than 0.75. The posterior sits between the prior and likelihood curves." style="display: block; margin: auto;" /> prior - önsel model | (scaled) likelihood - ölçekli olabilirlik | posterior - sonsal model --- class: middle <img src="img/combined.png" width="60%" style="display: block; margin: auto;" /> --- class: middle ```r one_mh_iteration <- function(w, current){ # STEP 1: Propose the next chain location proposal <- runif(1, min = current - w, max = current + w) # STEP 2: Decide whether or not to go there proposal_plaus <- dnorm(proposal, 0, 1) * dnorm(6.25, proposal, 0.75) current_plaus <- dnorm(current, 0, 1) * dnorm(6.25, current, 0.75) alpha <- min(1, proposal_plaus / current_plaus) next_stop <- sample(c(proposal, current), size = 1, prob = c(alpha, 1-alpha)) # Return the results return(data.frame(proposal, alpha, next_stop)) } ``` --- ```r mh_tour <- function(N, w){ # 1. Start the chain at location 3 current <- 3 # 2. Initialize the simulation mu <- rep(0, N) # 3. Simulate N Markov chain stops for(i in 1:N){ # Simulate one iteration sim <- one_mh_iteration(w = w, current = current) # Record next location mu[i] <- sim$next_stop # Reset the current location current <- sim$next_stop } # 4. Return the chain locations return(data.frame(iteration = c(1:N), mu)) } ``` --- ```r set.seed(84735) mh_simulation_1 <- mh_tour(N = 5000, w = 1) ``` .pull-left[ ![](index_files/figure-html/unnamed-chunk-12-1.png)<!-- --> ] .pull-right[ ![](index_files/figure-html/unnamed-chunk-13-1.png)<!-- --> ] --- class: middle ## `library(rstan)` .pull-left[ ```r # STEP 1: DEFINE the model stan_bike_model <- " data { int<lower=0> n; vector[n] Y; vector[n] X; } parameters { real beta0; real beta1; real<lower=0> sigma; } model { Y ~ normal(beta0 + beta1 * X, sigma); } " ``` ] .pull-right[ ```r # STEP 2: SIMULATE the posterior stan_bike_sim <- stan(model_code = stan_bike_model, data = list(n = nrow(bikes), Y = bikes$rides, X = bikes$temp_feel), chains = 4, iter = 5000*2, seed = 84735) ``` ] --- class: middle ## `library(rstanarm)` ```r normal_model_sim <- stan_glm(rides ~ temp_feel, data = bikes, family = gaussian, chains = 4, iter = 5000*2, seed = 84735) ``` --- class: center middle .large[Pedagojik Yaklaşım] --- class: middle center Aktif Öğrenme [Metropolis-Hastings Algorithm](https://www.bayesrulesbook.com/chapter-7.html#the-metropolis-hastings-algorithm) <img src="img/programming.png" title="An icon of a student sitting on a chair and in front a desk with a computer typing." alt="An icon of a student sitting on a chair and in front a desk with a computer typing." width="20%" style="display: block; margin: auto;" /> --- class: center middle ### İstatistik ve Programlama Bir Arada .pull-left[ <i class="fas fa-laptop-code fa-6x" aria-hidden="true" title="Laptop icon with code"></i> ] <i class="fas fa-subscript fa-6x" aria-hidden="true" title="X sub 1"></i> --- class: middle center .pull-left[ ### Bir Kere Hesap Yap <img src="img/build.png" title="A construction sign with a figure shoveling." alt="A construction sign with a figure shoveling." width="50%" style="display: block; margin: auto;" /> ] .pull-right[ ### Sonra Fonskiyonları Kullan <i class="fab fa-r-project fa-7x" aria-hidden="true" title="R logo"></i> ] --- class: middle ## Erişebilirlik - Görsel ve fiziksel erişim - Eğitim materyallerinin ögrencilerin ilgisini çekmesi - Geniş akademisyen kitlesinin çalışmalarından faydalanmak <br> [Dogucu, Johnson & Ott, 2021](https://arxiv.org/abs/2110.06355) --- class: center middle <span style="font-size:75px;"> Öğretme için R </span> --- class: middle # Örnekler .pull-left[ - Sunumlar - Çalışma kağıtları - Dersin websitesi [Dogucu & Çetinkaya-Rundel, 2022](https://arxiv.org/abs/2202.09504) ] .pull-right[ <img src="img/tools.png" title="NSF logo" alt="NSF logo" width="80%" style="display: block; margin: auto;" /> ] --- class: middle .pull-left[ <img src="img/gradetools-logo.png" title="NSF logo" alt="NSF logo" width="80%" style="display: block; margin: auto;" /> ] .pull-right[ - Geri bildirim ve notlandırma sürecini otomatikleştirme - Rubrik yönetimini kolaylaştırma [Ricci, Medina & Dogucu, 2022](https://federicazoe.github.io/gradetools) ] --- class: middle center # Fon desteği <img src="img/nsf-logo.png" title="NSF logo" alt="NSF logo" width="10%" style="display: block; margin: auto;" /> NSF HDR DSC award \#2123366 --- .center[ .middle[ # Teşekkürler .large[ [bit.ly/dogucu-talks](https://bit.ly/dogucu-talks) ] .large[
] <a href = "http://twitter.com/MineDogucu">MineDogucu</a> ] ] .footnote[<a href="https://www.freepnglogos.com">Images from freepnglogos.com</a>]