[Eventstudies-commits] r389 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Nov 18 12:57:14 CET 2014
Author: chiraganand
Date: 2014-11-18 12:57:14 +0100 (Tue, 18 Nov 2014)
New Revision: 389
Modified:
pkg/R/marketModel.R
Log:
Code formatting changes.
Modified: pkg/R/marketModel.R
===================================================================
--- pkg/R/marketModel.R 2014-11-18 11:41:06 UTC (rev 388)
+++ pkg/R/marketModel.R 2014-11-18 11:57:14 UTC (rev 389)
@@ -1,28 +1,28 @@
-marketModel <- function(firm.returns, market.returns,resid=TRUE) {
+marketModel <- function(firm.returns, market.returns,resid = TRUE) {
returns <- merge(firm.returns, market.returns, all = FALSE, fill = NA)
market.returns <- returns$market.returns
returns <- returns[, -match("market.returns", colnames(returns))]
- if(NCOL(returns)==1){ ## Output for a single firm
+ if (NCOL(returns) == 1) { # Output for a single firm
reg <- lm(returns ~ market.returns, na.action = na.exclude) #:DOC: na.exclude
- if(resid==TRUE){ ## MM-residuals for a single firm
+ if (resid == TRUE) { ## MM-residuals for a single firm
resid <- returns - predict(reg)
return(resid)
- }else{ ## Model estimates for a single firm
+ } else { ## Model estimates for a single firm
return(reg)
}
- }else{ ## Multi-firm case
+ } else { ## Multi-firm case
reg <- list()
resids <- list()
- if(resid==TRUE){ ## Residuals for the multi-firm case
- for(i in 1:ncol(returns)){
- reg[[i]] <- lm(returns[,i] ~ market.returns, na.action = na.exclude)
- resids[[i]] <- returns[,i]-predict(reg[[i]])
+ if (resid == TRUE) { ## Residuals for the multi-firm case
+ for (i in 1:ncol(returns)) {
+ reg[[i]] <- lm(returns[, i] ~ market.returns, na.action = na.exclude)
+ resids[[i]] <- returns[, i] - predict(reg[[i]])
}
names(resids) <- colnames(returns)
- resid <- do.call("merge",resids)
+ resid <- do.call("merge", resids)
return(resid)
- }else{ ## Model estimates for the multi-firm case
- for(i in 1:ncol(returns)){
+ } else { ## Model estimates for the multi-firm case
+ for (i in 1:ncol(returns)) {
reg[[i]] <- lm(returns[,i] ~ market.returns, na.action = na.exclude)
}
names(reg) <- colnames(returns)
More information about the Eventstudies-commits
mailing list