# Phase transitions in four-dimensional AdS black holes with a nonlinear
electrodynamics source

Ramón Bécar<EMAIL_ADDRESS>Departamento de Ciencias Matemáticas y Físicas,
Universidad Católica de Temuco, Montt 56, Casilla 15-D, Temuco, Chile. P. A.
González<EMAIL_ADDRESS>Facultad de Ingeniería y Ciencias, Universidad
Diego Portales, Avenida Ejército Libertador 441, Casilla 298-V, Santiago,
Chile. Joel Saavedra<EMAIL_ADDRESS>Instituto de Física, Pontificia
Universidad Católica de Valparaíso, Casilla 4950, Valparaíso, Chile. Yerko
Vásquez<EMAIL_ADDRESS>Departamento de Física, Facultad de Ciencias,
Universidad de La Serena,
Avenida Cisternas 1200, La Serena, Chile. Bin Wang<EMAIL_ADDRESS>Center
for Gravitation and Cosmology, College of Physical Science and Technology,
Yangzhou University, Yangzhou 225009, China.

###### Abstract

In this work we consider black hole solutions to Einstein theory coupled to a
nonlinear power-law electromagnetic field with a fixed exponent value. We
study the extended phase space thermodynamics in canonical and grand canonical
ensembles where the varying cosmological constant plays the role of an
effective thermodynamic pressure. We examine thermodynamical phase transitions
in such black hols and find that both first and second order phase transitions
can occur in the canonical ensemble, while for the grand canonical ensemble
the Hawking-Page and second order phase transitions are allowed.

##  1 Introduction

Phase transitions in gravitational systems have attracted more interests since
the discovery of Hawking-Page phase transitions in four-dimensional Anti-de
Sitter (AdS) backgrounds, where the low-temperature phase is thermal AdS and
the high temperature phase is the AdS black hole HP . Moreover in AdS, unlike
the flat spacetime where large black holes always have smaller temperature and
ordinary Schwarzschild has negative specific heat which is thermodynamically
unstable, it was found that large AdS black holes have positive specific heat.
If you make them bigger (higher energy), they get hotter. Small AdS black
holes have negative specific heat and very small AdS black holes do not care
about the cosmological constant at all so are just like the flat spacetime
Schwarzschild solution. Considering AdS black holes have the property that the
horizon is a $(d-2)$-dimensional compact Einstein space of positive, zero, or
negative curvature, it was argued that they have different phase
structuresBirmingham:1998nr . For Schwarzschild-AdS black holes with toroidal
or hyperbolic horizons, it was found that they are thermally stable and the
Hawking-Page phase transition does not occur. However, for Schwarzschild-AdS
black holes with spherical horizon, there exits Hawking-Page phase transition
between large stable black holes and thermal gas in the AdS space.

Considering the cosmological constant as a thermodynamic pressure, and its
conjugate variable as the thermodynamic volume, thermodynamical phase
transitions have been restudied extensively from the first article about it
Kastor:2009wy , for a review please refer to Kubiznak:2016qmn  and references
therein and Belhaj:2013cva ; Zeng:2016aly . Witten Witten:1998zw  extended the
four-dimensional transition to arbitrary dimension and provided a natural
explanation of a confinement/deconfinement transition on the boundary field
theory via the AdS/CFT correspondence. Dynamical signature of the
thermodynamical phase transition was uncovered in the study of perturbations
around black holes Shen:2007xk . In the extended phase space, the Van der
Waals like thermodynamic phase transition was further observed in quasinormal
modes Liu:2014gvf .

Further phase transition phenomena have been analyzed and classified by
exploiting Ehrenfest’s scheme Banerjee:2010da ; Banerjee:2010bx ;
Banerjee:2011au ; Banerjee:2011raa . Bragg-Williams’ construction of a free
energy function has also been applied to examine the black hole phase
transitions Banerjee:2010ve . In addition to standard thermodynamic methods,
geometrical ideas have also been introduced to study thermodynamic phase
transitions and it was argued that such geometric method could disclose the
intrinsic reason on the transition W ; R ; Ruppeiner:1995zz .

In this work, we want to generalize the phase transition study in black hole
solutions to Einstein theory coupled to a nonlinear electromagnetic field.
Introducing the nonlinear electrodynamics is to eliminate the problem of
infinite energy of the electron BI . The nonlinear electrodynamics plays an
important role in the construction of regular black hole solutions
AyonBeato:1998ub ; AyonBeato:1999rg ; Cataldo:2000ns ; Bronnikov:2000vy ;
Burinskii:2002pz ; Matyjasek:2004gh . Some black hole/brane solutions in
nonlinear electromagnetic fields have been investigated for instance in
Hendi:2010zz ; Hendi:2010bk ; Hendi:2010kv ; Cai:2004eh ; Dey:2004yt ;
Aiello:2004rz ; Hendi:2009sw ; Hendi:2013dwa ; Hendi:2015hoa ; Hendi:2016dmh
and references therein. The thermodynamics of Einstein-Born-Infeld black holes
with a negative cosmological constant was studied in Miskovic:2008ck  and of a
power-law electrodynamic hole in Gonzalez:2009nn , where the authors showed
that a set of small black holes are locally stable by computing the heat
capacity and the electrical permittivity. The thermodynamics of Gauss-Bonnet
black holes for a power-law electrodynamic was studied in Hendi:2010zza . On
the other hand, higher dimensional black hole solutions to Einstein-dilaton
theory coupled to Maxwell field were found in Sheykhi:2009pf ; Hendi:2015xya
and black hole solutions to Einstein-dilaton theory coupled to Born-Infeld and
power-law electrodynamics were found in Dehghani:2006zi ; Zangeneh:2015wia .
In our study on black hole solutions to Einstein theory coupled to a nonlinear
power-law electromagnetic field, taking the specific value of the exponent
power is motivated by the existence of exact hairy black hole solutions for
the $p=3/4$ value O.:2016wcf . Here we want to examine phase transitions in
both canonical and grand canonical ensembles. In the study of extended phase
space thermodynamics and P-V criticality of d-dimensional black holes, a
nonlinear source influence on the phase structure was disclosed Hendi:2012um .
Considering the presence of a generalized Maxwell theory, such as the power
Maxwell invariant, it was shown that a first order phase transition occurs in
both canonical and grand canonical ensembles, in contrast to the situation in
Reissner-Nordström black hole with standard Maxwell field where phase
transition only happens in the canonical ensemble. The power Maxwell invariant
(PMI) field contains richer physics than that of the Maxwell field, which
reduces to linear electromagnetic source at a special case ($p=1$). The black
hole solutions of the Einstein-PMI theory and their thermodynamics and
geometric properties have been studied in Hassaine:2007py ; Hendi:2009zzb ;
Hendi:2009zza ; Hassaine:2008pw ; Maeda:2008ha ; Hendi:2010zza ; Hendi:2010bk
; Hendi:2010zz ; Hendi:2010kv . Here we will concentrate to examine how the
nonlinearities, especially the power-law exponent of the nonlinear
electromagnetic field, influence the phase structures of black holes.

The paper is organized as follows. In Sec. 2 we give a brief review of the
background that we will study. In Sec. 3 we give an extended thermodynamics
description in canonical ensembles and grand canonical ensembles. Finally, we
conclude in Sec. 4.

##  2 General Formalism for NonLinear Electrodynamics

We consider topological black hole solutions for the power Maxwell theory
coupled to gravity described by the action, see Refs. Hendi:2012um ;
Zangeneh:2015wia

$\displaystyle I=\int
d^{4}x\sqrt{-g}\left(\frac{1}{2\kappa}(R-2\Lambda)+\eta\,|-F_{\mu\nu}F^{\mu\nu}|^{p}\right)\,,$
(1)

where $\kappa=8\pi G=1$,
$F_{\mu\nu}=\partial_{\mu}A_{\nu}-\partial_{\nu}A_{\mu}$ and $A_{\mu}$
represents the gauge potential. The exponent $p$ is a rational number and the
absolute value ensures that any configuration of electric and magnetic fields
can be described by these Lagrangians. One could also consider the Lagrangian
without the absolute value and the exponent $p$ restricted to being an integer
or a rational number with an odd denominator Hassaine:2008pw . The sign of the
coupling constant $\eta$ will be chosen such that the energy density of the
electromagnetic field is positive. This condition is guaranteed in the
following cases: $p>1/2$ and $\eta>0$ or $p<1/2$ and $\eta<0$ O.:2016wcf .
Here, we will consider the first condition and a specific value of the
exponent $p=3/4$. In Ref. O.:2016wcf  was shown that the field equations have
as solutions the topological nonlinearly charged black holes Refs. O.:2016wcf
, Hendi:2012um , Zangeneh:2015wia . The general AdS solution for power Maxwell
black hole can be written as follow

