[Eventstudies-commits] r252 - pkg/R

Vimal Balasubramaniam vimsaa at gmail.com
Fri Mar 28 16:20:17 CET 2014


On 28 March 2014 15:07, <noreply at r-forge.r-project.org> wrote:

>  ### Converting index outputModel to Date
>    index(outputModel) <- as.Date(index(outputModel))
> -  ## Stop if there is only one firm: phys2eventtime breaks down
> -  if(NCOL(outputModel)==1){stop("Event study does not work for one
> firm/column")}
>

Perfect.

  ### Convert to event frame

>     es <- phys2eventtime(z=outputModel, events=eventList, width=width)
> -  es.w <- window(es$z.e, start = -width, end = width)
> -  ## Adding column names to event output
> -  cn.names <- eventList[which(es$outcomes=="success"),1]
> +
> +  if (is.null(es$z.e) || length(es$z.e) == 0) {
> +    es.w <- NULL
> +    cn.names <- character(length = 0)
> +  } else {
> +    es.w <- window(es$z.e, start = -width, end = width)
> +                                        # Adding column names to event
> output
> +    cn.names <- eventList[which(es$outcomes=="success"),1]
> +  }
> +
>    if(length(cn.names)==1){
>      cat("Event date exists only for",cn.names,"\n")
>      inference <- FALSE
>      cat("No inference strategy for one column","\n")
> +  } else if (length(cn.names) == 0) {
> +    ## skip everything
> +    to.remap = FALSE
> +    inference = FALSE
>    } else {
>      colnames(es.w) <- cn.names
> -  }
> +  }
>
>
Okay. I totally agree. This makes sense to me. Except this:

  es.w <- window(es$z.e, start = -width, end = width)

That is not what should be done right? Because this will give you result
from phys2eventtime as only for the width chosen! The width differentiates
"wdatamissing" from "success". No?


 ### Remapping event frame
>    if (to.remap == TRUE) {
> @@ -124,7 +133,7 @@
>  print.es <- function(x, ...){
>    cat("The", x$inference, "inference output for CI and",
>        colnames(x$eventstudy.output)[2], "response:", "\n")
> -  return(x$eventstudy.output)
> +  print.default(x$eventstudy.output)
>  }
>
>
? I don't get this. But I leave it to you.



>   summary.es <- function(object, ...){
>
> Modified: pkg/R/phys2eventtime.R
> ===================================================================
> --- pkg/R/phys2eventtime.R      2014-03-28 13:03:55 UTC (rev 251)
> +++ pkg/R/phys2eventtime.R      2014-03-28 15:07:27 UTC (rev 252)
> @@ -47,6 +47,11 @@
>    rownums <- grep("outcome", names(answer))
>    outcomes <- as.character(do.call("c", answer[rownums]))
>    z.e <- do.call("cbind", answer[rownums[which(answer[rownums] ==
> "success")] - 1])
> +
> +  if (length(z.e) == 0) {               # no point of going forward
> +    return(list(z.e = z.e, outcomes = factor(outcomes)))
> +  }
> +
>    colnames(z.e) <- which(outcomes == "success")
>

Okay. This is fine too.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/eventstudies-commits/attachments/20140328/7dd7f356/attachment-0001.html>


More information about the Eventstudies-commits mailing list