plot_age_curve: Plots Simulated Aging Curves

Description Usage Arguments Examples

Description

Uses the results from sim_aging_curve to plot the focus player's performance, the estimated aging curve from the model, and the simulated aging curves from the mode.

Usage

1
2
plot_age_curve(curves, nsim, fp, stat = c("woba", "iso", "k", "bb", "fip",
  "hr"))

Arguments

curves

list returned from sim_aging_curve

nsim

The number of simulations that were run

fp

The name of the focus player

stat

character of length one. The statistic for which the focus player's aging curve has been simulated.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
load("H:/simScoresApp/b-comparison-app/bat_simscore_data.RData")
wts <- c(position = .05, pa = .9, bb.perc = .66, k.perc = .84, iso = .84, babip = .23, obp = .92)
f <- age_comps("Brown; Domonic L.", age_grp, wts)
x1 <- sim_age_curve("Brown; Domonic L.", f, age_grp, c(21,30),
                    type = "bat", stat = "woba", wt_power = 500)
p1 <- plot_age_curve(x1, 500, "Brown; Domonic L.", "woba")
p1 # not good - curve makes no sense

## let's try using more players -> increase ncomps
x2 <- sim_age_curve("Brown; Domonic L.", f, age_grp, c(21,30),
                    type = "bat", stat = "woba",
                    wt_power = 500, ncomps = 30)
x2$warnings # no warnings - that's good
p2 <- plot_age_curve(x2, 500, "Brown; Domonic L.", "woba")
p2 # plot still doesn't make much sense though

## maybe we should weigh top comparables less
x3 <- sim_age_curve("Brown; Domonic L.", f, age_grp, c(21,30),
                    type = "bat", stat = "woba",
                    wt_power = 10, ncomps = 30)
x3$warnings # no warnings - still good
p3 <- plot_age_curve(x3, 500, "Brown; Domonic L.", "woba")
p3 # much better!

## plotting ISO
x4 <- sim_age_curve("Brown; Domonic L.", f, age_grp, c(21,30),
                    type = "bat", stat = "iso",
                    wt_power = 0, ncomps = 30)
p4 <- plot_age_curve(x4, 500, "Brown; Domonic L.", "iso")
p4

## plotting K%
x5 <- sim_age_curve("Brown; Domonic L.", f, age_grp, c(21,30),
                    type = "bat", stat = "k",
                    wt_power = 0, ncomps = 30)
p5 <- plot_age_curve(x5, 500, "Brown; Domonic L.", "k")
p5

## plotting BB%
x6 <- sim_age_curve("Brown; Domonic L.", f, age_grp, c(21,30),
                    type = "bat", stat = "bb",
                    wt_power = 0, ncomps = 30)
p6 <- plot_age_curve(x6, 500, "Brown; Domonic L.", "bb")
p6 # this curve doesn't make much sense
x6$warnings # just because there aren't warnings, doesn't imply no problems

guytuori/simScores documentation built on May 17, 2019, 9:29 a.m.