$ds^{2}=-f(r)dt^{2}+\frac{dr^{2}}{f(r)}+r^{2}d\Omega^{2}\,,$ (2)

where $d\Omega^{2}$ is the metric of the spatial 2-section, which can have a
positive ($k=1$), negative ($k=-1$) or zero ($k=0$) curvature, and

$f(r)=k-\frac{m}{r}-\frac{\Lambda}{3}r^{2}+\eta\frac{2^{p}(2p-1)^{2}}{(3-2p)}\frac{q^{2p}}{r^{\frac{2}{2p-1}}}\,,$
(3)

where $m$ and $q$ are integration constants related to the ADM mass $M$ and
the electric charge $Q$ of the black hole by

$\displaystyle M$ $\displaystyle=$ $\displaystyle 4\pi m\,,$ (4)
$\displaystyle Q$ $\displaystyle=$ $\displaystyle\eta 2^{2p-1}p\,q^{2p-1}\,,$
(5)

respectively, and the gauge potential is given by

$A_{t}(r)=\frac{1-2p}{3-2p}\,q\,r^{\frac{3-2p}{1-2p}}\,.$ (6)

In Ref. O.:2016wcf  it has been shown that Eq. (3) describes a black hole
solution with an inner horizon ($r_{-}$) and an outer horizon ($r_{+}$). The
outer horizon $r_{+}$ of this black hole can be calculated numerically by
finding the largest real positive root of $f(r=r_{+})=0$, for different values
of $p$ parameter under consideration. In the following, we focus our attention
at the specific value $p=3/4$. Then, the metric (3) reads as follows

$f(r)=k-\frac{m}{r}+\eta\frac{q^{3/2}}{3\sqrt[4]{2}r^{4}}-\frac{\Lambda
r^{2}}{3}\,.$ (7)

In Fig. 1 we show the behaviour of this black hole metric function for
different values of the cosmological constant and $k=1$ with $p=\frac{3}{4}$.
We can observe that for a fixed values of the cosmological constant, black
hole charge, and the non-linear coupling constant $\eta$, there are different
kind of solutions; black holes with a Cauchy and an event horizon, an extremal
black hole configuration, and also naked singularities, when the black hole
mass decrease.

Figure 1: The behaviour of the lapse function as a function of $r$, for
different values of the black hole mass, and $q=1$, $\eta=1$ and $\Lambda=-1$

Now, using the surface gravity relation, and Eq. (7) we can obtain the Hawking
temperature of the black hole solutions, and also we can express
thermodynamics quantities as function of the event horizon and physical charge
rather than physical mass $M$

$T=\frac{1}{4\pi
r_{+}}\left(k-\eta\frac{q^{3/2}}{\sqrt[4]{2}r_{+}^{4}}-\Lambda
r_{+}^{2}\right)\,.$ (8)

The behaviour of the temperature of this black hole can be seen in Fig. 2.
Note that the temperature vanishes for $r_{+}=r_{extrem}$, and for
$r_{+}<r_{extrem}$ we obtain a negative temperature and therefore it
corresponds to a region with nonphysical meaning where the thermodynamics
description breakdown.

Figure 2: This figure shows Temperature for $k=1$, $Q=2$ and $\eta=1$, for
different values of the cosmological constant.

Besides, the electric potential $\Phi$, measured at infinity with respect to
the horizon is

$\Phi=-(A_{t}(r_{+})-A_{t}(\infty))=\frac{q}{3r_{+}^{3}}\,,$ (9)

while the Bekenstein-Hawking entropy $S$ is given by

$S=8\pi^{2}r_{+}^{2}\,.$ (10)

The next section is devoted to study the extended thermodynamics properties
and its particular P-V criticality.

##  3 Extended Thermodynamics Description

Now at the extended thermodynamics space we consider the cosmological constant
as another thermodynamics variable, and therefore the standard extensive
parameters will be the entropy, the black hole charge, and the cosmological
constant. In order to see this extended thermodynamics we consider the
cosmological constant as source of a dynamical pressure using the relation
$P=-\frac{\Lambda}{8\pi}$ Dolan:2010ha ; Dolan:2011xt , and the conjugate
thermodynamics volume is given by $V=\frac{32\pi^{2}}{3}r_{+}^{3}$. After
obtaining these quantities we verify that they satisfy the following Smarr
formula

$M=2TS+\frac{4}{3}\Phi Q-2VP\,,$ (11)

with $M$ given by

$M=4\pi
r_{+}{}\left(k+\eta\frac{2^{3/4}q^{3/2}}{6r_{+}^{4}}-\frac{1}{3}\Lambda
r_{+}^{2}\right).$ (12)

###  3.1 Canonical Ensemble (Fixed $Q$)

In this section we study phase transitions at the canonical ensemble, where we
are considering the fixed charge as an extensive parameter. First, we compute
the heat capacity for a fixed $Q$

$C_{Q}=T\left(\frac{\partial S}{\partial T}\right)_{Q}\,.$ (13)

So, from Eq. (8) the heat capacity yields

$C_{Q}=-\frac{16\pi^{2}r_{+}^{2}\left(-2kr_{+}^{4}+2^{3/4}\eta
q^{3/2}+2\Lambda r_{+}^{6}\right)}{5\ 2^{3/4}\eta
q^{3/2}-2r_{+}^{4}\left(k+\Lambda r_{+}^{2}\right)}\,.$ (14)

Now, from Eqs. (8) and (14) we can see that the temperature and the heat
capacity are always positive with the only exception for the extreme
configuration where $r_{+}=r_{-}=r_{extreme}$. There is a region where
$C_{Q}<0$ and according to Davies’s approach this could indicated the presence
of a type one phase transition, also it is important to remark that the
temperature in this region is also negative and therefore it is considered as
a non physical region, where the thermodynamics description breaks down.
Therefore, the main conclusion in according to Davies’s approach it is the
correlation between drastic change for the stability properties of a
thermodynamic black hole system and the change of the sign or divergences of
the heat capacity. In reference to the canonical ensemble, it is very well
known that black holes are locally stable thermodynamics systems if its heat
capacity is positive or non vanishing. Besides, at the points where the heat
capacity is divergent there is a type two phase transition. From Fig. 3 we can
see that this black hole solution is locally unstable from a thermal point of
view, because the heat capacity $C_{Q}$ has a divergent term, for the case
where the spatial section is spherical ($k=1$). For the hyperbolic ($k=-1$)
and flat ($k=0$) spatial sections we can conclude that the respective
configurations of black hole are locally stable. Then, following Davies and
according to Ehrenfest’s classification, second order phase transitions occur
at those points where the heat capacity diverges. These points can be obtained
from the following relation

$5\,*2^{3/4}\eta q^{3/2}-2r_{+}^{4}\left(k+\Lambda r_{+}^{2}\right)=0.\,.$
(15)

Here, we can identify three regions separated by two divergent points. Then,
we can recognize three different phases, two stables phases where $C_{Q}>0$
for small and large horizon radius, and one unstable phase $C_{Q}<0$ for
intermediate radius. Therefore, there are three different phases that we call
small black hole (SBH), meta-stable black hole (MBH) and large black hole
(LBH), some results have been reported for charged AdS black holes with
Maxwell and power Maxwell invariants in Majhi:2012fz ; Poshteh:2016rwc ;
Nam:2018sii .

Figure 3: The heat capacity for $k=1$, $Q=1$, $\eta=1$ and $\Lambda=-0.0246$.
This figure depict different regions according to the sign of the heat
capacity; I) $C_{Q}<0$ and $T<0$ corresponds to non-physical region (Non-PH) ,
II) $T>0$: $C_{Q}>0$ small black hole region (SBH), $C_{Q}<0$ meta-stable
black hole region (MBH) and $C_{Q}>0$ large black hole region (LBH). The
second order phase transitions occurs at the points where the heat capacity
shows a divergence.

Now, in order to figure out the second order phase transition and its
consequences we study the critical behaviour performing the comparison of the
equations of state with the Van der Waals equation. First using Eqs. (8), (12)
and the definition of pressure due to the cosmological constant for a fixed
charge $Q$, we obtain the equation of state, $P(V,T)$

