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 Regex Functions in Excel | |
'http://lispy.wordpress.com/2008/10/17/using-regex-functions-in-excel/ | |
' Turn on VBScript Regular Expressions 5.5 reference thing | |
Function M(Value As String, Pattern As String, Optional IgnoreCase As Boolean = False) | |
Dim r As New VBScript_RegExp_55.RegExp | |
r.Pattern = Pattern |
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
Rep. X, | |
Over the past several weeks there has been massive political unrest throughout the Middle East. As you know, Tunisia overthrew President Ben Ali a week ago, igniting a series of peaceful protests in Egypt, Algeria, Yemen, and other Middle Eastern nations. | |
Egypt has been in the throes of protests for 3 days now with nary a word from the US. Egypt is one of America's biggest allies in the region and has been a keystone of our foreign policy for decades. | |
President Mubarak's regime is attacking these protestors violently. Several Egyptians have been killed—hundreds have been arrested without due process or reason. And yet the US remains silent. | |
In the past hour, the Egyptian government has shut off all internet and SMS communications. Key cities, such as Suez, have had all landlines cut off. Egypt is in a black hole, giving Mubarak a free ticket to be as oppressive and violent as he wants with no immediate international repercussions. |
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
Fit Model( | |
Y( :CRIMARST ), | |
Effects( :UNEMPL, :MONTH, :CURFEW, :POLICCUR ), | |
Personality( Standard Least Squares ), | |
Emphasis( Effect Leverage ), | |
Run( | |
:CRIMARST << {Plot Actual by Predicted( 1 ), Plot Regression( 0 ), | |
Plot Residual by Predicted( 1 ), Plot Effect Leverage( 1 ), Show VIF( 1 )} | |
) | |
); |
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
Sub Generate_ICS() | |
Dim rng1 As Range, X, i As Long, v As Long | |
Dim objFSO, objFile | |
Dim FilePath As String | |
FilePath = "C:\output.ics" | |
Set objFSO = CreateObject("Scripting.FileSystemObject") | |
Set objFile = objFSO.CreateTextFile(FilePath) | |
Set rng1 = Range([a2], Cells(Rows.Count, "B").End(xlUp)) | |
X = rng1 | |
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/bin/env bash | |
# | |
#----------- | |
# mmd2docx | |
#----------- | |
# | |
# Author: Andrew Heiss - http://www.andrewheiss.com | |
# Project site: http://gist.github.com/1199596 | |
# Description: Convert MultiMarkdown files into docx files using LibreOffice | |
# License: Licensed under the MIT License (see below) |
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
Option Explicit | |
Sub switch_row() | |
Dim colors() As Variant | |
Dim current_color, i, new_index As Long | |
' Set up color array | |
colors = Array(2, 3, 4, 6, 7, 8) | |
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
coolSummary <- function(x) { | |
if (class(x) == "data.frame") { | |
x.min <- apply(x, 2, min, na.rm=TRUE) | |
x.max <- apply(x, 2, max, na.rm=TRUE) | |
x.sd <- apply(x, 2, sd, na.rm=TRUE) | |
x.mean <- as.numeric(lapply(x, mean, na.rm=TRUE)) | |
x.n <- apply(!is.na(x), 2, sum) | |
x.na <- apply(is.na(x), 2, sum) | |
row.names <- colnames(x) | |
} else { |
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
summary.with.betas <- function(model, logit=FALSE) { | |
model <- update(model, x=TRUE, y=TRUE) | |
sd.x <- apply(model$x, 2, sd) | |
sd.y <- sd(model$y) | |
std.coef <- coef(model) * (sd.x / sd.y) | |
coef.table <- as.data.frame(summary(model)$coefficients) | |
coef.table <- cbind(coef.table, beta=std.coef, sdX=sd.x) | |
if (logit == TRUE) { | |
e.beta <- exp(coefficients(model)) | |
e.bstdx <- exp(sd.x) |
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(forecast) | |
budgetData <- read.csv(file.choose()) | |
(series.ts <- ts(budgetData$taxTotals, start=c(1978, 1), frequency=4)) | |
series.ets <- ets(series.ts, model="ZZZ") | |
series.forecast <- forecast(series.ets, h=5) | |
plot(series.forecast) |
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(rms) # This is the library that does all the orginal logistic regression magic | |
EMC <- latest.EMC.2011.clean.v2 # Make a copy of the data frame with a shorter name | |
model <- lrm(lifeoverall ~ fire + med + streetrepair + streetclean, data=EMC) # Fit an ordinal logistic regression model | |
model # General model summary | |
exp(coefficients(model)) # Factor change coefficients? | |
anova(model) # Wald statistics | |
Predict(model, fire=0, med=0, streetrepair=0, streetclean=0) # Predict yhat based on given values |