This file contains hidden or 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
# Simple function for fitting a regression line with two predictor variables. | |
# Function takes two arguments: | |
# x must be a matrix or dataframe with only two columns (variables) | |
# y must be a vector containing the response values of the same length | |
# Output is similar to the lm() function | |
# Function used as a demonstration in post on multiple regression here: http://wp.me/p4aZEo-5Lh | |
two.predictor.regression <- function(x, y) { | |
y <- as.matrix(y) | |
if (ncol(y) > 1) { |
This file contains hidden or 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
# Function for calculating the confidence (mean) and prediction intervals of a fitted linear regression model. | |
# Replicates the predict() function with arguments 'confidence' and 'prediction' | |
# Used in post demonstrating the confidence and prediction intervals in linear regression: http://www.aaronschlegel.com/notebook/confidence-prediction-intervals/ | |
# Takes three arguments: | |
# x = vector of independent variable data points | |
# y = vector of dependent variable data points | |
# pred.x = value of x to find predicted y | |
conf.pred.intervals <- function(x, y, pred.x) { |
This file contains hidden or 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
# Quick function for performing linear regression with only one predictor variable. | |
# Takes two arguments, x and y. Variables must have same length. | |
# Output will be similar to output of lm() with one predictor. | |
# Gist created as part of post on linear regression: http://www.aaronschlegel.com/notebook/simple-linear-regression-models-r/ | |
simple.linear.coef <- function(x, y) { | |
# Find length of x to get sample size. Assuming x and y have the same sample size. | |
n <- length(x) | |
if (n != length(y)) |
This file contains hidden or 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
games.howell <- function(grp, obs) { | |
#Create combinations | |
combs <- combn(unique(grp), 2) | |
# Statistics that will be used throughout the calculations: | |
# n = sample size of each group | |
# groups = number of groups in data | |
# Mean = means of each group sample | |
# std = variance of each group sample |
This file contains hidden or 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(readr) | |
library(caret) | |
# Enter csv file path. If the data is in xls or xlsx, you will need to use read.table or the read_table function | |
# in the readr package | |
data <- read_csv("") | |
attach(data) | |
summary(data) | |
#Enter column name with categorical variables you want to model and predict between the empty quotations. |
This file contains hidden or 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
from xlwings import Workbook, Range, Sheet | |
import pandas as pd | |
import os | |
# Alternative method to split an Excel worksheet into multiple sheets based on a column name. | |
# The script will prompt four questions to enter in the required information. The workbook will then open and | |
# split the prompted worksheet into separate worksheets based on the desired column name. | |
# To run, open the command prompt and enter the command python Split_Excel_Worksheet_v2.py | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
This file contains hidden or 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
from xlwings import Workbook, Range, Sheet | |
import pandas as pd | |
# Split Excel data in one worksheet into multiple worksheets based on column name. | |
# Copy this file into the same location as the Excel workbook with the worksheet you wish to split. | |
# Download the zip of the xlwings Github repo here: https://github.com/ZoomerAnalytics/xlwings and copy the | |
# xlwings.bas file from the xlwings folder. Import the xlwings.bas file into your Excel workbook by entering ALT+F11 | |
# and then going to File, Import File and clicking on the file. | |
# Import the Split_Excel_Worksheet.bas file and run by going to the Developer tab on the Excel Ribbon, click Macros, |
This file contains hidden or 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
from xlwings import Workbook, Range | |
import pandas as pd | |
import os | |
import re | |
# Script to merge a folder containing Excel workbooks into a single workbook. | |
# The folder should only contain Excel workbooks and must all either be in csv, xls or xlsx format | |
# To run, open the command prompt and enter the command python Merge_Excel_Workbooks.py | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
This file contains hidden or 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(caret) | |
ginzberg <- read.csv('D:/Google_Drive/Google_Drive/Resources/Datasets/Rdata/car/Ginzberg.csv') | |
ginzberg <- ginzberg[2:4] | |
train <- createDataPartition(y = ginzberg$depression, | |
p = 0.50, | |
list = FALSE) | |
training <- ginzberg[ train,] |
This file contains hidden or 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
<!--PHP file for adding a basic template portfolio page for Wordpress themes using the Bootstrap framework.--> | |
<?php | |
/* | |
Template Name: Portfolio | |
*/ | |
?> | |
<?php get_header(); ?> |
NewerOlder