$.P=\frac{T}{2r_{+}}-\frac{k}{8\pi
r_{+}^{2}}+\eta\frac{q^{3/2}}{8\sqrt[4]{2}\pi r_{+}^{6}}\,,$ (16)

. where $r_{+}$ is the horizon radius. Following Gunasekaran:2012dq , we
identify the geometric quantities $P$ and $T$ with physical pressure and
temperature of the system by using dimensional analysis
$l_{P}^{2}=G_{d}\hbar/c^{3}$. Then, we can identify the following relations
between the geometric quantities $P$ and $T$ and the physical pressure and
temperature:

$[Press]=\frac{\hbar c}{l_{P}^{2}}[P]\,,\,\,\,\,\,[Temp]=\frac{\hbar
c}{k}[T]\,.$ (17)

Then,

$[Press]=\frac{\hbar c}{l_{P}^{2}}[P]=\frac{\hbar
c}{l_{P}^{2}}\frac{T}{2r_{+}}+\dots\,,$ (18)

from this expression we can identify the specific volume $v$ of the fluid with
the horizon radius of the black hole as $v=2r_{+}$, thus, Eq. (16) can be
written as

$P=\frac{T}{v}-\frac{k}{2\pi v^{2}}+4\eta\frac{2^{3/4}q^{3/2}}{\pi v^{6}}\,.$
(19)

In Fig. 4 we show the $P$-$v$ diagram, and it is possible to observe a similar
behaviour than the Van der Waals gas, that means, there is a critical point
corresponding to an inflection point over the critical isotherm curve.

Figure 4:  $P$-$v$ diagram with $k=1$, $q=1$ and $\eta=1$, for different
values of the temperature.

The critical point can be computed through

$\displaystyle\frac{\partial P}{\partial v}=0\,,$
$\displaystyle\frac{\partial^{2}P}{\partial v^{2}}=0\,,$ (20)

which yields

$\displaystyle v_{critical}$ $\displaystyle=$
$\displaystyle\frac{2^{15/16}\sqrt[4]{15}\sqrt[4]{\eta}q^{3/8}}{\sqrt[4]{k}}\,,$
$\displaystyle T_{critical}$ $\displaystyle=$
$\displaystyle\frac{2\sqrt[16]{2}k^{5/4}}{5\sqrt[4]{15}\pi\sqrt[4]{\eta}q^{3/8}}\,,$
$\displaystyle P_{critical}$ $\displaystyle=$ $\displaystyle\frac{k^{3/2}}{6\
2^{7/8}\sqrt{15}\pi\sqrt{\eta}q^{3/4}}\,.$ (21)

This critical point only exists for black hole with spherical spatial section
($k=1$), also we can compute the universal relation

$\rho_{0}=\frac{P_{critical}\times
v_{critical}}{T_{critical}}=\frac{5}{12}\,.$ (22)

This universal number corresponds to the critical number and it does not
depend on the black hole charge or the non-linear coupling constant $\eta$.
This universal number differs from the Van der Waals fluid, however the
critical point belongs to the same universality class as the one of the Van
der Waals fluid. Now we would like to discuss the P-V criticality and the
phase transition of charged black holes considering the power Maxwell
electrodynamics with $p=\frac{3}{4}$ in the canonical (fixed $Q$) ensemble. In
this ensemble it is possible to compute the Gibbs free energy evaluating the
Euclidean action on-shell. For doing this, we have to use the counterterm
method in order to cancel the divergences appearing in the on-shell Euclidean
action,

$I_{E}=I_{bulk}+I_{ct}+I_{GH}+I_{A}\,,$ (23)

where $I_{bulk}$ corresponds to the Euclidean on-shell bulk action, $I_{ct}$
is the action coming from the counterterm method, $I_{GH}$ is the well known
Gibbons-Hawking term and $I_{A}$ is a boundary term for the electromagnetic
field needed for a well posed action principle, this term in the canonical
ensemble (fixed $Q$) is not vanishing, and it is given by

$I_{em}=-\frac{p}{4\pi}\int_{\partial
M}d^{n}x\sqrt{h}(-F)^{s-1}n_{\mu}F^{\mu\nu}A_{\nu}=\beta Q\Phi\,,$ (24)

where $\beta=\frac{1}{T}$ and $h_{ij}$ is the induced metric at the boundary.
So, the Gibbs free energy or thermodynamics potential is given by

$G(T,Q,P)=\frac{I_{E}^{on-shell}}{\beta}=M-TS\,,$ (25)

and the corresponding expression in our case is given by

$G=2\pi r_{+}\left(k-\frac{8}{3}\pi
Pr_{+}^{3}+\eta\frac{5q^{3/2}}{3\sqrt[4]{2}r_{+}^{3}}\right)\,.$ (26)

Figure 5: Gibbs free energy for nonlinear Maxwell electrodynamics for
$p=\frac{3}{4}$, $k=1$, $q=2$ and $\eta=1$ at the canonical ensemble. We can
see that for $P<P_{C}$ ($P_{C}$ is represented by the dashed line) the system
is undergoing by a first order phase transition described by the
characteristic swallowtail

In Fig. 5, we depict of Gibbs free energy, clearly the critical pressure is
marking the point where the system is undergoing by a first order phase
transition. For $P<P_{C}$ it appears the well known characteristic swallowtail
where the first order phase transition is occurring at the intersection point
between the small and large black holes configurations. For those branches we
can verify that $T>0$ and $C_{Q}>0$, it does mean that SBH and LBH are locally
stable or also can be interpreted as the phases with positive specific heat in
the lower radius and higher radius regions are stable. Now, for $T>0$ and
$C_{Q}<0$ we have the MBH configuration and this means the MBH branch is
unstable. This meta-stable configuration can be explained because states of
the lowest Gibbs free energy are preferred by the system, similar situations
can occur for some states on the small and large black hole branches. From Eq.
(15) we can obtain the value of the point where the heat capacity diverges,
which is exactly the critical point (3.1). The first order phase transition
takes place between the stable branches, and when $P=P_{C}$ the two divergent
points merge to form a single divergence, removing the unstable region and
where the second order phase transition, described by $C_{Q}$, occurs. For
$P>P_{C}$ the heat capacity is positive definite and free of divergences, then
the black hole configurations are stable and free of critical behaviour.

Note that due to the conservation of electric charge there is no Hawking-Page
(HP) phase transition, for the charged black hole with a Gibbs free energy
essentially non vanishing to the thermal AdS space with a vanishing Gibbs free
energy. In the next section, we consider the grand canonical ensemble where
the charge $Q$ is not fixed and therefore we will be able to study the HP
phase transition.

###  3.2 Grand Canonical Ensemble (Fixed $\Phi$)

Now, in this section we discuss the P-V criticality of charged black holes
considering the power Maxwell electrodynmaics with $p=\frac{3}{4}$ in the
grand canonical (fixed $\Phi$) ensemble. As in the previous section, an
important quantity is the heat capacity $C_{\Phi}$ at fixed $\Phi$, which is
relevant to characterize the local stability in the grand canonical ensemble,
and it is given by

$C_{\Phi}=\frac{4S\left(2PS+2k\pi-3\times
2^{\frac{1}{4}}\sqrt{3\pi}S^{\frac{1}{4}}\eta\Phi^{\frac{1}{2}}\right)}{4PS-4k\pi+3\times
2^{\frac{1}{4}}\sqrt{3\pi}S^{\frac{1}{4}}\eta\Phi^{\frac{1}{2}}}\,.$ (27)

In Fig. 6, we plot the behaviour of the heat capacity as a function of the
entropy, and we can conclude that there is a second order phase transition at
the point where the heat capacity diverges. In fact, at the divergence point
the system is undergoing by a second order phase transition between unstable
small black hole configurations ($C_{\Phi}>0$) and stable large black hole
configurations ($C_{\Phi}>0$), as we will see in the following.

Figure 6: Heat capacity as a function of the entropy for $\Phi=0.5$, $k=1$,
$\eta=0.1$, and $P=5$.

In this ensemble it is possible to compute the grand canonical potential
evaluating the Euclidean action on-shell. In order to regularize the
divergences that appear in the on-shell Euclidean action we have to use the
counterterm method. However in the grand canonical ensemble $I_{A}$ is
vanishing, because the electric potential $\Phi$ is kept fixed, and the grand
potential becomes

$\mathcal{G}=M-TS-Q\Phi\,.$ (28)

