Skip to content

Instantly share code, notes, and snippets.

View ttungl's full-sized avatar

Tung Thanh Le ttungl

View GitHub Profile
@ttungl
ttungl / iptw_causal_analysis.r
Last active June 24, 2022 08:02
assignment_w4
## Data analysis project - carry out an IPTW causal analysis
install.packages("tableone")
install.packages("Matching")
install.packages("ipw")
install.packages("survey")
install.packages("MatchIt")
library(tableone)
@ttungl
ttungl / iptw_output
Created June 23, 2022 05:49
IPTW terminal output
R version 4.2.0 (2022-04-22) -- "Vigorous Calisthenics"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
@ttungl
ttungl / IPTW.r
Last active June 23, 2022 06:47
IPTW with R
###################
#RHC Example
#install packages (if needed)
install.packages("tableone")
install.packages("ipw")
install.packages("sandwich")
install.packages("survey")
@ttungl
ttungl / crashcoursecausal_data_example.r
Last active June 23, 2022 05:58
data example in r 1
###################
#RHC Example
#install packages
install.packages("tableone") ## useful when you're doing a matched analysis.
install.packages("Matching") ## carry out the actual matching.
#load packages
library(tableone)
library(Matching)
@ttungl
ttungl / ex matching.py
Created April 4, 2022 06:30 — forked from BioSciEconomist/ex matching.py
Very basic propensity score matching and IPTW analysis with balance diagnostics
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex matching.py
# | DATE: 6/25/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: very basic matching and IPTW analysis with balance diagnostics
# *----------------------------------------------------------------
def maxProfit(self, prices: List[int]) -> int:
# buy and then sell.
# sol 1:
# time O(n) space O(1)
if not prices:
return 0
buy_price = float('inf')
max_profit = 0
for p in prices: # O(n)
if buy_price < p:
def merge_two_arrays_3(a,b): ## len_a=n, len_b=m, m>n
# n is length of a; m is length of b
# time O(m+n) space O(n+m)
from collections import deque # first in first out
da = deque(a)
db = deque(b)
res = []
while len(da) or len(db):
@ttungl
ttungl / stacking_example.py
Last active October 31, 2021 03:10 — forked from geffy/stacking_example.py
Stacking example
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 23 23:16:44 2017
@author: Marios Michailidis
This is an example that performs stacking to improve mean squared error
This examples uses 2 bases learners (a linear regression and a random forest)
and linear regression (again) as a meta learner to achieve the best score.
The initial train data are split in 2 halves to commence the stacking.
@ttungl
ttungl / note0.ipynb
Last active February 13, 2017 20:08
test0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ttungl
ttungl / counting_sort.c
Last active February 13, 2017 20:15
Counting sort
// http://ideone.com/7RLpDt
#include <stdio.h>
#include <stdlib.h>
void Print_Array(int * array, int array_size){
for (int i = 0; i < array_size; ++i)
{
if(i == (array_size-1)){
printf("%d \n", array[i]);
} else {