A common experience for those in the social sciences migrating to R from SPSS or STATA is that some procedures that happened at the click of a button will now require more work or are too obscured by the unfamiliar language to see how to accomplish. One such procedure that I’ve experienced is when calculating […]

# regression

## Ridge regression in R exercises

Bias vs Variance tradeoff is always encountered in applying supervised learning algorithms. Least squares regression provides a good fit for the training set but can suffer from high variance which lowers predictive ability. To counter this problem, we can regularize the beta coefficients by employing a penalization term. Ridge regression applies l2 penalty to the […]

## LASSO regression in R exercises

Least Absolute Shrinkage and Selection Operator (LASSO) performs regularization and variable selection on a given model. Depending on the size of the penalty term, LASSO shrinks less relevant predictors to (possibly) zero. Thus, it enables us to consider a more parsimonious model. In this exercise set we will use the glmnet package (package description: here) […]

## Quantile Regression in R exercises

The standard OLS (Ordinary Least Squares) model explains the relationship between independent variables and the conditional mean of the dependent variable. In contrast, quantile regression models this relationship for different quantiles of the dependent variable. In this exercise set we will use the quantreg package (package description: here) to implement quantile regression in R. Answers […]

## Quantile Regression in R solutions

Below are the solutions to these exercises on Quantile regression. ############### # # # Exercise 1 # # # ############### library(quantreg) ## ## data(barro) summary(barro) ## y.net lgdp2 mse2 fse2 ## Min. :-0.056124 Min. :5.820 Min. :0.0240 Min. :0.0000 ## 1st Qu.: 0.003529 1st Qu.:6.989 1st Qu.:0.3180 1st Qu.:0.1350 ## Median : 0.019648 Median :7.745 […]

## Evaluate your model with R Exercises

There was a time where statistician had to manually crunch number when they wanted to fit their data to a model. Since this process was so long, those statisticians usually did a lot of preliminary work researching other model who worked in the past or looking for studies in other scientific field like psychology or […]