Now, using the specific volume $v=2r_{+}$, we can obtain the temperature in
this ensemble, which reads as follows

$T=\frac{1}{4\pi r_{+}}\left(k+8\pi
Pr_{+}^{2}-\eta\frac{3\sqrt{3}(r_{+}\Phi^{3})^{\frac{1}{2}}}{\sqrt[4]{2}}\right)\,,$
(29)

and the equation of state is given by

$P=\frac{T}{v}-\frac{k}{2\pi v^{2}}+\eta\frac{3\sqrt{3}\Phi^{3/2}}{2\
2^{3/4}\pi v^{3/2}}\,.$ (30)

Then, from Eq. (30) and the conditions $\partial P=\partial^{2}P=0$, the
critical point yields

$\displaystyle v_{critical}$ $\displaystyle=$
$\displaystyle\frac{128\sqrt{2}k^{2}}{243\eta^{2}\Phi^{3}}\,,$ $\displaystyle
T_{critical}$ $\displaystyle=$
$\displaystyle-\frac{243\eta^{2}\Phi^{3}}{128\sqrt{2}k\pi}\,,$ $\displaystyle
P_{critical}$ $\displaystyle=$
$\displaystyle\frac{19683\eta^{4}\Phi^{6}\left(8\eta\Phi^{3/2}\sqrt{\frac{k^{2}}{\eta^{2}\Phi^{3}}}-9k\right)}{65536\pi
k^{4}}\,.$ (31)

Note that, the critical point has physical meaning only for black hole with
hyperbolic spatial section ($k=-1$) and lose physical meaning for $k=1$ and
$k=0$, this point was argued in Ref. Hendi:2012um  for $p<1$. Then, for these
cases, the P-v diagram does not show a critical point because the condition
$\partial P=\partial^{2}P=0$ can not be satisfied and therefore there is not a
critical point in the gran canonical ensemble for $k=1$ and $k=0$. Therefore,
it is more like a solid–liquid phase transition, rather than a liquid–gas
phase transition. However, for an interval of the electric potential the
pressure has a maximum $P_{max}$, these results are summarized in Fig. 7.
Also, for $k=-1$ we can compute the universal relation
$\rho_{0}=\frac{P_{critical}*v_{critical}}{T_{critical}}$ for the gran
canonical ensemble, giving $\rho_{0}=1/6$.

Figure 7: $P$-$v$ diagram for $k=1$, $q=1$ and $\eta=1$, for different values
of the electric potential.

On the other hand, the thermodynamic grand potential can be written as

$\mathcal{G}=-\frac{1}{3}\pi\left(-6kr_{+}+16\pi Pr_{+}^{3}+3\
2^{3/4}\sqrt{3}\eta\Phi\sqrt{r_{+}^{3}\Phi}\right).$ (32)

An important difference between the canonical ensemble and the grand canonical
ensemble corresponds to the possibility that in the latter can occur a HP
first order phase transition to thermal AdS. Essentially, due to quantum
effects a black hole can emits energy to external background through Hawking
radiation and this allows to reach the thermal equilibrium between a stable
black hole configuration and the thermal AdS space and its gran thermodynamic
potential is zero. Fig. 8 summarizes the main results about this subject, and
we can see there the HP phase transition between the stable black hole and
thermal AdS, and also there is a second order phase transition between SMB and
LBH at the cusp temperature. Moreover, by observing the slope and concavity of
the thermodynamic potential, see Fig. 6, we can conclude that the black holes
with $S<S_{cusp}$ (SBH) are thermally unstable and with $S>S_{cusp}$ (LBH),
are thermally stable. Then, the former cannot establish the equilibrium with
the thermal AdS space.

Figure 8: Gibbs free energy for nonlinear Maxwell electrodynamics for
$p=\frac{3}{4}$, $k=1$, $\eta=0.1$ for different values of the electric
potential $\Phi$ at the grand canonical ensemble

##  4 Concluding Comments

In this paper we studied the thermodynamics description of black hole
solutions of Einstein theory coupled to a nonlinear power-law electromagnetic
field. We considered the extended phase space, by considering the cosmological
constant as a source of dynamical pressure, and we studied phase transitions
of first order including the Hawking-Page phase transition, and second order
phase transitions at both, canonical and grand canonical ensembles. Mainly, we
found that first and second order phase transitions can occur at the canonical
ensemble, while that for the grand canonical ensemble we found that phase
transitions of first order, of Hawking-Page type can occur. However, the first
order phase transitions depend on the parameter $k$, which describes the
curvature of the spatial 2-section, yielding that in the canonical ensemble
the first order phase transitions are allowed for $k=1$ (spherical), and in
the grand canonical ensemble are allowed for $k=-1$ (hyperbolic).

For the canonical ensemble, we obtained that the temperature and the heat
capacity are always positive with the only exception for the extreme black
hole configuration. From the analysis of the heat capacity at fixed charge we
showed that there is a region where $C_{Q}<0$, then according to Davies’s
approach this indicates the presence of a type one phase transition, also it
is important to remark that the temperature in this region is also negative
and therefore it is considered as a non physical region, where the
thermodynamic description breaks down. It is very well known that a black
holes is a locally stable thermodynamic system if its heat capacity is
positive and non vanishing. Besides, at the points where the heat capacity is
divergent there is a type two phase transition. Also, we have shown that the
black hole solution is locally unstable from a thermal point of view, because
the heat capacity $C_{Q}$ has a divergent term, for the case where the spatial
section is spherical ($k=1$). For the hyperbolic ($k=-1$) and flat ($k=0$)
spatial sections the black hole configurations are stable. Then, following
Davies and according to Ehrenfest’s classification, second order phase
transitions occur at those points where the heat capacity diverges. Then, we
obtain three different phases, two stables phases where $C_{Q}>0$ for small
and large horizon radius, and one unstable phase with $C_{Q}<0$ for
intermediate radius. Therefore, there are three different phases SMB, MBH, and
LBH. Also, we determined the Gibbs free energy, and we have shown that the
critical pressure corresponds to the point where the system is undergoing a
first order phase transition. For $P<P_{C}$ it appears the well known
characteristic swallow tail where the first order phase transition occurs at
the intersection point between the SBH and LBH, with $T>0$ and $C_{Q}>0$.
Therefore, SBH and LBM are locally stable or also we can interpreted as the
phases with positive specific heat in the lower radius and higher radius
regions are stable. When, $T>0$ and $C_{Q}<0$ we have an unstable MBH
configuration. This meta-stable configuration can be explained because states
of the lowest Gibbs free energy are preferred for the system, similar
situation can occur for some states on the small and large black hole
branches.

From the grand canonical ensemble point of view, we found there is a critical
point only for the case $k=-1$ and therefore there is a critical behavior
similar to the description in the canonical ensemble for $k=1$. For cases
$k=1$ and $k=0$, the P-V analysis shows that there is no critical points
because the condition $\partial P=\partial^{2}P=0$ can not be satisfied.
Finally, one important difference of the grand canonical ensemble in
comparison to the canonical ensemble corresponds to the possibility to have a
Hawking-Page first order phase transition to thermal AdS. Essentially, due to
quantum effects a black hole can emit energy to the external background
through Hawking radiation and this allows to reach the thermal equilibrium
between a stable black hole configuration and the thermal AdS space and its
grand thermodynamic potential is zero. Also, we have shown the existence of a
HP phase transition between a stable black hole and the thermal AdS, and also
there is a second order phase transition between SMB and LBH at the horizon
radius where $C_{\Phi}$ is divergent, this point corresponds to the $T_{cusp}$
temperature.

###### Acknowledgements.

This work is supported by ANID Chile through FONDECYT Grant No 1170279 (J.
S.). Y.V. acknowledge support by the Dirección de Investigación y Desarrollo
de la Universidad de La Serena, Grant No. PR18142. B.W. was supported in part
by NNSFC under grant No. 12075202.

