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
## ------------------------- ## | |
## An Example of ## | |
## Automating Plot Output ## | |
## ------------------------- ## | |
names = LETTERS[1:26] ## Gives a sequence of the letters of the alphabet | |
beta1 = rnorm(26, 5, 2) ## A vector of slopes (one for each letter) | |
beta0 = 10 ## A common intercept |
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
## ------------------------- ## | |
## An Example of ## | |
## Automating Plot Output ## | |
## ------------------------- ## | |
names = LETTERS[1:26] ## Gives a sequence of the letters of the alphabet | |
beta1 = rnorm(26, 5, 2) ## A vector of slopes (one for each letter) | |
beta0 = 10 ## A common intercept |
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
## --------------------------- ## | |
## Function takes a vector of ## | |
## dates as its input. ## | |
## ## | |
## It produces a vector of ## | |
## dates that are the first ## | |
## in their respective months ## | |
## --------------------------- ## | |
firstDayMonth=function(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
## ------------------------ ## | |
## Data Creation in R ## | |
## Tutorial by Tony Cookson ## | |
## ------------------------ ## | |
## Simplest way to create a vector is to use the colon. | |
a = 1:4 | |
b = 4:1 | |
a | |
b |
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
## ----------------------- ## | |
## Computing and Graphing ## | |
## Statistical Power ## | |
## ----------------------- ## | |
## Parameters of the Problem ## | |
mu0 = 6 ## Null-hypothesized value | |
alpha = 0.05 ## Significance Level | |
s.sq = 16 ## Variance from pilot study |
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
## -------------------------- ## | |
## An R Function that Shades ## | |
## under a normal density. ## | |
## ## | |
## This is a convenience ## | |
## function for polygon() ## | |
## -------------------------- ## | |
shadenorm = function(below=NULL, above=NULL, pcts = c(0.025,0.975), mu=0, sig=1, numpts = 500, color = "gray", dens = 40, | |
lines=FALSE,between=NULL,outside=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
## ---------------------------------------------------------------------------------------- ## | |
## Author: John Fox ## | |
## Source: http://r.789695.n4.nabble.com/R-extend-summary-lm-for-hccm-td815004.html ## | |
## Adapted by Tony Cookson. ## | |
## -- Only Change Made: Changed the name of the function (unwisely maybe) ## | |
## to summaryR from summaryHCCM.lm. I also changed the spelling of consistent ## | |
## ---------------------------------------------------------------------------------------- ## | |
summaryR.lm <- function(model, type=c("hc3", "hc0", "hc1", "hc2", "hc4"), ...){ |
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
## -------------------------------------- ## | |
## R Tutorial on Robust Standard Errors ## | |
## Author: Tony Cookson ## | |
## -------------------------------------- ## | |
## Read Data | |
library(foreign) | |
ed = read.dta("C://R//edudat2.dta") | |
## Obtain regression object |
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
## ----------------------------------- ## | |
## A homegrown IV regression command ## | |
## that handles the case where there ## | |
## is one endogenous variable and many ## | |
## (or one) instrument. ## | |
## ## | |
## Disadvantage: The command doesn't ## | |
## handle multiple endogenous vars ## | |
## ## | |
## Advantage: testing for relevance, ## |
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
## ------------------------ ## | |
## An Easy IV regression ## | |
## regression command for R ## | |
## ## | |
## Author: Tony Cookson ## | |
## Commands: ivregress() ## | |
## sum.iv() ## | |
## ------------------------ ## | |
## Read Data ## |
OlderNewer