This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c(-38.3455, 0.54882, 5.19848, 0.492518, 0.566555, -0.0479212, | |
0.333422, 8.85725, 0.450325, 0.277257, -148.454, 0.504147, 0.356457, | |
0.341726, 0.405021, 0.28855, 0.972497, 0.605668, 0.539456, -136.618, | |
-105.166, 1.49517, 0.707087, 0.0541961, 0.452244, 442.601, 0.288529, | |
0.0149293, 48.3507, 606.591, 0.971479, 1.81285, 6.27816, 0.531303, | |
0.874542, 16.5209, 0.446185, 0.76069, 12.3285, 0.629471, 0.719511, | |
-0.061535, 0.828019, 0.233507, 0.170131, 0.682919, 0.880852, | |
0.577185, 0.88224, 0.489173, 0.539035, 0.385609, 232.693, 0.504418, | |
0.654281, 0.59836, 0.457291, 2.51278, 0.459031, 12366.9, 0.773534, | |
6.5793, 1.02045, 0.451943, 0.176133, 463.412, 1549.17, 0.403163, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# python-2.7 | |
# new yorker caption contest | |
import requests | |
import bs4 # beautifulsoup | |
import mechanize | |
import cookielib | |
import getpass | |
def ny_url(num=500, pr=False): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/anaconda/bin/python | |
def bot(): | |
%magicstuff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################################################################################################### | |
# Author: Alex Keil | |
# Program: weight_bias.R | |
# Language: R | |
# Date: Friday, February 21, 2020 at 3:18:41 PM | |
# Project: qgcomp | |
# Description: # addressing a conjecture that WQS will yield better estimates of weights than qgcomp | |
# when the assumptions of WQS hold in sample sizes of 500 in a scenario in which | |
# exposures are all uncorrelated | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example in which weighted quantile sums estimates a significant, positive effect of exposure due to pure confounding | |
# even though there are no exposures that have a positive effect on the outcome | |
library(qgcomp) | |
library(gWQS) | |
dgm <- function(N = 100, b0=0, coef=c(1,0,0,0), family=gaussian(), ncor=0, corr=0.75, umc=FALSE){ | |
# simulate under data structure where WQS is the truth: e.g. an exposure with |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# simulation 1 from appendix of | |
# ”Per- and poly-fluoroalkyl substances and bone mineral density: | |
# Results from the Bayesian weighted quantile sum regression” by Colicino et al. | |
# | |
# simulate data and run the BWQS model | |
library(rstan) | |
library(qgcomp) | |
parallel:::setDefaultClusterOptions(setup_strategy = "sequential") # kludge for bug in parallel package with r4.0 | |
options(mc.cores = parallel::detectCores()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/env R | |
# a way to base the quantiles off of weighted data | |
library(qgcomp) | |
library(DescTools) # need this to calculate weighted quantiles | |
data(metals) | |
# new function to calculate weighted quantiles | |
quantize.wtd <- function (data, expnms, q = 4, breaks = NULL, weights=NULL) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# using qgcomp.cox.noboot in a nested case-control analysis as a way to fit a conditional logit qgcomp model | |
library(qgcomp) | |
library(survival) | |
# read in data from a nested case control study | |
data(infert, package = "datasets") | |
head(infert) | |
### 1) check that it works, part A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(qgcomp) | |
msm.fit.noint <- function(f, | |
qdata, | |
intvals, | |
expnms, | |
rr=TRUE, | |
main=TRUE, | |
degree=1, | |
id=NULL, |
OlderNewer