## References

  * (1) S. W. Hawking and D. N. Page, Commun. Math. Phys. 87, 577 (1983)
  * (2) D. Birmingham, “Topological black holes in Anti-de Sitter space,” Class. Quant. Grav. 16 (1999), 1197-1205 [arXiv:hep-th/9808032 [hep-th]].
  * (3) D. Kastor, S. Ray and J. Traschen, Class. Quant. Grav. 26, 195011 (2009) doi:10.1088/0264-9381/26/19/195011 [arXiv:0904.2765 [hep-th]].
  * (4) D. Kubiznak, R. B. Mann and M. Teo, Class. Quant. Grav. 34, no.6, 063001 (2017) doi:10.1088/1361-6382/aa5c69 [arXiv:1608.06147 [hep-th]].
  * (5) A. Belhaj, M. Chabab, H. E. Moumni, L. Medari and M. B. Sedra, “The Thermodynamical Behaviors of Kerr—Newman AdS Black Holes,” Chin. Phys. Lett. 30, 090402 (2013) [arXiv:1307.7421 [hep-th]].
  * (6) S. He, L. F. Li and X. X. Zeng, Nucl. Phys. B 915 (2017) 243 doi:10.1016/j.nuclphysb.2016.12.005 [arXiv:1608.04208 [hep-th]].
  * (7) E. Witten, “Anti-de Sitter space, thermal phase transition, and confinement in gauge theories,” Adv. Theor. Math. Phys. 2 (1998) 505 [hep-th/9803131].
  * (8) J. Shen, B. Wang, C. Y. Lin, R. G. Cai and R. K. Su, JHEP 07, 037 (2007) doi:10.1088/1126-6708/2007/07/037 [arXiv:hep-th/0703102 [hep-th]].
  * (9) Y. Liu, D. C. Zou and B. Wang, “Signature of the Van der Waals like small-large charged AdS black hole phase transition in quasinormal modes,” JHEP 09 (2014), 179 [arXiv:1405.2644 [hep-th]].
  * (10) R. Banerjee, S. Ghosh and D. Roychowdhury, “New type of phase transition in Reissner Nordström - AdS black hole and its thermodynamic geometry,” Phys. Lett. B 696 (2011) 156 [arXiv:1008.2644 [gr-qc]].
  * (11) R. Banerjee, S. K. Modak and S. Samanta, “Second Order Phase Transition and Thermodynamic Geometry in Kerr-AdS Black Hole,” Phys. Rev. D 84 (2011) 064024 [arXiv:1005.4832 [hep-th]].
  * (12) R. Banerjee and D. Roychowdhury, “Thermodynamics of phase transition in higher dimensional AdS black holes,” JHEP 1111 (2011) 004 [arXiv:1109.2433 [gr-qc]].
  * (13) R. Banerjee, S. K. Modak and D. Roychowdhury, “A unified picture of phase transition: from liquid-vapour systems to AdS black holes,” JHEP 1210 (2012) 125 [arXiv:1106.3877 [gr-qc]].
  * (14) S. Banerjee, S. K. Chakrabarti, S. Mukherji and B. Panda, “Black hole phase transitions via Bragg-Williams,” Int. J. Mod. Phys. A 26 (2011) 3469 [arXiv:1012.3256 [hep-th]].
  * (15) F. Weinhold, J. Chem. Phys. 63, 2479 (1975); 63, 2484 (1975); 63, 2488 (1975); 63, 2496 (1975); 65, 559 (1976).
  * (16) G. Ruppeiner, Phys. Rev. A 20, 1608 (1979).
  * (17) G. Ruppeiner, “Riemannian geometry in thermodynamic fluctuation theory,” Rev. Mod. Phys. 67, 605 (1995) Erratum: [Rev. Mod. Phys. 68, 313 (1996)].
  * (18) M. Born and L. Infeld, Proc. Roy. Soc. Lond. A 144, 425 (1934).
  * (19) E. Ayon-Beato and A. Garcia, “Regular black hole in general relativity coupled to nonlinear electrodynamics,” Phys. Rev. Lett. 80, 5056 (1998) [gr-qc/9911046].
  * (20) E. Ayon-Beato and A. Garcia, “New regular black hole solution from nonlinear electrodynamics,” Phys. Lett. B 464, 25 (1999) [hep-th/9911174].
  * (21) M. Cataldo and A. Garcia, “Regular (2+1)-dimensional black holes within nonlinear electrodynamics,” Phys. Rev. D 61, 084003 (2000) [hep-th/0004177].
  * (22) K. A. Bronnikov, “Regular magnetic black holes and monopoles from nonlinear electrodynamics,” Phys. Rev. D 63, 044005 (2001) [gr-qc/0006014].
  * (23) A. Burinskii and S. R. Hildebrandt, “New type of regular black holes and particle - like solutions from NED,” Phys. Rev. D 65, 104017 (2002) [hep-th/0202066].
  * (24) J. Matyjasek, “Extremal limit of the regular charged black holes in nonlinear electrodynamics,” Phys. Rev. D 70, 047504 (2004) [gr-qc/0403109].
  * (25) S. H. Hendi, “Slowly Rotating Black Holes in Einstein-Generalized Maxwell Gravity,” Prog. Theor. Phys. 124 (2010) 493 [arXiv:1008.0544 [hep-th]].
  * (26) S. H. Hendi, “Rotating black branes in the presence of nonlinear electromagnetic field,” Eur. Phys. J. C 69 (2010) 281 [arXiv:1008.0168 [hep-th]].
  * (27) S. H. Hendi, “Rotating Black String with Nonlinear Source,” Phys. Rev. D 82 (2010) 064040 [arXiv:1008.5210 [hep-th]].
  * (28) R. G. Cai, D. W. Pang and A. Wang, “Born-Infeld black holes in (A)dS spaces,” Phys. Rev. D 70, 124034 (2004) [hep-th/0410158].
  * (29) T. K. Dey, “Born-Infeld black holes in the presence of a cosmological constant,” Phys. Lett. B 595, 484 (2004) [hep-th/0406169].
  * (30) M. Aiello, R. Ferraro and G. Giribet, “Exact solutions of Lovelock-Born-Infeld black holes,” Phys. Rev. D 70, 104014 (2004) [gr-qc/0408078].
  * (31) S. H. Hendi, “The Relation between F(R) gravity and Einstein-conformally invariant Maxwell source,” Phys. Lett. B 690, 220 (2010) [arXiv:0907.2520 [gr-qc]].
  * (32) S. H.Hendi ‘Asymptotic Reissner-Nordstroem black holes,’ Annals Phys. 333, 282 (2013) [arXiv:1405.5359 [gr-qc]].
  * (33) S. H. Hendi, B. E. Panah and S. Panahiyan, “Einstein-Born-Infeld-Massive Gravity: adS-Black Hole Solutions and their Thermodynamical properties,” JHEP 1511, 157 (2015) [arXiv:1508.01311 [hep-th]].
  * (34) S. H. Hendi, S. Panahiyan, B. E. Panah and M. Momennia, “Thermodynamic instability of nonlinearly charged black holes in gravity?s rainbow,” Eur. Phys. J. C 76, no. 3, 150 (2016).
  * (35) O. Miskovic and R. Olea, “Thermodynamics of Einstein-Born-Infeld black holes with negative cosmological constant,” Phys. Rev. D 77, 124048 (2008) [arXiv:0802.2081 [hep-th]].
  * (36) H. A. Gonzalez, M. Hassaine and C. Martinez, “Thermodynamics of charged black holes with a nonlinear electrodynamics source,” Phys. Rev. D 80, 104008 (2009) [arXiv:0909.1365 [hep-th]].
  * (37) S. H. Hendi and B. E. Panah, “Thermodynamics of rotating black branes in Gauss-Bonnet-nonlinear Maxwell gravity,” Phys. Lett. B 684 (2010) 77 [arXiv:1008.0102 [hep-th]].
  * (38) A. Sheykhi, M. H. Dehghani and S. H. Hendi, “Thermodynamic instability of charged dilaton black holes in AdS spaces,” Phys. Rev. D 81, 084040 (2010) [arXiv:0912.4199 [hep-th]].
  * (39) S. H. Hendi, A. Sheykhi, S. Panahiyan and B. Eslam Panah, “Phase transition and thermodynamic geometry of Einstein-Maxwell-dilaton black holes,” Phys. Rev. D 92, no. 6, 064028 (2015) [arXiv:1509.08593 [hep-th]].
  * (40) M. H. Dehghani, S. H. Hendi, A. Sheykhi and H. Rastegar Sedehi, “Thermodynamics of rotating black branes in (n+1)-dimensional Einstein-Born-Infeld-dilaton gravity,” JCAP 0702, 020 (2007) [hep-th/0611288].
  * (41) M. K. Zangeneh, A. Sheykhi and M. H. Dehghani, “Thermodynamics of higher dimensional topological dilation black holes with a power-law Maxwell field,” Phys. Rev. D 91, no. 4, 044035 (2015) [arXiv:1505.01103 [gr-qc]].
  * (42) J. Barrientos, P. A. González and Y. Vásquez, “Four-dimensional black holes with scalar hair in nonlinear electrodynamics,” Eur. Phys. J. C 76, no.12, 677 (2016) [arXiv:1603.05571 [hep-th]].
  * (43) S. H. Hendi and M. H. Vahidinia, “Extended phase space thermodynamics and P-V criticality of black holes with a nonlinear source,” Phys. Rev. D 88, no.8, 084045 (2013) [arXiv:1212.6128 [hep-th]].
  * (44) M. Hassaine and C. Martinez, “Higher-dimensional black holes with a conformally invariant Maxwell source,” Phys. Rev. D 75 (2007), 027502 [arXiv:hep-th/0701058 [hep-th]].
  * (45) S. H. Hendi and H. R. Rastegar-Sedehi, “Ricci flat rotating black branes with a conformally invariant Maxwell source,” Gen. Rel. Grav. 41, 1355 (2009) [arXiv:1007.2475 [hep-th]].
  * (46) S. H. Hendi, “Topological black holes in Gauss-Bonnet gravity with conformally invariant Maxwell source,” Phys. Lett. B 677 (2009), 123-132 [arXiv:1007.2479 [hep-th]].
  * (47) M. Hassaine and C. Martinez, “Higher-dimensional charged black holes solutions with a nonlinear electrodynamics source,” Class. Quant. Grav. 25 (2008) 195023 [arXiv:0803.2946 [hep-th]].
  * (48) H. Maeda, M. Hassaine and C. Martinez, “Lovelock black holes with a nonlinear Maxwell field,” Phys. Rev. D 79 (2009) 044012 [arXiv:0812.2038 [gr-qc]].
  * (49) B. P. Dolan, “Pressure and volume in the first law of black hole thermodynamics,” Class. Quant. Grav. 28 (2011), 235017 [arXiv:1106.6260 [gr-qc]].
  * (50) B. P. Dolan, “The cosmological constant and the black hole equation of state,” Class. Quant. Grav. 28, 125020 (2011) [arXiv:1008.5023 [gr-qc]].
  * (51) B. R. Majhi and D. Roychowdhury, Class. Quant. Grav. 29 (2012), 245012 doi:10.1088/0264-9381/29/24/245012 [arXiv:1205.0146 [gr-qc]].
  * (52) M. B. J. Poshteh and N. Riazi, Gen. Rel. Grav. 49 (2017) no.5, 64 doi:10.1007/s10714-017-2227-6 [arXiv:1606.01408 [hep-th]].
  * (53) C. H. Nam, Eur. Phys. J. C 78 (2018) no.7, 581 doi:10.1140/epjc/s10052-018-6056-x
  * (54) S. Gunasekaran, R. B. Mann and D. Kubiznak, “Extended phase space thermodynamics for charged and rotating black holes and Born-Infeld vacuum polarization,” JHEP 11, 110 (2012) [arXiv:1208.6251 [hep-th]].


