Fitting zero inflated poisson to plot it in R - r

I have the following data
data<-c(1L, 4L, 5L, 10L, 13L, 8L, 3L, 5L, 13L, 9L, 5L, 10L, 9L, 4L,
4L, 13L, 10L, 10L, 7L, 7L, 3L, 1L, 11L, 4L, 5L, 9L, 10L, 3L,
2L, 7L, 8L, 4L, 5L, 6L, 3L, 4L, 13L, 7L, 8L, 6L, 5L, 3L, 10L,
4L, 8L, 8L, 2L, 9L, 5L, 2L, 8L, 7L, 6L, 6L, 6L, 4L, 3L, 9L, 11L,
6L, 7L, 7L, 3L, 4L, 18L, 14L, 8L, 9L, 5L, 3L, 7L, 3L, 8L, 3L,
9L, 3L, 4L, 7L, 7L, 5L, 8L, 7L, 10L, 9L, 9L, 11L, 8L, 3L, 9L,
10L, 11L, 9L, 12L, 13L, 9L, 15L, 11L, 13L, 3L, 24L, 11L, 13L,
14L, 14L, 5L, 10L, 6L, 10L, 8L, 9L, 13L, 5L, 8L, 8L, 6L, 17L,
11L, 11L, 8L, 2L, 14L, 6L, 1L, 7L, 5L, 3L, 12L, 6L, 10L, 7L,
15L, 9L, 7L, 3L, 9L, 11L, 3L, 5L, 14L, 7L, 3L, 20L, 17L, 14L,
7L, 11L, 11L, 2L, 4L, 9L, 5L, 10L, 7L, 10L, 13L, 7L, 18L, 13L,
18L, 20L, 16L, 9L, 5L, 13L, 16L, 11L, 9L, 7L, 12L, 13L, 21L,
9L, 7L, 13L, 4L, 7L, 5L, 13L, 19L, 17L, 8L, 7L, 4L, 18L, 14L,
8L, 8L, 16L, 13L, 9L, 14L, 8L, 20L, 7L, 12L, 14L, 8L, 16L, 10L,
9L, 20L, 5L, 7L, 8L, 16L, 11L, 10L, 12L, 20L, 5L, 2L, 21L, 16L,
18L, 0L, 16L, 4L, 6L, 16L, 6L, 15L, 15L, 10L, 8L, 13L, 22L, 14L,
5L, 8L, 11L, 14L, 7L, 9L, 7L, 7L, 8L, 5L, 12L, 6L, 20L, 10L,
17L, 9L, 7L, 13L, 9L, 13L, 15L, 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10L,
1L, 8L, 7L, 7L, 6L, 5L, 1L, 5L, 8L, 11L, 2L, 6L, 7L, 6L, 5L,
20L, 8L, 10L, 7L, 5L, 2L, 5L, 3L, 17L, 6L, 5L, 0L, 1L, 1L, 9L,
1L)
I have run a ZINB model and I know that it is the best fit for my data. I want to demonstrate on a graph that this distribution is my best option. I am using fitdist
library(fitdistrplus)
library(gamlss)
nb<-fitdist(data, "nbinom")
pois<-fitdist(data, "pois")
zinb<-fitdist(data, 'ZANBI',start = list(mu = 4, sigma = 0.2))
par(mfrow = c(2, 2))
plot.legend <- c("Negative binomial", "Poisson", "ZINB")
My problem is that, just as I wanted to demonstrate that nbinom and pois are not the best fit, I can't do it with zero inflated poissonZIP.
I am using gamlss
zip<-fitdist(data, 'ZIP',start = list(mu = 7.09, sigma = 4.5))
Here I'm using the values suggested in here considering mean(data[data != 0]) and var(data[data != 0]). I always get:
Error in fitdist(data, "ZIP", start = list(mu = 7.09, sigma = 4.5)) :
the function mle failed to estimate the parameters,
with the error code 100
In addition: Warning messages:
1: In fitdist(data, "ZIP", start = list(mu = 7.09, sigma = 4.5)) :
The dZIP function should return a zero-length vector when input has length zero and not raise an error
2: In fitdist(data, "ZIP", start = list(mu = 7.09, sigma = 4.5)) :
The pZIP function should return a zero-length vector when input has length zero and not raise an error
How can I plot a ZIP of my values to demonstrate is not the best fit?

The following arguments on the ZIP fit worked for me:
A start sigma < 1.
The Nelder-Mead optimizer
A (lower, upper) bounds for the optimization parameters mu and sigma set respectively to (0, Inf) and (0, 1),
The result of running the following code on your data array is below, which confirms that the Zero-Inflated Negative Binomial is the best fit (based on AIC and BIC).
library(fitdistrplus)
library(gamlss)
nb<-fitdist(data, "nbinom")
pois<-fitdist(data, "pois")
zinb<-fitdist(data, 'ZANBI',start = list(mu = 4, sigma = 0.2))
zip<-fitdist(data, 'ZIP', start = list(mu = 7.09, sigma = 0.5), discrete=TRUE,
optim.method="Nelder-Mead", lower = c(0, 0), upper = c(Inf, 1))
print(nb)
print(pois)
print(zinb)
print(zip)
cdfcomp(list(nb, zinb, pois, zip))
gofstat(list(nb, zinb, pois, zip))
The only thing that worries me is that the standard error of the estimated parameters for the ZIP fit are NA...
Partial OUTPUT
Fitting of the distribution ' nbinom ' by maximum likelihood
Parameters:
estimate Std. Error
size 1.007110 0.05297338
mu 5.548579 0.16643396
Fitting of the distribution ' pois ' by maximum likelihood
Parameters:
estimate Std. Error
lambda 5.548313 0.06522914
Fitting of the distribution ' ZANBI ' by maximum likelihood
Parameters:
estimate Std. Error
mu 6.8886199 0.1549058
sigma 0.3401722 0.0266448
Fitting of the distribution ' ZIP ' by maximum likelihood
Parameters:
estimate Std. Error
mu 7.0869552 NA
sigma 0.2171502 NA
Goodness-of-fit criteria
1-mle-nbinom 2-mle-ZANBI 3-mle-pois 4-mle-ZIP
Akaike's Information Criterion 7302.831 7141.004 10169.16 7981.985
Bayesian Information Criterion 7313.177 7151.350 10174.33 7992.331

Related

How to do a partial autocorrelation plot with many zeros in r

