You are on page 1of 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
-1.7946 -1.2770

Median
0.2540

3Q
1.1738

Max
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)

0.5

0.0

0.5

2
1

1.0

1.5

0.5

1.5

1.0

2
1

0.5

3
Cook's distance

0.00

Fitted values

0.10

0.20

Leverage

0.4

0.0

0.5

Standardized residuals

1.2
0.8

0.0

Standardized residuals

0.5

0.5

Residuals vs Leverage
2

Theoretical Quantiles

ScaleLocation

Fitted values

Standardized residuals

Normal QQ

Residuals

Residuals vs Fitted

0.30

0.5
1

You might also like