Examples for 'stats::weighted.residuals'


Compute Weighted Residuals

Aliases: weighted.residuals

Keywords: regression

### ** Examples

## following on from example(lm)
## Don't show: 
utils::example("lm", echo = FALSE)
plot of chunk example-stats-weighted.residuals-1
## End(Don't show)
all.equal(weighted.residuals(lm.D9),
          residuals(lm.D9))
[1] TRUE
x <- 1:10
w <- 0:9
y <- rnorm(x)
weighted.residuals(lmxy <- lm(y ~ x, weights = w))
          2           3           4           5           6           7 
-1.21578229  0.45445838 -0.43099526  1.49662264 -0.05526046  2.51557367 
          8           9          10 
-4.69108241  0.55567329  1.04259726 
weighted.residuals(lmxy, drop0 = FALSE)
          1           2           3           4           5           6 
 0.00000000 -1.21578229  0.45445838 -0.43099526  1.49662264 -0.05526046 
          7           8           9          10 
 2.51557367 -4.69108241  0.55567329  1.04259726 

[Package stats version 4.2.3 Index]