# HW 3 Q 6 boxplot6Q6.R JLCY, 19 Dec 2013

############################################################ 

# Compute statistics from the Historical DAta. obsstats = stats(LFmonflow)

{

    write(t(arcor), file = "arcorrs1", ncol = 12)
    write(t(armean), file = "armeans", ncol = 12)
    write(t(arvar), file = "arvar", ncol = 12)
    write(t(arskw), file = "arskews", ncol = 12)
    write(t(armax), file = "armax", ncol = 12)
    write(t(armin), file = "armin", ncol = 12)

    ############################################################ 

    # obs stat

    obsmean = apply(LFmonflow, 2, mean)
    obsvar = apply(LFmonflow, 2, var)
    obsskew = apply(LFmonflow, 2, skew)
    obslag1 = cor(LFmonflow[1:100, 5], LFmonflow[2:101, 5])
    obsmax = apply(LFmonflow, 2, max)
    obsmin = apply(LFmonflow, 2, min)

    ############################################################ 

    ## Boxplot of statistics

    # plot May
    par(mfrow = c(2, 3))

    boxplot(armean, main = "May Mean")
    par(new = T)
    plot(obsmean[5], col = "red")

    boxplot(arvar, main = "May Var")
    par(new = T)
    plot(obsvar[5], col = "red")

    boxplot(arskw, main = "May Skew")
    par(new = T)
    plot(obsskew[5], col = "red")

    boxplot(arcor, main = "May Lag-1")
    par(new = T)
    plot(obslag1, col = "red")

    boxplot(armax, main = "May Max")
    par(new = T)
    plot(obsmax[5], col = "red")

    boxplot(armin, main = "May Min")
    par(new = T)
    plot(obsmin[5], col = "red")

    ############################################################ 

}
## Error: 找不到物件 'arcor'