# A Copula-Based Attack Prediction Model for Vehicle-to-Grid Networks
## 4 Prediction Method  
In the context of our work, the attack prediction method proposed is inspired by the model presented in [22]. It is based on the notion of generalized binary regression. The aim of this model is to predict, in practice, a binary response variable through the explanatory variables. Specifically, let \(Y\) be a binary variable taking values 0 and 1, and let \(X=(X_{1},\ldots,X_{d})\) be a vector of explanatory variables. The goal is to estimate the predicted probability of an attack using the following equation:  
\[\pi(x)=\mathrm{P}(Y=1|X=x),\quad x\in\mathbb{R}^{d}. \tag{1}\]  
In the following, a new way to model the above predicted probability using the notion of copulas is presented. This idea consists of rewriting \(\pi(x)\) in terms of the marginal distribution and the copula of the vector \((Y,X_{1},\ldots,X_{d})\). This can be done using the Sklar Theorem (see [22] for more details). In fact, let \(p=\mathrm{P}(Y=1)\); then, one observes that  
\[\pi(x) = P(Y=1|X=x) \tag{2}\] \[= 1-P(Y\leq 0|X=x)\] \[= 1-C^{\epsilon}\{1-p|F_{1}(x_{1}),\ldots,F_{d}(x_{d})\},\]where \(C^{c}\{u|v_{1},\ldots,v_{d}\}\) denote the conditional copula expressed by  
\[C^{c}\{u|v_{1},\ldots,v_{d}\}=\frac{c(u,v_{1},\ldots,v_{d})}{c(1,v_{1},\ldots,v _{d})},\]  
with  
\[c(u,v_{1},\ldots,v_{d})=\frac{\partial^{d}C}{\partial v_{1}\cdots\partial v_{d }}(u,v_{1},\ldots,v_{d}).\]  
The estimation of the predicted probability described in (2) can be achieved by estimating separately the marginal quantities, \(p\), \(F_{1}(x_{1}),\ldots,F_{d}(x_{d})\), as well as the copula parameter \(\theta\). This means that the estimation procedure can be executed through the next steps. For this, let \((Y_{i},X_{i,1},\ldots,X_{i,d})\), \(i=1,\ldots,n\) be a sample from the random vector \((Y,X_{1},\ldots,X_{d})\). * Estimation of \(p\). The probability \(p\) can simply be estimated by the percentage of an attack, given by \[\hat{p}_{n}=\frac{1}{n}\sum_{i=1}^{n}\prod(Y_{i}=1).\]
* Estimation of marginal. The marginal distributions \(F_{1}(x_{1}),\ldots,F_{d}(x_{d})\) are estimated using empirical distribution: \[\hat{F}_{j,n}(x_{j})=\frac{1}{n+1}\sum_{i=1}^{n}\mathbb{I}(X_{ij}\leq x_{j}), \quad j=1,\ldots,d.\]
* Estimation of the copula parameter \(\theta\). The estimator \(\hat{\theta}_{n}\) of the dependence parameter \(\theta\) is derived from the maximum likelihood procedure. In fact, \(\hat{\theta}_{n}\) is obtained by maximizing in terms of \(\theta\) the following pseudo-likelihood function: \[\mathcal{L}(\theta)=\prod_{i=1}^{n}\ell(\theta,\hat{p},Y_{i},F_{n}(X_{i})),\] where \(F_{n}(X_{i})=(F_{1,n}(X_{i,1}),\ldots,F_{d,n}(X_{i,d}))\) and \(\ell(\theta,\hat{p},Y_{i},F_{n}(X_{i}))\) denotes \[\{1-C^{c}\{1-\hat{p}|F_{n}(X_{i});\theta\}\}^{Y_{i}}C^{c}\{1-\hat{p}|F_{n}(X_ {i});\theta\}^{1-Y_{i}}.\] Consequently, the desired estimator \(\hat{\theta}_{n}\) is given by \[\pi(x) = P(Y=1|X=x) \tag{2}\]0 The VineCopula package under software R was used to choose the copula that best represents the data and estimate the best-performing \(\theta\) parameter. From all of the above, the final estimator of \(\pi(x)\) is  
\[\pi(x) = P(Y=1|X=x) \tag{2}\]1  
In order to determine whether \(Y=1\) or \(Y=0\), it suffices thereafter to classify as follows: if the probability that \(Y_{i}=1\) knowing the explanatory variables \(x\) is greater than 50% and it is either \(Y=0\) or \(Y=1\), then we must associate \(Y_{i}\) with 1. Within the framework of the realization of the model under the software R, the following methodology inspired by [23] Equation (6) was used to estimate the parameter of the copula. By applying Formula (6) of [23] and considering four significant variables \(X_{1},X_{2},X_{3},X_{4}\), the distribution of \((Y,X_{2},X_{3},X_{4})\) can be rewritten as follows:  
\[\pi(x) = P(Y=1|X=x) \tag{2}\]2In this expression, the conditional distributions \(F(Y|X_{2},X_{3},X_{4})\) and \(F(X_{1}|X_{2},X_{3},X_{4})\) are unknowns that must be sought.