Swift a graph to end in 0?

3 ビュー (過去 30 日間)
Mercu Vestergaard
Mercu Vestergaard 2013 年 10 月 19 日
コメント済み: Image Analyst 2013 年 10 月 19 日
How do I swift the graph plot so that the end point becomes 0?
  1 件のコメント
Image Analyst
Image Analyst 2013 年 10 月 19 日
What does "swift" mean in this context?

サインインしてコメントする。

回答 (3 件)

Mercu Vestergaard
Mercu Vestergaard 2013 年 10 月 19 日
Eg. as done here in R
#### CREATE PLOT
IS <- cumsum(IS_error_N[2:length(IS_error_N)]^2)-cumsum(IS_error_A^2)
OOS <- cumsum(OOS_error_N^2)-cumsum(OOS_error_A^2)
df <- data.frame(x=seq.int(from=start + 1 + est_periods_OOS, to=end),
IS=IS[(1 + est_periods_OOS):length(IS)],
OOS=OOS) #Because you lose one observation due to the lag
#Shift IS errors vertically, so that the IS line begins
# at zero on the date of first OOS prediction. (see Goyal/Welch (2008, p. 1465))
df$IS <- df$IS - df$IS[1]
df <- melt(df, id.var="x")
plotGG <- ggplot(df) +
geom_line(aes(x=x, y=value,color=variable)) +
geom_rect(data=data.frame(),#Needed by ggplot2, otherwise not transparent
aes(xmin=1973, xmax=1975,ymin=-0.2,ymax=0.2),
fill='red',
alpha=0.1) +
scale_y_continuous('Cumulative SSE Difference', limits=c(-0.2, 0.2)) +
scale_x_continuous('Year')
##

Image Analyst
Image Analyst 2013 年 10 月 19 日
What does "swift" mean in this context? It usually means fast. By chance do you mean shift? As in using circshift
shiftedSignal = circshift(signal, 1);

Mercu Vestergaard
Mercu Vestergaard 2013 年 10 月 19 日
Sorry for the typo: yes of course i mean shift, not swift
  1 件のコメント
Image Analyst
Image Analyst 2013 年 10 月 19 日
OK, so did my answer do what you need to do?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by