# A Shiny Application for Conducting Electronic Surveys Using Randomized
Response Techniques

G.N. Singh  Department of Mathematics & Computing, Indian Institute of
Technology (Indian School of Mines), Dhanbad-826 004, Jharkhand, India. Email:
<EMAIL_ADDRESS><EMAIL_ADDRESS>D. Bhattacharyya  A.
Bandyopadhyay  Department of Mathematics, Asansol Engineering College,
Asansol-713305, India.
Email<EMAIL_ADDRESS>
###### Abstract

Randomized response techniques (RRT) are useful for collecting information on
sensitive or confidential attributes in sample surveys. However, such RRTs are
rarely used except for pure academic research, as they are deemed to be
confusing for respondents and difficult to be administered. Switching to an
electronic medium is a solution for this. Standard electronic survey mediums
lack the option of effectively incorporating a randomization device into it.
This paper introduces a Shiny application that implements two popular
Randomized Response Techniques, namely, Warner (1965) and Simmons (1967), to
collect information on sensitive issues via electronic surveys, and save them
using local or remote storage. Code and its detailed explanation has been
provided for suitable use by survey statisticians and practitioners. The
method suggested here can be extended to implement any Randomized Response
Technique. Thus, this paper lays the groundwork of implementing RRTs as
electronic surveys for widespread use by the polling industry.

Keywords: Randomized response technique, sample surveys, electronic survey,
shiny, R.

##  1 Introduction

Sensitive or confidential questions are often a part of sample surveys. Unlike
innocuous questions, which generally receive proper responses, interviewees
are often reluctant to disclose information related to stigmatized matters.
This is specially true for surveys related to socially relevant issues, such
as whether a high school student smokes, or whether an unmarried woman had an
abortion, etc. It is also true for the recent Covid-19 pandemic, as
individuals often hide their symptoms for fear of social isolation,
discrimination, etc. ([1])

One way to overcome hesitance from the respondent is to design methods that
protect his privacy and reveal no identifying information to the interviewer.
This is achieved by making use of randomization devices, such as dice, coins,
spinners, deck of cards, etc.

Surveys were traditionally conducted via face-to-face interviews, mails, or
telephonic conversations. However, there has been a recent shift towards
electronic surveys due to increased response rates, lower costs, and
administrative convenience. Such medium is specially suitable for surveys on
sensitive issues, as it provides confidence of anonymity in absence of an
interviewer. Electronic surveys are notably useful in times of global
pandemics such as Covid-19, when human contact should be minimized as far as
possible, and people are particularly cautious about exposure to interviewers
or questionnaires sent via mail.

The chief merit of conducting surveys employing RRT via an electronic medium,
however, is in its simplicity and effectiveness. As noted by ([8]), there are
astonishingly few applications of RRTs, despite the advances in the field over
a few decades. Use of RRTs has been chiefly limited to pure academic research.
This may be attributed to the difficulty of implementing the various methods
and the confusion it may cause for the respondents. Often, RRTs are elaborate,
multi-stage, with complicated instructions for the respondents. Switching to
an electronic medium and simulating the randomization device removes all the
complications of the method, while retaining all its advantages. The working
of the devices now happen ”behind the scenes”, and the interviewees are only
presented with the final statement obtained from the device, to which they
have to answer with a simple ”Yes” or ”No”. The entire process now becomes
simple and hassle-free.

A number of tools and websites are available to the survey statisticians and
practitioners for conducting sample surveys online. However, these surveys are
merely capable of providing questionnaires to interviewees and collecting
information. There is no scope for incorporating randomization devices, which
are essential for conducting surveys involving sensitive attributes.

This manuscript proposes tools to conduct surveys involving Randomized
Response Techniques (RRT) using Shiny-based applications. The authors have
chosen to develop the tools as a Shiny application, which is web-based,
instead of an add-on R package for their easy implementation to conduct web-
based surveys. The novelty of the manuscript lies in the fact that such tools
are not yet available for the survey statisticians, to the best of the
authors’ knowledge, and the implementation of RRT as electronic surveys has
the potential to revolutionize how surveys are conducted.

The methods for implementing Warner (1965) ([3]) and Simmons (1967) ([2]) RRTs
as web-based survey have been discussed in details in the manuscript. The
authors chose to demonstrate the development of web-based surveys using these
two particular RRTs because they are widely known, uncomplicated in nature and
easy to understand for even the less experienced. However, the application
developed here can be easily modified to implement any Randomized Response
Technique and conduct surveys on any sensitive attribute. Hence, it has wide-
spread applications for socio-economic, political, and other surveys.

The manuscript has been divided into the following sections: Section 2 briefly
recollects the Warner (1965) [3] and Simmons (1967) [2] Randomized Response
Techniques, with the corresponding R code for simulating the randomization
devices. Section 4 briefly discusses the merits and demerits of local and
remote storage. Code for an application involving local storage has been
discussed in details in Section 4.1. Remote storage option has been explored
in Section 4.2. Recommendations for survey statisticians have been put forward
in Section 5.

The applications developed here have been built in R ([4]), using the packages
Shiny ([6]), and googlesheets4 ([5]). The authors have used R version 3.6.2
(2019-12-12) – ”Dark and Stormy Night” for the purpose.

##  2 Simulation of the Randomization Device:

###  2.1 A revisit of Warner (1965) and Simmons (1967) RRT:

