tidyverse

Cluster dendrogram: An introduction and showcase

A cluster analysis is a classification problem. It is dealt in several ways, one of which is hierarchial agglomeration. The method allows for easy presentation of high dimensional data, more of so when the number of observations is readily fitted into a visualization.

Linear model fitting for regression: Basics and Variation

Linear model (simple forms) fitting I use mtcars dataset to construct some basic regression models and fit those. # convert available data to use in fitting mtcars_reg_df <- mtcars %>% rownames_to_column("carnames") %>% as_tibble() %>% mutate_at(c("gear", "am", "vs", "cyl"), as.

Logistic Regression: Part I - Fundamentals

Likelihood theory Probit models were the first of those being used to analyze non-normal data using non-linear models. In an early example of probit regression, Bliss(1934) describes an experiment in which nicotine is applied to aphids and the proportion killed is recorded.

Logistic Regression: Part II - Varietal adoption dataset

Binary classifier using categorical predictor Let’s say we have two variable – survey response of farmer to willingness to adopt improved rice variety (in YES/NO) and them having been trained earlier about agricultural input management (in trained/untrained). Read in the data and notice the summary.

Piecewise Linear Function: An Introduction

Definition and meaning Wikipedia defines a piecewise linear function as: “a function defined on a (possibly unbounded) interval of real numbers, such that there is a collection of intervals on each of which the function is an affine function”

The birthday problem: Non analytical solution

# Birthday problem crossing(n = 2:100, x = 2:4) %>% mutate(probability = map2_dbl(n, x, ~pbirthday(.x, coincident = .y))) %>% ggplot(aes(n, probability, color = factor(x))) + geom_line() + labs(x = "People in room", y = "Probability X people share a birthday", color = "X") # Approximating birthday paradox with Poisson distribution crossing(n = 2:250, x = 2:4) %>% mutate(combinations = choose(n, x), probability_each = (1/365)^(x-1), poisson = 1-dpois(0, combinations * probability_each), pbirthday_x = map2_dbl(n, x, ~pbirthday(.

String tip: complex pattern recognition

Background This post is all about examples and use cases. So…Let’s break a leg. Extract all words except last one using anchors and look arounds nasty_char <- c("I love playing wildly") # remove the last word 'wildly' stringr::str_extract(nasty_char, ".

Agriculture development chronology in Nepal

Toolbox for working with Unicode and Nepali fonts Here’s a collection of excellent python scripts to convert back and forth among unicode and preeti font. To convert unicode text to preeti font: https://github.com/globalpolicy/UnicodeToPreeti To convert preeti font to unicode text:

Expressing timestamp data in calendar

Unlike composing a text memos and keeping tracks of those, calendar graphics is a highly effective visual aid to taking notes and summarizing them. Well, we all have used calendar, one way or the other, in our lifetimes.

Grade X result

h1.title { font-size: 50px; color: DarkRed; text-align: center; } h4.author { /* Header 4 - and the author and data headers use this too */ font-size: 18px; font-family: "Times New Roman", Times, serif; color: DarkRed; text-align: center; } h4.