R

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.

Paste together multiple columns

# # paste together dataframe columns by column index # take the following df df <- data.frame(my_number = letters[1:5], column_odd1 = rnorm(5), column_even1 = rnorm(5), column_odd2 = rnorm(5), column_even2 = rnorm(5), column_odd3 = rnorm(5), column_even3 = rnorm(5)) df %>% select(1) %>% bind_cols(data.

Not so fun with Nepalese flag

Anatomy of flag The anatomy of flag is well described in tipsntricks/readresort section but the quirks of constructing it are not. I will be updating attending to complete the graphics as soon as I learn more. So far, only this ugly shape is what I have here to show;

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(.

Making Summary Tables in R

Background General purpose tables Summary tables rtables package qwraps2 package gtsummary package Background Table output of R is one of the richest and satisfying to use feature. Rmarkdown format provides loads of package support to create, format, and present tables beautifully.

Tidytuesday: Claremont Run, X-men Characters

X men characters Data dictionary explore Table 1: Data summary Name Piped data Number of rows 308 Number of columns 9 _______________________ Column type frequency: character 8 numeric 1 ________________________ Group variables Variable type: character

Array operation: Outer product

Incidentally, I ran into outer product function outer today. It is extremely powerful function, in that it computes all combinations of product of two objects. One simplest and obvious demonstration is the multiplication table of numbers. 😄 We can show multiplication table of numbers 1 through 12 each multiplied 1 through 10.

Time Series: Cointegration Analysis

Cointegration Although not a new topic in finance and portfolio management, as some of the tweets below suggest, it’s application in field of Agricultural Economics and commodity market analysis is not often highlighted. A tweet relating S2F and bitcoin (BTC) trading prices is here for reference.

Correlation and pathway analysis with path diagrams

Background Correlation study is one of the most extensively yet not fully appreciated topic. It forms the backbone of several other inferential studies. Path analysis, on a similar note, is a derived technique that explains directed dependencies among a set of variables.