Publications by PhamMinhTam
In-class Excercise 1
library(dplyr) library(tidyverse) library(wooldridge) C6: Dataset WAGE2 (i) SLR of IQ using educ data("wage2") slr1 <- lm(IQ ~ educ, data = wage2) summary(slr1) ## ## Call: ## lm(formula = IQ ~ educ, data = wage2) ## ## Residuals: ## Min 1Q Median 3Q Max ## -50.228 -7.262 0.907 8.772 37.373 ## ## Coeffici...
167 sym R (2437 sym/12 pcs)
Financial Innovation: Exercise 1
library(wooldridge) library(dplyr) C2: “Birth weight” dataset (i) data("bwght") total_women <- nrow(bwght) total_women ## [1] 1388 smoker <- sum(bwght$cigs != 0) smoker ## [1] 212 There are 1388 observations in the dataset, corresponds with 1388 women in the sample. There are 212 women reported smoking during pregnancy (ii) avg_cigs_p...
2056 sym R (1316 sym/37 pcs)
Final Exam: Financial Software Package - Part 1
Chapter 4: Classification 16. Using the Boston data set, fit classifcation models in order to predict whether a given census tract has a crime rate above or below the median. Explore logistic regression, LDA, naive Bayes, and KNN models using various subsets of the predictors. Describe your findings. #Load dataset data("Boston") head(Boston)...
4880 sym 6 img
Final Exam: Financial Software Package - Part 2
Using KNN in Predicting Price Direction For my example of application of machine learning in finance, I chose to use K-Nearest Neighbors (KNN) model for a classic classification problem in finance: “Will prices go up or down in the future?”. This is a very simple and straightforward example of how machine learning model, in particular KNN m...
3436 sym Python (6524 sym/19 pcs) 2 img
Final Exam: Portfolio Analysis
library(tidyquant) library(lubridate) library(timetk) library(purrr) library(dplyr) library(readr) library(fBasics) library(ggplot2) library(zoo) 1. Import data symbols <- c("SPY","QQQ", "EEM", "IWM", "EFA", "TLT", "IYR", "GLD") portfolioPrices <- NULL for (symbol in symbols) { portfolioPrices <- cbind(portfolioPrices, ...
777 sym R (14497 sym/25 pcs) 2 img
Factor Model
library(tidyverse) Data Processing retdata = read_csv("C:/Users/Admin/Downloads/FamaFrench_mon_69_98_3stocks.csv") ## Rows: 360 Columns: 9 ## ── Column specification ──────────────────────────────────────────────────────── ## Delim...
501 sym R (8044 sym/36 pcs) 2 img
In-class Exercise 5
library(tidymodels) library(ISLR2) Hitters <- as_tibble(Hitters) %>% filter(!is.na(Salary)) 1. Ridge Regression The mixture argument specifies the amount of different types of regularization, mixture = 0 specifies only ridge regularization and mixture = 1 specifies only lasso regularization. Setting mixture to a value between 0 and 1 let...
3622 sym R (9011 sym/44 pcs) 3 img
In-class Exercise 4
Resampling Methods library(tidymodels) library(ISLR2) Auto <- tibble(Auto) Portfolio <- tibble(Portfolio) 5.1 The Validation Set Approach set.seed(1) Auto_split <- initial_split(Auto, strata = mpg, prop = 0.5) Auto_split ## <Training/Testing/Total> ## <194/198/392> The testing and training data sets can be materialized using the testing() ...
3300 sym R (10836 sym/48 pcs) 1 img
HW04_Application of Financial Software Package
ISLR tidymodels labs: Classification 4.1 The Stock Market Data library(tidymodels) library(ISLR2) # For the Bikeshare data set library(discrim) library(poissonreg) To look at the correlation between the variables, we will use the corrr package. The correlate() function will calculate the correlation matrix between all the variables that it is...
7287 sym R (10853 sym/74 pcs) 5 img
Midterm Exam: Financial Software Package
Question 1: Answer the following using the dataset mtcars (a) Load up data mtcars and generate its descriptive statistics #Load libraries library(psych) library(tidyverse) library(tidymodels) library(vip) library(ISLR2) # Load up dataset data("mtcars") head(mtcars) ## mpg cyl disp hp drat wt qsec vs am gear carb ##...
9547 sym R (14230 sym/55 pcs) 24 img 1 tbl