I have a dataset of ER admissions with many zeros. These are daily admissions from 2016-06-05 to 2019-12-31. This is my data:
df<-structure(list(date = structure(c(1465084800, 1465171200, 1465257600,
1465344000, 1465430400, 1465516800, 1465603200, 1465689600, 1465776000,
1465862400, 1465948800, 1466035200, 1466121600, 1466208000, 1466294400,
1466380800, 1466467200, 1466553600, 1466640000, 1466726400, 1466812800,
1466899200, 1466985600, 1467072000, 1467158400, 1467244800, 1467331200,
1467417600, 1467504000, 1467590400, 1467676800, 1467763200, 1467849600,
1467936000, 1468022400, 1468108800, 1468195200, 1468281600, 1468368000,
1468454400, 1468540800, 1468627200, 1468713600, 1468800000, 1468886400,
1468972800, 1469059200, 1469145600, 1469232000, 1469318400, 1469404800,
1469491200, 1469577600, 1469664000, 1469750400, 1469836800, 1469923200,
1470009600, 1470096000, 1470182400, 1470268800, 1470355200, 1470441600,
1470528000, 1470614400, 1470700800, 1470787200, 1470873600, 1470960000,
1471046400, 1471132800, 1471219200, 1471305600, 1471392000, 1471478400,
1471564800, 1471651200, 1471737600, 1471824000, 1471910400, 1471996800,
1472083200, 1472169600, 1472256000, 1472342400, 1472428800, 1472515200,
1472601600, 1472688000, 1472774400, 1472860800, 1472947200, 1473033600,
1473120000, 1473206400, 1473292800, 1473379200, 1473465600, 1473552000,
1473638400, 1473724800, 1473811200, 1473897600, 1473984000, 1474070400,
1474156800, 1474243200, 1474329600, 1474416000, 1474502400, 1474588800,
1474675200, 1474761600, 1474848000, 1474934400, 1475020800, 1475107200,
1475193600, 1475280000, 1475366400, 1475452800, 1475539200, 1475625600,
1475712000, 1475798400, 1475884800, 1475971200, 1476057600, 1476144000,
1476230400, 1476316800, 1476403200, 1476489600, 1476576000, 1476662400,
1476748800, 1476835200, 1476921600, 1477008000, 1477094400, 1477180800,
1477267200, 1477353600, 1477440000, 1477526400, 1477612800, 1477699200,
1477785600, 1477872000, 1477958400, 1478044800, 1478131200, 1478217600,
1478304000, 1478390400, 1478476800, 1478563200, 1478649600, 1478736000,
1478822400, 1478908800, 1478995200, 1479081600, 1479168000, 1479254400,
1479340800, 1479427200, 1479513600, 1479600000, 1479686400, 1479772800,
1479859200, 1479945600, 1480032000, 1480118400, 1480204800, 1480291200,
1480377600, 1480464000, 1480550400, 1480636800, 1480723200, 1480809600,
1480896000, 1480982400, 1481068800, 1481155200, 1481241600, 1481328000,
1481414400, 1481500800, 1481587200, 1481673600, 1481760000, 1481846400,
1481932800, 1482019200, 1482105600, 1482192000, 1482278400, 1482364800,
1482451200, 1482537600, 1482624000, 1482710400, 1482796800, 1482883200,
1482969600, 1483056000, 1483142400, 1483228800, 1483315200, 1483401600,
1483488000, 1483574400, 1483660800, 1483747200, 1483833600, 1483920000,
1484006400, 1484092800, 1484179200, 1484352000, 1484438400, 1484524800,
1484611200, 1484697600, 1484784000, 1484870400, 1484956800, 1485043200,
1485129600, 1485216000, 1485302400, 1485388800, 1485475200, 1485561600,
1485648000, 1485734400, 1485820800, 1485907200, 1485993600, 1486080000,
1486166400, 1486252800, 1486339200, 1486425600, 1486512000, 1486598400,
1486684800, 1486771200, 1486857600, 1486944000, 1487030400, 1487116800,
1487203200, 1487289600, 1487376000, 1487462400, 1487548800, 1487635200,
1487721600, 1487808000, 1487894400, 1487980800, 1488067200, 1488153600,
1488240000, 1488326400, 1488412800, 1488499200, 1488585600, 1488672000,
1488758400, 1488844800, 1488931200, 1489017600, 1489104000, 1489190400,
1489276800, 1489363200, 1489449600, 1489536000, 1489622400, 1489708800,
1489795200, 1489881600, 1489968000, 1490054400, 1490140800, 1490227200,
1490313600, 1490400000, 1490486400, 1490572800, 1490659200, 1490745600,
1490832000, 1490918400, 1491004800, 1491091200, 1491177600, 1491264000,
1491350400, 1491436800, 1491523200, 1491609600, 1491696000, 1491782400,
1491868800, 1491955200, 1492041600, 1492128000, 1492214400, 1492300800,
1492387200, 1492473600, 1492560000, 1492646400, 1492732800, 1492819200,
1492905600, 1492992000, 1493078400, 1493164800, 1493251200, 1493337600,
1493424000, 1493510400, 1493596800, 1493683200, 1493769600, 1493856000,
1493942400, 1494028800, 1494115200, 1494201600, 1494288000, 1494374400,
1494460800, 1494547200, 1494633600, 1494720000, 1494806400, 1494892800,
1494979200, 1495065600, 1495152000, 1495238400, 1495324800, 1495411200,
1495497600, 1495584000, 1495670400, 1495756800, 1495843200, 1495929600,
1496016000, 1496102400, 1496188800, 1496275200, 1496361600, 1496448000,
1496534400, 1496620800, 1496707200, 1496793600, 1496880000, 1496966400,
1497052800, 1497139200, 1497225600, 1497312000, 1497398400, 1497484800,
1497571200, 1497657600, 1497744000, 1497830400, 1497916800, 1498003200,
1498089600, 1498176000, 1498262400, 1498348800, 1498435200, 1498521600,
1498608000, 1498694400, 1498780800, 1498867200, 1498953600, 1499040000,
1499126400, 1499212800, 1499299200, 1499385600, 1499472000, 1499558400,
1499644800, 1499731200, 1499817600, 1499904000, 1499990400, 1500076800,
1500163200, 1500249600, 1500336000, 1500422400, 1500508800, 1500595200,
1500681600, 1500768000, 1500854400, 1500940800, 1501027200, 1501113600,
1501200000, 1501286400, 1501372800, 1501459200, 1501545600, 1501632000,
1501718400, 1501804800, 1501891200, 1501977600, 1502064000, 1502150400,
1502236800, 1502323200, 1502409600, 1502496000, 1502582400, 1502668800,
1502755200, 1502841600, 1502928000, 1503014400, 1503100800, 1503187200,
1503273600, 1503360000, 1503446400, 1503532800, 1503619200, 1503705600,
1503792000, 1503878400, 1503964800, 1504051200, 1504137600, 1504224000,
1504310400, 1504396800, 1504483200, 1504569600, 1504656000, 1504742400,
1504828800, 1504915200, 1505001600, 1505088000, 1505174400, 1505260800,
1505347200, 1505433600, 1505520000, 1505606400, 1505692800, 1505779200,
1505865600, 1505952000, 1506038400, 1506124800, 1506211200, 1506297600,
1506384000, 1506470400, 1506556800, 1506643200, 1506729600, 1506816000,
1506902400, 1506988800, 1507075200, 1507161600, 1507248000, 1507334400,
1507420800, 1507507200, 1507593600, 1507680000, 1507766400, 1507852800,
1507939200, 1508025600, 1508112000, 1508198400, 1508284800, 1508371200,
1508457600, 1508544000, 1508630400, 1508716800, 1508803200, 1508889600,
1508976000, 1509062400, 1509148800, 1509235200, 1509321600, 1509408000,
1509494400, 1509580800, 1509667200, 1509753600, 1509840000, 1509926400,
1510012800, 1510099200, 1510185600, 1510272000, 1510358400, 1510444800,
1510531200, 1510617600, 1510704000, 1510790400, 1510876800, 1510963200,
1511049600, 1511136000, 1511222400, 1511308800, 1511395200, 1511481600,
1511568000, 1511654400, 1511740800, 1511827200, 1511913600, 1.512e+09,
1512086400, 1512172800, 1512259200, 1512345600, 1512432000, 1512518400,
1512604800, 1512691200, 1512777600, 1512864000, 1512950400, 1513036800,
1513123200, 1513209600, 1513296000, 1513382400, 1513468800, 1513555200,
1513641600, 1513728000, 1513814400, 1513900800, 1513987200, 1514073600,
1514160000, 1514246400, 1514332800, 1514419200, 1514505600, 1514592000,
1514678400, 1514764800, 1514851200, 1514937600, 1515024000, 1515110400,
1515196800, 1515283200, 1515369600, 1515456000, 1515542400, 1515628800,
1515715200, 1515801600, 1515888000, 1515974400, 1516060800, 1516147200,
1516233600, 1516320000, 1516406400, 1516492800, 1516579200, 1516665600,
1516752000, 1516838400, 1516924800, 1517011200, 1517097600, 1517184000,
1517270400, 1517356800, 1517443200, 1517529600, 1517616000, 1517702400,
1517788800, 1517875200, 1517961600, 1518048000, 1518134400, 1518220800,
1518307200, 1518393600, 1518480000, 1518566400, 1518652800, 1518739200,
1518825600, 1518912000, 1518998400, 1519084800, 1519171200, 1519257600,
1519344000, 1519430400, 1519516800, 1519603200, 1519689600, 1519776000,
1519862400, 1519948800, 1520035200, 1520121600, 1520208000, 1520294400,
1520380800, 1520467200, 1520553600, 1520640000, 1520726400, 1520812800,
1520899200, 1520985600, 1521072000, 1521158400, 1521244800, 1521331200,
1521417600, 1521504000, 1521590400, 1521676800, 1521763200, 1521849600,
1521936000, 1522022400, 1522108800, 1522195200, 1522281600, 1522368000,
1522454400, 1522540800, 1522627200, 1522713600, 1522800000, 1522886400,
1522972800, 1523059200, 1523145600, 1523232000, 1523318400, 1523404800,
1523491200, 1523577600, 1523664000, 1523750400, 1523836800, 1523923200,
1524009600, 1524096000, 1524182400, 1524268800, 1524355200, 1524441600,
1524528000, 1524614400, 1524700800, 1524787200, 1524873600, 1524960000,
1525046400, 1525132800, 1525219200, 1525305600, 1525392000, 1525478400,
1525564800, 1525651200, 1525737600, 1525824000, 1525910400, 1525996800,
1526083200, 1526169600, 1526256000, 1526342400, 1526428800, 1526515200,
1526601600, 1526688000, 1526774400, 1526860800, 1526947200, 1527033600,
1527120000, 1527206400, 1527292800, 1527379200, 1527465600, 1527552000,
1527638400, 1527724800, 1527811200, 1527897600, 1527984000, 1528070400,
1528156800, 1528243200, 1528329600, 1528416000, 1528502400, 1528588800,
1528675200, 1528761600, 1528848000, 1528934400, 1529020800, 1529107200,
1529193600, 1529280000, 1529366400, 1529452800, 1529539200, 1529625600,
1529712000, 1529798400, 1529884800, 1529971200, 1530057600, 1530144000,
1530230400, 1530316800, 1530403200, 1530489600, 1530576000, 1530662400,
1530748800, 1530835200, 1530921600, 1531008000, 1531094400, 1531180800,
1531267200, 1531353600, 1531440000, 1531526400, 1531612800, 1531699200,
1531785600, 1531872000, 1531958400, 1532044800, 1532131200, 1532217600,
1532304000, 1532390400, 1532476800, 1532563200, 1532649600, 1532736000,
1532822400, 1532908800, 1532995200, 1533081600, 1533168000, 1533254400,
1533340800, 1533427200, 1533513600, 1533600000, 1533686400, 1533772800,
1533859200, 1533945600, 1534032000, 1534118400, 1534204800, 1534291200,
1534377600, 1534464000, 1534550400, 1534636800, 1534723200, 1534809600,
1534896000, 1534982400, 1535068800, 1535155200, 1535241600, 1535328000,
1535414400, 1535500800, 1535587200, 1535673600, 1535760000, 1535846400,
1535932800, 1536019200, 1536105600, 1536192000, 1536278400, 1536364800,
1536451200, 1536537600, 1536624000, 1536710400, 1536796800, 1536883200,
1536969600, 1537056000, 1537142400, 1537228800, 1537315200, 1537401600,
1537488000, 1537574400, 1537660800, 1537747200, 1537833600, 1537920000,
1538006400, 1538092800, 1538179200, 1538265600, 1538352000, 1538438400,
1538524800, 1538611200, 1538697600, 1538784000, 1538870400, 1538956800,
1539043200, 1539129600, 1539216000, 1539302400, 1539388800, 1539475200,
1539561600, 1539648000, 1539734400, 1539820800, 1539907200, 1539993600,
1540080000, 1540166400, 1540252800, 1540339200, 1540425600, 1540512000,
1540598400, 1540684800, 1540771200, 1540857600, 1540944000, 1541030400,
1541116800, 1541203200, 1541289600, 1541376000, 1541462400, 1541548800,
1541635200, 1541721600, 1541808000, 1541894400, 1541980800, 1542067200,
1542153600, 1542240000, 1542326400, 1542412800, 1542499200, 1542585600,
1542672000, 1542758400, 1542844800, 1542931200, 1543017600, 1543104000,
1543190400, 1543276800, 1543363200, 1543449600, 1543536000, 1543622400,
1543708800, 1543795200, 1543881600, 1543968000, 1544054400, 1544140800,
1544227200, 1544313600, 1544400000, 1544486400, 1544572800, 1544659200,
1544745600, 1544832000, 1544918400, 1545004800, 1545091200, 1545177600,
1545264000, 1545350400, 1545436800, 1545523200, 1545609600, 1545696000,
1545782400, 1545868800, 1545955200, 1546041600, 1546128000, 1546214400,
1546300800, 1546387200, 1546473600, 1546560000, 1546646400, 1546732800,
1546819200, 1546905600, 1546992000, 1547078400, 1547164800, 1547251200,
1547337600, 1547424000, 1547510400, 1547596800, 1547683200, 1547769600,
1547856000, 1547942400, 1548028800, 1548115200, 1548201600, 1548288000,
1548374400, 1548460800, 1548547200, 1548633600, 1548720000, 1548806400,
1548892800, 1548979200, 1549065600, 1549152000, 1549238400, 1549324800,
1549411200, 1549497600, 1549584000, 1549670400, 1549756800, 1549843200,
1549929600, 1550016000, 1550102400, 1550188800, 1550275200, 1550361600,
1550448000, 1550534400, 1550620800, 1550707200, 1550793600, 1550880000,
1550966400, 1551052800, 1551139200, 1551225600, 1551312000, 1551398400,
1551484800, 1551571200, 1551657600, 1551744000, 1551830400, 1551916800,
1552003200, 1552089600, 1552176000, 1552262400, 1552348800, 1552435200,
1552521600, 1552608000, 1552694400, 1552780800, 1552867200, 1552953600,
1553040000, 1553126400, 1553212800, 1553299200, 1553385600, 1553472000,
1553558400, 1553644800, 1553731200, 1553817600, 1553904000, 1553990400,
1554076800, 1554163200, 1554249600, 1554336000, 1554422400, 1554508800,
1554595200, 1554681600, 1554768000, 1554854400, 1554940800, 1555027200,
1555113600, 1555200000, 1555286400, 1555372800, 1555459200, 1555545600,
1555632000, 1555718400, 1555804800, 1555891200, 1555977600, 1556064000,
1556150400, 1556236800, 1556323200, 1556409600, 1556496000, 1556582400,
1556668800, 1556755200, 1556841600, 1556928000, 1557014400, 1557100800,
1557187200, 1557273600, 1557360000, 1557446400, 1557532800, 1557619200,
1557705600, 1557792000, 1557878400, 1557964800, 1558051200, 1558137600,
1558224000, 1558310400, 1558396800, 1558483200, 1558569600, 1558656000,
1558742400, 1558828800, 1558915200, 1559001600, 1559088000, 1559174400,
1559260800, 1559347200, 1559433600, 1559520000, 1559606400, 1559692800,
1559779200, 1559865600, 1559952000, 1560038400, 1560124800, 1560211200,
1560297600, 1560384000, 1560470400, 1560556800, 1560643200, 1560729600,
1560816000, 1560902400, 1560988800, 1561075200, 1561161600, 1561248000,
1561334400, 1561420800, 1561507200, 1561593600, 1561680000, 1561766400,
1561852800, 1561939200, 1562025600, 1562112000, 1562198400, 1562284800,
1562371200, 1562457600, 1562544000, 1562630400, 1562716800, 1562803200,
1562889600, 1562976000, 1563062400, 1563148800, 1563235200, 1563321600,
1563408000, 1563494400, 1563580800, 1563667200, 1563753600, 1563840000,
1563926400, 1564012800, 1564099200, 1564185600, 1564272000, 1564358400,
1564444800, 1564531200, 1564617600, 1564704000, 1564790400, 1564876800,
1564963200, 1565049600, 1565136000, 1565222400, 1565308800, 1565395200,
1565481600, 1565568000, 1565654400, 1565740800, 1565827200, 1565913600,
1.566e+09, 1566086400, 1566172800, 1566259200, 1566345600, 1566432000,
1566518400, 1566604800, 1566691200, 1566777600, 1566864000, 1566950400,
1567036800, 1567123200, 1567209600, 1567296000, 1567382400, 1567468800,
1567555200, 1567641600, 1567728000, 1567814400, 1567900800, 1567987200,
1568073600, 1568160000, 1568246400, 1568332800, 1568419200, 1568505600,
1568592000, 1568678400, 1568764800, 1568851200, 1568937600, 1569024000,
1569110400, 1569196800, 1569283200, 1569369600, 1569456000, 1569542400,
1569628800, 1569715200, 1569801600, 1569888000, 1569974400, 1570060800,
1570147200, 1570233600, 1570320000, 1570406400, 1570492800, 1570579200,
1570665600, 1570752000, 1570838400, 1570924800, 1571011200, 1571097600,
1571184000, 1571270400, 1571356800, 1571443200, 1571529600, 1571616000,
1571702400, 1571788800, 1571875200, 1571961600, 1572048000, 1572134400,
1572220800, 1572307200, 1572393600, 1572480000, 1572566400, 1572652800,
1572739200, 1572825600, 1572912000, 1572998400, 1573084800, 1573171200,
1573257600, 1573344000, 1573430400, 1573516800, 1573603200, 1573689600,
1573776000, 1573862400, 1573948800, 1574035200, 1574121600, 1574208000,
1574294400, 1574380800, 1574467200, 1574553600, 1574640000, 1574726400,
1574812800, 1574899200, 1574985600, 1575072000, 1575158400, 1575244800,
1575331200, 1575417600, 1575504000, 1575590400, 1575676800, 1575763200,
1575849600, 1575936000, 1576022400, 1576108800, 1576195200, 1576281600,
1576368000, 1576454400, 1576540800, 1576627200, 1576713600, 1576800000,
1576886400, 1576972800, 1577059200, 1577145600, 1577232000, 1577318400,
1577404800, 1577491200, 1577577600, 1577664000, 1577750400), class = c("POSIXct",
"POSIXt"), tzone = "UTC"), adm = c(1L, 4L, 5L, 10L, 13L,
8L, 3L, 5L, 13L, 9L, 5L, 10L, 9L, 4L, 4L, 13L, 10L, 10L, 7L,
7L, 3L, 1L, 11L, 4L, 5L, 9L, 10L, 3L, 2L, 7L, 8L, 4L, 5L, 6L,
3L, 4L, 13L, 7L, 8L, 6L, 5L, 3L, 10L, 4L, 8L, 8L, 2L, 9L, 5L,
2L, 8L, 7L, 6L, 6L, 6L, 4L, 3L, 9L, 11L, 6L, 7L, 7L, 3L, 4L,
18L, 14L, 8L, 9L, 5L, 3L, 7L, 3L, 8L, 3L, 9L, 3L, 4L, 7L, 7L,
5L, 8L, 7L, 10L, 9L, 9L, 11L, 8L, 3L, 9L, 10L, 11L, 9L, 12L,
13L, 9L, 15L, 11L, 13L, 3L, 24L, 11L, 13L, 14L, 14L, 5L, 10L,
6L, 10L, 8L, 9L, 13L, 5L, 8L, 8L, 6L, 17L, 11L, 11L, 8L, 2L,
14L, 6L, 1L, 7L, 5L, 3L, 12L, 6L, 10L, 7L, 15L, 9L, 7L, 3L, 9L,
11L, 3L, 5L, 14L, 7L, 3L, 20L, 17L, 14L, 7L, 11L, 11L, 2L, 4L,
9L, 5L, 10L, 7L, 10L, 13L, 7L, 18L, 13L, 18L, 20L, 16L, 9L, 5L,
13L, 16L, 11L, 9L, 7L, 12L, 13L, 21L, 9L, 7L, 13L, 4L, 7L, 5L,
13L, 19L, 17L, 8L, 7L, 4L, 18L, 14L, 8L, 8L, 16L, 13L, 9L, 14L,
8L, 20L, 7L, 12L, 14L,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 2L, 9L, 2L, 6L, 2L, 9L, 4L, 3L, 4L, 9L, 7L,
6L, 5L, 4L, 5L, 6L, 4L, 5L, 2L, 5L, 4L, 7L, 3L, 9L, 6L, 9L, 7L,
2L, 7L, 6L, 7L, 3L, 4L, 8L, 3L, 8L, 10L, 3L, 3L, 5L, 4L, 8L,
6L, 5L, 4L, 5L, 1L, 6L, 6L, 8L, 9L, 5L, 10L, 1L, 8L, 7L, 7L,
6L, 5L, 1L, 5L, 8L, 11L, 2L, 6L, 7L, 6L, 5L, 20L, 8L, 10L, 7L,
5L, 2L, 5L, 3L, 17L, 6L, 5L, 0L, 1L, 1L, 9L, 1L)), row.names = c(NA,
-1304L), class = "data.frame")
I want to do a time series analysis with it.
I transformed it into a ts to get a pacf
ts1 <- zoo(df$adm, df$date)
ts <- as.xts(ts1)
pacf(ts)
The problem is that the x-axis, usually showing lags like, 1,2,3...is showing lags in magnitudes of hundred of thousands.
How can I correct this?
TL;DR: The pacf() function converts its main argument to ts by calling as.ts() and then computes the PACF from that. In your application you probably just want to treat the observations as an equidistant series so it's easiest to strip the time index and just compute the PACF of the data vector. You can do that via:
pacf(coredata(ts1))
pacf(coredata(ts))
Both lead to identical results.
Details: The as.ts() methods for both zoo and xts try to preserve the time index when creating the ts object. While the zoo method does not assume any knowledge about the time class and just converts it to numeric, the xts method behaves somewhat differently because it "understands" what a POSIXct object is.
In either case the time index gets coerced to numeric which is the time in seconds since 1970-01-01 for POSIXct. Therefore the distance between the observations is 1 day = 86400 seconds and hence the frequency is 1/86400 = 1.157407e-05. Using the simple Date class instead of POSIXct would avoid this problem.
Finally, pacf(ts1) fails because as.ts(ts1) creates a ts series with one missing value because there is one gap in the data:
ts1[221:224]
## 2017-01-11 2017-01-12 2017-01-14 2017-01-15
## 15 15 10 8
Possibly it may be sensible to fill the observation for 2017-01-13 with 0?
This is closely related to this question: Set frequency in xts object. The frequency is used in pacf here.
In particular, in your case the frequency (time in days between observations) is really small:
> frequency(ts)
[1] 1.157407e-05
You have daily data, so if you set attr(ts, 'frequency') <- 1 before pacf call, it will work.
ts1 <- zoo(df$adm, df$date)
ts <- xts::as.xts(ts1)
attr(ts, 'frequency') <- 1
pacf(ts)
Using the fpp3 forecasting packages I get the daily PACF lags per below if that helps.
(I don't use zoo/xts myself so can't say why that's showing the larger magnitudes.)
library(fpp3)
df <- structure(list(date = structure(c(
1465084800, 1465171200, 1465257600,
1465344000, 1465430400, 1465516800, 1465603200, 1465689600, 1465776000,
1465862400, 1465948800, 1466035200, 1466121600, 1466208000, 1466294400,
1466380800, 1466467200, 1466553600, 1466640000, 1466726400, 1466812800,
1466899200, 1466985600, 1467072000, 1467158400, 1467244800, 1467331200,
1467417600, 1467504000, 1467590400, 1467676800, 1467763200, 1467849600,
1467936000, 1468022400, 1468108800, 1468195200, 1468281600, 1468368000,
1468454400, 1468540800, 1468627200, 1468713600, 1468800000, 1468886400,
1468972800, 1469059200, 1469145600, 1469232000, 1469318400, 1469404800,
1469491200, 1469577600, 1469664000, 1469750400, 1469836800, 1469923200,
1470009600, 1470096000, 1470182400, 1470268800, 1470355200, 1470441600,
1470528000, 1470614400, 1470700800, 1470787200, 1470873600, 1470960000,
1471046400, 1471132800, 1471219200, 1471305600, 1471392000, 1471478400,
1471564800, 1471651200, 1471737600, 1471824000, 1471910400, 1471996800,
1472083200, 1472169600, 1472256000, 1472342400, 1472428800, 1472515200,
1472601600, 1472688000, 1472774400, 1472860800, 1472947200, 1473033600,
1473120000, 1473206400, 1473292800, 1473379200, 1473465600, 1473552000,
1473638400, 1473724800, 1473811200, 1473897600, 1473984000, 1474070400,
1474156800, 1474243200, 1474329600, 1474416000, 1474502400, 1474588800,
1474675200, 1474761600, 1474848000, 1474934400, 1475020800, 1475107200,
1475193600, 1475280000, 1475366400, 1475452800, 1475539200, 1475625600,
1475712000, 1475798400, 1475884800, 1475971200, 1476057600, 1476144000,
1476230400, 1476316800, 1476403200, 1476489600, 1476576000, 1476662400,
1476748800, 1476835200, 1476921600, 1477008000, 1477094400, 1477180800,
1477267200, 1477353600, 1477440000, 1477526400, 1477612800, 1477699200,
1477785600, 1477872000, 1477958400, 1478044800, 1478131200, 1478217600,
1478304000, 1478390400, 1478476800, 1478563200, 1478649600, 1478736000,
1478822400, 1478908800, 1478995200, 1479081600, 1479168000, 1479254400,
1479340800, 1479427200, 1479513600, 1479600000, 1479686400, 1479772800,
1479859200, 1479945600, 1480032000, 1480118400, 1480204800, 1480291200,
1480377600, 1480464000, 1480550400, 1480636800, 1480723200, 1480809600,
1480896000, 1480982400, 1481068800, 1481155200, 1481241600, 1481328000,
1481414400, 1481500800, 1481587200, 1481673600, 1481760000, 1481846400,
1481932800, 1482019200, 1482105600, 1482192000, 1482278400, 1482364800,
1482451200, 1482537600, 1482624000, 1482710400, 1482796800, 1482883200,
1482969600, 1483056000, 1483142400, 1483228800, 1483315200, 1483401600,
1483488000, 1483574400, 1483660800, 1483747200, 1483833600, 1483920000,
1484006400, 1484092800, 1484179200, 1484352000, 1484438400, 1484524800,
1484611200, 1484697600, 1484784000, 1484870400, 1484956800, 1485043200,
1485129600, 1485216000, 1485302400, 1485388800, 1485475200, 1485561600,
1485648000, 1485734400, 1485820800, 1485907200, 1485993600, 1486080000,
1486166400, 1486252800, 1486339200, 1486425600, 1486512000, 1486598400,
1486684800, 1486771200, 1486857600, 1486944000, 1487030400, 1487116800,
1487203200, 1487289600, 1487376000, 1487462400, 1487548800, 1487635200,
1487721600, 1487808000, 1487894400, 1487980800, 1488067200, 1488153600,
1488240000, 1488326400, 1488412800, 1488499200, 1488585600, 1488672000,
1488758400, 1488844800, 1488931200, 1489017600, 1489104000, 1489190400,
1489276800, 1489363200, 1489449600, 1489536000, 1489622400, 1489708800,
1489795200, 1489881600, 1489968000, 1490054400, 1490140800, 1490227200,
1490313600, 1490400000, 1490486400, 1490572800, 1490659200, 1490745600,
1490832000, 1490918400, 1491004800, 1491091200, 1491177600, 1491264000,
1491350400, 1491436800, 1491523200, 1491609600, 1491696000, 1491782400,
1491868800, 1491955200, 1492041600, 1492128000, 1492214400, 1492300800,
1492387200, 1492473600, 1492560000, 1492646400, 1492732800, 1492819200,
1492905600, 1492992000, 1493078400, 1493164800, 1493251200, 1493337600,
1493424000, 1493510400, 1493596800, 1493683200, 1493769600, 1493856000,
1493942400, 1494028800, 1494115200, 1494201600, 1494288000, 1494374400,
1494460800, 1494547200, 1494633600, 1494720000, 1494806400, 1494892800,
1494979200, 1495065600, 1495152000, 1495238400, 1495324800, 1495411200,
1495497600, 1495584000, 1495670400, 1495756800, 1495843200, 1495929600,
1496016000, 1496102400, 1496188800, 1496275200, 1496361600, 1496448000,
1496534400, 1496620800, 1496707200, 1496793600, 1496880000, 1496966400,
1497052800, 1497139200, 1497225600, 1497312000, 1497398400, 1497484800,
1497571200, 1497657600, 1497744000, 1497830400, 1497916800, 1498003200,
1498089600, 1498176000, 1498262400, 1498348800, 1498435200, 1498521600,
1498608000, 1498694400, 1498780800, 1498867200, 1498953600, 1499040000,
1499126400, 1499212800, 1499299200, 1499385600, 1499472000, 1499558400,
1499644800, 1499731200, 1499817600, 1499904000, 1499990400, 1500076800,
1500163200, 1500249600, 1500336000, 1500422400, 1500508800, 1500595200,
1500681600, 1500768000, 1500854400, 1500940800, 1501027200, 1501113600,
1501200000, 1501286400, 1501372800, 1501459200, 1501545600, 1501632000,
1501718400, 1501804800, 1501891200, 1501977600, 1502064000, 1502150400,
1502236800, 1502323200, 1502409600, 1502496000, 1502582400, 1502668800,
1502755200, 1502841600, 1502928000, 1503014400, 1503100800, 1503187200,
1503273600, 1503360000, 1503446400, 1503532800, 1503619200, 1503705600,
1503792000, 1503878400, 1503964800, 1504051200, 1504137600, 1504224000,
1504310400, 1504396800, 1504483200, 1504569600, 1504656000, 1504742400,
1504828800, 1504915200, 1505001600, 1505088000, 1505174400, 1505260800,
1505347200, 1505433600, 1505520000, 1505606400, 1505692800, 1505779200,
1505865600, 1505952000, 1506038400, 1506124800, 1506211200, 1506297600,
1506384000, 1506470400, 1506556800, 1506643200, 1506729600, 1506816000,
1506902400, 1506988800, 1507075200, 1507161600, 1507248000, 1507334400,
1507420800, 1507507200, 1507593600, 1507680000, 1507766400, 1507852800,
1507939200, 1508025600, 1508112000, 1508198400, 1508284800, 1508371200,
1508457600, 1508544000, 1508630400, 1508716800, 1508803200, 1508889600,
1508976000, 1509062400, 1509148800, 1509235200, 1509321600, 1509408000,
1509494400, 1509580800, 1509667200, 1509753600, 1509840000, 1509926400,
1510012800, 1510099200, 1510185600, 1510272000, 1510358400, 1510444800,
1510531200, 1510617600, 1510704000, 1510790400, 1510876800, 1510963200,
1511049600, 1511136000, 1511222400, 1511308800, 1511395200, 1511481600,
1511568000, 1511654400, 1511740800, 1511827200, 1511913600, 1.512e+09,
1512086400, 1512172800, 1512259200, 1512345600, 1512432000, 1512518400,
1512604800, 1512691200, 1512777600, 1512864000, 1512950400, 1513036800,
1513123200, 1513209600, 1513296000, 1513382400, 1513468800, 1513555200,
1513641600, 1513728000, 1513814400, 1513900800, 1513987200, 1514073600,
1514160000, 1514246400, 1514332800, 1514419200, 1514505600, 1514592000,
1514678400, 1514764800, 1514851200, 1514937600, 1515024000, 1515110400,
1515196800, 1515283200, 1515369600, 1515456000, 1515542400, 1515628800,
1515715200, 1515801600, 1515888000, 1515974400, 1516060800, 1516147200,
1516233600, 1516320000, 1516406400, 1516492800, 1516579200, 1516665600,
1516752000, 1516838400, 1516924800, 1517011200, 1517097600, 1517184000,
1517270400, 1517356800, 1517443200, 1517529600, 1517616000, 1517702400,
1517788800, 1517875200, 1517961600, 1518048000, 1518134400, 1518220800,
1518307200, 1518393600, 1518480000, 1518566400, 1518652800, 1518739200,
1518825600, 1518912000, 1518998400, 1519084800, 1519171200, 1519257600,
1519344000, 1519430400, 1519516800, 1519603200, 1519689600, 1519776000,
1519862400, 1519948800, 1520035200, 1520121600, 1520208000, 1520294400,
1520380800, 1520467200, 1520553600, 1520640000, 1520726400, 1520812800,
1520899200, 1520985600, 1521072000, 1521158400, 1521244800, 1521331200,
1521417600, 1521504000, 1521590400, 1521676800, 1521763200, 1521849600,
1521936000, 1522022400, 1522108800, 1522195200, 1522281600, 1522368000,
1522454400, 1522540800, 1522627200, 1522713600, 1522800000, 1522886400,
1522972800, 1523059200, 1523145600, 1523232000, 1523318400, 1523404800,
1523491200, 1523577600, 1523664000, 1523750400, 1523836800, 1523923200,
1524009600, 1524096000, 1524182400, 1524268800, 1524355200, 1524441600,
1524528000, 1524614400, 1524700800, 1524787200, 1524873600, 1524960000,
1525046400, 1525132800, 1525219200, 1525305600, 1525392000, 1525478400,
1525564800, 1525651200, 1525737600, 1525824000, 1525910400, 1525996800,
1526083200, 1526169600, 1526256000, 1526342400, 1526428800, 1526515200,
1526601600, 1526688000, 1526774400, 1526860800, 1526947200, 1527033600,
1527120000, 1527206400, 1527292800, 1527379200, 1527465600, 1527552000,
1527638400, 1527724800, 1527811200, 1527897600, 1527984000, 1528070400,
1528156800, 1528243200, 1528329600, 1528416000, 1528502400, 1528588800,
1528675200, 1528761600, 1528848000, 1528934400, 1529020800, 1529107200,
1529193600, 1529280000, 1529366400, 1529452800, 1529539200, 1529625600,
1529712000, 1529798400, 1529884800, 1529971200, 1530057600, 1530144000,
1530230400, 1530316800, 1530403200, 1530489600, 1530576000, 1530662400,
1530748800, 1530835200, 1530921600, 1531008000, 1531094400, 1531180800,
1531267200, 1531353600, 1531440000, 1531526400, 1531612800, 1531699200,
1531785600, 1531872000, 1531958400, 1532044800, 1532131200, 1532217600,
1532304000, 1532390400, 1532476800, 1532563200, 1532649600, 1532736000,
1532822400, 1532908800, 1532995200, 1533081600, 1533168000, 1533254400,
1533340800, 1533427200, 1533513600, 1533600000, 1533686400, 1533772800,
1533859200, 1533945600, 1534032000, 1534118400, 1534204800, 1534291200,
1534377600, 1534464000, 1534550400, 1534636800, 1534723200, 1534809600,
1534896000, 1534982400, 1535068800, 1535155200, 1535241600, 1535328000,
1535414400, 1535500800, 1535587200, 1535673600, 1535760000, 1535846400,
1535932800, 1536019200, 1536105600, 1536192000, 1536278400, 1536364800,
1536451200, 1536537600, 1536624000, 1536710400, 1536796800, 1536883200,
1536969600, 1537056000, 1537142400, 1537228800, 1537315200, 1537401600,
1537488000, 1537574400, 1537660800, 1537747200, 1537833600, 1537920000,
1538006400, 1538092800, 1538179200, 1538265600, 1538352000, 1538438400,
1538524800, 1538611200, 1538697600, 1538784000, 1538870400, 1538956800,
1539043200, 1539129600, 1539216000, 1539302400, 1539388800, 1539475200,
1539561600, 1539648000, 1539734400, 1539820800, 1539907200, 1539993600,
1540080000, 1540166400, 1540252800, 1540339200, 1540425600, 1540512000,
1540598400, 1540684800, 1540771200, 1540857600, 1540944000, 1541030400,
1541116800, 1541203200, 1541289600, 1541376000, 1541462400, 1541548800,
1541635200, 1541721600, 1541808000, 1541894400, 1541980800, 1542067200,
1542153600, 1542240000, 1542326400, 1542412800, 1542499200, 1542585600,
1542672000, 1542758400, 1542844800, 1542931200, 1543017600, 1543104000,
1543190400, 1543276800, 1543363200, 1543449600, 1543536000, 1543622400,
1543708800, 1543795200, 1543881600, 1543968000, 1544054400, 1544140800,
1544227200, 1544313600, 1544400000, 1544486400, 1544572800, 1544659200,
1544745600, 1544832000, 1544918400, 1545004800, 1545091200, 1545177600,
1545264000, 1545350400, 1545436800, 1545523200, 1545609600, 1545696000,
1545782400, 1545868800, 1545955200, 1546041600, 1546128000, 1546214400,
1546300800, 1546387200, 1546473600, 1546560000, 1546646400, 1546732800,
1546819200, 1546905600, 1546992000, 1547078400, 1547164800, 1547251200,
1547337600, 1547424000, 1547510400, 1547596800, 1547683200, 1547769600,
1547856000, 1547942400, 1548028800, 1548115200, 1548201600, 1548288000,
1548374400, 1548460800, 1548547200, 1548633600, 1548720000, 1548806400,
1548892800, 1548979200, 1549065600, 1549152000, 1549238400, 1549324800,
1549411200, 1549497600, 1549584000, 1549670400, 1549756800, 1549843200,
1549929600, 1550016000, 1550102400, 1550188800, 1550275200, 1550361600,
1550448000, 1550534400, 1550620800, 1550707200, 1550793600, 1550880000,
1550966400, 1551052800, 1551139200, 1551225600, 1551312000, 1551398400,
1551484800, 1551571200, 1551657600, 1551744000, 1551830400, 1551916800,
1552003200, 1552089600, 1552176000, 1552262400, 1552348800, 1552435200,
1552521600, 1552608000, 1552694400, 1552780800, 1552867200, 1552953600,
1553040000, 1553126400, 1553212800, 1553299200, 1553385600, 1553472000,
1553558400, 1553644800, 1553731200, 1553817600, 1553904000, 1553990400,
1554076800, 1554163200, 1554249600, 1554336000, 1554422400, 1554508800,
1554595200, 1554681600, 1554768000, 1554854400, 1554940800, 1555027200,
1555113600, 1555200000, 1555286400, 1555372800, 1555459200, 1555545600,
1555632000, 1555718400, 1555804800, 1555891200, 1555977600, 1556064000,
1556150400, 1556236800, 1556323200, 1556409600, 1556496000, 1556582400,
1556668800, 1556755200, 1556841600, 1556928000, 1557014400, 1557100800,
1557187200, 1557273600, 1557360000, 1557446400, 1557532800, 1557619200,
1557705600, 1557792000, 1557878400, 1557964800, 1558051200, 1558137600,
1558224000, 1558310400, 1558396800, 1558483200, 1558569600, 1558656000,
1558742400, 1558828800, 1558915200, 1559001600, 1559088000, 1559174400,
1559260800, 1559347200, 1559433600, 1559520000, 1559606400, 1559692800,
1559779200, 1559865600, 1559952000, 1560038400, 1560124800, 1560211200,
1560297600, 1560384000, 1560470400, 1560556800, 1560643200, 1560729600,
1560816000, 1560902400, 1560988800, 1561075200, 1561161600, 1561248000,
1561334400, 1561420800, 1561507200, 1561593600, 1561680000, 1561766400,
1561852800, 1561939200, 1562025600, 1562112000, 1562198400, 1562284800,
1562371200, 1562457600, 1562544000, 1562630400, 1562716800, 1562803200,
1562889600, 1562976000, 1563062400, 1563148800, 1563235200, 1563321600,
1563408000, 1563494400, 1563580800, 1563667200, 1563753600, 1563840000,
1563926400, 1564012800, 1564099200, 1564185600, 1564272000, 1564358400,
1564444800, 1564531200, 1564617600, 1564704000, 1564790400, 1564876800,
1564963200, 1565049600, 1565136000, 1565222400, 1565308800, 1565395200,
1565481600, 1565568000, 1565654400, 1565740800, 1565827200, 1565913600,
1.566e+09, 1566086400, 1566172800, 1566259200, 1566345600, 1566432000,
1566518400, 1566604800, 1566691200, 1566777600, 1566864000, 1566950400,
1567036800, 1567123200, 1567209600, 1567296000, 1567382400, 1567468800,
1567555200, 1567641600, 1567728000, 1567814400, 1567900800, 1567987200,
1568073600, 1568160000, 1568246400, 1568332800, 1568419200, 1568505600,
1568592000, 1568678400, 1568764800, 1568851200, 1568937600, 1569024000,
1569110400, 1569196800, 1569283200, 1569369600, 1569456000, 1569542400,
1569628800, 1569715200, 1569801600, 1569888000, 1569974400, 1570060800,
1570147200, 1570233600, 1570320000, 1570406400, 1570492800, 1570579200,
1570665600, 1570752000, 1570838400, 1570924800, 1571011200, 1571097600,
1571184000, 1571270400, 1571356800, 1571443200, 1571529600, 1571616000,
1571702400, 1571788800, 1571875200, 1571961600, 1572048000, 1572134400,
1572220800, 1572307200, 1572393600, 1572480000, 1572566400, 1572652800,
1572739200, 1572825600, 1572912000, 1572998400, 1573084800, 1573171200,
1573257600, 1573344000, 1573430400, 1573516800, 1573603200, 1573689600,
1573776000, 1573862400, 1573948800, 1574035200, 1574121600, 1574208000,
1574294400, 1574380800, 1574467200, 1574553600, 1574640000, 1574726400,
1574812800, 1574899200, 1574985600, 1575072000, 1575158400, 1575244800,
1575331200, 1575417600, 1575504000, 1575590400, 1575676800, 1575763200,
1575849600, 1575936000, 1576022400, 1576108800, 1576195200, 1576281600,
1576368000, 1576454400, 1576540800, 1576627200, 1576713600, 1576800000,
1576886400, 1576972800, 1577059200, 1577145600, 1577232000, 1577318400,
1577404800, 1577491200, 1577577600, 1577664000, 1577750400
), class = c(
"POSIXct",
"POSIXt"
), tzone = "UTC"), adm = c(
1L, 4L, 5L, 10L, 13L,
8L, 3L, 5L, 13L, 9L, 5L, 10L, 9L, 4L, 4L, 13L, 10L, 10L, 7L,
7L, 3L, 1L, 11L, 4L, 5L, 9L, 10L, 3L, 2L, 7L, 8L, 4L, 5L, 6L,
3L, 4L, 13L, 7L, 8L, 6L, 5L, 3L, 10L, 4L, 8L, 8L, 2L, 9L, 5L,
2L, 8L, 7L, 6L, 6L, 6L, 4L, 3L, 9L, 11L, 6L, 7L, 7L, 3L, 4L,
18L, 14L, 8L, 9L, 5L, 3L, 7L, 3L, 8L, 3L, 9L, 3L, 4L, 7L, 7L,
5L, 8L, 7L, 10L, 9L, 9L, 11L, 8L, 3L, 9L, 10L, 11L, 9L, 12L,
13L, 9L, 15L, 11L, 13L, 3L, 24L, 11L, 13L, 14L, 14L, 5L, 10L,
6L, 10L, 8L, 9L, 13L, 5L, 8L, 8L, 6L, 17L, 11L, 11L, 8L, 2L,
14L, 6L, 1L, 7L, 5L, 3L, 12L, 6L, 10L, 7L, 15L, 9L, 7L, 3L, 9L,
11L, 3L, 5L, 14L, 7L, 3L, 20L, 17L, 14L, 7L, 11L, 11L, 2L, 4L,
9L, 5L, 10L, 7L, 10L, 13L, 7L, 18L, 13L, 18L, 20L, 16L, 9L, 5L,
13L, 16L, 11L, 9L, 7L, 12L, 13L, 21L, 9L, 7L, 13L, 4L, 7L, 5L,
13L, 19L, 17L, 8L, 7L, 4L, 18L, 14L, 8L, 8L, 16L, 13L, 9L, 14L,
8L, 20L, 7L, 12L, 14L, 8L, 16L, 10L, 9L, 20L, 5L, 7L, 8L, 16L,
11L, 10L, 12L, 20L, 5L, 2L, 21L, 16L, 18L, 0L, 16L, 4L, 6L, 16L,
6L, 15L, 15L, 10L, 8L, 13L, 22L, 14L, 5L, 8L, 11L, 14L, 7L, 9L,
7L, 7L, 8L, 5L, 12L, 6L, 20L, 10L, 17L, 9L, 7L, 13L, 9L, 13L,
15L, 18L, 10L, 8L, 10L, 12L, 16L, 16L, 11L, 13L, 8L, 8L, 20L,
16L, 11L, 14L, 18L, 10L, 8L, 17L, 24L, 8L, 15L, 16L, 9L, 10L,
22L, 15L, 16L, 16L, 20L, 16L, 7L, 12L, 10L, 16L, 16L, 17L, 16L,
13L, 4L, 14L, 14L, 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date(date)) |>
tsibble(index = date) |>
fill_gaps() |>
PACF(adm) |>
autoplot()
Created on 2022-06-30 by the reprex package (v2.0.1)
You could solve your problem as below.
ts1 <- zoo(df$adm, df$date)
ts <- as.xts(ts1)
pl = pacf(ts, xaxt="n")
axis(1, pl$lag, seq_along(pl$lag))

set diagonal elements to a certain color on geom_tile ggplot2

I want to produce a confusion matrix plot where the diagonal entries are green, the zero entries white, and the off-diagonal non-zero entries should be red.
This is the data:
gg <- structure(list(Prediction = structure(c(1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L), .Label = c("0", "1", "2", "3", "4", "5", "6",
"7", "8", "9"), class = "factor"), Reference = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L), .Label = c("0", "1", "2", "3", "4",
"5", "6", "7", "8", "9"), class = "factor"), Freq = c(93L, 7L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 100L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 2L, 89L, 6L, 0L, 0L, 0L, 0L, 3L, 0L, 0L, 1L, 98L,
0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 26L, 0L, 0L, 71L, 0L, 0L,
3L, 0L, 0L, 2L, 69L, 0L, 0L, 1L, 25L, 0L, 3L, 0L, 0L, 6L, 64L,
0L, 0L, 0L, 0L, 30L, 0L, 0L, 0L, 1L, 13L, 0L, 0L, 0L, 0L, 0L,
86L, 0L, 0L, 3L, 96L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 4L, 37L,
0L, 0L, 5L, 0L, 0L, 54L, 0L, 0L)), class = "data.frame", row.names = c(NA,
-100L))
In this example, the off-diagonal zeros are white. But how can I intentionally set the diagonal to green and non-zero off-diagonal red?
gg %>% dplyr::mutate(Freq2 = ifelse(Freq == 0,NA,Freq)) %>%
ggplot(aes(Prediction, Reference, fill = Freq2)) +
geom_tile() +
geom_text(aes(label=Freq)) +
scale_fill_gradientn(colours = c("#f8766d", "#00ba38"),na.value="white") +
labs(x = "Prediction",y = "Reference", fill = "Freq")
One option using scale_fill_identity -
library(dplyr)
library(ggplot2)
gg %>%
mutate(color = case_when(Prediction == Reference ~ 'green',
Freq == 0 ~ 'white',
TRUE ~ ' red')) %>%
ggplot(aes(Prediction, Reference, fill = color)) +
geom_tile() +
geom_text(aes(label=Freq)) +
scale_fill_identity() +
labs(x = "Prediction",y = "Reference")
Figured it out. Had to use scale_fill_manual
gg2 <- gg %>% dplyr::mutate(Freq2 = ifelse(Freq == 0,NA,Freq))
gg2[gg2$Prediction == gg2$Reference,]$Freq2 = "diag"
gg2[gg2$Prediction != gg2$Reference & !is.na(gg2$Freq2),]$Freq2 = "notDiag"
gg2 %>%
ggplot(aes(Prediction, Reference, fill = Freq2)) +
geom_tile() +
geom_text(aes(label=Freq)) +
scale_fill_manual(values=c("#00ba38", "#f8766d"),na.value="white")+
labs(x = "Prediction",y = "Reference", fill = "Freq")

R - Easy significant test on 2 dataframes

I am stucking a simple statistical comparism of 2 dataframes. Both dataframes consist of different kind of observations (columns) and the observation days (rows). I counted the number of occurrences for each day and each case. I dont have the same number of observation days, the observations took place under different conditions and I want to find out if there is a significant difference between those two dataframes. So basically I want to compare Case1 of df1 with Case1 of df2. For that I calculated the number of occurrences per day of each dataframe and compared them (in%).
In reality I have thousands of these dataframes and all have different number of rows.
My problem is now, how can I get an idea of which of the results are significant? How can I see if only 9 day of observation is too less to be significant?
I tried to perform a Chi-Square test, is that the right thing to do?
Here is Dataframe 1:
structure(list(Case1 = c(17L, 9L, 4L, 3L, 5L, 4L, 5L, 4L, 6L, 13L,
7L, 17L, 9L, 11L, 10L, 8L, 7L, 22L, 7L, 14L, 15L, 13L, 17L, 7L,
13L, 12L, 10L, 16L, 7L, 6L, 13L, 10L, 12L, 12L, 11L, 13L, 12L,
9L, 11L, 12L, 14L, 10L, 11L, 14L, 15L, 9L, 12L, 13L, 19L, 14L,
10L, 10L, 4L, 10L, 9L, 11L, 10L, 4L, 6L, 3L, 11L, 10L, 7L, 8L,
12L, 8L, 7L, 3L, 5L, 5L, 6L, 5L, 8L, 10L, 9L, 3L, 5L, 9L, 9L,
4L, 9L, 7L, 8L, 6L, 4L, 7L, 6L, 9L, 4L, 17L, 16L, 9L, 16L, 12L,
9L, 10L, 14L, 6L, 17L, 14L, 14L, 11L, 10L, 11L, 15L, 12L, 11L,
15L, 10L, 12L, 12L, 5L, 7L, 7L, 15L, 9L, 8L, 14L, 15L, 20L, 8L,
12L, 12L, 19L, 10L, 18L, 6L, 14L, 17L, 17L, 17L, 13L, 12L, 10L,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 2L, 1L, 0L, 0L, 2L, 2L, 4L, 0L,
0L, 1L, 3L, 5L, 1L, 0L, 2L, 0L, 1L, 1L, 0L, 4L, 0L, 0L, 1L, 3L,
4L, 0L, 0L, 0L, 2L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 2L, 1L, 0L, 1L,
1L, 1L, 0L, 0L, 2L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 2L, 4L, 1L, 1L,
1L, 2L, 1L, 1L, 0L, 5L, 2L, 0L, 1L, 0L, 2L, 1L, 1L, 1L, 4L, 1L,
1L, 3L, 1L, 0L, 0L, 1L, 1L, 0L, 1L, 2L, 4L, 1L, 2L, 2L, 6L, 0L,
2L, 0L, 0L, 1L, 1L, 0L, 3L, 2L, 3L, 0L, 1L, 0L, 0L, 0L, 3L, 1L,
0L, 0L, 2L, 0L, 0L, 5L, 0L, 1L, 0L, 0L, 4L, 2L, 0L, 0L, 1L, 0L,
0L, 1L, 2L, 0L, 0L, 2L, 1L, 1L, 1L, 4L, 1L, 0L, 1L, 1L, 2L, 0L,
1L, 1L)), .Names = c("Case1", "Case2", "Case3"), class = "data.frame", row.names = c(NA,
-175L))
Here is Dataframe 2:
structure(list(Case1 = c(9L, 11L, 10L, 4L, 9L, 6L, 4L, 7L, 13L),
Case2 = c(7L, 10L, 8L, 4L, 8L, 4L, 3L, 6L, 8L), Case3 = c(2L, 1L,
2L, 0L, 1L, 2L, 1L, 1L, 5L)), .Names = c("Case1", "Case2", "Case3"), class = "data.frame", row.names = c(NA,
-9L))

R: Shiny - How to subset and then make a bargraph based on daterangeInput

i've this data frame:
date sessions Fuentes
1 2014-12-01 197 Directo
2 2014-12-01 1 Referencias
3 2014-12-01 7 Social Media
4 2014-12-01 13 SEO
5 2014-12-01 1 Email
6 2014-12-01 1 Referencias
This is the data after using dput():
structure(list(date = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L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, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L,
28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L,
28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L,
28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 29L, 29L,
29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L,
29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L,
29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L,
29L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 31L, 31L, 31L, 31L, 31L, 31L, 31L,
31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L,
31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L), .Label = c("2014-12-01",
"2014-12-02", "2014-12-03", "2014-12-04", "2014-12-05", "2014-12-06",
"2014-12-07", "2014-12-08", "2014-12-09", "2014-12-10", "2014-12-11",
"2014-12-12", "2014-12-13", "2014-12-14", "2014-12-15", "2014-12-16",
"2014-12-17", "2014-12-18", "2014-12-19", "2014-12-20", "2014-12-21",
"2014-12-22", "2014-12-23", "2014-12-24", "2014-12-25", "2014-12-26",
"2014-12-27", "2014-12-28", "2014-12-29", "2014-12-30", "2014-12-31"
), class = "factor"), sessions = c(197L, 1L, 7L, 13L, 1L, 1L,
10L, 1L, 3L, 3L, 5L, 3L, 566L, 1L, 27L, 159L, 7L, 1L, 6L, 1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,
5L, 4L, 5L, 2L, 5L, 5L, 5L, 5L, 6L, 3L, 5L, 4L, 4L, 6L, 4L, 5L,
5L, 5L, 7L, 6L, 5L, 5L, 4L, 5L, 5L, 4L, 4L, 5L, 5L, 5L, 3L, 6L,
6L, 5L, 5L, 7L, 6L, 5L, 5L, 5L, 5L, 7L, 5L, 4L, 2L, 5L, 5L, 5L,
5L, 5L, 6L, 7L, 3L, 4L, 6L, 5L, 5L, 4L, 5L, 5L, 7L, 1L, 6L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 4L, 4L, 5L, 6L, 3L, 6L, 6L, 6L, 5L, 5L,
5L, 5L, 7L, 6L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 3L, 6L, 4L, 6L, 5L,
5L, 7L, 7L, 5L, 6L, 5L, 5L, 5L, 5L), .Label = c("Adwords", "CampaƱas",
"Directo", "Email", "Referencias", "SEO", "Social Media"), class = "factor")), .Names = c("date",
"sessions", "Fuentes"), class = "data.frame", row.names = c(NA,
-1724L))
In a Shiny App, want to plot bars for Fuentes, acording to a data range specified by the user. I use daterangeInput in my ui.R, but cannot get it to plot what I need.
My ui.R
library(shiny)
# Define the overall UI
shinyUI(
# Use a fluid Bootstrap layout
fluidPage(
# Give the page a title
br(),
br(),
titlePanel("Visitas por fuente"),
# Generate a row with a sidebar
sidebarLayout(
# Define the sidebar with one input
sidebarPanel(
dateRangeInput("dates", label = h3("Date range"),
start = "2014-12-01", end = "2014-12-31")
),
# Create a spot for the barplot
mainPanel(
plotOutput("VisitasFuente")
)
)
)
)
My server.R ### Edited - Now can plot, but labels appeare as a blur from botton to top.
library(ggplot2)
library(dplyr)
require(scales)
Visitas_Por_Fuente <- read.csv("D:\\RCoursera\\Movistar- App-2\\Visitas_Por_Fuente_Dic.csv")
labels = c("Directo", "Email", "Referencias", "SEO", "Social Media")
Visitas_Por_Fuente$date <- as.Date(Visitas_Por_Fuente$date)
shinyServer(
function(input, output) {
output$VisitasFuente <- renderPlot({
# Filter the data based on user selection month
date_seq <- seq(input$dates[1], input$dates[2], by = "day")
#VisitasData <- filter(Visitas_Por_Fuente, date >= input$dates[1],
# date <= input$dates[2])
VisitasData <- filter(Visitas_Por_Fuente, date %in% date_seq & Fuentes %in% labels)
# Bar graph using ggplot2 library
ggplot(VisitasData, aes(factor(Fuentes), sessions, fill = Fuentes)) +
geom_bar(stat="identity", position = "dodge") +
geom_text(aes(label = comma(sessions)), position=position_dodge(width=0.9), vjust=-0.25) +
scale_fill_manual(breaks = c("0", "1", "3", "6", "9"),
labels = c("Directo", "Email", "References",
"SEO", "Social Media"),
values = c("#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2"))
})
})
This was fixied by loading the corresponded packages
Thanks to #goodtimeslim, i've made the recomendations you gave me. But now i get:
Error in match(x, table, nomatch = 0L) :
'match' requires vector arguments
What could it be? Thanks again.
#
Okay, first thing, you need to tell R that Visitas_Por_Fuente$date is a date, with Visitas_Por_Fuente$date <- as.Date(Visitas_Por_Fuente$date) .
You can do this right after you import your data at the beginning.
Now you want to create a range of dates, in your server file, using the date inputs, like so:
date_seq <- seq(input$dates[1], input$dates[2], by = "day")
Now you just need to change your filter, so that the date is in that sequence, like so:
VisitasData <- filter(Visitas_Por_Fuente, date %in% date_seq)
Now I admit that doesn't solve everything, I was getting some weird errors with your ggplot code, but this will solve the subsetting issue.
This issue with your ggplot is that your data has 7 variables, but you're only giving it information for 5. If you just want those 5 variables, then at the top (right after you import your data), write this:
labels = c("Directo", "Email", "References", "SEO", "Social Media")
and then, for your plot, get rid of the scale_manual line and replace it with:
scale_x_discrete(limit = labels)
That'll force those 5 on there, and at the moment, it'll do it in whatever color R wants. I'll let you figure out the rest if you want to change it.
Let me know if this is clear enough or if you just want the whole server.r code.
edit: Okay, I fixed it. You had an error in your code, you have "References", but in your data, it's "Referencias". So now, assuming you still want those five variables only, and not all 7, do this: change labels (at the top) like so:
labels = c("Directo", "Email", "Referencias", "SEO", "Social Media")
Change your filter like so:
VisitasData <- filter(Visitas_Por_Fuente, date %in% date_seq & Fuentes %in% labels)
Then you can get rid of that scale_x_discrete line I had, and put your line back in. It should all work now. (Except edit your labels in the manual_scale part to reflect the proper "Referencias".
edit 2: Here's the full server.r that runs just fine on my computer. I've made some slight changes for consistency/clarity, but otherwise it's mostly the same.
library(ggplot2)
Visitas_Por_Fuente <- read.csv("visitas.csv") ## put your path here
labelsF = c("Directo", "Email", "Referencias", "SEO", "Social Media")
Visitas_Por_Fuente$date <- as.Date(Visitas_Por_Fuente$date)
shinyServer(
function(input, output) {
output$VisitasFuente <- renderPlot({
# Filter the data based on user selection month
date_seq <- seq(input$dates[1], input$dates[2], by = "day")
#VisitasData <- filter(Visitas_Por_Fuente, date >= input$dates[1],
# date <= input$dates[2])
VisitasData <- filter(Visitas_Por_Fuente, date %in% date_seq & Fuentes %in% labelsF)
# Bar graph using ggplot2 library
ggplot(VisitasData, aes(factor(Fuentes), sessions, fill = Fuentes)) +
geom_bar(stat="identity", position = "dodge") +
scale_fill_manual(breaks = c("0", "1", "3", "6", "9"),
labels = labelsF,
values = c("#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2"))
})
})

geom.point in ggplot2, conditional shape

I'm putting together my first plot with ggplot2. I need to set a shape for values == 0. Here's my dataset and what I got so far :
structure(list(Var1 = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L,
14L, 15L, 16L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L, 14L, 15L, 16L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L,
14L, 15L, 16L), .Label = c("MD-1", "MD-2", "MD-3", "MD-4", "ME-1",
"ME-2", "ME-3", "ME-4", "ME-5", "ME-6", "MF-1", "MF-2", "MF-4",
"MF-6", "MF-7", "MF-8"), class = "factor"), Var2 = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,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 0L, 0L, 0L, 0L, 0L, 0L, 1L, 13L, 2L, 5L, 7L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 1L, 1L)), .Names = c("Var1",
"Var2", "Freq"), row.names = c(NA, -192L), class = "data.frame")
Here's the base of my plot
p <- ggplot(mat.bub, aes(Var1, Var2))
p + geom_point(aes(size = Freq))
Now, how to set geom.point to a specific shape if Freq==0 ? Here's what I tried so far:
p <- ggplot(mat.bub, aes(Var1, Var2,size=Freq))
p + geom_point(aes(Var1[Freq==0], Var2[Freq==0]), colour="black", shape=3, size=5, na.rm = T)
Inspired from this answer :
Modifying the shape for a subset of points with ggplot2
But I get an "arguments imply differing number of rows: 162, 192" error. Of course Var1 and Var2 are not numerical, that's what's different from the mtcars example.
How could I achieve this conditional shaping ? What am I missing ?
Thanx for any help !
As per my note on the answer you link to, try this:
p <- ggplot(mat.bub, aes(Var1, Var2,size=Freq)) + geom_point()
p + geom_point(data = subset(mat.bub,Freq == 0), colour="black", shape=3, size=5, na.rm = T)
As an explanation, while subsetting in the variables is possible, I much prefer handing each geom the specific subset of whatever data frame I'm dealing with. I find that easier to keep straight in my head, and is apparently less confusing for ggplot as well.

Resources