Examples for 'stats::case.names'


Case and Variable Names of Fitted Models

Aliases: case.names case.names.lm variable.names variable.names.lm

Keywords: regression models

### ** Examples

x <- 1:20
y <-  setNames(x + (x/4 - 2)^3 + rnorm(20, sd = 3),
               paste("O", x, sep = "."))
ww <- rep(1, 20); ww[13] <- 0
summary(lmxy <- lm(y ~ x + I(x^2)+I(x^3) + I((x-10)^2), weights = ww),
        correlation = TRUE)
Call:
lm(formula = y ~ x + I(x^2) + I(x^3) + I((x - 10)^2), weights = ww)

Weighted Residuals:
    Min      1Q  Median      3Q     Max 
-4.8175 -1.7069 -0.8891  1.6597  7.1939 

Coefficients: (1 not defined because of singularities)
                Estimate Std. Error t value Pr(>|t|)   
(Intercept)   -10.033423   3.547022  -2.829  0.01270 * 
x               4.176608   1.434296   2.912  0.01073 * 
I(x^2)         -0.385001   0.158197  -2.434  0.02792 * 
I(x^3)          0.016324   0.004995   3.268  0.00519 **
I((x - 10)^2)         NA         NA      NA       NA   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 3.243 on 15 degrees of freedom
Multiple R-squared:  0.9658,	Adjusted R-squared:  0.9589 
F-statistic:   141 on 3 and 15 DF,  p-value: 3.259e-11

Correlation of Coefficients:
       (Intercept) x     I(x^2)
x      -0.90                   
I(x^2)  0.80       -0.97       
I(x^3) -0.73        0.93 -0.99 
variable.names(lmxy)
[1] "(Intercept)" "x"           "I(x^2)"      "I(x^3)"     
variable.names(lmxy, full = TRUE)  # includes the last
[1] "(Intercept)"   "x"             "I(x^2)"        "I(x^3)"       
[5] "I((x - 10)^2)"
case.names(lmxy)
 [1] "O.1"  "O.2"  "O.3"  "O.4"  "O.5"  "O.6"  "O.7"  "O.8"  "O.9"  "O.10"
[11] "O.11" "O.12" "O.14" "O.15" "O.16" "O.17" "O.18" "O.19" "O.20"
case.names(lmxy, full = TRUE)      # includes the 0-weight case
 [1] "O.1"  "O.2"  "O.3"  "O.4"  "O.5"  "O.6"  "O.7"  "O.8"  "O.9"  "O.10"
[11] "O.11" "O.12" "O.13" "O.14" "O.15" "O.16" "O.17" "O.18" "O.19" "O.20"

[Package stats version 4.2.3 Index]