[3] pioneered the randomized response technique for estimating the proportion
of individuals in a population who possess a sensitive attribute. His
randomization device contains two statements- ”I possess sensitive character
S”, and ”I do not possess sensitive character S”. Either statement is
displayed, depending on the outcome of the randomization device. For example,
if a Coin is tossed and lands on ”Head”, the first statement may be displayed,
while ”Tails” may correspond to the second statement. The interviewee only has
to answer ”Yes” or ”No” to the interviewer, without revealing his actual
status with regard to the sensitive attribute.

[2] extended[3] model by introducing the use of an unrelated question about a
non-sensitive characteristic. Here, the statements used are ”I possess
sensitive character S” and ”I possess non-sensitive character Y”.

[3] RRT has the restriction that the parameter of the randomization device
$p\neq\frac{1}{2}$. [2] has no such restrictions.

###  2.2 Functions for Randomization Devices:

The Randomization Devices used by Warner (1965) [3] and Simmons (1967) [2] can
be easily simulated in R with the help of the function sample(). The survey
statistician has complete control over the parameters for the randomization
devices, namely, the probabilities of the randomization devices displaying the
statement bearing the sensitive attribute. For a single randomization device,
this parameter is named ”p”, while it is named ”p1” and ”p2” for two
randomization devices.

The function that simulates the randomization devices is illustrated with the
help of a simple example. Suppose it is of interest to discretely estimate the
proportion of individuals in a population who have high fever (sensitive
attribute), a symptom of Covid-19. The function that simulates the
randomization device proposed by Warner ([3]) is defined as:

    randrt<-function()
    {
    r<-sample(1:2,1,replace=F,prob=c(p,1-p))
    if (r==1)
    txt<-"I have high fever." #Set your sensitive attribute here
    else if (r==2)
    txt<-"I do not have high fever." #Set your non-sensitive attribute here
    return(txt)
    }

Here, ”r” presents the outcome of the Randomization device, and accordingly,
the relevant statement to be displayed is assigned.

Similarly, the function that simulates the randomization device for the
unrelated question model proposed by Simmons ([2]) is defined as

    randrt<-function()
    {
    r<-sample(1:2,1,replace=F,prob=c(p,1-p))
    if (r==1)
    txt<-"I have high fever." #Set your sensitive attribute here
    else if (r==2)
    txt<-"I do not have high fever." #Set your non-sensitive attribute here
    return(txt)
    }

When the proportion of individuals possessing the non-sensitive attribute Y is
unknown, two randomization devices are utilized. Hence, two functions,
randrt1() and randrt2(), with parameters $p1$ and $p2$ should be defined in
such cases, with the constraint that $p1\neq p2$.

Surveys involving any sensitive attribute can be conducted in this way. The
survey statistician can modify the statements according to the sensitive
attribute under study.

Similarly, any RRT can be implemented in this way. As a simple example of
modification of the function, the following code is provided, which displays
the colors of a rainbow depending on the outcome of a randomization device.

    randrt<-function()
    {
    r<-sample(1:7,1,replace=F,prob=c(0.1,0.2,0.1,0.3,0.1,0.1,0.1))
    if (r==1) txt<-"Violet."
    else if (r==2) txt<-"Indigo."
    else if (r==3) txt<-"Blue."
    else if (r==4) txt<-"Green."
    else if (r==5) txt<-"Yellow."
    else if (r==6) txt<-"Orange."
    else if (r==7) txt<-"Red."
    return(txt)
    }

##  3 Data Collection:

This section focuses on data collection, a crucial part of surveys. The two
main parts of the Shiny app are discussed, namely, the User Interface and the
Server Function.

###  3.1 The User Interface (UI) Object:

The layout and appearance of the application is controlled by the User
Interface (UI) Object. This can be set according to the personal preference of
the survey statisticians and the requirements of the survey. A fully
functional UI must consist of the following:

  1. 1.

Title of the survey, rendered using

        ΨtitlePanel("Title")
    Ψ

  2. 2.

Instructions for the respondents, displayed using

        ΨhelpText("Text")
    Ψ

For example, the following instructions may be displayed to the respondents:

”If the outcome of the device matches the attribute that you possess, (for
example: the device says *I am wearing black clothes* and you are indeed
wearing black clothes), then select Yes, else select No.”

  3. 3.

Privacy statements or disclaimers, displayed using

        ΨhelpText("Text")
    Ψ

A sample disclaimer is given below:

”Your response is completely anonymous. Only your Yes/No response is stored.”

  4. 4.

The outcome of the randomization device(s), rendered using

        ΨtextOutput("text")
    Ψ

  5. 5.

Interface for the respondent to answer Yes or No. The code used for this
purpose is:

        ΨtextOutput("text"), #Shows outcome of Randomization Device
    ΨradioButtons("resp","Do you possess the attribute that the Randomization Device says you do?",
    Ψc("Yes"="y","No"="n")), #Takes input
    ΨactionButton("submit","Submit",class="btn-success")
    Ψ

In surveys involving two randomization devices, the code given above is
suitably modified to display two outcomes (”text1” and ”text2”) and take two
user inputs (”resp1” and ”resp2”) for the two randomization devices
respectively.

  6. 6.

Table showing the responses received so far, displayed using

        ΨdataTableOutput("mydata", width = 300)
    Ψ

Displaying the collected data to the respondents is optional. However, it
helps to communicate to the respondent that no personal or identifying
information about them is being stored.

  7. 7.

An option of downloading the responses received so far can be given to the
public using the code

        ΨdownloadButton("download", "Download")
    Ψ

###  3.2 The Server function:

The Server function contains the instructions needed to carry out the
functionalities of the application. It is used for the following purposes:

  1. 1.

The text output of Randomization device are generated from function ”randrt()”
as follows:

        Ψoutput$text<-renderPrint(randrt())
    Ψ

For surveys involving two randomization devices, these are suitably modified
to generate two text outputs ”text1” and ”text2” corresponding to the two
functions ”randrt1()” and ”rantrt2()” respectively.

  2. 2.

The following code is used to save the data in the CSV file when the user
clicks the ”Submit” button:

        ΨformData <- reactive({
    Ψdata <- sapply(fields, function(x) input[[x]])
    Ψdata
    Ψ})
    Ψ
    ΨobserveEvent(input$submit, {
    ΨsaveData(formData())
    Ψwrite.csv(mydata,"data.csv",row.names = FALSE)
    Ψ})
    Ψ

  3. 3.

The following code is used for displaying the saved data as a table when the
user clicks the ”Submit” button:

        Ψoutput$mydata <- renderDataTable({
    Ψinput$submit
    ΨloadData()
    Ψ})
    Ψ

  4. 4.

The option for downloading the collected data as a CSV file is provided by the
following code:

        Ψoutput$download <- downloadHandler(
    Ψfilename = function() {
    Ψpaste("mydata-", Sys.Date(), ".csv", sep="")
    Ψ},
    Ψcontent = function(file) {
    Ψwrite.csv(mydata, file,row.names = FALSE)
    Ψ})
    Ψ

###  3.3 A call to the shinyApp function:

The following code is used to create the Shiny application from the UI/server
pair:

    shinyApp(ui = ui, server = server)

##  4 Data storage:

The data collected during the survey can be stored locally or in a remote
storage space. The advantage of storing data locally lies merely in its
simplicity. However, data may be lost when the application becomes inactive or
”sleeping” in the server, depending on the options provided by the server. The
simplest way to overcome this is to set a pre-defined time window for the
respondents to take part in the survey, and download the collected data as a
CSV file at the end of such time window. This is suitable only for small scale
surveys.

For surveys that involve a vast amount of data and involve a longer period of
data collection, which is the case for almost all surveys, it is more suitable
to use a reliable Remote Storage option such as Google Drive, DropBox, etc. R
packages such as googlesheets4 ([5]), rdrop2 ([7]), etc. are available for the
purpose. Caution should be exercised in such cases, as it requires non-
interactive authentication for the application to access the Remote Storage.

Applications built utilizing both local and remote storage have been discussed
in details in the following sections. It is recommended that the survey
statisticians further explore the storage options and pick the one that is
most suitable for their needs. ([9])

###  4.1 Local storage:

A single-file Shiny Web Application is created in RStudio. In the folder that
contains the application, a CSV file named ”data.csv” is also saved. For RRT
with a single randomization device, the first row of this file contains the
row heading ”resp”. For RRT with two randomization devices, the row headings
are ”resp1” and ”resp2”. The headings correspond to the names of the variables
of interest. The data collected, i.e. the Yes/No responses will be stored in
this file. This file should also be uploaded to the server that hosts the
application during deployment.

The functions for saving and loading data are as follows:

