Sea \(F\) una distribución de probabilidad en \(\mathbb{R}^d\), \(d \geq 1\). Supongamos que \(F\) es absolutamente continua y que \(\{X_1, \dots ,X_n\}\) es una muestra aleatoria de \(F\). Nótese que cada punto \(X_i\) es visto como un vector columna de dimensión \(d \times 1\).
Una función de profundidad es una función acotada \((\cdot,F):\mathbb{R}^d \mapsto [0,1]\) que asigna a cada punto \(x \in \mathbb{R}^d\) su grado de centralidad respecto a \(F\) o respecto a una nube de puntos \(\{X_1, \dots ,X_n\}\)
library(qcr)
## Loading required package: qcc
## Package 'qcc' version 2.7
## Type 'citation("qcc")' for citing this R package in publications.
## Loading required package: fda.usc
## Loading required package: fda
## Loading required package: splines
## Loading required package: Matrix
##
## Attaching package: 'fda'
## The following object is masked from 'package:graphics':
##
## matplot
## Loading required package: MASS
## Loading required package: mgcv
## Loading required package: nlme
## This is mgcv 1.8-23. For overview type 'help("mgcv-package")'.
## Loading required package: rpart
## Loading required package: mvtnorm
## Loading required package: qualityTools
## Loading required package: Rsolnp
##
## Attaching package: 'qualityTools'
## The following object is masked from 'package:stats':
##
## sigma
##
## Package qcr: Quality Control Review
## version 1.0 (built on 2016-07-19).
## Copyright Miguel A. Flores Sanchez 2016.
set.seed(356)
mu<-c(0,0)
Sigma<- matrix(c(1,0,0,1),nrow = 2,ncol = 2)
u <- c(2,2)
S <- matrix(c(4,0,0,4),nrow = 2,ncol = 2)
G <- rmvnorm(540, mean = mu, sigma = Sigma)
x<- rmvnorm(40,mean=u,sigma = S)
x <- rbind(G[501:540,],x)
M <- G[1:500,]
data.npqcd <- npqcd(x,M)
str(data.npqcd)
## List of 2
## $ x: num [1:80, 1:2, 1] 0.995 -1.274 -1.174 -0.347 0.931 ...
## $ G: num [1:500, 1:2] 0.306 -0.322 1.389 1.438 -0.784 ...
## - attr(*, "data.name")= chr "DATA"
## - attr(*, "type.data")= chr "Multivariate"
## - attr(*, "class")= chr [1:2] "npqcd" "list"
res.npqcs <- npqcs.r(data.npqcd,method = "Liu", alpha=0.025)
str(res.npqcs)
## List of 9
## $ npqcd :List of 2
## ..$ x: num [1:80, 1:2, 1] 0.995 -1.274 -1.174 -0.347 0.931 ...
## ..$ G: num [1:500, 1:2] 0.306 -0.322 1.389 1.438 -0.784 ...
## ..- attr(*, "data.name")= chr "DATA"
## ..- attr(*, "type.data")= chr "Multivariate"
## ..- attr(*, "class")= chr [1:2] "npqcd" "list"
## $ type : chr "r"
## $ depth.data: num [1:80, 1] 0.0243 0.0866 0.0292 0.2412 0.1214 ...
## $ statistics: num [1:80, 1] 0.242 0.532 0.268 0.974 0.666 0.268 0.42 0.136 0.824 0.118 ...
## $ alpha : num 0.025
## $ limits : Named num [1:2] 0.025 0.5
## ..- attr(*, "names")= chr [1:2] "lcl" "cl"
## $ data.name : chr "DATA"
## $ method : chr "Liu"
## $ violations: int [1:25] 42 43 44 46 48 49 50 52 53 54 ...
## - attr(*, "class")= chr [1:2] "npqcs.r" "npqcs"
summary(res.npqcs)
##
## Summary of group statistics:
## V1
## Min. :0.0140
## 1st Qu.:0.0140
## Median :0.1970
## Mean :0.3018
## 3rd Qu.:0.4810
## Max. :0.9760
##
## Number of quality characteristics: 2
## Number of samples or observations: 80
## Number of observations or sample size: 1
## Control limits:
## lcl cl
## 0.025 0.500
##
## Beyond limits of control:
## [1] 0.014 0.014 0.014 0.014 0.014 0.014 0.014 0.014 0.014 0.014 0.014
## [12] 0.014 0.014 0.014 0.014 0.014 0.016 0.014 0.014 0.014 0.014 0.014
## [23] 0.014 0.014 0.014
plot(res.npqcs,title =" r Control Chart")
En Liu and Tang (1996) se propuso simular una muestra aleatoria de 101 puntos de una distribución \(\mathcal{N}(0,1)\) y lo denotamos por \(\{A_1,\dots,A_{101}\}\). Luego, obtenemos independientemente una muestra de 100 observaciones de una distribución \(\mathcal{N}(0,0\mbox{.}1)\) y lo denotamos por \(\{y_1,\dots,y_{100}\}\).
Sea \(X_i=(A_i+A_{i+1})/2+y_i\), \(i=1,\dots,100\), esto es \(n=100\). Claramente los \(X_i\) son 1-dependientes, y \(X_i\) sigue una distribución \(\mathcal{N}(0,0\mbox{.}51)\) con \(cov(X_i,X_{i+1})=0.25\).
Repetimos el procedimiento MBB con \(\ell=4\) (\(=N\)) 1000 veces para obtener 1000 promedios de muestras boostrap \(\bar{X}_N^*\) y construimos un histograma de los 1000 valores de \(\sqrt[]{N}(\bar{\bar{X_N^*}}-\bar{\bar{X_n}})\). Aquí \(\bar{\bar{X_n}}\) es el promedio de los 100 primeros \(X_i\).
rm(list = ls())
set.seed(12125)
#Obtención de muestras de variables aleatorias
A <-rnorm(101)
y <-rnorm(n = 100,mean = 0,sd = 0.01)
x <-numeric(length(y))
for (i in 1:length(y))
x[i]<-(A[i]+A[i+1])/2+y[i]
#Tamaño de bloque
#Bloque de tamaño 4
b <-4
#Bloques
B <-matrix(0,ncol = b,nrow = (length(x)-b+1))
for (i in 1:(length(x)-b+1)){
B[i,]<-x[i:(i+b-1)]
}
#Moving Blocks Bootstrap
#Número de muestras boostrap
N <-1000
#Matriz de bloques boostrap
BB <-matrix(0,nrow=N,ncol=b)
BB<-B[sample(1:nrow(B),N,replace = TRUE),]
#Media observaciones Xi
mx <-mean(x)
#Medias matriz MBB
mbx <-apply(BB,1,mean)
#Cálculo de límites de control
alpha <-0.05
hbb <-sqrt(N)*(mbx-mx)
pbl <-quantile(hbb,probs = (alpha/2))
pbu <-quantile(hbb,probs = 1-(alpha/2))
LCL4 <-(sum(mbx)/length(mbx))+pbl/sqrt(N)
UCL4 <-(sum(mbx)/length(mbx))+pbu/sqrt(N)
#############################################################
#Tamaño de bloque
#Bloque de tamaño 2
b <-2
#Bloques
B <-matrix(0,ncol = b,nrow = (length(x)-b+1))
for (i in 1:(length(x)-b+1)){
B[i,]<-x[i:(i+b-1)]
}
#Moving Blocks Bootstrap
#Número de muestras boostrap
N <-1000
#Matriz de bloques boostrap
BB <-matrix(0,nrow=N,ncol=b)
BB<-B[sample(1:nrow(B),N,replace = TRUE),]
#Media observaciones Xi
mx <-mean(x)
#Medias matriz MBB
mbx <-apply(BB,1,mean)
#Cálculo de límites de control
alpha <-0.05
hbb <-sqrt(N)*(mbx-mx)
pbl <-quantile(hbb,probs = (alpha/2))
pbu <-quantile(hbb,probs = 1-(alpha/2))
LCL2 <-(sum(mbx)/length(mbx))+pbl/sqrt(N)
UCL2 <-(sum(mbx)/length(mbx))+pbu/sqrt(N)
########################################################################
#Tamaño de bloque
#Bloque de tamaño 1
b <-1
#Bloques
B <-matrix(0,ncol = b,nrow = (length(x)-b+1))
for (i in 1:(length(x)-b+1)){
B[i,]<-x[i:(i+b-1)]
}
#Moving Blocks Bootstrap
#Número de muestras boostrap
N <-1000
#Matriz de bloques boostrap
BB <-matrix(0,nrow=N,ncol=b)
BB<-B[sample(1:nrow(B),N,replace = TRUE),]
#Media observaciones Xi
mx <-mean(x)
#Cálculo de límites de control
alpha <-0.05
hbb <-sqrt(N)*(BB-mx)
pbl <-quantile(hbb,probs = (alpha/2))
pbu <-quantile(hbb,probs = 1-(alpha/2))
LCL1 <-(sum(mbx)/length(mbx))+pbl/sqrt(N)
UCL1 <-(sum(mbx)/length(mbx))+pbu/sqrt(N)
#Gráfico
#Obtenemos nuevas muestras
set.seed(32646)
A <-rnorm(101)
y <-rnorm(n = 100,mean = 0,sd = 0.01)
x <-numeric(length(y))
for (i in 1:length(y))
x[i]<-(A[i]+A[i+1])/2+y[i]
X<-matrix(x,25,4,byrow = TRUE)
#Límites de control exactos
#la posición de los límites de control depende de si la covarianza
# es negativa o positiva
LCL <- -0.92193
UCL <- 0.92193
plot(apply(X,1,mean),type = "b",ylab = "X-bar",xlab = "Time",
ylim = c(-1.4,1.7))
abline(h=UCL,col="blue")
text(25,0.9,"Std",col = "Blue")
abline(h=UCL4,col="red")
text(25,1.05,"b=1",col = "red")
abline(h=UCL2,col="brown")
text(25,1.35,"b=2",col = "brown")
abline(h=UCL1,col="green")
text(25,1.6,"b=4",col = "green")
abline(h=LCL,col="blue")
text(25,-0.85,"Std",col = "Blue")
abline(h=LCL4,col="red")
text(25,-0.65,"b=1",col = "red")
abline(h=LCL2,col="brown")
text(25,-1.01,"b=2",col = "brown")
abline(h=LCL1,col="green")
text(25,-1.35,"b=4",col = "green")
El análisis de datos funcionales cuya unidad básica de información es el dato funcional, se define como el nuevo campo de la estadística que proporciona información a partir de una muestra de observaciones de una familia continua \(\mathcal{X} = \{\mathcal{X}(t);t \in T\}\), por ejemplo: curvas, superficies o cualquier otra forma que cambia en un cont'inuo.
Sea $ L^{2}(T)$, el espacio de Hilbert separable definido por las funciones de cuadrado integrable en el intervalo \(T = \left[ a,b\right] \subset \mathbb{R}\):
\[ L^{2}(T) = \{ \mathcal{X} : T \rightarrow \mathbb{R}; \int_{T} \mathcal{X}(t)^{2} dt < \infty \} \] con un producto interno definido por:
\[ \left\langle \mathcal{X}(t),\mathcal{Y}(t) \right\rangle =\int_{T} \mathcal{X} \left ( t \right ) \mathcal{Y}\left ( t \right ) dt.\]
Liu, Regina Y. 1995. “Control Charts for Multivariate Processes.” Journal of the American Statistical Association 90 (432). Taylor & Francis Group: 1380–7.
Liu, Regina Y, and Jen Tang. 1996. “Control Charts for Dependent and Independent Measurements Based on Bootstrap Methods.” Journal of the American Statistical Association 91 (436). Taylor & Francis Group: 1694–1700.