Learn R Programming

arm (version 1.0-9)

sigma.hat: Extract Residual Errors

Description

This generic function extracts residual errors from a fitted model.

Usage

sigma.hat(object)

# methods for sigma.hat()
sigma.hat.lm (object)
sigma.hat.glm (object)
sigma.hat.mer (object)

Arguments

object
any fitted model object of lm, glm and mer class

See Also

display, summary, lm, glm, lmer

Examples

Run this code
group <- rep(1:10, rep(10,10))
   mu.a <- 0
   sigma.a <- 2
   mu.b <- 3
   sigma.b <- 4
   rho <- 0
   Sigma.ab <- array (c(sigma.a^2, rho*sigma.a*sigma.b, 
                    rho*sigma.a*sigma.b, sigma.b^2), c(2,2))
   sigma.y <- 1
   ab <- mvrnorm (10, c(mu.a,mu.b), Sigma.ab)
   a <- ab[,1]
   b <- ab[,2]

   x <- rnorm (100)
   y1 <- rnorm (100, a[group] + b[group]*x, sigma.y)
   y2 <- rbinom(100, 1, prob=invlogit(a[group] + b*x))
   
   M1 <- lm (y1 ~ x) 
   sigma.hat(M1)

   M2 <- glm (y2 ~ x, family=binomial(link="logit"))
   sigma.hat(M2)

   M3 <- lmer (y1 ~ (1+x|group))
   sigma.hat(M3) 
   
   M4 <- lmer (y2 ~ (1+x|group), family=binomial(link="logit"))
   sigma.hat(M4)

Run the code above in your browser using DataLab