Skip to content

Instantly share code, notes, and snippets.

View Aaronmoralesshildrick's full-sized avatar

Aaron Morales Shildrick Aaronmoralesshildrick

View GitHub Profile
##solar sesame assignment!!
#set wd using the session tab in Rstudio
#libraries
library(readr)
library(ggplot2)
library(dplyr)
library(plyr)
library("writexl")
cd "/Users/aaron/Documents/Minerva/SS 154/Final Project"
rename Pollutantemissionsfromtranspo temissions
rename GDPperCapita GDPpc
rename PurchasingPowerAdijustedGDPp PP
rename PriceofGasolineinUSdollars Gasprice
rename Renewableenergyshare Renewable
line temissions Year if ID == 28
line TotalCO2 Year if ID == 28
/* set the folder for the project*/
cd "/Users/aaron/Documents/Minerva/Capstone/test 3/"
/*open data*/
use CapstoneDataStata
/*Rename the variables*/
rename Pollutantemissionsfromtranspo temissions
rename GDPperCapita GDPpc
rename PurchasingPowerAdijustedGDPp PP
* get data from 17.2 from http://pages.stern.nyu.edu/~wgreene/Text/Edition7/tablelist8new.htm
label var yrb "Constructed measure of time spent in extramarital affairs"
label var v1 "Rating of the marriage"
label var v2 "Age in years aggregated"
label var v3 "Number of years married"
label var v4 "Number of childen"
label var v5 "Religiosity"
label var v6 "Education"
label var v7 "Occupation"
/* Q1 */
/* Data cleaning */
egen P = anymatch(personid), values (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15) /*gives a 1 value to all people from 1 to 15 */
keep if P /* leave the 15 perople only */
drop P
gen P = 0
bysort personid (personid): replace P= 1 if _n == 1 /*assigns a one for the
drop if wsal_val == 0
/* Drop values for people who have no income */
gen wage = wsal_val/wkswork/hrswk
drop if wage < 1
/* Drop values for people who have income under 1 */
gen educ = a_hga
gen propval = hprop_val
#PART 1
# In the document
#PART 2: Replication of FIG 8.
fulldata <- read.csv("https://course-resources.minerva.kgi.edu/uploaded_files/mke/00086677-3767/peace.csv")
names(fulldata)
fulldata <- fulldata[, c(99, 50, 114, 49, 63, 136, 109, 126, 48, 160, 142, 10)]
@Aaronmoralesshildrick
Aaronmoralesshildrick / CS112Assignment2
Last active October 20, 2018 05:19
Regression and Bootstrapping CS 112 Assignment 2
#Question 1
set.seed(123)
#Creation of data
X <- c(runif(99, min = 0, max = 12))
Y = (study_time^2 * 5) + rnorm(99, mean = 0, sd = 50)
mydata = data.frame(X, Y)
#Creation of the models and plots (also calls for summary function are here)
plot(Y~X, main = "How Outliers Affect Regression")
lm1 = lm(Y~X, data = mydata)
install.packages("tree")
library("tree")
library("ISLR")
attach(Carseats)
High = ifelse(Carseats$Sales <=8,"No","Yes ")
Carseats = data.frame(Carseats, High)
Carseats
@Aaronmoralesshildrick
Aaronmoralesshildrick / CS112Assignment1
Created September 20, 2018 11:25
CS112 Assignment 1 Code
# Morales is my surname so, M = 13, O = 15, R = 18.
#Leads to us perfomring the code with said seed
#Using the second digit of each we arrive at 358 as a number.
set.seed(358)
my_questions_are_these <- sort(sample(c(1:10), 3, replace = FALSE))
my_questions_are_these
#answer to this is: 4, 9, 10
mydata <- read.csv("/Users/aaron/Downloads/AarondatasetforCS112\ -\ TA.csv")