frame_mle: General Cook's distance or Q-function distance of quantile...

Description Usage Arguments Details Value Author(s) Examples

View source: R/frame_mle.R

Description

dataframe used to plot generalized Cook's distance or Q-function distance for observations.

Usage

1
2
frame_mle(y, x, tau, error = 1e-06, iter = 100,
  method = c("cook.distance", "qfunction"))

Arguments

y

vector, dependent variable for quantile regression

x

matrix, design matrix for quantile regression. For quantile regression model with intercept, the firt column of x is 1.

tau

sigular or vector, quantiles

error

the EM algorithm accuracy of error used in MLE estimation

iter

the iteration frequancy for EM algorithm used in MLE estimation

method

use method 'cook.distance' or 'qfunction'

Details

Gerneralized Cook's distance and Q-function distance are commonly used in detecting the influence data point when performing regression analysis. They involve the log-likelihood function and estimations of based on the complete and case-deletion data. We used EM algorithm to estimate the coefficiences of quantile regression with asymmetric Laplace distribution.

Value

generalized Cook's distance or Q-function distance for multiple quantiles

Author(s)

Wenjing Wangwenjingwangr@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
library(ggplot2)
data(ais)
ais_female <- subset(ais, Sex == 1)
y <- ais_female$BMI
x <- cbind(1, ais_female$LBM, ais_female$Bfat)
tau <- c(0.1, 0.5, 0.9)
case <- rep(1:length(y), length(tau))
GCD <- frame_mle(y, x, tau, error = 1e-06, iter = 10000,
                 method = 'cook.distance')
GCD_m <- cbind(case, GCD)
ggplot(GCD_m, aes(x = case, y = value )) +
  geom_point() +
  facet_wrap(~variable, scale = 'free') +
  geom_text(data = subset(GCD_m, value > mean(value) + 2*sd(value)),
            aes(label = case), hjust = 0, vjust = 0) +
  xlab("case number") +
  ylab("Generalized Cook Distance")

QD <- frame_mle(y, x, tau, error = 1e-06, iter = 10000,
                method = 'qfunction')
QD_m <- cbind(case, QD)
ggplot(QD_m, aes(x = case, y = value)) +
  geom_point() +
  facet_wrap(~variable, scale = 'free')+
  geom_text(data = subset(QD_m, value > mean(value) + sd(value)),
            aes(label = case), hjust = 0, vjust = 0) +
  xlab('case number') +
  ylab('Qfunction Distance')

quokar documentation built on May 2, 2019, 6:39 a.m.