example-2

2
First we define a figure hook: > options(SweaveHooks = list(fig = function() par(mfrow = c(2, + 2)))) Then we setup variable definitions without actually evaluating them > x <- 1:10 > y <- rnorm(x) Then we put the pieces together: > x <- 1:10 > y <- rnorm(x) > lm1 <- lm(y ~ x) > summary(lm1) Call: lm(formula = y ~ x) Residuals: Min 1Q Median 3Q Max -1.7946 -1.2770 0.2540 1.1738 1.5092 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.25501 0.92836 0.275 0.791 x -0.05714 0.14962 -0.382 0.713 Residual standard error: 1.359 on 8 degrees of freedom Multiple R-Squared: 0.0179, Adjusted R-squared: -0.1049 F-statistic: 0.1458 on 1 and 8 DF, p-value: 0.7125 > plot(lm1) 1

description

dfbd

Transcript of example-2

  • First we define a figure hook:

    > options(SweaveHooks = list(fig = function() par(mfrow = c(2,

    + 2))))

    Then we setup variable definitions without actually evaluating them

    > x y x y lm1 summary(lm1)

    Call:lm(formula = y ~ x)

    Residuals:Min 1Q Median 3Q Max

    -1.7946 -1.2770 0.2540 1.1738 1.5092

    Coefficients:Estimate Std. Error t value Pr(>|t|)

    (Intercept) 0.25501 0.92836 0.275 0.791x -0.05714 0.14962 -0.382 0.713

    Residual standard error: 1.359 on 8 degrees of freedomMultiple R-Squared: 0.0179, Adjusted R-squared: -0.1049F-statistic: 0.1458 on 1 and 8 DF, p-value: 0.7125

    > plot(lm1)

    1

  • 0.5 0.0 0.5 1.0

    1

    01

    2

    Fitted values

    Res

    idua

    ls

    l

    l

    l

    ll

    lll

    l

    l

    Residuals vs Fitted2

    3 1l

    l

    l

    l l

    lll

    l

    l

    1.5 0.5 0.5 1.5

    1

    01

    2

    Theoretical Quantiles

    Stan

    dard

    ized

    resid

    uals

    Normal QQ2

    1 3

    0.5 0.0 0.5 1.0

    0.0

    0.4

    0.8

    1.2

    Fitted values

    Sta

    nda

    rdiz

    ed

    resi

    dua

    ls

    l

    l

    l

    ll

    l

    l

    l

    ll

    ScaleLocation2

    13

    0.00 0.10 0.20 0.30

    2

    1

    01

    2

    Leverage

    Stan

    dard

    ized

    resid

    uals

    l

    l

    l

    ll

    l ll

    l

    l

    Cook's distance1

    0.5

    0.5

    1

    Residuals vs Leverage2

    13

    2