The variables to be stored are first defined for single and two randomization
devices as follows:

    fields <- c("resp") #single randomization device
    fields <- c("resp1","resp2") #two randomization devices

The file for storing the data, namely, ”data.csv”, located in the same folder
as the application, is loaded into a data frame named ”mydata” using the
following code:

    mydata<-read.csv("data.csv")

The function for saving the collected data into this data frame is defined as
follows:

    saveData <- function(data)
    {
    data <- as.data.frame(t(data))
    if (exists("mydata"))
    mydata <<- rbind(mydata, data)
    else
    mydata <<- mydata
    }

The following function is used to load and display the data saved in the data
frame created above:

    loadData <- function()
    {
    if (exists("mydata"))
    mydata
    }

Complete code for Warner’s RRT ([3]) using local storage has been provided as
Appendix 1.

###  4.2 Data storage in Google Sheets:

The R package ”googlesheets4” [5] can be used to store the responses within a
Google Sheet. The survey statisticians first have to create a Google Sheet
where the responses will be stored and obtain its key or id. Data collected
will be saved in this sheet using the function

    sheet_append()

The survey statisticians also need to obtain a ”token” that allows the Shiny
Application to access the Google Sheet. This is done using the following code
when the application is run for the first time:

    gs4_auth(cache = ".secrets")

It opens up a browser window, where credentials are to be entered and access
granted. The token is saved in a folder named ”.secrets”, which is to be
uploaded to the server alongside the application when the application is
deployed. Once a token has been obtained, this token is used in the subsequent
sessions for non-interactive authentication by substituting the code given
above with the following code:

    gs4_auth(cache = ".secrets", email = TRUE, use_oob = TRUE)

Detailed instructions for non-interactive authentication is available on the
web, such as ([10]).

The code for storing data in Google Sheet from a survey involving Simmons’
(1967) RRT ([2]) with single randomization device has been provided as
Appendix 2.

##  5 Discussions:

Although Warner (1965) ([3]) and Simmons (1965) ([2]) RRTs have been used here
as illustrations, any Randomized Response Technique can be implemented as a
web-based survey using the code given in the manuscript, with the mere
modification of the function ”randrt()”.

Hence, the Shiny application introduced above has wide-scale applications for
survey statisticians and practitioners conducting surveys involving sensitive
attributes.

For the purpose of demonstrating the effectiveness of the code presented in
this paper, the authors have designed an electronic survey, where the data
collected is stored securely in their Google Drive. The survey can be accessed
at https://samplesurveyscholar.shinyapps.io/simmonsforpaper/.

## Acknowledgment/ Funding:

We are thankful to the Department of Science and Technology, Science &
Engineering Research Board (DST-SERB) for providing financial assistance under
Grant EMR/2017/000882 and also to IIT (ISM) Dhanbad for providing the
infrastructure facilities.

##  6 Appendix 1: Warner (1965) RRT with local data storage

    library(shiny)

    #Parameter setting for the survey statistician
    #Set the probability of the sensitive attribute in the randomization device
    p=0.4

    mydata<-read.csv("data.csv")

    fields <- c("resp")

    randrt<-function()
    {
    r<-sample(1:2,1,replace=F,prob=c(p,1-p))
    if (r==1)
    txt<-"I am a smoker." #Set your sensitive attribute here
    else if (r==2)
    txt<-"I am not a smoker." #Set your non-sensitive attribute here
    return(txt)
    }

    saveData <- function(data) {
    data <- as.data.frame(t(data))
    if (exists("mydata")) {
    mydata <<- rbind(mydata, data)
    } else {
    mydata <<- mydata
    }
    }

    loadData <- function() {
    if (exists("mydata")) {
    mydata
    }
    }

    ui <- fluidPage(

    titlePanel("Warner (1965) RRT to anonymously determine the proportion of individuals with high fever in a given population"),

    sidebarLayout(
    sidebarPanel(
    helpText("INSTRUCTIONS:"),
    helpText("PRIVACY:"),
    helpText("The Randomization Device has generated the outcome:"),
    textOutput("text"),

    radioButtons("resp","Do you possess the attribute that the Randomization Device says you do?",
    c("Yes"="y","No"="n")),
    actionButton("submit","Submit",class="btn-success"),
    width=6
    ),
    mainPanel(
    dataTableOutput("mydata", width = 300), tags$hr(),
    downloadButton("download", "Download"),
    width=4
    )
    )
    )

    server <- function(input, output, session) {

    output$text<-renderPrint(randrt())

    formData <- reactive({
    data <- sapply(fields, function(x) input[[x]])
    data
    })

    observeEvent(input$submit, {
    saveData(formData())
    write.csv(mydata,"data.csv",row.names = FALSE)
    })

    output$mydata <- renderDataTable({
    input$submit
    loadData()
    })

    #thedata <- reactive(mydata)

    output$download <- downloadHandler(
    filename = function() {
    paste("mydata-", Sys.Date(), ".csv", sep="")
    },
    content = function(file) {
    write.csv(mydata, file,row.names = FALSE)
    })

    }

    # Run the application
    shinyApp(ui = ui, server = server)

##  7 Appendix 2: Simmons (1967) RRT with remote data storage

    library(shiny)
    library(shinydashboard)
    library(googlesheets4)
    library(googledrive)

    gs4_auth(cache = ".secrets") #for the first time running the app in R to get the OAuth token
    gs4_auth(cache = ".secrets", email = TRUE, use_oob = TRUE)
    fields <- c("resp")

    randrt<-function()
    {
    r<-sample(1:2,1,replace=F,prob=c(0.4,0.6))
    if (r==1)
    {
    txt<-"I have high fever."
    }
    else if (r==2)
    {
    txt<-"I was born on a Sunday."
    }
    return(txt)
    }

    ui <- fluidPage(

    titlePanel("Simmons (1967) RRT to anonymously determine the proportion of smokers in a given population"),

    sidebarLayout(
    sidebarPanel(
    helpText("INSTRUCTIONS"),
    helpText("PRIVACY"),
    helpText("The Randomization Device has generated the outcome:"),
    textOutput("text"),
    width=6
    ),
    mainPanel(
    radioButtons("resp","Do you possess the attribute that the Randomization Device says you do?",
    c("Yes"="y","No"="n")),
    actionButton("submit","Submit",class="btn-success"),
    width=4
    )
    )
    )

    server <- function(input, output, session) {

    output$text<-renderPrint(randrt())
    observeEvent(input$submit,{
    sheet_append("XXX",as.data.frame(input$resp)) #XXX is Google Sheet key

    })

    }

    # Run the application
    shinyApp(ui = ui, server = server)

## References

  * [1] O’Connor, A. M., & Evans, A. D. (2020). Dishonesty during a pandemic: The concealment of COVID-19 information. Journal of Health Psychology, 1359105320951603.
  * [2] Greenberg, B. G., Abul-Ela, A. L. A., Simmons, W. R., & Horvitz, D. G. (1969). The unrelated question randomized response model: Theoretical framework. Journal of the American Statistical Association, 64(326), 520-539.
  * [3] Warner, S. L. (1965). Randomized response: A survey technique for eliminating evasive answer bias. Journal of the American Statistical Association, 60(309), 63-69.
  * [4] R Core Team (2019). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL https://www.R-project.org/.
  * [5] Jennifer Bryan and Joanna Zhao (2018). googlesheets: Manage Google Spreadsheets from R. R package version 0.3.0. https://CRAN.R-project.org/package=googlesheets
  * [6] Winston Chang, Joe Cheng, JJ Allaire, Yihui Xie and Jonathan McPherson (2020). shiny: Web Application Framework for R. R package version 1.5.0. https://CRAN.R-project.org/package=shiny
  * [7] Karthik Ram and Clayton Yochum (2020). rdrop2: Programmatic Interface to the ’Dropbox’ API. R package version 0.8.2.1. https://CRAN.R-project.org/package=rdrop2
  * [8] Blair, G., Imai, K., & Zhou, Y. Y. (2015). Design and analysis of the randomized response technique. Journal of the American Statistical Association, 110(511), 1304-1319.
  * [9] Attali, D. (2020). Persistent data storage in Shiny apps. url: http://https://shiny.rstudio.com/articles/persistent-data-storage.html. Last updated: 23-11-2020, Accessed: 23-12-2020.
  * [10] Non-interactive auth. Url: https://gargle.r-lib.org/articles/non-interactive-auth.html. Accessed: 23-12-2020