R

{caret} custom function implementation

Problem: Optimal Probability Threshold It’s been a while! I’m writing this post for a couple of reasons. I don’t want to only be writing my dissertation… Someone found me on github and asked me to help them. I am happy to be writing this post for the two reasons listed above so let’s jump straight into the problem. Recently, a random stranger e-mailed me about a problem they were having at work.

Tidy simulation!

Simulations? But… why? When I was taking classess at University of Colorado Anschutz Medical Campus, I was one of those guys that was strong in programming/coding but had to spend much of my time on the math behind statistics. I stopped taking math after vector calculus during undergrad (which I regret) because I was a Biochem major. I thoroughly enjoyed learning all the tricks but I so wish I had learned about (real) analysis and higher (proof-based) maths when I was younger.

Performance of my stock vs. cpi

Intro As a new years resolution, I made a promise to myself to be more conscious about the investments that I’m making. Of the few that I have, I’ve decided to look into the historical performance of one of the funds that I have. I want to compare the stock price increase over time with the overall consumer price for products in the U.S. (using the CPI-U). Using quantmod to see performance quantmod is an R package that makes it easy for users to track their stock.

Replacing missing values in R

Problem So I’m a regular visitor of the r/rstats subreddit and recently there was a post about replacing missing values using a certain logic. Specifically here is the problem: Below is a dataframe where each row represents a city and the idea is to fill the missing unemployment rate. The OP (original poster) wanted to fill in the NA columns based on the mean value of the unemployment rate of the same State and Size.