File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ suppressPackageStartupMessages({
14
14
library(readr )
15
15
library(tidyr )
16
16
library(stringr )
17
+ library(lubridate )
17
18
})
18
19
19
20
args_trailing <- commandArgs(trailingOnly = TRUE )
@@ -121,6 +122,27 @@ if (nrow(ls_df) == 0) {
121
122
stop(" No LS portfolio rows found for the requested predictors. Ensure upstream portfolios have been generated." )
122
123
}
123
124
125
+ sample_info <- signal_doc %> %
126
+ select(signalname , SampleStartYear , SampleEndYear , Year )
127
+
128
+ ls_df <- ls_df %> %
129
+ mutate(date = as.Date(date )) %> %
130
+ left_join(sample_info , by = " signalname" ) %> %
131
+ mutate(
132
+ sample_year = year(date ),
133
+ samptype = case_when(
134
+ ! is.na(SampleStartYear ) & ! is.na(SampleEndYear ) &
135
+ sample_year > = SampleStartYear & sample_year < = SampleEndYear ~ " insamp" ,
136
+ ! is.na(Year ) & sample_year > Year ~ " postpub" ,
137
+ TRUE ~ NA_character_
138
+ )
139
+ ) %> %
140
+ filter(samptype == " insamp" )
141
+
142
+ if (nrow(ls_df ) == 0 ) {
143
+ stop(" No in-sample LS portfolio rows matched the documentation-defined sample period for the requested predictors." )
144
+ }
145
+
124
146
summary_df <- ls_df %> %
125
147
mutate(
126
148
Ncheck = pmin(Nlong , Nshort , na.rm = TRUE )
You can’t perform that action at this time.
0 commit comments