diff --git a/conda-envs/environment-test.yml b/conda-envs/environment-test.yml index 450b46e30..16cfcc3b3 100644 --- a/conda-envs/environment-test.yml +++ b/conda-envs/environment-test.yml @@ -1,17 +1,20 @@ name: pymc-extras-test channels: - conda-forge -- nodefaults dependencies: -- pymc>=5.21 -- pytest-cov>=2.5 -- pytest>=3.0 +- blackjax +- ipywidgets +- ipython +- pymc +- pytest-cov +- pytest - dask - xhistogram - statsmodels -- numba<=0.60.0 +- numba +- nutpie - pip +- scikit-learn - pip: - - blackjax - - scikit-learn - better_optimize + - -e . diff --git a/notebooks/batch-examples.ipynb b/notebooks/batch-examples.ipynb new file mode 100644 index 000000000..7529b8589 --- /dev/null +++ b/notebooks/batch-examples.ipynb @@ -0,0 +1,2306 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "0a5841d3", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "import pytensor\n", + "import pytensor.tensor as pt\n", + "from pymc_extras.statespace.filters import StandardFilter\n", + "from tests.statespace.utilities.test_helpers import make_test_inputs\n", + "from pytensor.graph.replace import vectorize_graph\n", + "from importlib import reload\n", + "import pymc_extras.statespace.filters.distributions as pmss_dist\n", + "from pymc_extras.statespace.filters.distributions import SequenceMvNormal\n", + "import pymc as pm" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "14299e50", + "metadata": {}, + "outputs": [], + "source": [ + "seed = sum(map(ord, \"batched-kf\"))\n", + "rng = np.random.default_rng(seed)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "71bc513e", + "metadata": {}, + "outputs": [], + "source": [ + "def create_batch_inputs(batch_size, p=1, m=5, r=1, n=10, rng=rng):\n", + " \"\"\"\n", + " Create batched inputs for testing.\n", + "\n", + " Parameters\n", + " ----------\n", + " batch_size : int\n", + " Number of batches to create\n", + " p : int\n", + " First dimension parameter\n", + " m : int\n", + " Second dimension parameter\n", + " r : int\n", + " Third dimension parameter\n", + " n : int\n", + " Fourth dimension parameter\n", + " rng : numpy.random.Generator\n", + " Random number generator\n", + "\n", + " Returns\n", + " -------\n", + " list\n", + " List of stacked inputs for each batch\n", + " \"\"\"\n", + " # Create individual inputs for each batch\n", + " np_batch_inputs = []\n", + " for i in range(batch_size):\n", + " inputs = make_test_inputs(p, m, r, n, rng)\n", + " np_batch_inputs.append(inputs)\n", + "\n", + " return [np.stack(x, axis=0) for x in zip(*np_batch_inputs)]" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "0c1824cf", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(3, 10, 1)" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Create batch inputs with batch size 3\n", + "np_batch_inputs = create_batch_inputs(3)\n", + "np_batch_inputs[0].shape" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "773d4cb4", + "metadata": {}, + "outputs": [], + "source": [ + "p, m, r, n = 1, 5, 1, 10\n", + "inputs = [pt.as_tensor(x).type() for x in make_test_inputs(p, m, r, n, rng)]" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "511de29f", + "metadata": {}, + "outputs": [], + "source": [ + "kf = StandardFilter()\n", + "kf_outputs = kf.build_graph(*inputs)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "33006d8e", + "metadata": {}, + "outputs": [], + "source": [ + "batched_inputs = [pt.tensor(shape=(None, *x.type.shape)) for x in inputs]\n", + "vec_subs = dict(zip(inputs, batched_inputs))\n", + "bacthed_kf_outputs = vectorize_graph(kf_outputs, vec_subs)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "987a4647", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[filtered_states,\n", + " predicted_states,\n", + " observed_states,\n", + " filtered_covariances,\n", + " predicted_covariances,\n", + " observed_covariances,\n", + " loglike_obs]" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "kf_outputs" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "4b8be0f9", + "metadata": {}, + "outputs": [], + "source": [ + "mu = bacthed_kf_outputs[1]\n", + "cov = bacthed_kf_outputs[4]\n", + "logp = bacthed_kf_outputs[-1]" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "1dc80f94", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(None, 10, 5)" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "mu.type.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "1262c7d4", + "metadata": {}, + "outputs": [], + "source": [ + "pmss_dist = reload(pmss_dist)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "2dcd3958", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "mus_.type.shape: (None, 10, 5), covs_.type.shape: (None, 10, 5, 5)\n", + "mus.type.shape: (10, None, 5), covs.type.shape: (10, None, 5, 5)\n", + "mvn_seq.type.shape: (None, None, 5)\n", + "mvn_seq.type.shape: (None, 10, 5)\n", + "mvn_seq.type.shape: (None, 10, 5)\n", + "mvn_seq.type.shape: (None, 10, 5)\n", + "mus_.type.shape: (None, 10, 5), covs_.type.shape: (None, 10, 5, 5)\n", + "mus.type.shape: (10, None, 5), covs.type.shape: (10, None, 5, 5)\n", + "mvn_seq.type.shape: (None, None, 5)\n", + "mvn_seq.type.shape: (None, 10, 5)\n", + "mvn_seq.type.shape: (None, 10, 5)\n", + "mvn_seq.type.shape: (None, 10, 5)\n" + ] + } + ], + "source": [ + "mv_outputs = pmss_dist.SequenceMvNormal.dist(mus=mu, covs=cov, logp=logp)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "6f41344f", + "metadata": {}, + "outputs": [], + "source": [ + "np_batch_inputs = create_batch_inputs(3)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "44905b8a", + "metadata": {}, + "outputs": [], + "source": [ + "np_batch_inputs[0] = rng.normal(size=(3, 10, 1))" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "34fe01b8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(3, 10, 5)" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "f_test = pytensor.function(batched_inputs, mv_outputs)\n", + "f_test(*np_batch_inputs).shape" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "f37efe79", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(None, 10, 1) (None, 10, 5) (None, 10, 5, 5)\n" + ] + } + ], + "source": [ + "f_mv = pytensor.function(batched_inputs, pm.logp(mv_outputs, batched_inputs[0]))" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "7b45de74", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(3, 10)" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "f_mv(*np_batch_inputs).shape" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f14596aa", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "69519822", + "metadata": {}, + "outputs": [], + "source": [ + "f = pytensor.function(batched_inputs, bacthed_kf_outputs)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "3f745449", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "675 μs ± 22.3 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n", + "1.64 ms ± 37.5 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n", + "5.28 ms ± 424 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n" + ] + } + ], + "source": [ + "for s in [1, 3, 10]:\n", + " np_batch_inputs = create_batch_inputs(s)\n", + " %timeit outputs = f(*np_batch_inputs)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "42366399", + "metadata": {}, + "outputs": [], + "source": [ + "from pymc_extras.statespace.filters.kalman_smoother import KalmanSmoother" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "d5fcadef", + "metadata": {}, + "outputs": [], + "source": [ + "def build_fk(data, a0, P0, c, d, T, Z, R, H, Q):\n", + " kf = StandardFilter()\n", + " kf_outputs = kf.build_graph(data, a0, P0, c, d, T, Z, R, H, Q)\n", + "\n", + " ks = KalmanSmoother()\n", + " ks_outputs = ks.build_graph(T, R, Q, kf_outputs[0], kf_outputs[3])\n", + "\n", + " return (*kf_outputs, *ks_outputs)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "c479ff22", + "metadata": {}, + "outputs": [], + "source": [ + "signature = \"(t, o), (s), (s, s), (s), (o), (s, s), (o, s), (s, p), (o, o), (p, p) -> (t, s), (t, s), (t, o), (t, s, s), (t, s, s), (t, o, o), (t), (t, s), (t, s, s)\"" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "d3a403e9", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Join [id A]\n", + " ├─ 0 [id B]\n", + " ├─ Subtensor{::step} [id C]\n", + " │ ├─ Subtensor{start:} [id D]\n", + " │ │ ├─ Scan{kalman_smoother, while_loop=False, inplace=none}.0 [id E]\n", + " │ │ │ ├─ Minimum [id F]\n", + " │ │ │ │ ├─ Subtensor{i} [id G]\n", + " │ │ │ │ │ ├─ Shape [id H]\n", + " │ │ │ │ │ │ └─ Subtensor{::step} [id I]\n", + " │ │ │ │ │ │ ├─ Subtensor{start:} [id J]\n", + " │ │ │ │ │ │ │ ├─ Subtensor{:stop} [id K]\n", + " │ │ │ │ │ │ │ │ ├─ SpecifyShape [id L] 'filtered_states'\n", + " │ │ │ │ │ │ │ │ │ ├─ Scan{forward_kalman_pass, while_loop=False, inplace=none}.2 [id M]\n", + " │ │ │ │ │ │ │ │ │ │ ├─ Subtensor{i} [id N]\n", + " │ │ │ │ │ │ │ │ │ │ │ ├─ Shape [id O]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ └─ Subtensor{start:} [id P]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ ├─ [id Q]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ └─ 0 [id R]\n", + " │ │ │ │ │ │ │ │ │ │ │ └─ 0 [id S]\n", + " │ │ │ │ │ │ │ │ │ │ ├─ Subtensor{:stop} [id T]\n", + " │ │ │ │ │ │ │ │ │ │ │ ├─ Subtensor{start:} [id P]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ │ │ │ └─ ScalarFromTensor [id U]\n", + " │ │ │ │ │ │ │ │ │ │ │ └─ Subtensor{i} [id N]\n", + " │ │ │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ │ │ ├─ SetSubtensor{:stop} [id V]\n", + " │ │ │ │ │ │ │ │ │ │ │ ├─ AllocEmpty{dtype='float64'} [id W]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ ├─ Add [id X]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ ├─ Subtensor{i} [id N]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ └─ Subtensor{i} [id Y]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ ├─ Shape [id Z]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─ ExpandDims{axis=0} [id BA]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─ [id BB]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ └─ 0 [id BC]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ └─ Subtensor{i} [id BD]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ ├─ Shape [id Z]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ │ │ │ │ └─ 1 [id BE]\n", + " │ │ │ │ │ │ │ │ │ │ │ ├─ ExpandDims{axis=0} [id BA]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ │ │ │ └─ ScalarFromTensor [id BF]\n", + " │ │ │ │ │ │ │ │ │ │ │ └─ Subtensor{i} [id Y]\n", + " │ │ │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ │ │ ├─ SetSubtensor{:stop} [id BG]\n", + " │ │ │ │ │ │ │ │ │ │ │ ├─ AllocEmpty{dtype='float64'} [id BH]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ ├─ Add [id BI]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ ├─ Subtensor{i} [id N]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ └─ Subtensor{i} [id BJ]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ ├─ Shape [id BK]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─ ExpandDims{axis=0} [id BL]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─ [id BM]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ └─ 0 [id BN]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ ├─ Subtensor{i} [id BO]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ ├─ Shape [id BK]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ └─ 1 [id BP]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ └─ Subtensor{i} [id BQ]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ ├─ Shape [id BK]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ │ │ │ │ └─ 2 [id BR]\n", + " │ │ │ │ │ │ │ │ │ │ │ ├─ ExpandDims{axis=0} [id BL]\n", + " │ │ │ │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ │ │ │ └─ ScalarFromTensor [id BS]\n", + " │ │ │ │ │ │ │ │ │ │ │ └─ Subtensor{i} [id BJ]\n", + " │ │ │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ │ │ ├─ Subtensor{i} [id N]\n", + " │ │ │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ │ │ ├─ Subtensor{i} [id N]\n", + " │ │ │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ │ │ ├─ Subtensor{i} [id N]\n", + " │ │ │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ │ │ ├─ Subtensor{i} [id N]\n", + " │ │ │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ │ │ ├─ Subtensor{i} [id N]\n", + " │ │ │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ │ │ ├─ [id BT]\n", + " │ │ │ │ │ │ │ │ │ │ ├─ [id BU]\n", + " │ │ │ │ │ │ │ │ │ │ ├─ [id BV]\n", + " │ │ │ │ │ │ │ │ │ │ ├─ [id BW]\n", + " │ │ │ │ │ │ │ │ │ │ ├─ [id BX]\n", + " │ │ │ │ │ │ │ │ │ │ ├─ [id BY]\n", + " │ │ │ │ │ │ │ │ │ │ └─ [id BZ]\n", + " │ │ │ │ │ │ │ │ │ ├─ 10 [id CA]\n", + " │ │ │ │ │ │ │ │ │ └─ 5 [id CB]\n", + " │ │ │ │ │ │ │ │ └─ -1 [id CC]\n", + " │ │ │ │ │ │ │ └─ 0 [id CD]\n", + " │ │ │ │ │ │ └─ -1 [id CE]\n", + " │ │ │ │ │ └─ 0 [id CF]\n", + " │ │ │ │ └─ Subtensor{i} [id CG]\n", + " │ │ │ │ ├─ Shape [id CH]\n", + " │ │ │ │ │ └─ Subtensor{::step} [id CI]\n", + " │ │ │ │ │ ├─ Subtensor{start:} [id CJ]\n", + " │ │ │ │ │ │ ├─ Subtensor{:stop} [id CK]\n", + " │ │ │ │ │ │ │ ├─ SpecifyShape [id CL] 'filtered_covariances'\n", + " │ │ │ │ │ │ │ │ ├─ Scan{forward_kalman_pass, while_loop=False, inplace=none}.4 [id M]\n", + " │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ ├─ 10 [id CM]\n", + " │ │ │ │ │ │ │ │ ├─ 5 [id CN]\n", + " │ │ │ │ │ │ │ │ └─ 5 [id CO]\n", + " │ │ │ │ │ │ │ └─ -1 [id CP]\n", + " │ │ │ │ │ │ └─ 0 [id CQ]\n", + " │ │ │ │ │ └─ -1 [id CR]\n", + " │ │ │ │ └─ 0 [id CS]\n", + " │ │ │ ├─ Subtensor{:stop} [id CT]\n", + " │ │ │ │ ├─ Subtensor{::step} [id I]\n", + " │ │ │ │ │ └─ ···\n", + " │ │ │ │ └─ ScalarFromTensor [id CU]\n", + " │ │ │ │ └─ Minimum [id F]\n", + " │ │ │ │ └─ ···\n", + " │ │ │ ├─ Subtensor{:stop} [id CV]\n", + " │ │ │ │ ├─ Subtensor{::step} [id CI]\n", + " │ │ │ │ │ └─ ···\n", + " │ │ │ │ └─ ScalarFromTensor [id CW]\n", + " │ │ │ │ └─ Minimum [id F]\n", + " │ │ │ │ └─ ···\n", + " │ │ │ ├─ SetSubtensor{:stop} [id CX]\n", + " │ │ │ │ ├─ AllocEmpty{dtype='float64'} [id CY]\n", + " │ │ │ │ │ ├─ Add [id CZ]\n", + " │ │ │ │ │ │ ├─ Minimum [id F]\n", + " │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ └─ Subtensor{i} [id DA]\n", + " │ │ │ │ │ │ ├─ Shape [id DB]\n", + " │ │ │ │ │ │ │ └─ ExpandDims{axis=0} [id DC]\n", + " │ │ │ │ │ │ │ └─ Subtensor{i} [id DD]\n", + " │ │ │ │ │ │ │ ├─ SpecifyShape [id L] 'filtered_states'\n", + " │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ └─ -1 [id DE]\n", + " │ │ │ │ │ │ └─ 0 [id DF]\n", + " │ │ │ │ │ └─ Subtensor{i} [id DG]\n", + " │ │ │ │ │ ├─ Shape [id DB]\n", + " │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ └─ 1 [id DH]\n", + " │ │ │ │ ├─ ExpandDims{axis=0} [id DC]\n", + " │ │ │ │ │ └─ ···\n", + " │ │ │ │ └─ ScalarFromTensor [id DI]\n", + " │ │ │ │ └─ Subtensor{i} [id DA]\n", + " │ │ │ │ └─ ···\n", + " │ │ │ ├─ SetSubtensor{:stop} [id DJ]\n", + " │ │ │ │ ├─ AllocEmpty{dtype='float64'} [id DK]\n", + " │ │ │ │ │ ├─ Add [id DL]\n", + " │ │ │ │ │ │ ├─ Minimum [id F]\n", + " │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ └─ Subtensor{i} [id DM]\n", + " │ │ │ │ │ │ ├─ Shape [id DN]\n", + " │ │ │ │ │ │ │ └─ ExpandDims{axis=0} [id DO]\n", + " │ │ │ │ │ │ │ └─ Subtensor{i} [id DP]\n", + " │ │ │ │ │ │ │ ├─ SpecifyShape [id CL] 'filtered_covariances'\n", + " │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ └─ -1 [id DQ]\n", + " │ │ │ │ │ │ └─ 0 [id DR]\n", + " │ │ │ │ │ ├─ Subtensor{i} [id DS]\n", + " │ │ │ │ │ │ ├─ Shape [id DN]\n", + " │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ └─ 1 [id DT]\n", + " │ │ │ │ │ └─ Subtensor{i} [id DU]\n", + " │ │ │ │ │ ├─ Shape [id DN]\n", + " │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ └─ 2 [id DV]\n", + " │ │ │ │ ├─ ExpandDims{axis=0} [id DO]\n", + " │ │ │ │ │ └─ ···\n", + " │ │ │ │ └─ ScalarFromTensor [id DW]\n", + " │ │ │ │ └─ Subtensor{i} [id DM]\n", + " │ │ │ │ └─ ···\n", + " │ │ │ ├─ [id BV]\n", + " │ │ │ ├─ [id BX]\n", + " │ │ │ └─ [id BZ]\n", + " │ │ └─ 1 [id DX]\n", + " │ └─ -1 [id DY]\n", + " └─ ExpandDims{axis=0} [id DZ]\n", + " └─ Subtensor{i} [id DD]\n", + " └─ ···\n", + "\n", + "Inner graphs:\n", + "\n", + "Scan{kalman_smoother, while_loop=False, inplace=none} [id E]\n", + " ← Add [id EA]\n", + " ├─ *0- [id EB] -> [id CT]\n", + " └─ Squeeze{axis=1} [id EC]\n", + " └─ Blockwise{dot, (m,k),(k,n)->(m,n)} [id ED]\n", + " ├─ Transpose{axes=[1, 0]} [id EE]\n", + " │ └─ dot [id EF]\n", + " │ ├─ dot [id EG]\n", + " │ │ ├─ Blockwise{MatrixPinv{hermitian=False}, (m,n)->(n,m)} [id EH]\n", + " │ │ │ └─ Add [id EI]\n", + " │ │ │ ├─ Add [id EJ]\n", + " │ │ │ │ ├─ Mul [id EK]\n", + " │ │ │ │ │ ├─ ExpandDims{axes=[0, 1]} [id EL]\n", + " │ │ │ │ │ │ └─ 0.5 [id EM]\n", + " │ │ │ │ │ └─ Add [id EN]\n", + " │ │ │ │ │ ├─ dot [id EO]\n", + " │ │ │ │ │ │ ├─ dot [id EP]\n", + " │ │ │ │ │ │ │ ├─ *4- [id EQ] -> [id BV]\n", + " │ │ │ │ │ │ │ └─ *1- [id ER] -> [id CV]\n", + " │ │ │ │ │ │ └─ Transpose{axes=[1, 0]} [id ES]\n", + " │ │ │ │ │ │ └─ *4- [id EQ] -> [id BV]\n", + " │ │ │ │ │ └─ Transpose{axes=[1, 0]} [id ET]\n", + " │ │ │ │ │ └─ dot [id EO]\n", + " │ │ │ │ │ └─ ···\n", + " │ │ │ │ └─ Mul [id EU]\n", + " │ │ │ │ ├─ ExpandDims{axes=[0, 1]} [id EV]\n", + " │ │ │ │ │ └─ 0.5 [id EW]\n", + " │ │ │ │ └─ Add [id EX]\n", + " │ │ │ │ ├─ dot [id EY]\n", + " │ │ │ │ │ ├─ dot [id EZ]\n", + " │ │ │ │ │ │ ├─ *5- [id FA] -> [id BX]\n", + " │ │ │ │ │ │ └─ *6- [id FB] -> [id BZ]\n", + " │ │ │ │ │ └─ Transpose{axes=[1, 0]} [id FC]\n", + " │ │ │ │ │ └─ *5- [id FA] -> [id BX]\n", + " │ │ │ │ └─ Transpose{axes=[1, 0]} [id FD]\n", + " │ │ │ │ └─ dot [id EY]\n", + " │ │ │ │ └─ ···\n", + " │ │ │ └─ Mul [id FE]\n", + " │ │ │ ├─ Eye{dtype='float64'} [id FF]\n", + " │ │ │ │ ├─ Subtensor{i} [id FG]\n", + " │ │ │ │ │ ├─ Shape [id FH]\n", + " │ │ │ │ │ │ └─ Add [id EJ]\n", + " │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ └─ 0 [id FI]\n", + " │ │ │ │ ├─ Subtensor{i} [id FJ]\n", + " │ │ │ │ │ ├─ Shape [id FK]\n", + " │ │ │ │ │ │ └─ Add [id EJ]\n", + " │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ └─ 1 [id FL]\n", + " │ │ │ │ └─ 0 [id FM]\n", + " │ │ │ └─ ExpandDims{axes=[0, 1]} [id FN]\n", + " │ │ │ └─ 1e-08 [id FO]\n", + " │ │ └─ *4- [id EQ] -> [id BV]\n", + " │ └─ *1- [id ER] -> [id CV]\n", + " └─ ExpandDims{axis=1} [id FP]\n", + " └─ Sub [id FQ]\n", + " ├─ *2- [id FR] -> [id CX]\n", + " └─ dot [id FS]\n", + " ├─ *4- [id EQ] -> [id BV]\n", + " └─ *0- [id EB] -> [id CT]\n", + " ← Add [id FT]\n", + " ├─ Add [id FU]\n", + " │ ├─ Add [id FV]\n", + " │ │ ├─ *1- [id ER] -> [id CV]\n", + " │ │ └─ Mul [id FW]\n", + " │ │ ├─ ExpandDims{axes=[0, 1]} [id FX]\n", + " │ │ │ └─ 0.5 [id FY]\n", + " │ │ └─ Add [id FZ]\n", + " │ │ ├─ dot [id GA]\n", + " │ │ │ ├─ dot [id GB]\n", + " │ │ │ │ ├─ Transpose{axes=[1, 0]} [id EE]\n", + " │ │ │ │ │ └─ ···\n", + " │ │ │ │ └─ Sub [id GC]\n", + " │ │ │ │ ├─ *3- [id GD] -> [id DJ]\n", + " │ │ │ │ └─ Add [id EI]\n", + " │ │ │ │ └─ ···\n", + " │ │ │ └─ Transpose{axes=[1, 0]} [id GE]\n", + " │ │ │ └─ Transpose{axes=[1, 0]} [id EE]\n", + " │ │ │ └─ ···\n", + " │ │ └─ Transpose{axes=[1, 0]} [id GF]\n", + " │ │ └─ dot [id GA]\n", + " │ │ └─ ···\n", + " │ └─ Mul [id GG]\n", + " │ ├─ Eye{dtype='float64'} [id GH]\n", + " │ │ ├─ Subtensor{i} [id GI]\n", + " │ │ │ ├─ Shape [id GJ]\n", + " │ │ │ │ └─ Add [id FV]\n", + " │ │ │ │ └─ ···\n", + " │ │ │ └─ 0 [id GK]\n", + " │ │ ├─ Subtensor{i} [id GL]\n", + " │ │ │ ├─ Shape [id GM]\n", + " │ │ │ │ └─ Add [id FV]\n", + " │ │ │ │ └─ ···\n", + " │ │ │ └─ 1 [id GN]\n", + " │ │ └─ 0 [id GO]\n", + " │ └─ ExpandDims{axes=[0, 1]} [id GP]\n", + " │ └─ 1e-08 [id GQ]\n", + " └─ Mul [id GR]\n", + " ├─ Eye{dtype='float64'} [id GS]\n", + " │ ├─ Subtensor{i} [id GT]\n", + " │ │ ├─ Shape [id GU]\n", + " │ │ │ └─ Add [id FU]\n", + " │ │ │ └─ ···\n", + " │ │ └─ 0 [id GV]\n", + " │ ├─ Subtensor{i} [id GW]\n", + " │ │ ├─ Shape [id GX]\n", + " │ │ │ └─ Add [id FU]\n", + " │ │ │ └─ ···\n", + " │ │ └─ 1 [id GY]\n", + " │ └─ 0 [id GZ]\n", + " └─ ExpandDims{axes=[0, 1]} [id HA]\n", + " └─ 1e-08 [id HB]\n", + "\n", + "Scan{forward_kalman_pass, while_loop=False, inplace=none} [id M]\n", + " ← Add [id HC]\n", + " ├─ dot [id HD]\n", + " │ ├─ *5- [id HE] -> [id BV]\n", + " │ └─ Add [id HF]\n", + " │ ├─ *1- [id HG] -> [id V]\n", + " │ └─ dot [id HH]\n", + " │ ├─ Transpose{axes=[1, 0]} [id HI]\n", + " │ │ └─ Blockwise{Solve{assume_a='pos', lower=False, check_finite=False, b_ndim=2, overwrite_a=False, overwrite_b=False}, (m,m),(m,n)->(m,n)} [id HJ]\n", + " │ │ ├─ Transpose{axes=[1, 0]} [id HK]\n", + " │ │ │ └─ Add [id HL]\n", + " │ │ │ ├─ dot [id HM]\n", + " │ │ │ │ ├─ dot [id HN]\n", + " │ │ │ │ │ ├─ AllocDiag{self.axis1=0, self.axis2=1, self.offset=0} [id HO]\n", + " │ │ │ │ │ │ └─ Cast{float64} [id HP]\n", + " │ │ │ │ │ │ └─ Invert [id HQ]\n", + " │ │ │ │ │ │ └─ Or [id HR]\n", + " │ │ │ │ │ │ ├─ Isnan [id HS]\n", + " │ │ │ │ │ │ │ └─ *0- [id HT] -> [id T]\n", + " │ │ │ │ │ │ └─ Eq [id HU]\n", + " │ │ │ │ │ │ ├─ *0- [id HT] -> [id T]\n", + " │ │ │ │ │ │ └─ ExpandDims{axis=0} [id HV]\n", + " │ │ │ │ │ │ └─ -9999.0 [id HW]\n", + " │ │ │ │ │ └─ *6- [id HX] -> [id BW]\n", + " │ │ │ │ └─ dot [id HY]\n", + " │ │ │ │ ├─ *2- [id HZ] -> [id BG]\n", + " │ │ │ │ └─ Transpose{axes=[1, 0]} [id IA]\n", + " │ │ │ │ └─ dot [id HN]\n", + " │ │ │ │ └─ ···\n", + " │ │ │ └─ Add [id IB]\n", + " │ │ │ ├─ dot [id IC]\n", + " │ │ │ │ ├─ AllocDiag{self.axis1=0, self.axis2=1, self.offset=0} [id HO]\n", + " │ │ │ │ │ └─ ···\n", + " │ │ │ │ └─ *8- [id ID] -> [id BY]\n", + " │ │ │ └─ Mul [id IE]\n", + " │ │ │ ├─ Eye{dtype='float64'} [id IF]\n", + " │ │ │ │ ├─ Subtensor{i} [id IG]\n", + " │ │ │ │ │ ├─ Shape [id IH]\n", + " │ │ │ │ │ │ └─ dot [id IC]\n", + " │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ └─ 0 [id II]\n", + " │ │ │ │ ├─ Subtensor{i} [id IJ]\n", + " │ │ │ │ │ ├─ Shape [id IK]\n", + " │ │ │ │ │ │ └─ dot [id IC]\n", + " │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ └─ 1 [id IL]\n", + " │ │ │ │ └─ 0 [id IM]\n", + " │ │ │ └─ ExpandDims{axes=[0, 1]} [id IN]\n", + " │ │ │ └─ 1e-08 [id IO]\n", + " │ │ └─ Transpose{axes=[1, 0]} [id IP]\n", + " │ │ └─ dot [id HY]\n", + " │ │ └─ ···\n", + " │ └─ Sub [id IQ]\n", + " │ ├─ AdvancedSetSubtensor [id IR]\n", + " │ │ ├─ *0- [id HT] -> [id T]\n", + " │ │ ├─ 0.0 [id IS]\n", + " │ │ └─ Or [id HR]\n", + " │ │ └─ ···\n", + " │ └─ Add [id IT]\n", + " │ ├─ *4- [id IU] -> [id BU]\n", + " │ └─ dot [id IV]\n", + " │ ├─ dot [id HN]\n", + " │ │ └─ ···\n", + " │ └─ *1- [id HG] -> [id V]\n", + " └─ *3- [id IW] -> [id BT]\n", + " ← Add [id IX]\n", + " ├─ Mul [id IY]\n", + " │ ├─ ExpandDims{axes=[0, 1]} [id IZ]\n", + " │ │ └─ 0.5 [id JA]\n", + " │ └─ Add [id JB]\n", + " │ ├─ dot [id JC]\n", + " │ │ ├─ dot [id JD]\n", + " │ │ │ ├─ *5- [id HE] -> [id BV]\n", + " │ │ │ └─ Add [id JE]\n", + " │ │ │ ├─ Add [id JF]\n", + " │ │ │ │ ├─ Mul [id JG]\n", + " │ │ │ │ │ ├─ ExpandDims{axes=[0, 1]} [id JH]\n", + " │ │ │ │ │ │ └─ 0.5 [id JI]\n", + " │ │ │ │ │ └─ Add [id JJ]\n", + " │ │ │ │ │ ├─ dot [id JK]\n", + " │ │ │ │ │ │ ├─ dot [id JL]\n", + " │ │ │ │ │ │ │ ├─ Sub [id JM]\n", + " │ │ │ │ │ │ │ │ ├─ Eye{dtype='float64'} [id JN]\n", + " │ │ │ │ │ │ │ │ │ ├─ 5 [id JO]\n", + " │ │ │ │ │ │ │ │ │ ├─ 5 [id JP]\n", + " │ │ │ │ │ │ │ │ │ └─ 0 [id JQ]\n", + " │ │ │ │ │ │ │ │ └─ dot [id JR]\n", + " │ │ │ │ │ │ │ │ ├─ Transpose{axes=[1, 0]} [id HI]\n", + " │ │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ │ └─ dot [id HN]\n", + " │ │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ │ └─ *2- [id HZ] -> [id BG]\n", + " │ │ │ │ │ │ └─ Transpose{axes=[1, 0]} [id JS]\n", + " │ │ │ │ │ │ └─ Sub [id JM]\n", + " │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ └─ Transpose{axes=[1, 0]} [id JT]\n", + " │ │ │ │ │ └─ dot [id JK]\n", + " │ │ │ │ │ └─ ···\n", + " │ │ │ │ └─ Mul [id JU]\n", + " │ │ │ │ ├─ ExpandDims{axes=[0, 1]} [id JV]\n", + " │ │ │ │ │ └─ 0.5 [id JW]\n", + " │ │ │ │ └─ Add [id JX]\n", + " │ │ │ │ ├─ dot [id JY]\n", + " │ │ │ │ │ ├─ dot [id JZ]\n", + " │ │ │ │ │ │ ├─ Transpose{axes=[1, 0]} [id HI]\n", + " │ │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ │ └─ dot [id IC]\n", + " │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ └─ Transpose{axes=[1, 0]} [id KA]\n", + " │ │ │ │ │ └─ Transpose{axes=[1, 0]} [id HI]\n", + " │ │ │ │ │ └─ ···\n", + " │ │ │ │ └─ Transpose{axes=[1, 0]} [id KB]\n", + " │ │ │ │ └─ dot [id JY]\n", + " │ │ │ │ └─ ···\n", + " │ │ │ └─ Mul [id KC]\n", + " │ │ │ ├─ Eye{dtype='float64'} [id KD]\n", + " │ │ │ │ ├─ Subtensor{i} [id KE]\n", + " │ │ │ │ │ ├─ Shape [id KF]\n", + " │ │ │ │ │ │ └─ Add [id JF]\n", + " │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ └─ 0 [id KG]\n", + " │ │ │ │ ├─ Subtensor{i} [id KH]\n", + " │ │ │ │ │ ├─ Shape [id KI]\n", + " │ │ │ │ │ │ └─ Add [id JF]\n", + " │ │ │ │ │ │ └─ ···\n", + " │ │ │ │ │ └─ 1 [id KJ]\n", + " │ │ │ │ └─ 0 [id KK]\n", + " │ │ │ └─ ExpandDims{axes=[0, 1]} [id KL]\n", + " │ │ │ └─ 1e-08 [id KM]\n", + " │ │ └─ Transpose{axes=[1, 0]} [id KN]\n", + " │ │ └─ *5- [id HE] -> [id BV]\n", + " │ └─ Transpose{axes=[1, 0]} [id KO]\n", + " │ └─ dot [id JC]\n", + " │ └─ ···\n", + " └─ Mul [id KP]\n", + " ├─ ExpandDims{axes=[0, 1]} [id KQ]\n", + " │ └─ 0.5 [id KR]\n", + " └─ Add [id KS]\n", + " ├─ dot [id KT]\n", + " │ ├─ dot [id KU]\n", + " │ │ ├─ *7- [id KV] -> [id BX]\n", + " │ │ └─ *9- [id KW] -> [id BZ]\n", + " │ └─ Transpose{axes=[1, 0]} [id KX]\n", + " │ └─ *7- [id KV] -> [id BX]\n", + " └─ Transpose{axes=[1, 0]} [id KY]\n", + " └─ dot [id KT]\n", + " └─ ···\n", + " ← Add [id HF]\n", + " └─ ···\n", + " ← Add [id IT]\n", + " └─ ···\n", + " ← Add [id JE]\n", + " └─ ···\n", + " ← Add [id HL]\n", + " └─ ···\n", + " ← Switch [id KZ]\n", + " ├─ Cast{float64} [id LA]\n", + " │ └─ All{axes=None} [id LB]\n", + " │ └─ Or [id HR]\n", + " │ └─ ···\n", + " ├─ 0.0 [id LC]\n", + " └─ Mul [id LD]\n", + " ├─ -0.5 [id LE]\n", + " └─ Subtensor{i} [id LF]\n", + " ├─ Reshape{1} [id LG]\n", + " │ ├─ Add [id LH]\n", + " │ │ ├─ Add [id LI]\n", + " │ │ │ ├─ Log [id LJ]\n", + " │ │ │ │ └─ Mul [id LK]\n", + " │ │ │ │ ├─ 2 [id LL]\n", + " │ │ │ │ └─ 3.141592653589793 [id LM]\n", + " │ │ │ └─ Log [id LN]\n", + " │ │ │ └─ Blockwise{Det, (m,m)->()} [id LO]\n", + " │ │ │ └─ Add [id HL]\n", + " │ │ │ └─ ···\n", + " │ │ └─ dot [id LP]\n", + " │ │ ├─ Sub [id IQ]\n", + " │ │ │ └─ ···\n", + " │ │ └─ Blockwise{Solve{assume_a='pos', lower=False, check_finite=False, b_ndim=1, overwrite_a=False, overwrite_b=False}, (m,m),(m)->(m)} [id LQ]\n", + " │ │ ├─ Add [id HL]\n", + " │ │ │ └─ ···\n", + " │ │ └─ Sub [id IQ]\n", + " │ │ └─ ···\n", + " │ └─ [-1] [id LR]\n", + " └─ 0 [id LS]\n", + "\n", + "AllocDiag{self.axis1=0, self.axis2=1, self.offset=0} [id HO]\n", + " ← AdvancedSetSubtensor [id LT]\n", + " ├─ Alloc [id LU]\n", + " │ ├─ 0.0 [id LV]\n", + " │ ├─ Add [id LW]\n", + " │ │ ├─ Subtensor{i} [id LX]\n", + " │ │ │ ├─ Shape [id LY]\n", + " │ │ │ │ └─ *0- [id HT]\n", + " │ │ │ └─ -1 [id LZ]\n", + " │ │ └─ 0 [id MA]\n", + " │ └─ Add [id LW]\n", + " │ └─ ···\n", + " ├─ *0- [id HT]\n", + " ├─ Add [id MB]\n", + " │ ├─ ARange{dtype='int64'} [id MC]\n", + " │ │ ├─ 0 [id MD]\n", + " │ │ ├─ Subtensor{i} [id ME]\n", + " │ │ │ ├─ Shape [id MF]\n", + " │ │ │ │ └─ *0- [id HT]\n", + " │ │ │ └─ -1 [id MG]\n", + " │ │ └─ 1 [id MH]\n", + " │ └─ ExpandDims{axis=0} [id MI]\n", + " │ └─ 0 [id MJ]\n", + " └─ Add [id MK]\n", + " ├─ ARange{dtype='int64'} [id MC]\n", + " │ └─ ···\n", + " └─ ExpandDims{axis=0} [id ML]\n", + " └─ 0 [id MM]\n" + ] + }, + { + "data": { + "text/plain": [ + "(3, 10, 5)" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pt.vectorize(build_fk, signature=signature)(*[pt.as_tensor(x) for x in np_batch_inputs])[\n", + " 0\n", + "].eval().shape" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "a8c1a39f", + "metadata": {}, + "outputs": [], + "source": [ + "def make_signature(inputs, outputs):\n", + " states = \"s\"\n", + " obs = \"p\"\n", + " exog = \"r\"\n", + " time = \"t\"\n", + "\n", + " matrix_to_shape = {\n", + " \"data\": (time, obs),\n", + " \"a0\": (states,),\n", + " \"P0\": (states, states),\n", + " \"c\": (states,),\n", + " \"d\": (obs,),\n", + " \"T\": (states, states),\n", + " \"Z\": (obs, states),\n", + " \"R\": (states, exog),\n", + " \"H\": (obs, obs),\n", + " \"Q\": (exog, exog),\n", + " \"filtered_states\": (time, states),\n", + " \"filtered_covariances\": (time, states, states),\n", + " \"predicted_states\": (time, states),\n", + " \"predicted_covariances\": (time, states, states),\n", + " \"observed_states\": (time, obs),\n", + " \"observed_covariances\": (time, obs, obs),\n", + " \"smoothed_states\": (time, states),\n", + " \"smoothed_covariances\": (time, states, states),\n", + " \"loglike_obs\": (time,),\n", + " }\n", + " input_shapes = []\n", + " output_shapes = []\n", + "\n", + " for matrix in inputs:\n", + " name = matrix.name\n", + " input_shapes.append(matrix_to_shape[name])\n", + "\n", + " for matrix in outputs:\n", + " print(matrix, matrix.name)\n", + " name = matrix.name\n", + " output_shapes.append(matrix_to_shape[name])\n", + "\n", + " input_signature = \",\".join([\"(\" + \",\".join(shapes) + \")\" for shapes in input_shapes])\n", + " output_signature = \",\".join([\"(\" + \",\".join(shapes) + \")\" for shapes in output_shapes])\n", + "\n", + " return f\"{input_signature} -> {output_signature}\"" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "828ce742", + "metadata": {}, + "outputs": [], + "source": [ + "floatX = \"float64\"\n", + "data = pt.tensor(name=\"data\", dtype=floatX, shape=(None, None))\n", + "a0 = pt.vector(name=\"a0\", dtype=floatX)\n", + "P0 = pt.matrix(name=\"P0\", dtype=floatX)\n", + "c = pt.vector(name=\"c\", dtype=floatX)\n", + "d = pt.vector(name=\"d\", dtype=floatX)\n", + "Q = pt.tensor(name=\"Q\", dtype=floatX, shape=(None, None, None))\n", + "H = pt.tensor(name=\"H\", dtype=floatX, shape=(None, None, None))\n", + "T = pt.tensor(name=\"T\", dtype=floatX, shape=(None, None, None))\n", + "R = pt.tensor(name=\"R\", dtype=floatX, shape=(None, None, None))\n", + "Z = pt.tensor(name=\"Z\", dtype=floatX, shape=(None, None, None))\n", + "\n", + "inputs = [data, a0, P0, c, d, T, Z, R, H, Q]" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "52e105e3", + "metadata": {}, + "outputs": [], + "source": [ + "outputs = build_fk(*inputs)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "9b5d94ab", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "filtered_states filtered_states\n", + "predicted_states predicted_states\n", + "observed_states observed_states\n", + "filtered_covariances filtered_covariances\n", + "predicted_covariances predicted_covariances\n", + "observed_covariances observed_covariances\n", + "loglike_obs loglike_obs\n", + "smoothed_states smoothed_states\n", + "smoothed_covariances smoothed_covariances\n" + ] + }, + { + "data": { + "text/plain": [ + "'(t,p),(s),(s,s),(s),(p),(s,s),(p,s),(s,r),(p,p),(r,r) -> (t,s),(t,s),(t,p),(t,s,s),(t,s,s),(t,p,p),(t),(t,s),(t,s,s)'" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "make_signature(inputs, outputs)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ce8e287b", + "metadata": {}, + "outputs": [], + "source": [ + "signature = \"(t, o), (s), (s, s), (s), (o), (s, s), (o, s), (s, p), (o, o), (p, p) -> (t, s), (t, s), (t, o), (t, s, s), (t, s, s), (t, o, o), (t), (t, s), (t, s, s)\"" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "8a2632bc", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "filtered_states filtered_states\n", + "predicted_states predicted_states\n", + "observed_states observed_states\n", + "filtered_covariances filtered_covariances\n", + "predicted_covariances predicted_covariances\n", + "observed_covariances observed_covariances\n", + "loglike_obs loglike_obs\n", + "smoothed_states smoothed_states\n", + "smoothed_covariances smoothed_covariances\n" + ] + }, + { + "data": { + "text/plain": [ + "(3, 10, 5)" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pt.vectorize(build_fk, signature=make_signature(inputs, outputs))(\n", + " *[pt.as_tensor(x) for x in np_batch_inputs]\n", + ")[0].eval().shape" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "bd771148", + "metadata": {}, + "outputs": [], + "source": [ + "kf = StandardFilter()\n", + "ks = KalmanSmoother()" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "e523bf60", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "filtered_states filtered_states\n", + "predicted_states predicted_states\n", + "observed_states observed_states\n", + "filtered_covariances filtered_covariances\n", + "predicted_covariances predicted_covariances\n", + "observed_covariances observed_covariances\n", + "loglike_obs loglike_obs\n" + ] + } + ], + "source": [ + "kf_outputs = kf.build_graph(*inputs)\n", + "kf_signature = make_signature(inputs, kf_outputs)" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "e651e683", + "metadata": {}, + "outputs": [], + "source": [ + "make_batched_kf = pt.vectorize(kf.build_graph, signature=kf_signature)\n", + "ks_inputs = [T, R, Q, kf_outputs[0], kf_outputs[3]]\n", + "ks_outputs = ks.build_graph(*ks_inputs)" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "272c49f5", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "smoothed_states smoothed_states\n", + "smoothed_covariances smoothed_covariances\n" + ] + } + ], + "source": [ + "ks_signature = make_signature(ks_inputs, ks_outputs)\n", + "make_batched_ks = pt.vectorize(ks.build_graph, signature=ks_signature)" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "0f9c8aa8", + "metadata": {}, + "outputs": [], + "source": [ + "batched_kf_outputs = make_batched_kf(*[pt.as_tensor(x) for x in np_batch_inputs])" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "32c57d14", + "metadata": {}, + "outputs": [], + "source": [ + "data, a0, P0, c, d, T, Z, R, H, Q = np_batch_inputs" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "9c7f5519", + "metadata": {}, + "outputs": [], + "source": [ + "batched_ks_outputs = make_batched_ks(\n", + " *[pt.as_tensor_variable(x) for x in [T, R, Q, batched_kf_outputs[0], batched_kf_outputs[3]]]\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "875ea24a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(3, 10, 5)" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "batched_ks_outputs[0].eval().shape" + ] + }, + { + "cell_type": "markdown", + "id": "d65f4814", + "metadata": {}, + "source": [ + "# Test example: French Presidents' Approval" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "e40a7600", + "metadata": {}, + "outputs": [], + "source": [ + "%load_ext autoreload\n", + "%autoreload 2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9ab99eb5", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "import pandas as pd\n", + "import pymc as pm\n", + "import pymc_extras.statespace as pmss\n", + "import pytensor.tensor as pt\n", + "import xarray as xr" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "08329289", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
datepresidentsondagesamplesizemethodapprove_prdisapprove_prdaymonthyear
8622002-05-15chirac2Ifop924phone51.044.01552002
8632002-05-20chirac2Kantar972face to face50.048.02052002
8642002-05-23chirac2BVA1054phone52.037.02352002
8652002-05-26chirac2Ipsos907phone48.048.02652002
8662002-06-16chirac2Ifop974phone49.043.01662002
.................................
20302022-05-21macron2Ifop1946phone&internet41.058.02152022
20312022-05-25macron2Odoxa1005internet44.056.02552022
20322022-05-26macron2Harris1002internet49.051.02652022
20332022-05-30macron2Kantar1000internet37.056.03052022
20342022-06-01macron2Elabe2000internet32.059.0162022
\n", + "

1173 rows × 10 columns

\n", + "
" + ], + "text/plain": [ + " date president sondage samplesize method approve_pr \\\n", + "862 2002-05-15 chirac2 Ifop 924 phone 51.0 \n", + "863 2002-05-20 chirac2 Kantar 972 face to face 50.0 \n", + "864 2002-05-23 chirac2 BVA 1054 phone 52.0 \n", + "865 2002-05-26 chirac2 Ipsos 907 phone 48.0 \n", + "866 2002-06-16 chirac2 Ifop 974 phone 49.0 \n", + "... ... ... ... ... ... ... \n", + "2030 2022-05-21 macron2 Ifop 1946 phone&internet 41.0 \n", + "2031 2022-05-25 macron2 Odoxa 1005 internet 44.0 \n", + "2032 2022-05-26 macron2 Harris 1002 internet 49.0 \n", + "2033 2022-05-30 macron2 Kantar 1000 internet 37.0 \n", + "2034 2022-06-01 macron2 Elabe 2000 internet 32.0 \n", + "\n", + " disapprove_pr day month year \n", + "862 44.0 15 5 2002 \n", + "863 48.0 20 5 2002 \n", + "864 37.0 23 5 2002 \n", + "865 48.0 26 5 2002 \n", + "866 43.0 16 6 2002 \n", + "... ... ... ... ... \n", + "2030 58.0 21 5 2022 \n", + "2031 56.0 25 5 2022 \n", + "2032 51.0 26 5 2022 \n", + "2033 56.0 30 5 2022 \n", + "2034 59.0 1 6 2022 \n", + "\n", + "[1173 rows x 10 columns]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data = pd.read_csv(\"popularite.csv\", index_col=0).reset_index().rename(columns={\"index\": \"date\"})\n", + "data = data[data.president.isin([\"chirac2\", \"sarkozy\", \"hollande\", \"macron\", \"macron2\"])]\n", + "data[\"date\"] = pd.to_datetime(data[\"date\"])\n", + "data[[\"day\", \"month\", \"year\"]] = data[\"date\"].apply(lambda x: pd.Series([x.day, x.month, x.year]))\n", + "data" + ] + }, + { + "cell_type": "markdown", + "id": "1a7690db", + "metadata": {}, + "source": [ + "## Just for testing: average over months" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "8e110a0a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
presidentyearmonthsamplesizeapprove_prdisapprove_prdaydatemonth_id
0chirac220025964.25000050.25000044.25000021.0000002002-05-010
1chirac220026970.00000050.50000042.50000020.0000002002-06-011
2chirac220027947.33333353.33333340.66666721.0000002002-07-012
3chirac2200281028.00000052.00000041.66666720.3333332002-08-013
4chirac2200291017.50000052.50000042.00000021.2500002002-09-014
..............................
238sarkozy201112990.66666733.00000065.00000020.3333332011-12-0155
239sarkozy201211033.50000031.75000066.50000019.7500002012-01-0156
240sarkozy201221000.50000031.75000066.50000018.2500002012-02-0157
241sarkozy201231022.50000035.00000063.00000020.2500002012-03-0158
242sarkozy20124995.00000037.66666760.66666720.6666672012-04-0159
\n", + "

243 rows × 9 columns

\n", + "
" + ], + "text/plain": [ + " president year month samplesize approve_pr disapprove_pr day \\\n", + "0 chirac2 2002 5 964.250000 50.250000 44.250000 21.000000 \n", + "1 chirac2 2002 6 970.000000 50.500000 42.500000 20.000000 \n", + "2 chirac2 2002 7 947.333333 53.333333 40.666667 21.000000 \n", + "3 chirac2 2002 8 1028.000000 52.000000 41.666667 20.333333 \n", + "4 chirac2 2002 9 1017.500000 52.500000 42.000000 21.250000 \n", + ".. ... ... ... ... ... ... ... \n", + "238 sarkozy 2011 12 990.666667 33.000000 65.000000 20.333333 \n", + "239 sarkozy 2012 1 1033.500000 31.750000 66.500000 19.750000 \n", + "240 sarkozy 2012 2 1000.500000 31.750000 66.500000 18.250000 \n", + "241 sarkozy 2012 3 1022.500000 35.000000 63.000000 20.250000 \n", + "242 sarkozy 2012 4 995.000000 37.666667 60.666667 20.666667 \n", + "\n", + " date month_id \n", + "0 2002-05-01 0 \n", + "1 2002-06-01 1 \n", + "2 2002-07-01 2 \n", + "3 2002-08-01 3 \n", + "4 2002-09-01 4 \n", + ".. ... ... \n", + "238 2011-12-01 55 \n", + "239 2012-01-01 56 \n", + "240 2012-02-01 57 \n", + "241 2012-03-01 58 \n", + "242 2012-04-01 59 \n", + "\n", + "[243 rows x 9 columns]" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "agg = data.groupby([\"president\", \"year\", \"month\"]).mean(numeric_only=True).reset_index()\n", + "agg[\"date\"] = pd.to_datetime(agg[[\"year\", \"month\"]].assign(DAY=1))\n", + "agg[\"month_id\"] = agg.groupby([\"president\"]).cumcount().to_numpy()\n", + "agg" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "81f84589", + "metadata": {}, + "outputs": [], + "source": [ + "presidents = agg.president.unique()" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "03fb6c4e", + "metadata": {}, + "outputs": [], + "source": [ + "mod = pmss.structural.LevelTrendComponent(order=2, innovations_order=[0, 1])\n", + "mod += pmss.structural.AutoregressiveComponent(order=1)\n", + "mod += pmss.structural.MeasurementError(name=\"obs\")" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "cb752615", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "[autoreload of cutils_ext failed: Traceback (most recent call last):\n", + " File \"/Users/aandorra/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/IPython/extensions/autoreload.py\", line 283, in check\n", + " superreload(m, reload, self.old_objects)\n", + " File \"/Users/aandorra/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/IPython/extensions/autoreload.py\", line 483, in superreload\n", + " module = reload(module)\n", + " ^^^^^^^^^^^^^^\n", + " File \"/Users/aandorra/miniforge3/envs/pymc-extras-test/lib/python3.12/importlib/__init__.py\", line 130, in reload\n", + " raise ModuleNotFoundError(f\"spec not found for the module {name!r}\", name=name)\n", + "ModuleNotFoundError: spec not found for the module 'cutils_ext'\n", + "]\n" + ] + }, + { + "data": { + "text/html": [ + "
                Model Requirements                 \n",
+       "                                                   \n",
+       "  Variable      Shape   Constraints    Dimensions  \n",
+       " ───────────────────────────────────────────────── \n",
+       "  ar_params     (3,)    None          ('ar_lag',)  \n",
+       "  sigma_state   None    Positive             None  \n",
+       "                                                   \n",
+       "These parameters should be assigned priors inside a\n",
+       "        PyMC model block before calling the        \n",
+       "          build_statespace_graph method.           \n",
+       "
\n" + ], + "text/plain": [ + "\u001b[3m Model Requirements \u001b[0m\n", + " \n", + " \u001b[1m \u001b[0m\u001b[1mVariable \u001b[0m\u001b[1m \u001b[0m \u001b[1m \u001b[0m\u001b[1mShape\u001b[0m\u001b[1m \u001b[0m \u001b[1m \u001b[0m\u001b[1mConstraints\u001b[0m\u001b[1m \u001b[0m \u001b[1m \u001b[0m\u001b[1m Dimensions\u001b[0m\u001b[1m \u001b[0m \n", + " ───────────────────────────────────────────────── \n", + " ar_params \u001b[1m(\u001b[0m\u001b[1;36m3\u001b[0m,\u001b[1m)\u001b[0m \u001b[3;35mNone\u001b[0m \u001b[1m(\u001b[0m\u001b[32m'ar_lag'\u001b[0m,\u001b[1m)\u001b[0m \n", + " sigma_state \u001b[3;35mNone\u001b[0m Positive \u001b[3;35mNone\u001b[0m \n", + " \n", + "\u001b[2;3mThese parameters should be assigned priors inside a\u001b[0m\n", + "\u001b[2;3m PyMC model block before calling the \u001b[0m\n", + "\u001b[2;3m build_statespace_graph method. \u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "ss_mod = pmss.BayesianSARIMA(order=(3, 0, 0), batch_coords={\"president\": presidents})" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "54b44a47", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
                             Model Requirements                             \n",
+       "                                                                            \n",
+       "  Variable        Shape    Constraints                          Dimensions  \n",
+       " ────────────────────────────────────────────────────────────────────────── \n",
+       "  initial_trend   (2,)                                    ('trend_state',)  \n",
+       "  sigma_trend     (1,)     Positive                       ('trend_shock',)  \n",
+       "  ar_params       (1,)                                         ('ar_lag',)  \n",
+       "  sigma_ar        ()       Positive                                   None  \n",
+       "  sigma_obs       ()       Positive                                   None  \n",
+       "  P0              (3, 3)   Positive semi-definite   ('state', 'state_aux')  \n",
+       "                                                                            \n",
+       "These parameters should be assigned priors inside a PyMC model block before \n",
+       "                 calling the build_statespace_graph method.                 \n",
+       "
\n" + ], + "text/plain": [ + "\u001b[3m Model Requirements \u001b[0m\n", + " \n", + " \u001b[1m \u001b[0m\u001b[1mVariable \u001b[0m\u001b[1m \u001b[0m \u001b[1m \u001b[0m\u001b[1mShape \u001b[0m\u001b[1m \u001b[0m \u001b[1m \u001b[0m\u001b[1mConstraints \u001b[0m\u001b[1m \u001b[0m \u001b[1m \u001b[0m\u001b[1m Dimensions\u001b[0m\u001b[1m \u001b[0m \n", + " ────────────────────────────────────────────────────────────────────────── \n", + " initial_trend \u001b[1m(\u001b[0m\u001b[1;36m2\u001b[0m,\u001b[1m)\u001b[0m \u001b[1m(\u001b[0m\u001b[32m'trend_state'\u001b[0m,\u001b[1m)\u001b[0m \n", + " sigma_trend \u001b[1m(\u001b[0m\u001b[1;36m1\u001b[0m,\u001b[1m)\u001b[0m Positive \u001b[1m(\u001b[0m\u001b[32m'trend_shock'\u001b[0m,\u001b[1m)\u001b[0m \n", + " ar_params \u001b[1m(\u001b[0m\u001b[1;36m1\u001b[0m,\u001b[1m)\u001b[0m \u001b[1m(\u001b[0m\u001b[32m'ar_lag'\u001b[0m,\u001b[1m)\u001b[0m \n", + " sigma_ar \u001b[1m(\u001b[0m\u001b[1m)\u001b[0m Positive \u001b[3;35mNone\u001b[0m \n", + " sigma_obs \u001b[1m(\u001b[0m\u001b[1m)\u001b[0m Positive \u001b[3;35mNone\u001b[0m \n", + " P0 \u001b[1m(\u001b[0m\u001b[1;36m3\u001b[0m, \u001b[1;36m3\u001b[0m\u001b[1m)\u001b[0m Positive semi-definite \u001b[1m(\u001b[0m\u001b[32m'state'\u001b[0m, \u001b[32m'state_aux'\u001b[0m\u001b[1m)\u001b[0m \n", + " \n", + "\u001b[2;3mThese parameters should be assigned priors inside a PyMC model block before \u001b[0m\n", + "\u001b[2;3m calling the build_statespace_graph method. \u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "ss_mod = mod.build(\n", + " name=\"president\",\n", + " batch_coords={\"president\": presidents}, # this is gonna be leftmost dimension\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "5e811c18", + "metadata": {}, + "outputs": [], + "source": [ + "ss_array = (\n", + " agg.set_index([\"president\", \"month_id\"])[\"approve_pr\"].unstack(\"month_id\").to_numpy()[..., None]\n", + ") # (president, timesteps, obs_dim)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "2945612e", + "metadata": {}, + "outputs": [], + "source": [ + "initial_trend_dims, sigma_trend_dims, ar_param_dims, P0_dims = ss_mod.param_dims.values()\n", + "coords = ss_mod.coords" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "66607080", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'trend_state': ['level', 'trend'],\n", + " 'trend_shock': ['trend'],\n", + " 'ar_lag': [1],\n", + " 'state': ['level', 'trend', 'L1.data'],\n", + " 'state_aux': ['level', 'trend', 'L1.data'],\n", + " 'observed_state': ['president'],\n", + " 'observed_state_aux': ['president'],\n", + " 'shock': ['trend', 'AutoRegressive_innovation'],\n", + " 'shock_aux': ['trend', 'AutoRegressive_innovation']}" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "coords" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3ca25e93", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + ":4: UserWarning: No time index found on the supplied data. A simple range index will be automatically generated.\n", + "/Users/aandorra/open-source/pymc-extras/pymc_extras/statespace/utils/data_tools.py:178: ImputationWarning: Provided data contains missing values and will be automatically imputed as hidden states during Kalman filtering.\n", + " raise ValueError(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "mus_.type.shape: (None, None, 1), covs_.type.shape: (None, None, 1, 1)\n", + "mus.type.shape: (None, None, 1), covs.type.shape: (None, None, 1, 1)\n", + "mvn_seq.type.shape: (None, None, 1)\n", + "mvn_seq.type.shape: (None, None, 1)\n", + "mvn_seq.type.shape: (None, None, 1)\n", + "mvn_seq.type.shape: (None, None, 1)\n", + "mus_.type.shape: (None, None, 1), covs_.type.shape: (None, None, 1, 1)\n", + "mus.type.shape: (None, None, 1), covs.type.shape: (None, None, 1, 1)\n", + "mvn_seq.type.shape: (None, None, 1)\n", + "mvn_seq.type.shape: (None, None, 1)\n", + "mvn_seq.type.shape: (None, None, 1)\n", + "mvn_seq.type.shape: (None, None, 1)\n" + ] + }, + { + "ename": "ValueError", + "evalue": "shape mismatch: value array of shape (5,) could not be broadcast to indexing result of shape (5,1)\nApply node that caused the error: AdvancedSetSubtensor(Alloc.0, Pow.0, SliceConstant{None, None, None}, 0, [0], [0])\nToposort index: 4\nInputs types: [TensorType(float64, shape=(None, 1, 1, 1)), TensorType(float64, shape=(None,)), , TensorType(int64, shape=()), TensorType(int64, shape=(1,)), TensorType(int64, shape=(1,))]\nInputs shapes: [(5, 1, 1, 1), (5,), 'No shapes', (), (1,), (1,)]\nInputs strides: [(8, 8, 8, 8), (8,), 'No strides', (), (8,), (8,)]\nInputs values: [array([[[[0.]]],\n\n\n [[[0.]]],\n\n\n [[[0.]]],\n\n\n [[[0.]]],\n\n\n [[[0.]]]]), array([0.08827229, 0.05365894, 1.10456341, 0.32252835, 0.00666647]), slice(None, None, None), array(0), array([0]), array([0])]\nOutputs clients: [[Squeeze{axis=1}(AdvancedSetSubtensor.0)]]\n\nBacktrace when the node is created (use PyTensor flag traceback__limit=N to make it longer):\n File \"/Users/aandorra/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/IPython/core/interactiveshell.py\", line 3607, in run_ast_nodes\n if await self.run_code(code, result, async_=asy):\n File \"/Users/aandorra/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/IPython/core/interactiveshell.py\", line 3667, in run_code\n exec(code_obj, self.user_global_ns, self.user_ns)\n File \"/var/folders/7b/004t4lgj4_1bc491p3qg41tc0000gp/T/ipykernel_87868/2589321262.py\", line 17, in \n ss_mod.build_statespace_graph(ss_array, mode=\"JAX\")\n File \"\", line 49, in build_statespace_graph\n File \"/Users/aandorra/open-source/pymc-extras/pymc_extras/statespace/core/statespace.py\", line 734, in _insert_random_variables\n self.subbed_ssm = vectorize_graph(matrices, replace=replacement_dict)\n File \"/Users/aandorra/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pytensor/graph/replace.py\", line 301, in vectorize_graph\n vect_node = vectorize_node(node, *vect_inputs)\n File \"/Users/aandorra/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pytensor/graph/replace.py\", line 217, in vectorize_node\n return _vectorize_node(op, node, *batched_inputs)\n File \"/Users/aandorra/miniforge3/envs/pymc-extras-test/lib/python3.12/functools.py\", line 912, in wrapper\n return dispatch(args[0].__class__)(*args, **kw)\n\nHINT: Use the PyTensor flag `exception_verbosity=high` for a debug print-out and storage map footprint of this Apply node.", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mValueError\u001b[39m Traceback (most recent call last)", + "\u001b[36mFile \u001b[39m\u001b[32m~/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pytensor/link/vm.py:406\u001b[39m, in \u001b[36mLoop.__call__\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 403\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m thunk, node, old_storage \u001b[38;5;129;01min\u001b[39;00m zip_longest(\n\u001b[32m 404\u001b[39m \u001b[38;5;28mself\u001b[39m.thunks, \u001b[38;5;28mself\u001b[39m.nodes, \u001b[38;5;28mself\u001b[39m.post_thunk_clear, fillvalue=()\n\u001b[32m 405\u001b[39m ):\n\u001b[32m--> \u001b[39m\u001b[32m406\u001b[39m \u001b[43mthunk\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 407\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m old_s \u001b[38;5;129;01min\u001b[39;00m old_storage:\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pytensor/graph/op.py:531\u001b[39m, in \u001b[36mOp.make_py_thunk..rval\u001b[39m\u001b[34m(p, i, o, n, cm)\u001b[39m\n\u001b[32m 523\u001b[39m \u001b[38;5;129m@is_thunk_type\u001b[39m\n\u001b[32m 524\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mrval\u001b[39m(\n\u001b[32m 525\u001b[39m p=p,\n\u001b[32m (...)\u001b[39m\u001b[32m 529\u001b[39m cm=node_compute_map,\n\u001b[32m 530\u001b[39m ):\n\u001b[32m--> \u001b[39m\u001b[32m531\u001b[39m r = \u001b[43mp\u001b[49m\u001b[43m(\u001b[49m\u001b[43mn\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43mx\u001b[49m\u001b[43m[\u001b[49m\u001b[32;43m0\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mx\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mi\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mo\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 532\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m entry \u001b[38;5;129;01min\u001b[39;00m cm:\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pytensor/tensor/subtensor.py:2873\u001b[39m, in \u001b[36mAdvancedIncSubtensor.perform\u001b[39m\u001b[34m(self, node, inputs, out_)\u001b[39m\n\u001b[32m 2872\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.set_instead_of_inc:\n\u001b[32m-> \u001b[39m\u001b[32m2873\u001b[39m \u001b[43mout\u001b[49m\u001b[43m[\u001b[49m\u001b[32;43m0\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;28;43mtuple\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mindices\u001b[49m\u001b[43m)\u001b[49m\u001b[43m]\u001b[49m = y\n\u001b[32m 2874\u001b[39m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.ignore_duplicates:\n", + "\u001b[31mValueError\u001b[39m: shape mismatch: value array of shape (5,) could not be broadcast to indexing result of shape (5,1)", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[31mValueError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[18]\u001b[39m\u001b[32m, line 19\u001b[39m\n\u001b[32m 17\u001b[39m ss_mod.build_statespace_graph(ss_array, mode=\u001b[33m\"\u001b[39m\u001b[33mJAX\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m 18\u001b[39m \u001b[38;5;66;03m# idata = pm.sample_prior_predictive()\u001b[39;00m\n\u001b[32m---> \u001b[39m\u001b[32m19\u001b[39m \u001b[43mmodel_1\u001b[49m\u001b[43m.\u001b[49m\u001b[43mto_graphviz\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pymc/model/core.py:2029\u001b[39m, in \u001b[36mModel.to_graphviz\u001b[39m\u001b[34m(self, var_names, formatting, save, figsize, dpi)\u001b[39m\n\u001b[32m 1962\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mto_graphviz\u001b[39m(\n\u001b[32m 1963\u001b[39m \u001b[38;5;28mself\u001b[39m,\n\u001b[32m 1964\u001b[39m *,\n\u001b[32m (...)\u001b[39m\u001b[32m 1969\u001b[39m dpi: \u001b[38;5;28mint\u001b[39m = \u001b[32m300\u001b[39m,\n\u001b[32m 1970\u001b[39m ):\n\u001b[32m 1971\u001b[39m \u001b[38;5;250m \u001b[39m\u001b[33;03m\"\"\"Produce a graphviz Digraph from a PyMC model.\u001b[39;00m\n\u001b[32m 1972\u001b[39m \n\u001b[32m 1973\u001b[39m \u001b[33;03m Requires graphviz, which may be installed most easily with\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 2027\u001b[39m \u001b[33;03m schools.to_graphviz().render(\"schools\")\u001b[39;00m\n\u001b[32m 2028\u001b[39m \u001b[33;03m \"\"\"\u001b[39;00m\n\u001b[32m-> \u001b[39m\u001b[32m2029\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mmodel_to_graphviz\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 2030\u001b[39m \u001b[43m \u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 2031\u001b[39m \u001b[43m \u001b[49m\u001b[43mvar_names\u001b[49m\u001b[43m=\u001b[49m\u001b[43mvar_names\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 2032\u001b[39m \u001b[43m \u001b[49m\u001b[43mformatting\u001b[49m\u001b[43m=\u001b[49m\u001b[43mformatting\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 2033\u001b[39m \u001b[43m \u001b[49m\u001b[43msave\u001b[49m\u001b[43m=\u001b[49m\u001b[43msave\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 2034\u001b[39m \u001b[43m \u001b[49m\u001b[43mfigsize\u001b[49m\u001b[43m=\u001b[49m\u001b[43mfigsize\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 2035\u001b[39m \u001b[43m \u001b[49m\u001b[43mdpi\u001b[49m\u001b[43m=\u001b[49m\u001b[43mdpi\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 2036\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pymc/model_graph.py:776\u001b[39m, in \u001b[36mmodel_to_graphviz\u001b[39m\u001b[34m(model, var_names, formatting, save, figsize, dpi, node_formatters, graph_attr, include_dim_lengths)\u001b[39m\n\u001b[32m 772\u001b[39m model = pm.modelcontext(model)\n\u001b[32m 773\u001b[39m graph = ModelGraph(model)\n\u001b[32m 774\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m make_graph(\n\u001b[32m 775\u001b[39m model.name,\n\u001b[32m--> \u001b[39m\u001b[32m776\u001b[39m plates=\u001b[43mgraph\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_plates\u001b[49m\u001b[43m(\u001b[49m\u001b[43mvar_names\u001b[49m\u001b[43m=\u001b[49m\u001b[43mvar_names\u001b[49m\u001b[43m)\u001b[49m,\n\u001b[32m 777\u001b[39m edges=graph.edges(var_names=var_names),\n\u001b[32m 778\u001b[39m formatting=formatting,\n\u001b[32m 779\u001b[39m save=save,\n\u001b[32m 780\u001b[39m figsize=figsize,\n\u001b[32m 781\u001b[39m dpi=dpi,\n\u001b[32m 782\u001b[39m graph_attr=graph_attr,\n\u001b[32m 783\u001b[39m node_formatters=node_formatters,\n\u001b[32m 784\u001b[39m create_plate_label=create_plate_label_with_dim_length\n\u001b[32m 785\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m include_dim_lengths\n\u001b[32m 786\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m create_plate_label_without_dim_length,\n\u001b[32m 787\u001b[39m )\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pymc/model_graph.py:370\u001b[39m, in \u001b[36mModelGraph.get_plates\u001b[39m\u001b[34m(self, var_names)\u001b[39m\n\u001b[32m 363\u001b[39m \u001b[38;5;66;03m# TODO: Evaluate all RV shapes at once\u001b[39;00m\n\u001b[32m 364\u001b[39m \u001b[38;5;66;03m# This should help find discrepencies, and\u001b[39;00m\n\u001b[32m 365\u001b[39m \u001b[38;5;66;03m# avoids unnecessary function compiles for determining labels.\u001b[39;00m\n\u001b[32m 366\u001b[39m dim_lengths: \u001b[38;5;28mdict\u001b[39m[\u001b[38;5;28mstr\u001b[39m, \u001b[38;5;28mint\u001b[39m] = {\n\u001b[32m 367\u001b[39m dim_name: fast_eval(value).item() \u001b[38;5;28;01mfor\u001b[39;00m dim_name, value \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m.model.dim_lengths.items()\n\u001b[32m 368\u001b[39m }\n\u001b[32m 369\u001b[39m var_shapes: \u001b[38;5;28mdict\u001b[39m[\u001b[38;5;28mstr\u001b[39m, \u001b[38;5;28mtuple\u001b[39m[\u001b[38;5;28mint\u001b[39m, ...]] = {\n\u001b[32m--> \u001b[39m\u001b[32m370\u001b[39m var_name: \u001b[38;5;28mtuple\u001b[39m(\u001b[43mfast_eval\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m[\u001b[49m\u001b[43mvar_name\u001b[49m\u001b[43m]\u001b[49m\u001b[43m.\u001b[49m\u001b[43mshape\u001b[49m\u001b[43m)\u001b[49m)\n\u001b[32m 371\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m var_name \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m.vars_to_plot(var_names)\n\u001b[32m 372\u001b[39m }\n\u001b[32m 374\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m var_name \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m.vars_to_plot(var_names):\n\u001b[32m 375\u001b[39m shape: \u001b[38;5;28mtuple\u001b[39m[\u001b[38;5;28mint\u001b[39m, ...] = var_shapes[var_name]\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pymc/model_graph.py:81\u001b[39m, in \u001b[36mfast_eval\u001b[39m\u001b[34m(var)\u001b[39m\n\u001b[32m 80\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mfast_eval\u001b[39m(var):\n\u001b[32m---> \u001b[39m\u001b[32m81\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunction\u001b[49m\u001b[43m(\u001b[49m\u001b[43m[\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvar\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmode\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mFAST_COMPILE\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pytensor/compile/function/types.py:1037\u001b[39m, in \u001b[36mFunction.__call__\u001b[39m\u001b[34m(self, output_subset, *args, **kwargs)\u001b[39m\n\u001b[32m 1035\u001b[39m t0_fn = time.perf_counter()\n\u001b[32m 1036\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m-> \u001b[39m\u001b[32m1037\u001b[39m outputs = \u001b[43mvm\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;28;01mif\u001b[39;00m output_subset \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;28;01melse\u001b[39;00m vm(output_subset=output_subset)\n\u001b[32m 1038\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m:\n\u001b[32m 1039\u001b[39m \u001b[38;5;28mself\u001b[39m._restore_defaults()\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pytensor/link/vm.py:410\u001b[39m, in \u001b[36mLoop.__call__\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 408\u001b[39m old_s[\u001b[32m0\u001b[39m] = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 409\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m410\u001b[39m \u001b[43mraise_with_op\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mfgraph\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnode\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mthunk\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 412\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m.perform_updates()\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pytensor/link/utils.py:526\u001b[39m, in \u001b[36mraise_with_op\u001b[39m\u001b[34m(fgraph, node, thunk, exc_info, storage_map)\u001b[39m\n\u001b[32m 521\u001b[39m warnings.warn(\n\u001b[32m 522\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mexc_type\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m error does not allow us to add an extra error message\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 523\u001b[39m )\n\u001b[32m 524\u001b[39m \u001b[38;5;66;03m# Some exception need extra parameter in inputs. So forget the\u001b[39;00m\n\u001b[32m 525\u001b[39m \u001b[38;5;66;03m# extra long error message in that case.\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m526\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m exc_value.with_traceback(exc_trace)\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pytensor/link/vm.py:406\u001b[39m, in \u001b[36mLoop.__call__\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 402\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m 403\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m thunk, node, old_storage \u001b[38;5;129;01min\u001b[39;00m zip_longest(\n\u001b[32m 404\u001b[39m \u001b[38;5;28mself\u001b[39m.thunks, \u001b[38;5;28mself\u001b[39m.nodes, \u001b[38;5;28mself\u001b[39m.post_thunk_clear, fillvalue=()\n\u001b[32m 405\u001b[39m ):\n\u001b[32m--> \u001b[39m\u001b[32m406\u001b[39m \u001b[43mthunk\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 407\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m old_s \u001b[38;5;129;01min\u001b[39;00m old_storage:\n\u001b[32m 408\u001b[39m old_s[\u001b[32m0\u001b[39m] = \u001b[38;5;28;01mNone\u001b[39;00m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pytensor/graph/op.py:531\u001b[39m, in \u001b[36mOp.make_py_thunk..rval\u001b[39m\u001b[34m(p, i, o, n, cm)\u001b[39m\n\u001b[32m 523\u001b[39m \u001b[38;5;129m@is_thunk_type\u001b[39m\n\u001b[32m 524\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mrval\u001b[39m(\n\u001b[32m 525\u001b[39m p=p,\n\u001b[32m (...)\u001b[39m\u001b[32m 529\u001b[39m cm=node_compute_map,\n\u001b[32m 530\u001b[39m ):\n\u001b[32m--> \u001b[39m\u001b[32m531\u001b[39m r = \u001b[43mp\u001b[49m\u001b[43m(\u001b[49m\u001b[43mn\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43mx\u001b[49m\u001b[43m[\u001b[49m\u001b[32;43m0\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mx\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mi\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mo\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 532\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m entry \u001b[38;5;129;01min\u001b[39;00m cm:\n\u001b[32m 533\u001b[39m entry[\u001b[32m0\u001b[39m] = \u001b[38;5;28;01mTrue\u001b[39;00m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pytensor/tensor/subtensor.py:2873\u001b[39m, in \u001b[36mAdvancedIncSubtensor.perform\u001b[39m\u001b[34m(self, node, inputs, out_)\u001b[39m\n\u001b[32m 2870\u001b[39m out[\u001b[32m0\u001b[39m] = x\n\u001b[32m 2872\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.set_instead_of_inc:\n\u001b[32m-> \u001b[39m\u001b[32m2873\u001b[39m \u001b[43mout\u001b[49m\u001b[43m[\u001b[49m\u001b[32;43m0\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;28;43mtuple\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mindices\u001b[49m\u001b[43m)\u001b[49m\u001b[43m]\u001b[49m = y\n\u001b[32m 2874\u001b[39m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.ignore_duplicates:\n\u001b[32m 2875\u001b[39m out[\u001b[32m0\u001b[39m][\u001b[38;5;28mtuple\u001b[39m(indices)] += y\n", + "\u001b[31mValueError\u001b[39m: shape mismatch: value array of shape (5,) could not be broadcast to indexing result of shape (5,1)\nApply node that caused the error: AdvancedSetSubtensor(Alloc.0, Pow.0, SliceConstant{None, None, None}, 0, [0], [0])\nToposort index: 4\nInputs types: [TensorType(float64, shape=(None, 1, 1, 1)), TensorType(float64, shape=(None,)), , TensorType(int64, shape=()), TensorType(int64, shape=(1,)), TensorType(int64, shape=(1,))]\nInputs shapes: [(5, 1, 1, 1), (5,), 'No shapes', (), (1,), (1,)]\nInputs strides: [(8, 8, 8, 8), (8,), 'No strides', (), (8,), (8,)]\nInputs values: [array([[[[0.]]],\n\n\n [[[0.]]],\n\n\n [[[0.]]],\n\n\n [[[0.]]],\n\n\n [[[0.]]]]), array([0.08827229, 0.05365894, 1.10456341, 0.32252835, 0.00666647]), slice(None, None, None), array(0), array([0]), array([0])]\nOutputs clients: [[Squeeze{axis=1}(AdvancedSetSubtensor.0)]]\n\nBacktrace when the node is created (use PyTensor flag traceback__limit=N to make it longer):\n File \"/Users/aandorra/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/IPython/core/interactiveshell.py\", line 3607, in run_ast_nodes\n if await self.run_code(code, result, async_=asy):\n File \"/Users/aandorra/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/IPython/core/interactiveshell.py\", line 3667, in run_code\n exec(code_obj, self.user_global_ns, self.user_ns)\n File \"/var/folders/7b/004t4lgj4_1bc491p3qg41tc0000gp/T/ipykernel_87868/2589321262.py\", line 17, in \n ss_mod.build_statespace_graph(ss_array, mode=\"JAX\")\n File \"\", line 49, in build_statespace_graph\n File \"/Users/aandorra/open-source/pymc-extras/pymc_extras/statespace/core/statespace.py\", line 734, in _insert_random_variables\n self.subbed_ssm = vectorize_graph(matrices, replace=replacement_dict)\n File \"/Users/aandorra/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pytensor/graph/replace.py\", line 301, in vectorize_graph\n vect_node = vectorize_node(node, *vect_inputs)\n File \"/Users/aandorra/miniforge3/envs/pymc-extras-test/lib/python3.12/site-packages/pytensor/graph/replace.py\", line 217, in vectorize_node\n return _vectorize_node(op, node, *batched_inputs)\n File \"/Users/aandorra/miniforge3/envs/pymc-extras-test/lib/python3.12/functools.py\", line 912, in wrapper\n return dispatch(args[0].__class__)(*args, **kw)\n\nHINT: Use the PyTensor flag `exception_verbosity=high` for a debug print-out and storage map footprint of this Apply node." + ] + } + ], + "source": [ + "with pm.Model(coords=coords | ss_mod.batch_coords) as model_1:\n", + " P0_diag = pm.Gamma(\"P0_diag\", alpha=5, beta=5, dims=\"president\")\n", + " P0 = pm.Deterministic(\n", + " \"P0\", pt.eye(ss_mod.k_states)[None] * P0_diag[..., None, None], dims=(\"president\", *P0_dims)\n", + " )\n", + "\n", + " initial_trend = pm.Normal(\"initial_trend\", dims=(\"president\", *initial_trend_dims))\n", + " ar_params = pm.Beta(\"ar_params\", alpha=3, beta=3, dims=(\"president\", *ar_param_dims))\n", + "\n", + " sigma_trend = pm.Gamma(\"sigma_trend\", alpha=2, beta=50, dims=(\"president\", *sigma_trend_dims))\n", + " sigma_ar = pm.Gamma(\"sigma_ar\", alpha=2, beta=5, dims=\"president\")\n", + " sigma_obs = pm.HalfNormal(\"sigma_obs\", sigma=0.05, dims=\"president\")\n", + "\n", + " ss_mod.build_statespace_graph(ss_array, mode=\"JAX\")\n", + " # idata = pm.sample_prior_predictive()\n", + "model_1.to_graphviz()" + ] + }, + { + "cell_type": "markdown", + "id": "6f5516ec", + "metadata": {}, + "source": [ + "## Real use case" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "01efa5d9", + "metadata": {}, + "outputs": [], + "source": [ + "data[\"month_id\"] = np.hstack(\n", + " [\n", + " pd.Categorical(data[data.president == president][\"date\"].dt.to_period(\"M\")).codes\n", + " for president in data.president.unique()\n", + " ]\n", + ")\n", + "months = np.arange(max(data[\"month_id\"]) + 1)" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "id": "0b99a1c0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
datepresidentsondagesamplesizemethodapprove_prdisapprove_prdaymonthyearmonth_id
8622002-05-15chirac2Ifop924phone51.044.015520020
8632002-05-20chirac2Kantar972face to face50.048.020520020
8642002-05-23chirac2BVA1054phone52.037.023520020
8652002-05-26chirac2Ipsos907phone48.048.026520020
8662002-06-16chirac2Ifop974phone49.043.016620021
....................................
20302022-05-21macron2Ifop1946phone&internet41.058.021520221
20312022-05-25macron2Odoxa1005internet44.056.025520221
20322022-05-26macron2Harris1002internet49.051.026520221
20332022-05-30macron2Kantar1000internet37.056.030520221
20342022-06-01macron2Elabe2000internet32.059.01620222
\n", + "

1173 rows × 11 columns

\n", + "
" + ], + "text/plain": [ + " date president sondage samplesize ... day month year month_id\n", + "862 2002-05-15 chirac2 Ifop 924 ... 15 5 2002 0\n", + "863 2002-05-20 chirac2 Kantar 972 ... 20 5 2002 0\n", + "864 2002-05-23 chirac2 BVA 1054 ... 23 5 2002 0\n", + "865 2002-05-26 chirac2 Ipsos 907 ... 26 5 2002 0\n", + "866 2002-06-16 chirac2 Ifop 974 ... 16 6 2002 1\n", + "... ... ... ... ... ... .. ... ... ...\n", + "2030 2022-05-21 macron2 Ifop 1946 ... 21 5 2022 1\n", + "2031 2022-05-25 macron2 Odoxa 1005 ... 25 5 2022 1\n", + "2032 2022-05-26 macron2 Harris 1002 ... 26 5 2022 1\n", + "2033 2022-05-30 macron2 Kantar 1000 ... 30 5 2022 1\n", + "2034 2022-06-01 macron2 Elabe 2000 ... 1 6 2022 2\n", + "\n", + "[1173 rows x 11 columns]" + ] + }, + "execution_count": 83, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a61880b1", + "metadata": {}, + "outputs": [], + "source": [ + "COORDS = {\n", + " \"month\": months,\n", + " # each observation is uniquely identified by (pollster, field_date):\n", + " \"observation\": data.set_index([\"sondage\", \"date\"]).index,\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a08c4a5d", + "metadata": {}, + "outputs": [], + "source": [ + "mod = st.LevelTrendComponent(order=2, innovations_order=[0, 1])\n", + "mod += st.AutoregressiveComponent(order=1)\n", + "mod += st.MeasurementError(name=\"obs\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2f6bc6b8", + "metadata": {}, + "outputs": [], + "source": [ + "ss_mod = mod.build(\n", + " name=\"nile\",\n", + " batch_coords={\"president\": presidents}, # this is gonna be leftmost dimension\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "20482a90", + "metadata": {}, + "outputs": [], + "source": [ + "initial_trend_dims, sigma_trend_dims, ar_param_dims, P0_dims = ss_mod.param_dims.values()\n", + "coords = ss_mod.coords" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "615a6979", + "metadata": {}, + "outputs": [], + "source": [ + "with pm.Model(coords=coords) as model_1:\n", + " P0_diag = pm.Gamma(\"P0_diag\", alpha=5, beta=5, dims=\"president\")\n", + " P0 = pm.Deterministic(\"P0\", pt.eye(ss_mod.k_states) * P0_diag, dims=P0_dims)\n", + "\n", + " initial_trend = pm.Normal(\"initial_trend\", dims=initial_trend_dims)\n", + " ar_params = pm.Beta(\"ar_params\", alpha=3, beta=3, dims=ar_param_dims)\n", + "\n", + " sigma_trend = pm.Gamma(\"sigma_trend\", alpha=2, beta=50, dims=sigma_trend_dims)\n", + " sigma_ar = pm.Gamma(\"sigma_ar\", alpha=2, beta=5, dims=\"president\")\n", + " sigma_obs = pm.HalfNormal(\"sigma_obs\", sigma=0.05, dims=\"president\")\n", + "\n", + " ss_mod.build_statespace_graph(nile, mode=\"JAX\")\n", + " idata = pm.sample(**sampler_kwargs())" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "pymc-extras-test", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notebooks/popularite.csv b/notebooks/popularite.csv new file mode 100644 index 000000000..adcb9bfdc --- /dev/null +++ b/notebooks/popularite.csv @@ -0,0 +1,2036 @@ +,president,sondage,samplesize,method,approve_pr,disapprove_pr +1978-09-28,vge,Kantar,1040,face to face,60.0,33.0 +1978-10-17,vge,Ifop,949,phone,52.0,35.0 +1978-10-28,vge,Kantar,964,face to face,59.0,34.0 +1978-11-19,vge,Ifop,1069,phone,53.0,37.0 +1978-11-24,vge,Kantar,928,face to face,62.0,33.0 +1978-12-15,vge,Ifop,1035,phone,52.0,37.0 +1978-12-20,vge,Kantar,993,face to face,62.0,34.0 +1979-01-15,vge,Ifop,1049,phone,54.0,35.0 +1979-01-24,vge,Kantar,904,face to face,57.0,38.0 +1979-02-15,vge,Ifop,967,phone,48.0,41.0 +1979-02-23,vge,Kantar,1004,face to face,51.0,43.0 +1979-03-15,vge,Ifop,1037,phone,49.0,40.0 +1979-03-21,vge,Kantar,978,face to face,54.0,40.0 +1979-04-16,vge,Ifop,1002,phone,47.0,42.0 +1979-04-23,vge,Kantar,920,face to face,56.0,39.0 +1979-05-17,vge,Ifop,1084,phone,47.0,43.0 +1979-05-20,vge,Kantar,1066,face to face,56.0,41.0 +1979-06-19,vge,Ifop,1044,phone,46.0,42.0 +1979-06-21,vge,Kantar,1087,face to face,54.0,41.0 +1979-07-20,vge,Ifop,983,phone,48.0,40.0 +1979-07-23,vge,Kantar,1081,face to face,51.0,43.0 +1979-08-27,vge,Kantar,1058,face to face,49.0,45.0 +1979-09-20,vge,Ifop,901,phone,40.0,44.0 +1979-09-27,vge,Kantar,1059,face to face,51.0,44.0 +1979-10-19,vge,Ifop,1071,phone,45.0,40.0 +1979-10-23,vge,Kantar,1049,face to face,52.0,43.0 +1979-11-18,vge,Ifop,1012,phone,47.0,44.0 +1979-11-28,vge,Kantar,927,face to face,55.0,40.0 +1979-12-19,vge,Ifop,918,phone,46.0,39.0 +1979-12-27,vge,Kantar,1034,face to face,54.0,42.0 +1980-01-15,vge,Ifop,1016,phone,46.0,40.0 +1980-01-27,vge,Kantar,1007,face to face,58.0,38.0 +1980-02-19,vge,Ifop,1073,phone,49.0,35.0 +1980-02-24,vge,Kantar,1079,face to face,59.0,37.0 +1980-03-19,vge,Ifop,1041,phone,47.0,37.0 +1980-03-25,vge,Kantar,900,face to face,56.0,41.0 +1980-04-18,vge,Ifop,1046,phone,45.0,42.0 +1980-04-23,vge,Kantar,1047,face to face,51.0,45.0 +1980-05-17,vge,Ifop,1021,phone,45.0,41.0 +1980-05-22,vge,Kantar,985,face to face,53.0,43.0 +1980-06-15,vge,Ifop,978,phone,45.0,42.0 +1980-06-22,vge,Kantar,1061,face to face,51.0,44.0 +1980-07-15,vge,Ifop,984,phone,44.0,40.0 +1980-07-24,vge,Kantar,935,face to face,52.0,42.0 +1980-08-25,vge,Kantar,1015,face to face,54.0,41.0 +1980-09-17,vge,Ifop,1095,phone,41.0,42.0 +1980-09-20,vge,Kantar,945,face to face,51.0,43.0 +1980-10-28,vge,Kantar,944,face to face,50.0,46.0 +1980-11-15,vge,Ifop,1015,phone,44.0,47.0 +1980-11-28,vge,Kantar,975,face to face,53.0,42.0 +1980-12-19,vge,Ifop,1081,phone,40.0,46.0 +1980-12-27,vge,Kantar,1016,face to face,47.0,49.0 +1981-01-17,vge,Ifop,902,phone,37.0,47.0 +1981-01-25,vge,Kantar,1063,face to face,44.0,51.0 +1981-02-20,vge,Ifop,938,phone,37.0,51.0 +1981-02-22,vge,Kantar,992,face to face,41.0,55.0 +1981-03-20,vge,Ifop,1063,phone,35.0,47.0 +1981-03-23,vge,Kantar,963,face to face,44.0,52.0 +1981-04-16,vge,Ifop,1069,phone,40.0,46.0 +1981-04-28,vge,Kantar,997,face to face,44.0,52.0 +1981-05-26,mitterrand1,Kantar,1052,face to face,74.0,20.0 +1981-06-15,mitterrand1,Ifop,973,phone,54.0,16.0 +1981-06-23,mitterrand1,Kantar,1086,face to face,71.0,24.0 +1981-06-29,mitterrand1,BVA,1052,phone,61.0,17.0 +1981-07-24,mitterrand1,Kantar,1052,face to face,66.0,29.0 +1981-08-24,mitterrand1,Kantar,1065,face to face,62.0,32.0 +1981-09-15,mitterrand1,Ifop,916,phone,48.0,25.0 +1981-09-22,mitterrand1,Kantar,1005,face to face,64.0,31.0 +1981-09-23,mitterrand1,BVA,900,phone,49.0,28.0 +1981-10-15,mitterrand1,Ifop,961,phone,47.0,25.0 +1981-10-23,mitterrand1,Kantar,1028,face to face,60.0,35.0 +1981-11-15,mitterrand1,Ifop,996,phone,46.0,29.0 +1981-11-25,mitterrand1,Kantar,983,face to face,57.0,37.0 +1981-12-17,mitterrand1,Ifop,1099,phone,46.0,31.0 +1981-12-28,mitterrand1,Kantar,1053,face to face,59.0,35.0 +1981-12-29,mitterrand1,BVA,991,phone,59.0,30.0 +1982-01-18,mitterrand1,Ifop,1097,phone,51.0,28.0 +1982-01-21,mitterrand1,Kantar,1097,face to face,58.0,37.0 +1982-02-19,mitterrand1,Ifop,1005,phone,51.0,32.0 +1982-02-27,mitterrand1,Kantar,1054,face to face,58.0,36.0 +1982-03-15,mitterrand1,Ifop,1072,phone,49.0,33.0 +1982-03-18,mitterrand1,BVA,1065,phone,51.0,34.0 +1982-03-20,mitterrand1,Kantar,913,face to face,56.0,39.0 +1982-04-20,mitterrand1,Ifop,975,phone,54.0,35.0 +1982-04-25,mitterrand1,Kantar,1063,face to face,58.0,37.0 +1982-05-20,mitterrand1,Ifop,932,phone,54.0,30.0 +1982-05-21,mitterrand1,Kantar,1051,face to face,63.0,33.0 +1982-06-20,mitterrand1,Ifop,999,phone,48.0,32.0 +1982-06-23,mitterrand1,BVA,1052,phone,56.0,33.0 +1982-06-28,mitterrand1,Kantar,1027,face to face,57.0,39.0 +1982-07-17,mitterrand1,Ifop,969,phone,41.0,40.0 +1982-07-18,mitterrand1,BVA,934,phone,56.0,35.0 +1982-07-25,mitterrand1,Kantar,972,face to face,55.0,40.0 +1982-08-23,mitterrand1,Kantar,1020,face to face,54.0,42.0 +1982-09-16,mitterrand1,Ifop,1009,phone,42.0,45.0 +1982-09-21,mitterrand1,Kantar,1024,face to face,51.0,43.0 +1982-09-29,mitterrand1,BVA,973,phone,52.0,37.0 +1982-10-15,mitterrand1,Ifop,911,phone,44.0,45.0 +1982-10-19,mitterrand1,BVA,1039,phone,52.0,36.0 +1982-10-23,mitterrand1,Kantar,918,face to face,53.0,43.0 +1982-11-16,mitterrand1,Ifop,1048,phone,43.0,46.0 +1982-11-17,mitterrand1,BVA,914,phone,48.0,40.0 +1982-11-25,mitterrand1,Kantar,939,face to face,49.0,46.0 +1982-12-15,mitterrand1,Ifop,1054,phone,37.0,46.0 +1982-12-18,mitterrand1,BVA,1026,phone,53.0,37.0 +1982-12-20,mitterrand1,Kantar,1000,face to face,48.0,47.0 +1983-01-20,mitterrand1,Ifop,962,phone,39.0,42.0 +1983-01-24,mitterrand1,BVA,1009,phone,48.0,38.0 +1983-01-28,mitterrand1,Kantar,955,face to face,50.0,45.0 +1983-02-16,mitterrand1,Ifop,920,phone,42.0,42.0 +1983-02-21,mitterrand1,Kantar,1015,face to face,48.0,46.0 +1983-02-26,mitterrand1,BVA,971,phone,55.0,33.0 +1983-03-18,mitterrand1,Ifop,918,phone,45.0,38.0 +1983-03-26,mitterrand1,Kantar,949,face to face,48.0,46.0 +1983-03-27,mitterrand1,BVA,901,phone,48.0,36.0 +1983-04-16,mitterrand1,BVA,1014,phone,46.0,41.0 +1983-04-19,mitterrand1,Ifop,982,phone,38.0,48.0 +1983-04-26,mitterrand1,Kantar,1084,face to face,49.0,47.0 +1983-05-20,mitterrand1,Ifop,1030,phone,33.0,50.0 +1983-05-21,mitterrand1,Kantar,981,face to face,46.0,51.0 +1983-05-26,mitterrand1,BVA,1064,phone,39.0,48.0 +1983-06-20,mitterrand1,Ifop,968,phone,35.0,53.0 +1983-06-21,mitterrand1,Kantar,1077,face to face,40.0,58.0 +1983-06-27,mitterrand1,BVA,949,phone,37.0,47.0 +1983-07-17,mitterrand1,Ifop,1065,phone,35.0,51.0 +1983-07-20,mitterrand1,Kantar,1084,face to face,41.0,54.0 +1983-07-29,mitterrand1,BVA,1076,phone,39.0,47.0 +1983-08-20,mitterrand1,Ifop,1033,phone,35.0,53.0 +1983-08-27,mitterrand1,Kantar,937,face to face,43.0,51.0 +1983-09-16,mitterrand1,Ifop,990,phone,33.0,53.0 +1983-09-18,mitterrand1,BVA,984,phone,40.0,46.0 +1983-09-21,mitterrand1,Kantar,1073,face to face,38.0,56.0 +1983-10-19,mitterrand1,Ifop,950,phone,32.0,54.0 +1983-10-21,mitterrand1,Kantar,996,face to face,42.0,54.0 +1983-10-29,mitterrand1,BVA,1078,phone,41.0,48.0 +1983-11-19,mitterrand1,Ifop,1008,phone,39.0,48.0 +1983-11-20,mitterrand1,Kantar,1075,face to face,46.0,50.0 +1983-12-16,mitterrand1,Ifop,1047,phone,37.0,47.0 +1983-12-20,mitterrand1,BVA,1076,phone,45.0,46.0 +1983-12-22,mitterrand1,Kantar,978,face to face,47.0,48.0 +1984-01-18,mitterrand1,Ifop,917,phone,34.0,52.0 +1984-01-28,mitterrand1,Kantar,999,face to face,44.0,52.0 +1984-01-30,mitterrand1,BVA,1038,phone,43.0,44.0 +1984-02-17,mitterrand1,Ifop,1062,phone,35.0,49.0 +1984-02-21,mitterrand1,Kantar,1016,face to face,43.0,53.0 +1984-02-26,mitterrand1,BVA,1038,phone,43.0,45.0 +1984-03-15,mitterrand1,Ifop,937,phone,32.0,51.0 +1984-03-21,mitterrand1,BVA,974,phone,41.0,46.0 +1984-03-22,mitterrand1,Kantar,987,face to face,44.0,52.0 +1984-04-19,mitterrand1,Ifop,957,phone,34.0,50.0 +1984-04-20,mitterrand1,BVA,1004,phone,36.0,54.0 +1984-04-27,mitterrand1,Kantar,1066,face to face,40.0,54.0 +1984-05-15,mitterrand1,Ifop,1089,phone,30.0,54.0 +1984-05-16,mitterrand1,BVA,1075,phone,35.0,51.0 +1984-05-27,mitterrand1,Kantar,1088,face to face,41.0,54.0 +1984-06-16,mitterrand1,BVA,1078,phone,44.0,47.0 +1984-06-17,mitterrand1,Ifop,996,phone,33.0,53.0 +1984-06-22,mitterrand1,Kantar,1021,face to face,40.0,56.0 +1984-07-17,mitterrand1,Ifop,971,phone,33.0,52.0 +1984-07-19,mitterrand1,BVA,945,phone,35.0,54.0 +1984-07-26,mitterrand1,Kantar,1043,face to face,40.0,56.0 +1984-08-15,mitterrand1,Ifop,936,phone,32.0,51.0 +1984-08-24,mitterrand1,Kantar,1034,face to face,40.0,56.0 +1984-09-19,mitterrand1,Ifop,964,phone,33.0,54.0 +1984-09-20,mitterrand1,Kantar,983,face to face,38.0,57.0 +1984-09-30,mitterrand1,BVA,947,phone,33.0,53.0 +1984-10-19,mitterrand1,Ifop,1000,phone,31.0,52.0 +1984-10-22,mitterrand1,Kantar,931,face to face,37.0,59.0 +1984-10-26,mitterrand1,BVA,994,phone,37.0,55.0 +1984-11-20,mitterrand1,Ifop,920,phone,26.0,57.0 +1984-11-23,mitterrand1,BVA,1074,phone,37.0,56.0 +1984-11-26,mitterrand1,Kantar,945,face to face,36.0,60.0 +1984-12-16,mitterrand1,Ifop,939,phone,28.0,55.0 +1984-12-19,mitterrand1,BVA,973,phone,33.0,55.0 +1984-12-24,mitterrand1,Kantar,916,face to face,36.0,60.0 +1985-01-16,mitterrand1,Ifop,983,phone,31.0,54.0 +1985-01-27,mitterrand1,BVA,977,phone,32.0,58.0 +1985-01-28,mitterrand1,Kantar,1071,face to face,39.0,59.0 +1985-02-16,mitterrand1,Ifop,942,phone,33.0,53.0 +1985-02-17,mitterrand1,BVA,1078,phone,34.0,55.0 +1985-02-22,mitterrand1,Kantar,994,face to face,41.0,54.0 +1985-03-16,mitterrand1,Ifop,1055,phone,35.0,46.0 +1985-03-20,mitterrand1,Kantar,1062,face to face,39.0,56.0 +1985-03-21,mitterrand1,BVA,1021,phone,35.0,52.0 +1985-04-17,mitterrand1,BVA,1023,phone,37.0,50.0 +1985-04-20,mitterrand1,Ifop,1085,phone,33.0,50.0 +1985-04-22,mitterrand1,Kantar,976,face to face,38.0,58.0 +1985-05-16,mitterrand1,BVA,956,phone,37.0,53.0 +1985-05-17,mitterrand1,Ifop,947,phone,33.0,49.0 +1985-05-21,mitterrand1,Kantar,1084,face to face,41.0,54.0 +1985-06-15,mitterrand1,Ifop,922,phone,31.0,48.0 +1985-06-17,mitterrand1,BVA,1071,phone,42.0,51.0 +1985-06-23,mitterrand1,Kantar,1024,face to face,38.0,57.0 +1985-07-18,mitterrand1,Ifop,962,phone,35.0,48.0 +1985-07-26,mitterrand1,BVA,1090,phone,34.0,56.0 +1985-07-28,mitterrand1,Kantar,976,face to face,38.0,56.0 +1985-08-17,mitterrand1,Ifop,1070,phone,33.0,47.0 +1985-08-24,mitterrand1,Kantar,1093,face to face,38.0,56.0 +1985-09-15,mitterrand1,Ifop,1010,phone,34.0,48.0 +1985-09-23,mitterrand1,BVA,1006,phone,32.0,58.0 +1985-09-23,mitterrand1,Kantar,1086,face to face,38.0,57.0 +1985-10-18,mitterrand1,Ifop,972,phone,35.0,46.0 +1985-10-21,mitterrand1,Kantar,932,face to face,41.0,54.0 +1985-10-28,mitterrand1,BVA,949,phone,36.0,53.0 +1985-11-16,mitterrand1,Ifop,1036,phone,32.0,50.0 +1985-11-21,mitterrand1,Kantar,1001,face to face,43.0,51.0 +1985-11-26,mitterrand1,BVA,1078,phone,35.0,53.0 +1985-12-16,mitterrand1,BVA,1069,phone,39.0,53.0 +1985-12-19,mitterrand1,Ifop,960,phone,34.0,48.0 +1985-12-21,mitterrand1,Kantar,967,face to face,43.0,53.0 +1986-01-15,mitterrand1,BVA,1007,phone,39.0,50.0 +1986-01-17,mitterrand1,Ifop,916,phone,36.0,45.0 +1986-01-20,mitterrand1,Kantar,1056,face to face,45.0,50.0 +1986-02-17,mitterrand1,Ifop,1077,phone,39.0,43.0 +1986-02-23,mitterrand1,Kantar,909,face to face,46.0,48.0 +1986-02-27,mitterrand1,BVA,937,phone,44.0,47.0 +1986-03-16,mitterrand1,Ifop,1100,phone,48.0,35.0 +1986-03-17,mitterrand1,Ifop,1027,phone,39.0,41.0 +1986-03-23,mitterrand1,Kantar,991,face to face,56.0,39.0 +1986-03-28,mitterrand1,BVA,1049,phone,45.0,45.0 +1986-04-15,mitterrand1,BVA,988,phone,54.0,35.0 +1986-04-17,mitterrand1,Ifop,1039,phone,44.0,36.0 +1986-04-22,mitterrand1,Kantar,1050,face to face,56.0,39.0 +1986-05-20,mitterrand1,Ifop,944,phone,52.0,30.0 +1986-05-23,mitterrand1,BVA,1041,phone,54.0,35.0 +1986-05-23,mitterrand1,Kantar,1017,face to face,55.0,40.0 +1986-06-16,mitterrand1,Ifop,999,phone,55.0,34.0 +1986-06-21,mitterrand1,Kantar,1046,face to face,59.0,35.0 +1986-06-22,mitterrand1,BVA,1014,phone,61.0,35.0 +1986-07-16,mitterrand1,Ifop,964,phone,59.0,29.0 +1986-07-20,mitterrand1,BVA,1042,phone,62.0,29.0 +1986-07-25,mitterrand1,Kantar,920,face to face,57.0,37.0 +1986-08-17,mitterrand1,Ifop,947,phone,51.0,35.0 +1986-08-24,mitterrand1,Kantar,915,face to face,55.0,40.0 +1986-09-16,mitterrand1,BVA,1094,phone,55.0,34.0 +1986-09-19,mitterrand1,Ifop,990,phone,57.0,30.0 +1986-09-28,mitterrand1,Kantar,971,face to face,61.0,34.0 +1986-10-16,mitterrand1,BVA,901,phone,58.0,32.0 +1986-10-19,mitterrand1,Ifop,1043,phone,57.0,32.0 +1986-10-26,mitterrand1,Kantar,1067,face to face,58.0,35.0 +1986-11-16,mitterrand1,Ifop,922,phone,61.0,28.0 +1986-11-20,mitterrand1,BVA,1035,phone,59.0,32.0 +1986-11-20,mitterrand1,Kantar,962,face to face,56.0,39.0 +1986-12-16,mitterrand1,Ifop,1005,phone,57.0,31.0 +1986-12-19,mitterrand1,BVA,1082,phone,56.0,32.0 +1986-12-28,mitterrand1,Kantar,930,face to face,58.0,38.0 +1987-01-17,mitterrand1,Ifop,916,phone,50.0,34.0 +1987-01-21,mitterrand1,BVA,1006,phone,56.0,34.0 +1987-01-26,mitterrand1,Kantar,935,face to face,56.0,39.0 +1987-02-20,mitterrand1,Ifop,915,phone,52.0,35.0 +1987-02-24,mitterrand1,BVA,1040,phone,52.0,35.0 +1987-02-25,mitterrand1,Kantar,1073,face to face,51.0,45.0 +1987-03-16,mitterrand1,BVA,903,phone,55.0,32.0 +1987-03-18,mitterrand1,Ifop,1032,phone,53.0,35.0 +1987-03-21,mitterrand1,Kantar,928,face to face,54.0,40.0 +1987-04-16,mitterrand1,Ifop,1081,phone,56.0,32.0 +1987-04-20,mitterrand1,Kantar,1089,face to face,57.0,37.0 +1987-04-25,mitterrand1,BVA,1011,phone,58.0,31.0 +1987-05-15,mitterrand1,Ifop,1096,phone,52.0,33.0 +1987-05-18,mitterrand1,BVA,979,phone,56.0,33.0 +1987-05-21,mitterrand1,Kantar,1094,face to face,54.0,40.0 +1987-06-15,mitterrand1,Ifop,1014,phone,55.0,31.0 +1987-06-23,mitterrand1,Kantar,917,face to face,57.0,37.0 +1987-06-29,mitterrand1,BVA,902,phone,55.0,32.0 +1987-07-15,mitterrand1,Ifop,925,phone,52.0,35.0 +1987-07-20,mitterrand1,BVA,1065,phone,55.0,35.0 +1987-07-20,mitterrand1,Kantar,1004,face to face,59.0,35.0 +1987-08-18,mitterrand1,Ifop,975,phone,52.0,27.0 +1987-08-27,mitterrand1,Kantar,917,face to face,61.0,34.0 +1987-09-17,mitterrand1,Ifop,1061,phone,56.0,31.0 +1987-09-22,mitterrand1,Kantar,976,face to face,60.0,34.0 +1987-09-25,mitterrand1,BVA,983,phone,57.0,31.0 +1987-10-17,mitterrand1,Ifop,964,phone,53.0,35.0 +1987-10-26,mitterrand1,Kantar,930,face to face,58.0,37.0 +1987-10-29,mitterrand1,BVA,995,phone,60.0,31.0 +1987-11-20,mitterrand1,Ifop,948,phone,51.0,32.0 +1987-11-24,mitterrand1,Kantar,1025,face to face,56.0,38.0 +1987-11-28,mitterrand1,BVA,1066,phone,58.0,32.0 +1987-12-20,mitterrand1,Ifop,1089,phone,56.0,30.0 +1987-12-21,mitterrand1,Kantar,1021,face to face,58.0,37.0 +1987-12-25,mitterrand1,BVA,1043,phone,59.0,29.0 +1988-01-16,mitterrand1,Ifop,965,phone,60.0,29.0 +1988-01-23,mitterrand1,BVA,991,phone,61.0,31.0 +1988-01-24,mitterrand1,Kantar,1058,face to face,62.0,34.0 +1988-02-17,mitterrand1,Ifop,995,phone,55.0,33.0 +1988-02-24,mitterrand1,BVA,1080,phone,61.0,28.0 +1988-02-28,mitterrand1,Kantar,927,face to face,61.0,33.0 +1988-03-20,mitterrand1,Ifop,1004,phone,55.0,33.0 +1988-03-25,mitterrand1,Kantar,921,face to face,59.0,38.0 +1988-03-26,mitterrand1,BVA,1066,phone,63.0,28.0 +1988-04-18,mitterrand1,Ifop,1059,phone,54.0,33.0 +1988-04-23,mitterrand1,Kantar,1067,face to face,57.0,39.0 +1988-04-26,mitterrand1,BVA,1074,phone,60.0,36.0 +1988-05-17,mitterrand2,BVA,1023,phone,65.0,29.0 +1988-05-18,mitterrand2,Ifop,1023,phone,54.0,29.0 +1988-05-25,mitterrand2,Kantar,993,face to face,63.0,35.0 +1988-06-15,mitterrand2,Ifop,1029,phone,49.0,36.0 +1988-06-25,mitterrand2,BVA,971,phone,63.0,31.0 +1988-06-26,mitterrand2,Kantar,917,face to face,63.0,33.0 +1988-07-20,mitterrand2,Ifop,974,phone,49.0,32.0 +1988-07-26,mitterrand2,Kantar,1084,face to face,62.0,33.0 +1988-07-30,mitterrand2,BVA,1027,phone,63.0,26.0 +1988-08-18,mitterrand2,Ifop,1026,phone,51.0,31.0 +1988-08-24,mitterrand2,Kantar,995,face to face,62.0,34.0 +1988-09-15,mitterrand2,Ifop,984,phone,51.0,32.0 +1988-09-23,mitterrand2,Kantar,982,face to face,64.0,32.0 +1988-09-27,mitterrand2,BVA,1078,phone,63.0,26.0 +1988-10-19,mitterrand2,Ifop,1093,phone,50.0,36.0 +1988-10-23,mitterrand2,Kantar,1034,face to face,63.0,33.0 +1988-10-28,mitterrand2,BVA,1053,phone,60.0,30.0 +1988-11-19,mitterrand2,Ifop,1058,phone,49.0,36.0 +1988-11-27,mitterrand2,BVA,1081,phone,56.0,33.0 +1988-11-27,mitterrand2,Kantar,997,face to face,58.0,38.0 +1988-12-15,mitterrand2,Ifop,1005,phone,46.0,39.0 +1988-12-22,mitterrand2,Kantar,966,face to face,60.0,36.0 +1988-12-27,mitterrand2,BVA,1025,phone,54.0,34.0 +1989-01-16,mitterrand2,Ifop,930,phone,47.0,38.0 +1989-01-22,mitterrand2,BVA,1042,phone,53.0,34.0 +1989-01-28,mitterrand2,Kantar,996,face to face,58.0,38.0 +1989-02-18,mitterrand2,Ifop,958,phone,48.0,35.0 +1989-02-28,mitterrand2,BVA,1018,phone,54.0,36.0 +1989-02-28,mitterrand2,Kantar,974,face to face,58.0,39.0 +1989-03-20,mitterrand2,Ifop,1027,phone,47.0,37.0 +1989-03-28,mitterrand2,Kantar,990,face to face,60.0,36.0 +1989-04-15,mitterrand2,Ifop,932,phone,46.0,33.0 +1989-04-22,mitterrand2,BVA,1089,phone,58.0,35.0 +1989-04-25,mitterrand2,Kantar,927,face to face,61.0,34.0 +1989-05-18,mitterrand2,Ifop,1015,phone,49.0,33.0 +1989-05-22,mitterrand2,BVA,941,phone,61.0,31.0 +1989-05-24,mitterrand2,Kantar,980,face to face,62.0,35.0 +1989-06-17,mitterrand2,Ifop,1070,phone,46.0,34.0 +1989-06-20,mitterrand2,BVA,1052,phone,60.0,32.0 +1989-06-22,mitterrand2,Kantar,996,face to face,58.0,38.0 +1989-07-18,mitterrand2,BVA,1073,phone,58.0,33.0 +1989-07-20,mitterrand2,Ifop,975,phone,43.0,37.0 +1989-07-27,mitterrand2,Kantar,931,face to face,58.0,38.0 +1989-08-17,mitterrand2,Ifop,929,phone,50.0,32.0 +1989-08-24,mitterrand2,Kantar,1090,face to face,59.0,37.0 +1989-09-16,mitterrand2,Ifop,942,phone,43.0,36.0 +1989-09-21,mitterrand2,Kantar,949,face to face,57.0,37.0 +1989-09-24,mitterrand2,BVA,984,phone,55.0,34.0 +1989-10-16,mitterrand2,Ifop,1073,phone,43.0,38.0 +1989-10-20,mitterrand2,BVA,1068,phone,52.0,38.0 +1989-10-25,mitterrand2,Kantar,1035,face to face,55.0,42.0 +1989-11-19,mitterrand2,Ifop,983,phone,44.0,37.0 +1989-11-20,mitterrand2,Kantar,977,face to face,58.0,40.0 +1989-11-30,mitterrand2,BVA,981,phone,53.0,37.0 +1989-12-18,mitterrand2,BVA,1026,phone,56.0,33.0 +1989-12-19,mitterrand2,Ifop,924,phone,42.0,38.0 +1989-12-21,mitterrand2,Kantar,1033,face to face,56.0,41.0 +1990-01-19,mitterrand2,Ifop,961,phone,45.0,36.0 +1990-01-23,mitterrand2,BVA,1083,phone,59.0,32.0 +1990-01-24,mitterrand2,Kantar,942,face to face,61.0,37.0 +1990-02-18,mitterrand2,Ifop,1041,phone,45.0,36.0 +1990-02-19,mitterrand2,BVA,1066,phone,58.0,34.0 +1990-02-26,mitterrand2,Kantar,1007,face to face,61.0,35.0 +1990-03-18,mitterrand2,Ifop,1038,phone,44.0,36.0 +1990-03-19,mitterrand2,BVA,1051,phone,55.0,35.0 +1990-03-26,mitterrand2,Kantar,1100,face to face,55.0,41.0 +1990-04-19,mitterrand2,Ifop,1092,phone,39.0,42.0 +1990-04-21,mitterrand2,BVA,999,phone,53.0,38.0 +1990-04-25,mitterrand2,Kantar,971,face to face,53.0,43.0 +1990-05-19,mitterrand2,BVA,929,phone,54.0,37.0 +1990-05-19,mitterrand2,Ifop,1087,phone,35.0,44.0 +1990-05-23,mitterrand2,Kantar,949,face to face,52.0,45.0 +1990-06-19,mitterrand2,Ifop,974,phone,39.0,43.0 +1990-06-25,mitterrand2,BVA,923,phone,52.0,37.0 +1990-06-28,mitterrand2,Kantar,1076,face to face,54.0,43.0 +1990-07-15,mitterrand2,BVA,940,phone,49.0,41.0 +1990-07-17,mitterrand2,Ifop,1048,phone,37.0,41.0 +1990-07-26,mitterrand2,Kantar,1033,face to face,54.0,41.0 +1990-08-18,mitterrand2,Ifop,986,phone,37.0,42.0 +1990-08-21,mitterrand2,Kantar,923,face to face,55.0,40.0 +1990-09-19,mitterrand2,BVA,925,phone,55.0,36.0 +1990-09-20,mitterrand2,Ifop,1075,phone,42.0,38.0 +1990-09-22,mitterrand2,Kantar,1014,face to face,64.0,33.0 +1990-10-16,mitterrand2,BVA,1087,phone,53.0,37.0 +1990-10-18,mitterrand2,Ifop,1053,phone,43.0,39.0 +1990-10-20,mitterrand2,Kantar,949,face to face,60.0,36.0 +1990-11-15,mitterrand2,Ifop,929,phone,41.0,39.0 +1990-11-25,mitterrand2,Kantar,950,face to face,53.0,44.0 +1990-11-28,mitterrand2,BVA,1052,phone,53.0,38.0 +1990-12-19,mitterrand2,Ifop,921,phone,38.0,45.0 +1990-12-20,mitterrand2,BVA,1094,phone,49.0,40.0 +1990-12-27,mitterrand2,Kantar,934,face to face,55.0,42.0 +1991-01-17,mitterrand2,Ifop,997,phone,37.0,45.0 +1991-01-26,mitterrand2,BVA,1008,phone,54.0,36.0 +1991-01-28,mitterrand2,Kantar,914,face to face,65.0,32.0 +1991-02-17,mitterrand2,BVA,1054,phone,61.0,33.0 +1991-02-17,mitterrand2,Ifop,1044,phone,47.0,36.0 +1991-02-27,mitterrand2,Kantar,1027,face to face,62.0,34.0 +1991-03-20,mitterrand2,BVA,1026,phone,65.0,28.0 +1991-03-20,mitterrand2,Ifop,958,phone,56.0,27.0 +1991-03-28,mitterrand2,Kantar,983,face to face,61.0,36.0 +1991-04-15,mitterrand2,Ifop,1069,phone,47.0,36.0 +1991-04-26,mitterrand2,Kantar,951,face to face,56.0,42.0 +1991-04-28,mitterrand2,BVA,935,phone,55.0,38.0 +1991-05-15,mitterrand2,Ifop,928,phone,42.0,42.0 +1991-05-21,mitterrand2,BVA,1062,phone,57.0,38.0 +1991-05-22,mitterrand2,Kantar,1093,face to face,54.0,43.0 +1991-06-16,mitterrand2,BVA,939,phone,48.0,44.0 +1991-06-16,mitterrand2,Ifop,939,phone,40.0,42.0 +1991-06-26,mitterrand2,Kantar,998,face to face,48.0,48.0 +1991-07-20,mitterrand2,BVA,984,phone,51.0,40.0 +1991-07-20,mitterrand2,Ifop,954,phone,33.0,48.0 +1991-07-26,mitterrand2,Kantar,1011,face to face,50.0,46.0 +1991-08-16,mitterrand2,Ifop,924,phone,33.0,50.0 +1991-08-20,mitterrand2,Kantar,938,face to face,52.0,45.0 +1991-09-15,mitterrand2,Ifop,1058,phone,34.0,49.0 +1991-09-16,mitterrand2,BVA,989,phone,46.0,45.0 +1991-09-25,mitterrand2,Kantar,965,face to face,46.0,51.0 +1991-10-16,mitterrand2,Ifop,1022,phone,33.0,52.0 +1991-10-17,mitterrand2,BVA,963,phone,44.0,48.0 +1991-10-24,mitterrand2,Kantar,1031,face to face,39.0,58.0 +1991-11-19,mitterrand2,Ifop,1027,phone,28.0,57.0 +1991-11-26,mitterrand2,Kantar,1065,face to face,31.0,66.0 +1991-11-30,mitterrand2,BVA,958,phone,39.0,52.0 +1991-12-16,mitterrand2,BVA,1073,phone,36.0,53.0 +1991-12-20,mitterrand2,Ifop,965,phone,22.0,65.0 +1991-12-21,mitterrand2,Kantar,973,face to face,35.0,62.0 +1992-01-17,mitterrand2,BVA,1071,phone,34.0,58.0 +1992-01-19,mitterrand2,Ifop,958,phone,26.0,63.0 +1992-01-25,mitterrand2,Kantar,1059,face to face,35.0,61.0 +1992-02-18,mitterrand2,Ifop,1061,phone,24.0,63.0 +1992-02-20,mitterrand2,Kantar,997,face to face,35.0,60.0 +1992-02-29,mitterrand2,BVA,1073,phone,35.0,58.0 +1992-03-16,mitterrand2,Ifop,1051,phone,26.0,59.0 +1992-03-26,mitterrand2,Kantar,918,face to face,33.0,65.0 +1992-03-30,mitterrand2,BVA,1055,phone,31.0,62.0 +1992-04-16,mitterrand2,BVA,1058,phone,38.0,55.0 +1992-04-20,mitterrand2,Ifop,1008,phone,26.0,60.0 +1992-04-23,mitterrand2,Kantar,946,face to face,37.0,59.0 +1992-05-17,mitterrand2,Ifop,968,phone,29.0,56.0 +1992-05-26,mitterrand2,BVA,1092,phone,40.0,50.0 +1992-05-28,mitterrand2,Kantar,1041,face to face,37.0,60.0 +1992-06-15,mitterrand2,Ifop,989,phone,28.0,58.0 +1992-06-17,mitterrand2,BVA,1038,phone,38.0,55.0 +1992-06-21,mitterrand2,Kantar,1003,face to face,38.0,59.0 +1992-07-15,mitterrand2,Ifop,939,phone,26.0,62.0 +1992-07-21,mitterrand2,Kantar,1042,face to face,37.0,60.0 +1992-07-30,mitterrand2,BVA,1099,phone,35.0,58.0 +1992-08-15,mitterrand2,Ifop,1099,phone,26.0,60.0 +1992-08-21,mitterrand2,Kantar,908,face to face,36.0,61.0 +1992-08-28,mitterrand2,BVA,1019,phone,33.0,59.0 +1992-09-19,mitterrand2,Ifop,1099,phone,32.0,58.0 +1992-09-22,mitterrand2,Kantar,1052,face to face,43.0,54.0 +1992-10-15,mitterrand2,BVA,902,phone,36.0,56.0 +1992-10-19,mitterrand2,Ifop,931,phone,31.0,59.0 +1992-10-24,mitterrand2,BVA,980,phone,39.0,54.0 +1992-10-25,mitterrand2,Kantar,1078,face to face,34.0,63.0 +1992-11-15,mitterrand2,BVA,1016,phone,36.0,56.0 +1992-11-17,mitterrand2,Ifop,920,phone,29.0,59.0 +1992-11-28,mitterrand2,Kantar,1050,face to face,32.0,65.0 +1992-12-16,mitterrand2,BVA,945,phone,32.0,60.0 +1992-12-16,mitterrand2,Ifop,1044,phone,28.0,61.0 +1992-12-25,mitterrand2,Kantar,978,face to face,33.0,65.0 +1993-01-15,mitterrand2,BVA,1098,phone,37.0,57.0 +1993-01-16,mitterrand2,Ifop,1019,phone,26.0,63.0 +1993-01-26,mitterrand2,Kantar,990,face to face,31.0,67.0 +1993-02-15,mitterrand2,Ifop,1064,phone,26.0,61.0 +1993-02-24,mitterrand2,BVA,915,phone,35.0,60.0 +1993-02-27,mitterrand2,Kantar,978,face to face,31.0,66.0 +1993-03-17,mitterrand2,Ifop,935,phone,24.0,62.0 +1993-03-18,mitterrand2,BVA,1036,phone,36.0,57.0 +1993-03-22,mitterrand2,BVA,1082,phone,33.0,61.0 +1993-03-27,mitterrand2,Kantar,1011,face to face,39.0,58.0 +1993-04-16,mitterrand2,Ifop,976,phone,34.0,55.0 +1993-04-18,mitterrand2,BVA,1098,phone,41.0,52.0 +1993-04-20,mitterrand2,Kantar,1067,face to face,34.0,62.0 +1993-04-21,mitterrand2,BVA,1095,phone,40.0,52.0 +1993-05-19,mitterrand2,Ifop,1025,phone,39.0,50.0 +1993-05-22,mitterrand2,BVA,1071,phone,41.0,52.0 +1993-05-25,mitterrand2,Kantar,1050,face to face,35.0,62.0 +1993-06-16,mitterrand2,Ifop,931,phone,41.0,48.0 +1993-06-22,mitterrand2,BVA,970,phone,46.0,47.0 +1993-06-24,mitterrand2,Kantar,928,face to face,37.0,59.0 +1993-07-17,mitterrand2,Ifop,1038,phone,39.0,47.0 +1993-07-24,mitterrand2,BVA,939,phone,45.0,48.0 +1993-07-24,mitterrand2,Kantar,1035,face to face,38.0,58.0 +1993-08-20,mitterrand2,Ifop,1045,phone,44.0,44.0 +1993-08-22,mitterrand2,Kantar,1099,face to face,39.0,58.0 +1993-09-20,mitterrand2,Ifop,1099,phone,42.0,47.0 +1993-09-25,mitterrand2,Kantar,976,face to face,40.0,57.0 +1993-09-28,mitterrand2,BVA,1063,phone,49.0,43.0 +1993-10-18,mitterrand2,Ifop,1045,phone,42.0,49.0 +1993-10-26,mitterrand2,Kantar,1003,face to face,40.0,57.0 +1993-10-28,mitterrand2,BVA,1032,phone,47.0,47.0 +1993-11-15,mitterrand2,Ifop,1052,phone,39.0,52.0 +1993-11-17,mitterrand2,BVA,1034,phone,47.0,45.0 +1993-11-23,mitterrand2,Kantar,1038,face to face,38.0,59.0 +1993-12-15,mitterrand2,BVA,1059,phone,44.0,48.0 +1993-12-15,mitterrand2,Ifop,1096,phone,41.0,49.0 +1993-12-26,mitterrand2,Kantar,1011,face to face,41.0,57.0 +1994-01-18,mitterrand2,Ifop,1006,phone,42.0,48.0 +1994-01-25,mitterrand2,Kantar,1004,face to face,38.0,60.0 +1994-01-26,mitterrand2,BVA,1022,phone,49.0,44.0 +1994-02-19,mitterrand2,Ifop,986,phone,41.0,50.0 +1994-02-20,mitterrand2,Kantar,1022,face to face,40.0,57.0 +1994-02-26,mitterrand2,BVA,1033,phone,44.0,48.0 +1994-03-16,mitterrand2,Ifop,979,phone,44.0,48.0 +1994-03-24,mitterrand2,Kantar,911,face to face,39.0,57.0 +1994-03-25,mitterrand2,BVA,1061,phone,47.0,46.0 +1994-04-15,mitterrand2,Ifop,917,phone,41.0,49.0 +1994-04-23,mitterrand2,Kantar,1092,face to face,40.0,56.0 +1994-04-27,mitterrand2,BVA,969,phone,46.0,45.0 +1994-05-20,mitterrand2,Ifop,961,phone,45.0,46.0 +1994-05-23,mitterrand2,Kantar,960,face to face,43.0,52.0 +1994-05-26,mitterrand2,BVA,930,phone,47.0,47.0 +1994-06-16,mitterrand2,Ifop,938,phone,46.0,45.0 +1994-06-23,mitterrand2,Kantar,1095,face to face,40.0,56.0 +1994-06-27,mitterrand2,BVA,1003,phone,47.0,45.0 +1994-07-19,mitterrand2,Ifop,1032,phone,51.0,43.0 +1994-07-20,mitterrand2,Kantar,997,face to face,42.0,55.0 +1994-07-29,mitterrand2,BVA,1043,phone,52.0,38.0 +1994-08-15,mitterrand2,Ifop,992,phone,51.0,44.0 +1994-08-20,mitterrand2,Kantar,1082,face to face,43.0,55.0 +1994-09-20,mitterrand2,Ifop,1072,phone,45.0,44.0 +1994-09-23,mitterrand2,Kantar,1011,face to face,42.0,55.0 +1994-09-27,mitterrand2,BVA,959,phone,51.0,40.0 +1994-10-17,mitterrand2,Ifop,1020,phone,45.0,45.0 +1994-10-19,mitterrand2,BVA,907,phone,51.0,42.0 +1994-10-20,mitterrand2,Kantar,973,face to face,41.0,57.0 +1994-11-15,mitterrand2,Ifop,956,phone,49.0,45.0 +1994-11-21,mitterrand2,BVA,926,phone,53.0,40.0 +1994-11-23,mitterrand2,Kantar,982,face to face,38.0,59.0 +1994-12-15,mitterrand2,Ifop,924,phone,48.0,45.0 +1994-12-22,mitterrand2,BVA,943,phone,51.0,44.0 +1994-12-28,mitterrand2,Kantar,1045,face to face,42.0,52.0 +1995-01-16,mitterrand2,Ifop,1068,phone,53.0,43.0 +1995-01-22,mitterrand2,BVA,1020,phone,50.0,45.0 +1995-01-22,mitterrand2,Kantar,904,face to face,42.0,56.0 +1995-02-17,mitterrand2,Ifop,1042,phone,49.0,46.0 +1995-02-23,mitterrand2,BVA,1092,phone,52.0,45.0 +1995-02-25,mitterrand2,Kantar,1033,face to face,41.0,56.0 +1995-03-18,mitterrand2,Ifop,945,phone,46.0,49.0 +1995-03-22,mitterrand2,BVA,1009,phone,51.0,42.0 +1995-03-24,mitterrand2,Kantar,1063,face to face,35.0,60.0 +1995-04-20,mitterrand2,Ifop,1086,phone,45.0,49.0 +1995-04-25,mitterrand2,Kantar,1084,face to face,34.0,61.0 +1995-04-30,mitterrand2,BVA,966,phone,51.0,45.0 +1995-05-19,chirac1,Ifop,935,phone,59.0,22.0 +1995-05-20,chirac1,Kantar,1004,face to face,64.0,32.0 +1995-05-30,chirac1,BVA,1042,phone,62.0,22.0 +1995-06-18,chirac1,Ifop,958,phone,54.0,31.0 +1995-06-22,chirac1,Kantar,1055,face to face,63.0,35.0 +1995-06-30,chirac1,BVA,1086,phone,55.0,27.0 +1995-07-15,chirac1,BVA,981,phone,51.0,33.0 +1995-07-19,chirac1,Ifop,1045,phone,44.0,36.0 +1995-07-20,chirac1,Kantar,992,face to face,56.0,41.0 +1995-08-20,chirac1,Ifop,992,phone,39.0,39.0 +1995-08-22,chirac1,Kantar,1081,face to face,54.0,44.0 +1995-09-16,chirac1,BVA,909,phone,44.0,47.0 +1995-09-20,chirac1,Ifop,935,phone,33.0,51.0 +1995-09-25,chirac1,Kantar,940,face to face,41.0,57.0 +1995-10-16,chirac1,Ifop,1081,phone,28.0,59.0 +1995-10-26,chirac1,Kantar,921,face to face,37.0,61.0 +1995-10-28,chirac1,BVA,1025,phone,36.0,56.0 +1995-11-16,chirac1,Ifop,956,phone,27.0,64.0 +1995-11-27,chirac1,Kantar,927,face to face,39.0,59.0 +1995-11-30,chirac1,BVA,990,phone,32.0,61.0 +1995-12-17,chirac1,Ifop,1092,phone,30.0,63.0 +1995-12-26,chirac1,BVA,1071,phone,37.0,59.0 +1995-12-28,chirac1,Kantar,958,face to face,35.0,63.0 +1996-01-12,chirac1,Ipsos,980,phone,37.6,55.9 +1996-01-17,chirac1,BVA,957,phone,37.0,56.0 +1996-01-18,chirac1,Ifop,981,phone,36.0,53.0 +1996-01-25,chirac1,Kantar,912,face to face,40.0,58.0 +1996-02-15,chirac1,Ipsos,959,phone,42.7,49.9 +1996-02-19,chirac1,Ifop,1064,phone,36.0,54.0 +1996-02-20,chirac1,Kantar,1054,face to face,40.0,59.0 +1996-02-23,chirac1,BVA,911,phone,37.0,58.0 +1996-03-12,chirac1,Ipsos,921,phone,43.3,50.9 +1996-03-15,chirac1,Ifop,994,phone,38.0,51.0 +1996-03-23,chirac1,BVA,1007,phone,44.0,50.0 +1996-03-27,chirac1,Kantar,961,face to face,45.0,53.0 +1996-04-16,chirac1,Ifop,1093,phone,37.0,49.0 +1996-04-26,chirac1,Kantar,1027,face to face,44.0,55.0 +1996-04-27,chirac1,BVA,900,phone,48.0,46.0 +1996-04-27,chirac1,Ipsos,1017,phone,42.1,48.6 +1996-05-19,chirac1,Ifop,1061,phone,37.0,47.0 +1996-05-22,chirac1,Ipsos,1006,phone,44.5,49.1 +1996-05-24,chirac1,BVA,967,phone,44.0,49.0 +1996-05-28,chirac1,Kantar,951,face to face,47.0,51.0 +1996-06-10,chirac1,Ipsos,1086,phone,44.0,50.6 +1996-06-20,chirac1,Ifop,1066,phone,35.0,52.0 +1996-06-23,chirac1,BVA,926,phone,44.0,51.0 +1996-06-23,chirac1,Kantar,981,face to face,42.0,56.0 +1996-07-19,chirac1,BVA,929,phone,40.0,53.0 +1996-07-19,chirac1,Ifop,974,phone,35.0,53.0 +1996-07-25,chirac1,Ipsos,917,phone,40.9,51.4 +1996-07-27,chirac1,Kantar,987,face to face,43.0,55.0 +1996-08-16,chirac1,Ipsos,1069,phone,41.4,52.1 +1996-08-20,chirac1,Ifop,1053,phone,38.0,50.0 +1996-08-20,chirac1,Kantar,1072,face to face,40.0,58.0 +1996-08-22,chirac1,BVA,982,phone,46.0,46.0 +1996-09-19,chirac1,Ifop,938,phone,31.0,55.0 +1996-09-21,chirac1,Ipsos,1053,phone,36.1,57.7 +1996-09-23,chirac1,BVA,1035,phone,40.0,54.0 +1996-09-26,chirac1,Kantar,1058,face to face,37.0,61.0 +1996-10-19,chirac1,Ifop,981,phone,28.0,61.0 +1996-10-21,chirac1,Ipsos,968,phone,31.7,63.9 +1996-10-22,chirac1,Kantar,1085,face to face,32.0,66.0 +1996-10-23,chirac1,BVA,1050,phone,35.0,60.0 +1996-11-17,chirac1,Ipsos,1019,phone,31.7,63.8 +1996-11-20,chirac1,Ifop,972,phone,27.0,58.0 +1996-11-21,chirac1,Kantar,947,face to face,37.0,62.0 +1996-11-30,chirac1,BVA,967,phone,35.0,60.0 +1996-12-17,chirac1,BVA,1053,phone,35.0,58.0 +1996-12-20,chirac1,Ifop,1081,phone,30.0,59.0 +1996-12-20,chirac1,Ipsos,965,phone,34.2,62.8 +1996-12-26,chirac1,Kantar,960,face to face,36.0,63.0 +1997-01-19,chirac1,Ifop,998,phone,30.0,56.0 +1997-01-22,chirac1,Ipsos,951,phone,34.0,60.9 +1997-01-25,chirac1,BVA,904,phone,37.0,57.0 +1997-01-28,chirac1,Kantar,925,face to face,35.0,64.0 +1997-02-19,chirac1,Ifop,922,phone,34.0,55.0 +1997-02-19,chirac1,Ipsos,1001,phone,33.3,62.9 +1997-02-24,chirac1,Kantar,1058,face to face,41.0,60.0 +1997-02-25,chirac1,BVA,980,phone,39.0,55.0 +1997-03-11,chirac1,Ipsos,923,phone,38.9,52.9 +1997-03-19,chirac1,Ifop,1084,phone,32.0,55.0 +1997-03-22,chirac1,Kantar,926,face to face,38.0,60.0 +1997-03-26,chirac1,BVA,1040,phone,39.0,55.0 +1997-04-20,chirac1,Ifop,965,phone,31.0,56.0 +1997-04-20,chirac1,Kantar,994,face to face,38.0,60.0 +1997-04-21,chirac1,Ipsos,935,phone,36.8,55.3 +1997-04-30,chirac1,BVA,1022,phone,35.0,57.0 +1997-05-20,chirac1,Ifop,1003,phone,39.0,52.0 +1997-05-23,chirac1,BVA,1029,phone,40.0,55.0 +1997-05-26,chirac1,Ipsos,1057,phone,45.4,52.0 +1997-05-27,chirac1,Kantar,996,face to face,41.0,57.0 +1997-06-16,chirac1,Ifop,910,phone,38.0,45.0 +1997-06-17,chirac1,Ipsos,975,phone,35.4,55.0 +1997-06-26,chirac1,Kantar,913,face to face,46.0,52.0 +1997-07-16,chirac1,Ifop,918,phone,42.0,43.0 +1997-07-17,chirac1,Ipsos,946,phone,45.6,48.2 +1997-07-23,chirac1,BVA,1004,phone,48.0,44.0 +1997-07-23,chirac1,Kantar,948,face to face,47.0,51.0 +1997-08-13,chirac1,Ipsos,993,phone,47.2,42.3 +1997-08-16,chirac1,Ifop,1011,phone,40.0,42.0 +1997-08-20,chirac1,Kantar,949,face to face,45.0,53.0 +1997-09-18,chirac1,Ifop,1072,phone,44.0,36.0 +1997-09-20,chirac1,Ipsos,997,phone,45.7,43.6 +1997-09-21,chirac1,Kantar,1040,face to face,41.0,58.0 +1997-09-24,chirac1,BVA,952,phone,50.0,40.0 +1997-10-12,chirac1,Ipsos,907,phone,48.0,38.8 +1997-10-16,chirac1,BVA,1053,phone,51.0,40.0 +1997-10-17,chirac1,Ifop,1070,phone,45.0,41.0 +1997-10-24,chirac1,Kantar,1030,face to face,41.0,56.0 +1997-11-17,chirac1,Ifop,1098,phone,47.0,30.0 +1997-11-20,chirac1,Ipsos,1083,phone,48.7,41.9 +1997-11-20,chirac1,Kantar,1004,face to face,41.0,56.0 +1997-11-25,chirac1,BVA,990,phone,51.0,39.0 +1997-12-17,chirac1,Ifop,988,phone,48.0,37.0 +1997-12-22,chirac1,Ipsos,1003,phone,51.2,40.7 +1997-12-23,chirac1,BVA,1043,phone,51.0,38.0 +1997-12-26,chirac1,Kantar,1075,face to face,44.0,43.0 +1998-01-19,chirac1,Ifop,1010,phone,45.0,41.0 +1998-01-20,chirac1,BVA,991,phone,47.0,43.0 +1998-01-22,chirac1,Kantar,1027,face to face,47.0,49.0 +1998-01-24,chirac1,Ipsos,938,phone,47.1,42.5 +1998-02-15,chirac1,Ifop,909,phone,54.0,33.0 +1998-02-24,chirac1,Ipsos,965,phone,54.2,35.6 +1998-02-26,chirac1,BVA,1098,phone,54.0,35.0 +1998-02-26,chirac1,Kantar,948,face to face,55.0,43.0 +1998-03-15,chirac1,Ifop,1022,phone,47.0,38.0 +1998-03-19,chirac1,Ipsos,1000,phone,60.8,31.4 +1998-03-23,chirac1,BVA,996,phone,55.0,35.0 +1998-03-25,chirac1,Kantar,1073,face to face,51.0,47.0 +1998-04-10,chirac1,Ipsos,935,phone,52.3,37.8 +1998-04-15,chirac1,Ifop,1041,phone,44.0,38.0 +1998-04-20,chirac1,BVA,1079,phone,55.0,33.0 +1998-04-22,chirac1,Kantar,915,face to face,48.0,50.0 +1998-05-10,chirac1,Ipsos,1078,phone,53.7,35.9 +1998-05-17,chirac1,Ifop,984,phone,44.0,37.0 +1998-05-22,chirac1,Kantar,956,face to face,45.0,53.0 +1998-05-26,chirac1,BVA,900,phone,51.0,37.0 +1998-06-16,chirac1,BVA,936,phone,60.0,31.0 +1998-06-19,chirac1,Ifop,954,phone,48.0,35.0 +1998-06-25,chirac1,Kantar,1056,face to face,52.0,45.0 +1998-06-26,chirac1,Ipsos,988,phone,53.2,40.3 +1998-07-16,chirac1,Ipsos,927,phone,67.7,25.0 +1998-07-18,chirac1,Ifop,1044,phone,59.0,25.0 +1998-07-24,chirac1,Kantar,935,face to face,59.0,38.0 +1998-07-29,chirac1,BVA,974,phone,67.0,23.0 +1998-08-16,chirac1,Ipsos,946,phone,67.3,26.7 +1998-08-18,chirac1,Ifop,925,phone,62.0,26.0 +1998-08-28,chirac1,Kantar,1005,face to face,56.0,41.0 +1998-09-17,chirac1,Ipsos,1100,phone,65.5,24.3 +1998-09-19,chirac1,Ifop,934,phone,62.0,24.0 +1998-09-23,chirac1,Kantar,1059,face to face,57.0,40.0 +1998-09-30,chirac1,BVA,1089,phone,64.0,27.0 +1998-10-15,chirac1,Ipsos,1062,phone,65.8,25.3 +1998-10-20,chirac1,Ifop,908,phone,56.0,29.0 +1998-10-23,chirac1,BVA,1013,phone,62.0,29.0 +1998-10-26,chirac1,Kantar,1098,face to face,52.0,45.0 +1998-11-17,chirac1,Ifop,1065,phone,54.0,28.0 +1998-11-18,chirac1,Ipsos,1057,phone,63.3,26.1 +1998-11-20,chirac1,BVA,925,phone,61.0,31.0 +1998-11-21,chirac1,Kantar,1030,face to face,52.0,45.0 +1998-12-11,chirac1,Ipsos,944,phone,66.6,27.3 +1998-12-18,chirac1,BVA,951,phone,60.0,30.0 +1998-12-18,chirac1,Ifop,1033,phone,55.0,29.0 +1998-12-27,chirac1,Kantar,995,face to face,54.0,44.0 +1999-01-12,chirac1,Ipsos,1003,phone,74.2,20.8 +1999-01-16,chirac1,Ifop,1040,phone,55.0,27.0 +1999-01-20,chirac1,Kantar,1048,face to face,52.0,46.0 +1999-01-27,chirac1,BVA,958,phone,59.0,28.0 +1999-02-14,chirac1,Ipsos,1094,phone,67.5,27.9 +1999-02-19,chirac1,Ifop,1002,phone,57.0,28.0 +1999-02-23,chirac1,BVA,946,phone,60.0,28.0 +1999-02-27,chirac1,Kantar,940,face to face,55.0,43.0 +1999-03-15,chirac1,Ifop,1028,phone,56.0,30.0 +1999-03-21,chirac1,Ipsos,902,phone,62.0,27.1 +1999-03-25,chirac1,BVA,952,phone,60.0,29.0 +1999-03-25,chirac1,Kantar,1030,face to face,53.0,44.0 +1999-04-11,chirac1,Ipsos,970,phone,67.3,26.9 +1999-04-17,chirac1,Ifop,1043,phone,63.0,27.0 +1999-04-27,chirac1,Kantar,969,face to face,63.0,34.0 +1999-04-28,chirac1,BVA,910,phone,65.0,25.0 +1999-05-17,chirac1,BVA,944,phone,62.0,27.0 +1999-05-19,chirac1,Ifop,1100,phone,63.0,29.0 +1999-05-23,chirac1,Ipsos,1027,phone,70.6,21.1 +1999-05-26,chirac1,Kantar,973,face to face,54.0,43.0 +1999-06-16,chirac1,Ifop,963,phone,58.0,29.0 +1999-06-20,chirac1,Ipsos,989,phone,61.7,33.1 +1999-06-20,chirac1,Kantar,1032,face to face,55.0,42.0 +1999-06-30,chirac1,BVA,930,phone,60.0,29.0 +1999-07-13,chirac1,Ipsos,1022,phone,64.5,28.0 +1999-07-17,chirac1,Ifop,1060,phone,60.0,28.0 +1999-07-25,chirac1,BVA,1067,phone,64.0,24.0 +1999-07-26,chirac1,Kantar,1005,face to face,58.0,39.0 +1999-08-11,chirac1,Ipsos,968,phone,65.0,26.3 +1999-08-18,chirac1,Ifop,946,phone,55.0,28.0 +1999-08-24,chirac1,Kantar,942,face to face,52.0,45.0 +1999-09-15,chirac1,Ifop,976,phone,60.0,29.0 +1999-09-15,chirac1,Ipsos,938,phone,63.0,28.0 +1999-09-23,chirac1,Kantar,975,face to face,56.0,40.0 +1999-09-26,chirac1,BVA,931,phone,60.0,28.0 +1999-10-17,chirac1,BVA,900,phone,59.0,26.0 +1999-10-19,chirac1,Ifop,924,phone,58.0,30.0 +1999-10-24,chirac1,Kantar,982,face to face,51.0,46.0 +1999-10-25,chirac1,Ipsos,974,phone,62.8,27.8 +1999-11-16,chirac1,Ifop,1042,phone,58.0,29.0 +1999-11-25,chirac1,Ipsos,971,phone,63.5,30.3 +1999-11-26,chirac1,Kantar,1017,face to face,50.0,47.0 +1999-11-28,chirac1,BVA,1023,phone,57.0,29.0 +1999-12-12,chirac1,Ipsos,907,phone,62.5,28.9 +1999-12-15,chirac1,Ifop,1058,phone,61.0,30.0 +1999-12-23,chirac1,BVA,950,phone,60.0,27.0 +1999-12-25,chirac1,Kantar,972,face to face,53.0,44.0 +2000-01-15,chirac1,Ipsos,947,phone,61.5,29.0 +2000-01-18,chirac1,Ifop,987,phone,60.0,30.0 +2000-01-28,chirac1,Kantar,976,face to face,49.0,48.0 +2000-01-30,chirac1,BVA,917,phone,62.0,23.0 +2000-02-13,chirac1,Ipsos,987,phone,58.7,31.5 +2000-02-17,chirac1,Ifop,1094,phone,56.0,31.0 +2000-02-22,chirac1,Kantar,999,face to face,52.0,44.0 +2000-02-25,chirac1,BVA,930,phone,55.0,31.0 +2000-03-15,chirac1,Ipsos,1021,phone,63.9,27.5 +2000-03-20,chirac1,Ifop,1006,phone,59.0,31.0 +2000-03-20,chirac1,Kantar,962,face to face,53.0,44.0 +2000-03-21,chirac1,BVA,1016,phone,58.0,28.0 +2000-04-18,chirac1,Ifop,991,phone,61.0,28.0 +2000-04-24,chirac1,BVA,1041,phone,60.0,25.0 +2000-04-24,chirac1,Kantar,900,face to face,54.0,43.0 +2000-04-26,chirac1,Ipsos,1055,phone,61.5,29.4 +2000-05-15,chirac1,Ifop,978,phone,64.0,25.0 +2000-05-15,chirac1,Ipsos,1097,phone,68.7,22.5 +2000-05-16,chirac1,BVA,925,phone,63.0,25.0 +2000-05-22,chirac1,Kantar,927,face to face,52.0,44.0 +2000-06-17,chirac1,BVA,1036,phone,62.0,27.0 +2000-06-20,chirac1,Ifop,1062,phone,60.0,30.0 +2000-06-20,chirac1,Ipsos,1087,phone,61.6,29.1 +2000-06-22,chirac1,Kantar,960,face to face,55.0,42.0 +2000-07-19,chirac1,Ifop,916,phone,60.0,26.0 +2000-07-21,chirac1,BVA,1003,phone,66.0,23.0 +2000-07-21,chirac1,Kantar,915,face to face,57.0,40.0 +2000-07-27,chirac1,Ipsos,960,phone,67.4,24.1 +2000-08-15,chirac1,Ipsos,984,phone,64.3,22.2 +2000-08-20,chirac1,Ifop,1048,phone,61.0,25.0 +2000-08-23,chirac1,Kantar,946,face to face,52.0,45.0 +2000-09-15,chirac1,Ifop,1044,phone,51.0,36.0 +2000-09-15,chirac1,Ipsos,1005,phone,61.6,29.3 +2000-09-22,chirac1,Kantar,1080,face to face,41.0,57.0 +2000-09-23,chirac1,BVA,979,phone,57.0,32.0 +2000-10-17,chirac1,Ifop,923,phone,55.0,34.0 +2000-10-18,chirac1,Ipsos,964,phone,54.8,35.9 +2000-10-21,chirac1,BVA,909,phone,53.0,35.0 +2000-10-28,chirac1,Kantar,1023,face to face,49.0,49.0 +2000-11-18,chirac1,Ipsos,910,phone,57.0,31.0 +2000-11-19,chirac1,Ifop,1045,phone,56.0,32.0 +2000-11-21,chirac1,Kantar,909,face to face,47.0,49.0 +2000-11-29,chirac1,BVA,908,phone,55.0,30.0 +2000-12-16,chirac1,Ifop,1027,phone,55.0,35.0 +2000-12-20,chirac1,Ipsos,1030,phone,55.0,34.0 +2000-12-26,chirac1,Kantar,950,face to face,50.0,47.0 +2000-12-29,chirac1,BVA,1004,phone,61.0,29.0 +2001-01-16,chirac1,Ipsos,904,phone,54.0,34.0 +2001-01-18,chirac1,Ifop,923,phone,57.0,34.0 +2001-01-27,chirac1,BVA,950,phone,57.0,31.0 +2001-01-28,chirac1,Kantar,930,face to face,50.0,48.0 +2001-02-15,chirac1,Ipsos,1021,phone,61.0,28.0 +2001-02-17,chirac1,BVA,1022,phone,62.0,27.0 +2001-02-19,chirac1,Ifop,1067,phone,57.0,35.0 +2001-02-21,chirac1,Kantar,995,face to face,49.0,49.0 +2001-03-17,chirac1,Ifop,916,phone,60.0,28.0 +2001-03-18,chirac1,BVA,931,phone,59.0,30.0 +2001-03-20,chirac1,Ipsos,1050,phone,56.0,33.0 +2001-03-22,chirac1,Kantar,1021,face to face,51.0,46.0 +2001-03-27,chirac1,BVA,1076,phone,58.0,31.0 +2001-04-17,chirac1,Ifop,1073,phone,56.0,33.0 +2001-04-17,chirac1,Ipsos,971,phone,53.0,34.0 +2001-04-23,chirac1,BVA,1057,phone,59.0,31.0 +2001-04-24,chirac1,Kantar,1017,face to face,46.0,51.0 +2001-05-20,chirac1,Ifop,931,phone,54.0,32.0 +2001-05-22,chirac1,Ipsos,923,phone,58.0,30.0 +2001-05-26,chirac1,BVA,945,phone,57.0,31.0 +2001-05-28,chirac1,Kantar,1077,face to face,45.0,51.0 +2001-06-16,chirac1,Ipsos,974,phone,57.0,32.0 +2001-06-20,chirac1,Ifop,969,phone,61.0,33.0 +2001-06-26,chirac1,BVA,931,phone,58.0,30.0 +2001-06-26,chirac1,Kantar,981,face to face,45.0,52.0 +2001-07-14,chirac1,Ipsos,995,phone,57.0,30.0 +2001-07-15,chirac1,Ifop,960,phone,54.0,31.0 +2001-07-20,chirac1,Kantar,1087,face to face,45.0,51.0 +2001-07-23,chirac1,BVA,935,phone,55.0,33.0 +2001-08-19,chirac1,Ifop,1065,phone,60.0,31.0 +2001-08-21,chirac1,Ipsos,1072,phone,55.0,32.0 +2001-08-25,chirac1,Kantar,971,face to face,47.0,50.0 +2001-09-11,chirac1,Ipsos,1095,phone,50.0,35.0 +2001-09-15,chirac1,Ifop,997,phone,62.0,30.0 +2001-09-23,chirac1,Kantar,1030,face to face,57.0,40.0 +2001-09-25,chirac1,BVA,954,phone,61.0,33.0 +2001-10-16,chirac1,Ifop,927,phone,58.0,34.0 +2001-10-23,chirac1,Kantar,928,face to face,56.0,41.0 +2001-10-25,chirac1,Ipsos,1051,phone,65.0,24.0 +2001-10-26,chirac1,BVA,957,phone,59.0,31.0 +2001-11-19,chirac1,Ifop,1096,phone,54.0,31.0 +2001-11-20,chirac1,BVA,904,phone,58.0,31.0 +2001-11-21,chirac1,Kantar,901,face to face,50.0,48.0 +2001-11-23,chirac1,Ipsos,932,phone,63.0,30.0 +2001-12-18,chirac1,BVA,903,phone,55.0,35.0 +2001-12-18,chirac1,Ipsos,962,phone,55.0,35.0 +2001-12-20,chirac1,Ifop,988,phone,54.0,36.0 +2001-12-20,chirac1,Kantar,1096,face to face,46.0,51.0 +2002-01-17,chirac1,Ifop,1087,phone,53.0,39.0 +2002-01-20,chirac1,Kantar,963,face to face,46.0,51.0 +2002-01-21,chirac1,BVA,919,phone,57.0,32.0 +2002-01-22,chirac1,Ipsos,1074,phone,57.0,32.0 +2002-02-17,chirac1,BVA,1081,phone,55.0,40.0 +2002-02-20,chirac1,Ifop,1004,phone,50.0,44.0 +2002-02-20,chirac1,Ipsos,959,phone,47.0,46.0 +2002-02-20,chirac1,Kantar,986,face to face,43.0,54.0 +2002-03-18,chirac1,Ifop,967,phone,43.0,51.0 +2002-03-21,chirac1,Ipsos,1093,phone,43.0,49.0 +2002-03-22,chirac1,Kantar,959,face to face,40.0,58.0 +2002-03-28,chirac1,BVA,930,phone,50.0,45.0 +2002-04-15,chirac1,BVA,962,phone,52.0,42.0 +2002-04-15,chirac1,Ifop,1047,phone,47.0,48.0 +2002-04-20,chirac1,Kantar,979,face to face,52.0,47.0 +2002-04-23,chirac1,Ipsos,1056,phone,47.0,49.0 +2002-05-15,chirac2,Ifop,924,phone,51.0,44.0 +2002-05-20,chirac2,Kantar,972,face to face,50.0,48.0 +2002-05-23,chirac2,BVA,1054,phone,52.0,37.0 +2002-05-26,chirac2,Ipsos,907,phone,48.0,48.0 +2002-06-16,chirac2,Ifop,974,phone,49.0,43.0 +2002-06-17,chirac2,Ipsos,1050,phone,53.0,40.0 +2002-06-20,chirac2,BVA,938,phone,53.0,36.0 +2002-06-27,chirac2,Kantar,918,face to face,47.0,51.0 +2002-07-18,chirac2,Ifop,989,phone,53.0,38.0 +2002-07-19,chirac2,Ipsos,933,phone,53.0,39.0 +2002-07-26,chirac2,Kantar,920,face to face,54.0,45.0 +2002-08-13,chirac2,Ipsos,1008,phone,56.0,34.0 +2002-08-20,chirac2,Ifop,977,phone,53.0,40.0 +2002-08-28,chirac2,Kantar,1099,face to face,47.0,51.0 +2002-09-15,chirac2,Ifop,1095,phone,52.0,42.0 +2002-09-20,chirac2,BVA,1037,phone,56.0,37.0 +2002-09-24,chirac2,Ipsos,967,phone,52.0,41.0 +2002-09-26,chirac2,Kantar,971,face to face,50.0,48.0 +2002-10-16,chirac2,Ifop,1079,phone,57.0,37.0 +2002-10-22,chirac2,Ipsos,1051,phone,54.0,38.0 +2002-10-23,chirac2,BVA,906,phone,53.0,40.0 +2002-10-26,chirac2,Kantar,903,face to face,49.0,48.0 +2002-11-16,chirac2,Ifop,1014,phone,56.0,37.0 +2002-11-20,chirac2,BVA,930,phone,56.0,36.0 +2002-11-23,chirac2,Ipsos,1006,phone,62.0,33.0 +2002-11-27,chirac2,Kantar,964,face to face,47.0,50.0 +2002-12-17,chirac2,Ifop,951,phone,57.0,36.0 +2002-12-20,chirac2,Kantar,1100,face to face,52.0,45.0 +2002-12-22,chirac2,BVA,1064,phone,61.0,32.0 +2002-12-23,chirac2,Ipsos,1081,phone,60.0,36.0 +2003-01-10,chirac2,Ipsos,1029,phone,58.0,34.0 +2003-01-16,chirac2,Ifop,940,phone,60.0,33.0 +2003-01-20,chirac2,BVA,926,phone,58.0,36.0 +2003-01-21,chirac2,Kantar,985,face to face,50.0,49.0 +2003-02-16,chirac2,Ifop,965,phone,57.0,35.0 +2003-02-24,chirac2,Kantar,903,face to face,55.0,42.0 +2003-02-26,chirac2,Ipsos,947,phone,62.0,33.0 +2003-02-27,chirac2,BVA,983,phone,61.0,31.0 +2003-03-15,chirac2,Ipsos,976,phone,69.0,25.0 +2003-03-19,chirac2,BVA,923,phone,69.0,25.0 +2003-03-20,chirac2,Ifop,1091,phone,67.0,27.0 +2003-03-28,chirac2,Kantar,982,face to face,60.0,37.0 +2003-04-15,chirac2,Ifop,1087,phone,65.0,27.0 +2003-04-15,chirac2,Ipsos,1058,phone,70.0,25.0 +2003-04-20,chirac2,Kantar,1073,face to face,53.0,44.0 +2003-04-25,chirac2,BVA,1013,phone,66.0,28.0 +2003-05-18,chirac2,Ifop,978,phone,58.0,36.0 +2003-05-22,chirac2,Ipsos,918,phone,68.0,28.0 +2003-05-23,chirac2,Kantar,946,face to face,49.0,49.0 +2003-05-28,chirac2,BVA,946,phone,64.0,28.0 +2003-06-10,chirac2,Ipsos,1064,phone,61.0,35.0 +2003-06-19,chirac2,BVA,932,phone,60.0,30.0 +2003-06-19,chirac2,Ifop,949,phone,56.0,37.0 +2003-06-25,chirac2,Kantar,1076,face to face,47.0,50.0 +2003-07-18,chirac2,Ipsos,1027,phone,57.0,37.0 +2003-07-19,chirac2,Ifop,966,phone,56.0,40.0 +2003-07-21,chirac2,BVA,1076,phone,57.0,34.0 +2003-07-27,chirac2,Kantar,987,face to face,50.0,48.0 +2003-08-18,chirac2,Ifop,1071,phone,54.0,42.0 +2003-08-20,chirac2,Ipsos,1036,phone,53.0,41.0 +2003-08-20,chirac2,Kantar,1085,face to face,46.0,51.0 +2003-09-15,chirac2,Ipsos,1086,phone,55.0,40.0 +2003-09-17,chirac2,Ifop,949,phone,50.0,47.0 +2003-09-23,chirac2,Kantar,1092,face to face,43.0,54.0 +2003-09-29,chirac2,BVA,1085,phone,52.0,39.0 +2003-10-12,chirac2,Ipsos,1005,phone,50.0,42.0 +2003-10-18,chirac2,BVA,980,phone,51.0,39.0 +2003-10-19,chirac2,Ifop,1020,phone,49.0,48.0 +2003-10-25,chirac2,Kantar,1035,face to face,40.0,59.0 +2003-11-16,chirac2,Ifop,1024,phone,49.0,48.0 +2003-11-22,chirac2,Ipsos,1008,phone,52.0,43.0 +2003-11-23,chirac2,BVA,995,phone,50.0,41.0 +2003-11-28,chirac2,Kantar,1094,face to face,40.0,58.0 +2003-12-18,chirac2,Ifop,929,phone,50.0,48.0 +2003-12-20,chirac2,Ipsos,1043,phone,52.0,40.0 +2003-12-23,chirac2,BVA,918,phone,53.0,39.0 +2003-12-27,chirac2,Kantar,947,face to face,43.0,55.0 +2004-01-12,chirac2,Ipsos,901,phone,58.0,38.0 +2004-01-17,chirac2,BVA,1001,phone,53.0,39.0 +2004-01-20,chirac2,Ifop,956,phone,53.0,45.0 +2004-01-21,chirac2,Kantar,978,face to face,39.0,59.0 +2004-02-10,chirac2,Ipsos,1081,phone,51.0,45.0 +2004-02-19,chirac2,Ifop,914,phone,47.0,51.0 +2004-02-26,chirac2,Kantar,1012,face to face,35.0,62.0 +2004-03-16,chirac2,Ifop,1038,phone,48.0,49.0 +2004-03-23,chirac2,Kantar,948,face to face,40.0,57.0 +2004-03-27,chirac2,Ipsos,1071,phone,46.0,48.0 +2004-03-30,chirac2,BVA,1055,phone,46.0,45.0 +2004-04-15,chirac2,Ipsos,1047,phone,46.0,51.0 +2004-04-20,chirac2,Ifop,1004,phone,44.0,53.0 +2004-04-21,chirac2,Kantar,1043,face to face,32.0,65.0 +2004-04-28,chirac2,BVA,951,phone,42.0,50.0 +2004-05-10,chirac2,Ipsos,1004,phone,50.0,46.0 +2004-05-18,chirac2,Ifop,922,phone,43.0,53.0 +2004-05-22,chirac2,Kantar,950,face to face,35.0,62.0 +2004-06-18,chirac2,Ipsos,941,phone,51.0,44.0 +2004-06-19,chirac2,Ifop,970,phone,45.0,51.0 +2004-06-23,chirac2,BVA,959,phone,46.0,46.0 +2004-06-23,chirac2,Kantar,954,face to face,34.0,64.0 +2004-07-16,chirac2,Ifop,928,phone,49.0,49.0 +2004-07-22,chirac2,Ipsos,1078,phone,49.0,45.0 +2004-07-26,chirac2,Kantar,921,face to face,37.0,61.0 +2004-08-18,chirac2,Ifop,915,phone,49.0,48.0 +2004-08-20,chirac2,Ipsos,1080,phone,49.0,46.0 +2004-08-26,chirac2,Kantar,1062,face to face,36.0,62.0 +2004-09-16,chirac2,Ifop,1092,phone,43.0,53.0 +2004-09-18,chirac2,BVA,1043,phone,54.0,37.0 +2004-09-20,chirac2,Kantar,992,face to face,36.0,61.0 +2004-09-25,chirac2,Ipsos,1049,phone,54.0,40.0 +2004-10-11,chirac2,Ipsos,981,phone,53.0,41.0 +2004-10-15,chirac2,BVA,1067,phone,53.0,39.0 +2004-10-20,chirac2,Ifop,946,phone,41.0,56.0 +2004-10-25,chirac2,Kantar,1086,face to face,36.0,62.0 +2004-11-15,chirac2,Ipsos,1097,phone,52.0,43.0 +2004-11-18,chirac2,BVA,1070,phone,54.0,39.0 +2004-11-19,chirac2,Ifop,958,phone,48.0,48.0 +2004-11-20,chirac2,Kantar,963,face to face,38.0,60.0 +2004-12-15,chirac2,BVA,1080,phone,57.0,36.0 +2004-12-18,chirac2,Ifop,980,phone,50.0,47.0 +2004-12-18,chirac2,Ipsos,963,phone,54.0,40.0 +2004-12-24,chirac2,Kantar,955,face to face,41.0,56.0 +2005-01-15,chirac2,Ifop,1053,phone,49.0,49.0 +2005-01-22,chirac2,BVA,1035,phone,55.0,37.0 +2005-01-24,chirac2,Ipsos,917,phone,53.0,40.0 +2005-01-24,chirac2,Kantar,1039,face to face,37.0,59.0 +2005-02-15,chirac2,Ipsos,960,phone,49.0,43.0 +2005-02-17,chirac2,Ifop,938,phone,47.0,48.0 +2005-02-22,chirac2,Kantar,917,face to face,36.0,61.0 +2005-02-26,chirac2,BVA,1076,phone,50.0,40.0 +2005-03-16,chirac2,Ifop,978,phone,42.0,54.0 +2005-03-22,chirac2,Ipsos,1063,phone,49.0,44.0 +2005-03-23,chirac2,Kantar,1074,face to face,36.0,62.0 +2005-03-24,chirac2,BVA,937,phone,50.0,45.0 +2005-04-16,chirac2,Ifop,1089,phone,45.0,52.0 +2005-04-19,chirac2,BVA,990,phone,48.0,46.0 +2005-04-25,chirac2,Ipsos,1030,phone,48.0,49.0 +2005-04-26,chirac2,Kantar,1052,face to face,32.0,66.0 +2005-05-15,chirac2,Ifop,1026,phone,40.0,59.0 +2005-05-20,chirac2,BVA,1001,phone,39.0,56.0 +2005-05-24,chirac2,Ipsos,1002,phone,47.0,51.0 +2005-05-28,chirac2,Kantar,1081,face to face,24.0,74.0 +2005-06-15,chirac2,BVA,956,phone,35.0,59.0 +2005-06-20,chirac2,Ifop,1030,phone,28.0,70.0 +2005-06-24,chirac2,Ipsos,909,phone,27.0,69.0 +2005-06-24,chirac2,Kantar,927,face to face,21.0,77.0 +2005-07-13,chirac2,Ipsos,1060,phone,32.0,63.0 +2005-07-16,chirac2,Ifop,959,phone,32.0,66.0 +2005-07-25,chirac2,BVA,1004,phone,36.0,56.0 +2005-07-25,chirac2,Kantar,911,face to face,28.0,69.0 +2005-08-15,chirac2,Ifop,1048,phone,35.0,64.0 +2005-08-21,chirac2,Ipsos,966,phone,39.0,55.0 +2005-08-27,chirac2,Kantar,1036,face to face,26.0,71.0 +2005-09-17,chirac2,BVA,1070,phone,46.0,47.0 +2005-09-17,chirac2,Ifop,1035,phone,37.0,61.0 +2005-09-23,chirac2,Ipsos,915,phone,42.0,53.0 +2005-09-24,chirac2,Kantar,901,face to face,26.0,72.0 +2005-10-16,chirac2,Ifop,951,phone,38.0,61.0 +2005-10-19,chirac2,Ipsos,1009,phone,33.0,62.0 +2005-10-20,chirac2,Kantar,1028,face to face,24.0,74.0 +2005-10-23,chirac2,BVA,972,phone,39.0,54.0 +2005-11-18,chirac2,Ifop,935,phone,35.0,64.0 +2005-11-24,chirac2,Ipsos,937,phone,39.0,58.0 +2005-11-24,chirac2,Kantar,937,face to face,26.0,72.0 +2005-11-27,chirac2,BVA,904,phone,39.0,54.0 +2005-12-13,chirac2,Ipsos,975,phone,40.0,53.0 +2005-12-16,chirac2,Ifop,935,phone,33.0,65.0 +2005-12-22,chirac2,Kantar,1064,face to face,21.0,77.0 +2005-12-28,chirac2,BVA,1052,phone,36.0,55.0 +2006-01-16,chirac2,Ifop,905,phone,37.0,61.0 +2006-01-17,chirac2,Ipsos,987,phone,38.0,57.0 +2006-01-19,chirac2,BVA,1043,phone,40.0,52.0 +2006-01-24,chirac2,Kantar,911,face to face,21.0,77.0 +2006-02-18,chirac2,BVA,953,phone,39.0,53.0 +2006-02-19,chirac2,Ipsos,971,phone,41.0,56.0 +2006-02-20,chirac2,Ifop,971,phone,37.0,61.0 +2006-02-26,chirac2,Kantar,933,face to face,23.0,75.0 +2006-03-17,chirac2,Ifop,982,phone,39.0,60.0 +2006-03-21,chirac2,Ipsos,1062,phone,40.0,57.0 +2006-03-27,chirac2,Kantar,914,face to face,20.0,78.0 +2006-04-11,chirac2,Ipsos,1097,phone,29.0,67.0 +2006-04-17,chirac2,Ifop,905,phone,29.0,70.0 +2006-04-26,chirac2,BVA,1055,phone,36.0,56.0 +2006-04-28,chirac2,Kantar,1031,face to face,19.0,80.0 +2006-05-16,chirac2,Ifop,964,phone,29.0,70.0 +2006-05-17,chirac2,Ipsos,1068,phone,32.0,65.0 +2006-05-25,chirac2,Kantar,991,face to face,17.0,81.0 +2006-05-26,chirac2,BVA,1096,phone,32.0,58.0 +2006-06-18,chirac2,Ifop,927,phone,27.0,70.0 +2006-06-18,chirac2,Ipsos,1023,phone,32.0,64.0 +2006-06-21,chirac2,Kantar,1092,face to face,16.0,81.0 +2006-06-27,chirac2,BVA,972,phone,35.0,57.0 +2006-07-16,chirac2,Ifop,958,phone,38.0,61.0 +2006-07-22,chirac2,Kantar,993,face to face,21.0,77.0 +2006-07-23,chirac2,Ipsos,984,phone,38.0,58.0 +2006-08-15,chirac2,Ifop,1074,phone,36.0,63.0 +2006-08-24,chirac2,Kantar,1019,face to face,25.0,73.0 +2006-08-26,chirac2,Ipsos,904,phone,41.0,55.0 +2006-09-20,chirac2,Ifop,1022,phone,38.0,61.0 +2006-09-24,chirac2,Ipsos,956,phone,41.0,55.0 +2006-09-24,chirac2,Kantar,1084,face to face,24.0,74.0 +2006-10-18,chirac2,Ipsos,1038,phone,42.0,55.0 +2006-10-19,chirac2,Ifop,1100,phone,38.0,61.0 +2006-10-23,chirac2,Kantar,1084,face to face,24.0,74.0 +2006-10-28,chirac2,BVA,1034,phone,40.0,49.0 +2006-11-17,chirac2,Ifop,971,phone,36.0,63.0 +2006-11-23,chirac2,Ipsos,1079,phone,45.0,53.0 +2006-11-24,chirac2,BVA,900,phone,43.0,49.0 +2006-11-25,chirac2,Kantar,1037,face to face,25.0,73.0 +2006-12-19,chirac2,Ifop,941,phone,38.0,61.0 +2006-12-20,chirac2,Kantar,1091,face to face,23.0,75.0 +2006-12-24,chirac2,Ipsos,1036,phone,46.0,51.0 +2007-01-15,chirac2,Ifop,1041,phone,41.0,57.0 +2007-01-20,chirac2,Ipsos,1018,phone,41.0,56.0 +2007-01-20,chirac2,Kantar,1098,face to face,25.0,72.0 +2007-02-15,chirac2,Ifop,1013,phone,43.0,56.0 +2007-02-22,chirac2,Ipsos,1024,phone,46.0,50.0 +2007-02-22,chirac2,Kantar,1013,face to face,29.0,69.0 +2007-03-15,chirac2,Ifop,1026,phone,46.0,53.0 +2007-03-24,chirac2,Kantar,950,face to face,30.0,67.0 +2007-03-25,chirac2,Ipsos,992,phone,53.0,45.0 +2007-04-15,chirac2,Ifop,969,phone,47.0,52.0 +2007-04-22,chirac2,Ipsos,1011,phone,53.0,45.0 +2007-04-25,chirac2,Kantar,904,face to face,30.0,64.0 +2007-05-16,sarkozy,Ifop,1001,phone,65.0,31.0 +2007-05-20,sarkozy,Kantar,982,face to face,63.0,34.0 +2007-05-24,sarkozy,Ipsos,1086,phone,64.0,24.0 +2007-06-20,sarkozy,Ifop,1003,phone,65.0,34.0 +2007-06-20,sarkozy,Kantar,943,face to face,65.0,31.0 +2007-06-22,sarkozy,Ipsos,912,phone,61.0,31.0 +2007-07-18,sarkozy,Ifop,1046,phone,66.0,30.0 +2007-07-23,sarkozy,Ipsos,936,phone,66.0,25.0 +2007-07-25,sarkozy,Kantar,908,face to face,64.0,33.0 +2007-08-17,sarkozy,Ifop,907,phone,69.0,29.0 +2007-08-20,sarkozy,Kantar,950,face to face,64.0,32.0 +2007-08-27,sarkozy,Ipsos,1067,phone,61.0,30.0 +2007-09-15,sarkozy,BVA,926,phone,57.0,33.0 +2007-09-18,sarkozy,Ipsos,982,phone,64.0,30.0 +2007-09-19,sarkozy,Ifop,918,phone,61.0,36.0 +2007-09-27,sarkozy,Kantar,984,face to face,57.0,40.0 +2007-10-13,sarkozy,Ipsos,1052,phone,63.0,34.0 +2007-10-17,sarkozy,BVA,1077,phone,55.0,37.0 +2007-10-18,sarkozy,Ifop,904,phone,59.0,39.0 +2007-10-20,sarkozy,Kantar,1016,face to face,53.0,42.0 +2007-11-17,sarkozy,Ifop,1060,phone,55.0,44.0 +2007-11-19,sarkozy,Ipsos,1091,phone,58.0,39.0 +2007-11-23,sarkozy,BVA,914,phone,55.0,38.0 +2007-11-24,sarkozy,Kantar,1091,face to face,49.0,49.0 +2007-12-16,sarkozy,Ifop,942,phone,52.0,47.0 +2007-12-20,sarkozy,Ipsos,933,phone,55.0,41.0 +2007-12-24,sarkozy,Kantar,950,face to face,49.0,48.0 +2007-12-25,sarkozy,BVA,1070,phone,51.0,43.0 +2008-01-16,sarkozy,Ifop,1020,phone,47.0,52.0 +2008-01-18,sarkozy,Ipsos,1004,phone,49.0,49.0 +2008-01-21,sarkozy,Kantar,974,face to face,41.0,55.0 +2008-01-24,sarkozy,BVA,936,phone,45.0,48.0 +2008-02-18,sarkozy,BVA,1078,phone,36.0,58.0 +2008-02-20,sarkozy,Ifop,924,phone,38.0,62.0 +2008-02-21,sarkozy,Kantar,1087,face to face,37.0,61.0 +2008-02-27,sarkozy,Ipsos,975,phone,39.0,58.0 +2008-03-16,sarkozy,Ipsos,941,phone,41.0,56.0 +2008-03-17,sarkozy,Ifop,1010,phone,37.0,63.0 +2008-03-25,sarkozy,Kantar,911,face to face,37.0,60.0 +2008-03-30,sarkozy,BVA,955,phone,40.0,55.0 +2008-04-15,sarkozy,Ipsos,972,phone,40.0,57.0 +2008-04-17,sarkozy,Ifop,919,phone,36.0,64.0 +2008-04-20,sarkozy,BVA,990,phone,32.0,64.0 +2008-04-21,sarkozy,Kantar,997,face to face,32.0,66.0 +2008-05-18,sarkozy,Ifop,1056,phone,35.0,64.0 +2008-05-23,sarkozy,BVA,1069,phone,35.0,60.0 +2008-05-24,sarkozy,Kantar,1002,face to face,37.0,61.0 +2008-05-27,sarkozy,Ipsos,1095,phone,40.0,58.0 +2008-06-18,sarkozy,Ifop,1009,phone,37.0,62.0 +2008-06-20,sarkozy,Kantar,1038,face to face,33.0,65.0 +2008-06-26,sarkozy,Ipsos,1091,phone,38.0,60.0 +2008-06-28,sarkozy,BVA,954,phone,36.0,59.0 +2008-07-17,sarkozy,BVA,1039,phone,35.0,60.0 +2008-07-18,sarkozy,Ifop,1074,phone,38.0,61.0 +2008-07-24,sarkozy,Ipsos,983,phone,39.0,57.0 +2008-08-18,sarkozy,Ifop,1086,phone,40.0,59.0 +2008-08-24,sarkozy,Kantar,1080,face to face,34.0,62.0 +2008-08-26,sarkozy,Ipsos,938,phone,44.0,52.0 +2008-09-15,sarkozy,Ifop,1048,phone,37.0,62.0 +2008-09-17,sarkozy,Ipsos,1010,phone,42.0,55.0 +2008-09-20,sarkozy,Kantar,931,face to face,36.0,61.0 +2008-09-28,sarkozy,BVA,999,phone,47.0,48.0 +2008-10-20,sarkozy,Ifop,919,phone,43.0,56.0 +2008-10-21,sarkozy,Ipsos,993,phone,41.0,56.0 +2008-10-26,sarkozy,Kantar,936,face to face,39.0,57.0 +2008-10-30,sarkozy,BVA,929,phone,43.0,54.0 +2008-11-12,sarkozy,Ipsos,948,phone,49.0,49.0 +2008-11-16,sarkozy,Ifop,1005,phone,44.0,56.0 +2008-11-17,sarkozy,BVA,917,phone,48.0,47.0 +2008-11-23,sarkozy,Kantar,1055,face to face,37.0,59.0 +2008-12-15,sarkozy,Ifop,1003,phone,44.0,55.0 +2008-12-25,sarkozy,Ipsos,975,phone,46.0,51.0 +2008-12-26,sarkozy,Kantar,1015,face to face,41.0,56.0 +2009-01-17,sarkozy,Ifop,932,phone,44.0,56.0 +2009-01-21,sarkozy,Ipsos,1033,phone,45.0,51.0 +2009-01-22,sarkozy,Kantar,984,face to face,37.0,60.0 +2009-01-25,sarkozy,BVA,955,phone,47.0,45.0 +2009-02-16,sarkozy,Ifop,964,phone,37.0,62.0 +2009-02-21,sarkozy,BVA,989,phone,41.0,53.0 +2009-02-23,sarkozy,Kantar,932,face to face,38.0,58.0 +2009-02-27,sarkozy,Ipsos,1010,phone,36.0,61.0 +2009-03-16,sarkozy,BVA,1013,phone,42.0,53.0 +2009-03-17,sarkozy,Ifop,907,phone,36.0,63.0 +2009-03-22,sarkozy,Ipsos,1095,phone,37.0,58.0 +2009-03-23,sarkozy,Kantar,1030,face to face,36.0,62.0 +2009-04-16,sarkozy,Ifop,1038,phone,40.0,59.0 +2009-04-19,sarkozy,Ipsos,1077,phone,43.0,55.0 +2009-04-23,sarkozy,Kantar,1093,face to face,32.0,65.0 +2009-04-26,sarkozy,BVA,985,phone,43.0,49.0 +2009-05-16,sarkozy,Ifop,1087,phone,38.0,62.0 +2009-05-18,sarkozy,BVA,977,phone,43.0,50.0 +2009-05-21,sarkozy,Ipsos,1080,phone,45.0,54.0 +2009-05-25,sarkozy,Kantar,1074,face to face,41.0,57.0 +2009-06-15,sarkozy,BVA,928,phone,45.0,51.0 +2009-06-19,sarkozy,Ifop,1035,phone,41.0,59.0 +2009-06-20,sarkozy,Ipsos,948,phone,48.0,51.0 +2009-06-25,sarkozy,Kantar,917,face to face,38.0,60.0 +2009-07-19,sarkozy,Ifop,953,phone,43.0,56.0 +2009-07-26,sarkozy,Ipsos,1025,phone,45.0,52.0 +2009-08-16,sarkozy,Ifop,1069,phone,45.0,54.0 +2009-08-22,sarkozy,Kantar,1080,face to face,39.0,57.0 +2009-08-23,sarkozy,Ipsos,1077,phone,46.0,50.0 +2009-09-15,sarkozy,Ipsos,1094,phone,46.0,51.0 +2009-09-19,sarkozy,Ifop,903,phone,39.0,60.0 +2009-09-20,sarkozy,Kantar,900,face to face,39.0,57.0 +2009-09-22,sarkozy,BVA,904,phone,47.0,49.0 +2009-10-17,sarkozy,Ifop,1099,phone,38.0,61.0 +2009-10-22,sarkozy,BVA,904,phone,42.0,54.0 +2009-10-24,sarkozy,Kantar,1060,face to face,37.0,60.0 +2009-10-25,sarkozy,Ipsos,961,phone,44.0,54.0 +2009-11-16,sarkozy,BVA,1010,phone,43.0,52.0 +2009-11-17,sarkozy,Ipsos,1081,phone,39.0,60.0 +2009-11-19,sarkozy,Ifop,948,phone,36.0,63.0 +2009-11-27,sarkozy,Kantar,1016,face to face,34.0,63.0 +2009-12-15,sarkozy,Ifop,1088,phone,37.0,62.0 +2009-12-23,sarkozy,Ipsos,947,phone,38.0,60.0 +2009-12-27,sarkozy,Kantar,1067,face to face,32.0,63.0 +2009-12-29,sarkozy,BVA,1013,phone,42.0,53.0 +2010-01-15,sarkozy,Ifop,1092,phone,38.0,61.0 +2010-01-27,sarkozy,Ipsos,1021,phone,38.0,59.0 +2010-01-28,sarkozy,BVA,1068,phone,43.0,53.0 +2010-01-28,sarkozy,Kantar,910,face to face,31.0,65.0 +2010-02-15,sarkozy,Ipsos,951,phone,39.0,59.0 +2010-02-17,sarkozy,Ifop,1021,phone,36.0,63.0 +2010-02-21,sarkozy,Kantar,1090,face to face,31.0,65.0 +2010-02-27,sarkozy,BVA,983,phone,39.0,56.0 +2010-03-14,sarkozy,Ipsos,987,phone,32.0,65.0 +2010-03-15,sarkozy,BVA,1048,phone,41.0,56.0 +2010-03-18,sarkozy,Ifop,917,phone,30.0,65.0 +2010-03-27,sarkozy,Kantar,1053,face to face,28.0,70.0 +2010-04-19,sarkozy,Ifop,976,phone,31.0,68.0 +2010-04-22,sarkozy,BVA,988,phone,40.0,57.0 +2010-04-27,sarkozy,Ipsos,1040,phone,32.0,65.0 +2010-04-27,sarkozy,Kantar,1087,face to face,30.0,67.0 +2010-05-12,sarkozy,Ipsos,921,phone,36.0,61.0 +2010-05-20,sarkozy,Ifop,1004,phone,33.0,66.0 +2010-05-21,sarkozy,BVA,936,phone,36.0,59.0 +2010-05-26,sarkozy,Kantar,1036,face to face,28.0,67.0 +2010-06-16,sarkozy,Ifop,994,phone,34.0,66.0 +2010-06-25,sarkozy,Ipsos,971,phone,35.0,63.0 +2010-06-28,sarkozy,Kantar,1043,face to face,26.0,71.0 +2010-07-19,sarkozy,Ifop,1043,phone,34.0,66.0 +2010-07-25,sarkozy,Ipsos,985,phone,35.0,61.0 +2010-07-26,sarkozy,BVA,1045,phone,33.0,64.0 +2010-08-10,sarkozy,Ipsos,1019,phone,34.0,63.0 +2010-08-20,sarkozy,Ifop,1089,phone,36.0,64.0 +2010-08-23,sarkozy,Kantar,1023,face to face,30.0,67.0 +2010-09-14,sarkozy,Ipsos,983,phone,34.0,62.0 +2010-09-16,sarkozy,Ifop,1015,phone,32.0,67.0 +2010-09-20,sarkozy,Kantar,969,face to face,26.0,72.0 +2010-09-21,sarkozy,BVA,995,phone,32.0,64.0 +2010-10-16,sarkozy,Ifop,915,phone,29.0,70.0 +2010-10-20,sarkozy,Ipsos,971,phone,31.0,65.0 +2010-10-24,sarkozy,Kantar,947,face to face,26.0,71.0 +2010-10-29,sarkozy,BVA,1100,phone,30.0,69.0 +2010-11-12,sarkozy,Ipsos,978,phone,30.0,66.0 +2010-11-19,sarkozy,Ifop,1080,phone,32.0,68.0 +2010-11-24,sarkozy,BVA,925,phone,34.0,63.0 +2010-11-25,sarkozy,Kantar,908,face to face,24.0,71.0 +2010-12-18,sarkozy,BVA,1040,phone,33.0,61.0 +2010-12-18,sarkozy,Ifop,1086,phone,31.0,69.0 +2010-12-22,sarkozy,Kantar,1041,face to face,27.0,70.0 +2010-12-27,sarkozy,Ipsos,981,phone,35.0,61.0 +2011-01-17,sarkozy,Ifop,910,phone,30.0,70.0 +2011-01-18,sarkozy,Ipsos,1087,phone,33.0,65.0 +2011-01-23,sarkozy,BVA,927,phone,34.0,61.0 +2011-01-23,sarkozy,Kantar,946,face to face,24.0,72.0 +2011-02-10,sarkozy,Ipsos,1042,phone,34.0,63.0 +2011-02-20,sarkozy,Ifop,1062,phone,31.0,69.0 +2011-02-23,sarkozy,Kantar,920,face to face,22.0,75.0 +2011-02-28,sarkozy,BVA,1045,phone,30.0,66.0 +2011-03-18,sarkozy,Ifop,928,phone,29.0,71.0 +2011-03-20,sarkozy,Kantar,1074,face to face,23.0,74.0 +2011-03-21,sarkozy,Ipsos,934,phone,31.0,68.0 +2011-03-25,sarkozy,BVA,926,phone,32.0,65.0 +2011-04-10,sarkozy,Ipsos,908,phone,29.0,68.0 +2011-04-17,sarkozy,Ifop,1027,phone,28.0,72.0 +2011-04-27,sarkozy,Kantar,1034,face to face,20.0,76.0 +2011-04-28,sarkozy,BVA,989,phone,31.0,66.0 +2011-05-15,sarkozy,Ifop,1009,phone,29.0,71.0 +2011-05-19,sarkozy,Ipsos,1055,phone,31.0,66.0 +2011-05-22,sarkozy,Kantar,1100,face to face,22.0,76.0 +2011-05-23,sarkozy,BVA,942,phone,35.0,62.0 +2011-06-13,sarkozy,Ipsos,980,phone,30.0,66.0 +2011-06-20,sarkozy,BVA,923,phone,37.0,62.0 +2011-06-20,sarkozy,Ifop,917,phone,30.0,70.0 +2011-06-21,sarkozy,Kantar,913,face to face,25.0,73.0 +2011-07-10,sarkozy,Ipsos,953,phone,35.0,61.0 +2011-07-20,sarkozy,Ifop,939,phone,36.0,64.0 +2011-08-17,sarkozy,Ifop,927,phone,33.0,67.0 +2011-08-17,sarkozy,Ipsos,1043,phone,35.0,61.0 +2011-08-22,sarkozy,Kantar,950,face to face,24.0,72.0 +2011-09-13,sarkozy,Ipsos,1017,phone,35.0,62.0 +2011-09-16,sarkozy,Ifop,1097,phone,32.0,67.0 +2011-09-20,sarkozy,BVA,1061,phone,32.0,65.0 +2011-09-23,sarkozy,Kantar,970,face to face,24.0,72.0 +2011-10-12,sarkozy,Ipsos,936,phone,35.0,61.0 +2011-10-15,sarkozy,Ifop,1044,phone,31.0,69.0 +2011-10-20,sarkozy,Kantar,1042,face to face,30.0,66.0 +2011-10-26,sarkozy,BVA,980,phone,32.0,66.0 +2011-11-18,sarkozy,Ifop,958,phone,34.0,66.0 +2011-11-20,sarkozy,BVA,1092,phone,38.0,61.0 +2011-11-20,sarkozy,Kantar,1065,face to face,29.0,68.0 +2011-11-24,sarkozy,Ipsos,958,phone,37.0,59.0 +2011-12-14,sarkozy,Ipsos,942,phone,36.0,61.0 +2011-12-20,sarkozy,Ifop,1026,phone,34.0,66.0 +2011-12-27,sarkozy,Kantar,1004,face to face,29.0,68.0 +2012-01-18,sarkozy,Ipsos,1080,phone,34.0,63.0 +2012-01-19,sarkozy,Ifop,934,phone,32.0,68.0 +2012-01-20,sarkozy,BVA,1056,phone,32.0,67.0 +2012-01-22,sarkozy,Kantar,1064,face to face,29.0,68.0 +2012-02-13,sarkozy,Ipsos,980,phone,36.0,60.0 +2012-02-16,sarkozy,BVA,955,phone,32.0,67.0 +2012-02-19,sarkozy,Ifop,1043,phone,33.0,67.0 +2012-02-25,sarkozy,Kantar,1024,face to face,26.0,72.0 +2012-03-15,sarkozy,Ifop,1087,phone,36.0,64.0 +2012-03-21,sarkozy,Kantar,998,face to face,33.0,63.0 +2012-03-22,sarkozy,BVA,912,phone,33.0,66.0 +2012-03-23,sarkozy,Ipsos,1093,phone,38.0,59.0 +2012-04-15,sarkozy,Ifop,989,phone,36.0,64.0 +2012-04-21,sarkozy,Kantar,1004,face to face,37.0,60.0 +2012-04-26,sarkozy,Ipsos,992,phone,40.0,58.0 +2012-05-11,hollande,Ipsos,1052,phone,53.0,27.0 +2012-05-20,hollande,Ifop,1026,phone,61.0,33.0 +2012-05-28,hollande,Kantar,912,face to face,55.0,37.0 +2012-05-30,hollande,BVA,1047,internet,61.0,37.0 +2012-06-12,hollande,Ipsos,952,phone,53.0,37.0 +2012-06-15,hollande,BVA,1035,internet,61.0,38.0 +2012-06-17,hollande,Ifop,905,phone,59.0,40.0 +2012-06-24,hollande,Kantar,903,face to face,55.0,39.0 +2012-07-11,hollande,Ipsos,997,phone,55.0,37.0 +2012-07-20,hollande,Ifop,1061,phone,56.0,44.0 +2012-08-15,hollande,Ifop,990,phone,54.0,45.0 +2012-08-21,hollande,Kantar,1075,face to face,50.0,45.0 +2012-08-22,hollande,Ipsos,1085,phone,44.0,47.0 +2012-09-10,hollande,Ipsos,989,phone,44.0,49.0 +2012-09-18,hollande,Ifop,1070,phone,43.0,56.0 +2012-09-23,hollande,BVA,1095,internet,46.0,53.0 +2012-09-23,hollande,Kantar,1009,face to face,41.0,56.0 +2012-10-15,hollande,Ifop,900,phone,42.0,57.0 +2012-10-21,hollande,Kantar,919,face to face,36.0,60.0 +2012-10-22,hollande,Ipsos,973,phone,42.0,51.0 +2012-10-25,hollande,BVA,918,internet,44.0,55.0 +2012-11-13,hollande,Ipsos,944,phone,41.0,53.0 +2012-11-17,hollande,BVA,1014,internet,44.0,55.0 +2012-11-18,hollande,Ifop,1061,phone,41.0,58.0 +2012-11-25,hollande,Kantar,1027,face to face,35.0,61.0 +2012-12-13,hollande,Ipsos,1036,phone,35.0,60.0 +2012-12-19,hollande,Ifop,909,phone,37.0,62.0 +2012-12-21,hollande,Kantar,1036,face to face,35.0,62.0 +2012-12-27,hollande,BVA,1096,internet,40.0,59.0 +2013-01-18,hollande,Ifop,927,phone,38.0,62.0 +2013-01-19,hollande,BVA,973,internet,44.0,55.0 +2013-01-24,hollande,Ipsos,1026,phone,36.0,58.0 +2013-01-28,hollande,Kantar,926,face to face,35.0,61.0 +2013-02-17,hollande,Ifop,1040,phone,37.0,62.0 +2013-02-18,hollande,Ipsos,997,phone,36.0,59.0 +2013-02-23,hollande,BVA,989,internet,43.0,56.0 +2013-02-27,hollande,Kantar,930,face to face,30.0,66.0 +2013-03-18,hollande,BVA,909,internet,35.0,64.0 +2013-03-19,hollande,Ifop,1012,phone,31.0,68.0 +2013-03-20,hollande,Kantar,1007,face to face,27.0,70.0 +2013-03-26,hollande,Ipsos,1086,phone,31.0,64.0 +2013-04-15,hollande,Ifop,988,phone,25.0,74.0 +2013-04-19,hollande,Ipsos,1057,phone,26.0,70.0 +2013-04-20,hollande,BVA,1024,internet,34.0,66.0 +2013-04-21,hollande,Kantar,935,face to face,24.0,73.0 +2013-05-15,hollande,Ifop,992,phone,29.0,71.0 +2013-05-22,hollande,Ipsos,957,phone,25.0,72.0 +2013-05-23,hollande,Kantar,996,face to face,29.0,68.0 +2013-05-25,hollande,BVA,1015,internet,35.0,64.0 +2013-06-11,hollande,Ipsos,1017,phone,26.0,70.0 +2013-06-15,hollande,Ifop,1043,phone,26.0,73.0 +2013-06-24,hollande,BVA,938,internet,31.0,68.0 +2013-06-24,hollande,Kantar,963,face to face,27.0,70.0 +2013-07-14,hollande,Ipsos,1001,phone,26.0,71.0 +2013-07-16,hollande,Ifop,1059,phone,27.0,72.0 +2013-08-19,hollande,Ifop,948,phone,28.0,71.0 +2013-08-25,hollande,Ipsos,1083,phone,28.0,67.0 +2013-08-26,hollande,Kantar,1068,face to face,27.0,70.0 +2013-09-17,hollande,BVA,970,internet,32.0,66.0 +2013-09-18,hollande,Ifop,954,phone,23.0,76.0 +2013-09-27,hollande,Ipsos,1096,phone,27.0,68.0 +2013-09-28,hollande,Kantar,1074,face to face,23.0,74.0 +2013-10-18,hollande,Ifop,952,phone,23.0,77.0 +2013-10-22,hollande,BVA,914,internet,26.0,73.0 +2013-10-23,hollande,Ipsos,993,phone,24.0,71.0 +2013-10-23,hollande,Kantar,1038,face to face,21.0,76.0 +2013-11-10,hollande,Ipsos,1070,phone,21.0,75.0 +2013-11-19,hollande,Ifop,949,phone,20.0,79.0 +2013-11-20,hollande,BVA,953,internet,29.0,69.0 +2013-11-26,hollande,Kantar,1076,face to face,21.0,76.0 +2013-12-12,hollande,Ipsos,1077,phone,23.0,74.0 +2013-12-17,hollande,Ifop,975,phone,22.0,78.0 +2013-12-20,hollande,BVA,1031,internet,33.0,66.0 +2013-12-25,hollande,Kantar,975,face to face,21.0,74.0 +2014-01-14,hollande,Ipsos,1081,phone,24.0,74.0 +2014-01-16,hollande,Ifop,1014,phone,22.0,77.0 +2014-01-26,hollande,Kantar,1096,face to face,19.0,78.0 +2014-01-30,hollande,BVA,986,internet,31.0,68.0 +2014-02-11,hollande,Ipsos,1066,phone,21.0,76.0 +2014-02-18,hollande,BVA,964,internet,27.0,72.0 +2014-02-18,hollande,Ifop,965,phone,20.0,79.0 +2014-02-20,hollande,Kantar,925,face to face,17.0,80.0 +2014-03-18,hollande,Ifop,1011,phone,23.0,76.0 +2014-03-22,hollande,Ipsos,1076,phone,22.0,74.0 +2014-03-27,hollande,BVA,1097,internet,28.0,71.0 +2014-03-28,hollande,Kantar,997,face to face,20.0,77.0 +2014-04-15,hollande,BVA,925,internet,21.0,78.0 +2014-04-19,hollande,Ifop,1097,phone,18.0,82.0 +2014-04-20,hollande,Ipsos,987,phone,18.0,76.0 +2014-04-20,hollande,Kantar,1048,face to face,18.0,78.0 +2014-05-16,hollande,BVA,996,internet,21.0,78.0 +2014-05-20,hollande,Ifop,917,phone,18.0,82.0 +2014-05-21,hollande,Kantar,1091,face to face,16.0,81.0 +2014-05-23,hollande,Ipsos,996,phone,19.0,78.0 +2014-06-14,hollande,Ipsos,1043,phone,19.0,78.0 +2014-06-16,hollande,Ifop,941,phone,18.0,81.0 +2014-06-17,hollande,BVA,947,internet,22.0,77.0 +2014-06-23,hollande,Kantar,1024,face to face,18.0,79.0 +2014-07-15,hollande,Ifop,952,phone,18.0,81.0 +2014-07-25,hollande,Ipsos,947,phone,20.0,75.0 +2014-08-17,hollande,BVA,1075,internet,19.0,80.0 +2014-08-17,hollande,Ipsos,1048,phone,17.0,79.0 +2014-08-19,hollande,Ifop,975,phone,17.0,81.0 +2014-08-20,hollande,Kantar,1027,face to face,13.0,85.0 +2014-09-12,hollande,Ipsos,1056,phone,13.0,83.0 +2014-09-18,hollande,BVA,967,internet,23.0,76.0 +2014-09-18,hollande,Ifop,972,phone,13.0,86.0 +2014-09-22,hollande,Kantar,1079,face to face,14.0,84.0 +2014-10-17,hollande,Odoxa,972,internet,20.0,80.0 +2014-10-18,hollande,Ipsos,1078,phone,16.0,81.0 +2014-10-20,hollande,Ifop,1077,phone,14.0,84.0 +2014-10-24,hollande,BVA,1096,internet,20.0,79.0 +2014-10-28,hollande,Kantar,1016,face to face,13.0,85.0 +2014-11-14,hollande,Ipsos,1021,phone,15.0,81.0 +2014-11-15,hollande,Ifop,1048,phone,13.0,85.0 +2014-11-20,hollande,BVA,941,internet,20.0,79.0 +2014-11-21,hollande,Odoxa,988,internet,16.0,83.0 +2014-11-22,hollande,Kantar,983,face to face,15.0,83.0 +2014-12-12,hollande,Odoxa,1030,internet,21.0,78.0 +2014-12-19,hollande,Ifop,1089,phone,17.0,82.0 +2014-12-24,hollande,Ipsos,959,phone,18.0,78.0 +2014-12-24,hollande,Kantar,1037,face to face,20.0,77.0 +2014-12-27,hollande,BVA,1017,internet,24.0,76.0 +2015-01-16,hollande,Ipsos,913,phone,38.0,57.0 +2015-01-17,hollande,Ifop,1039,phone,29.0,70.0 +2015-01-23,hollande,Odoxa,1033,internet,31.0,68.0 +2015-01-27,hollande,Kantar,1035,face to face,23.0,75.0 +2015-01-28,hollande,BVA,1080,internet,34.0,65.0 +2015-02-18,hollande,Ifop,945,phone,24.0,76.0 +2015-02-20,hollande,Odoxa,975,internet,26.0,73.0 +2015-02-25,hollande,Kantar,1025,face to face,22.0,75.0 +2015-02-26,hollande,BVA,1011,internet,30.0,69.0 +2015-02-27,hollande,Ipsos,988,phone,30.0,67.0 +2015-03-18,hollande,Ifop,930,phone,25.0,75.0 +2015-03-20,hollande,Odoxa,904,internet,24.0,75.0 +2015-03-22,hollande,BVA,1016,internet,27.0,72.0 +2015-03-24,hollande,Kantar,995,face to face,18.0,77.0 +2015-03-27,hollande,Ipsos,980,phone,26.0,69.0 +2015-04-14,hollande,Ipsos,926,phone,23.0,73.0 +2015-04-16,hollande,Ifop,968,phone,21.0,78.0 +2015-04-17,hollande,Odoxa,903,internet,21.0,78.0 +2015-04-18,hollande,BVA,1042,internet,26.0,74.0 +2015-04-27,hollande,Kantar,1045,face to face,16.0,82.0 +2015-05-15,hollande,BVA,993,internet,27.0,72.0 +2015-05-15,hollande,Ifop,908,phone,21.0,78.0 +2015-05-22,hollande,Odoxa,979,internet,23.0,76.0 +2015-05-25,hollande,Kantar,929,face to face,19.0,78.0 +2015-05-26,hollande,Ipsos,1055,phone,24.0,74.0 +2015-06-14,hollande,Ipsos,937,phone,20.0,77.0 +2015-06-17,hollande,BVA,921,internet,26.0,73.0 +2015-06-20,hollande,Ifop,1061,phone,22.0,77.0 +2015-06-24,hollande,Kantar,1000,face to face,19.0,78.0 +2015-06-26,hollande,Odoxa,979,internet,22.0,76.0 +2015-07-11,hollande,Ipsos,931,phone,26.0,71.0 +2015-07-15,hollande,BVA,1007,internet,28.0,71.0 +2015-07-18,hollande,Ifop,1083,phone,22.0,77.0 +2015-07-30,hollande,BVA,1073,internet,23.0,76.0 +2015-08-16,hollande,Ifop,986,phone,24.0,75.0 +2015-08-20,hollande,Kantar,968,face to face,18.0,80.0 +2015-09-10,hollande,Ipsos,966,phone,24.0,72.0 +2015-09-16,hollande,Ifop,919,phone,23.0,77.0 +2015-09-25,hollande,Odoxa,1027,internet,21.0,77.0 +2015-09-27,hollande,BVA,926,internet,23.0,76.0 +2015-09-28,hollande,Kantar,944,face to face,16.0,82.0 +2015-10-12,hollande,Ipsos,1068,phone,24.0,72.0 +2015-10-16,hollande,Odoxa,968,internet,22.0,77.0 +2015-10-18,hollande,Ifop,1049,phone,20.0,79.0 +2015-10-23,hollande,Kantar,992,face to face,15.0,82.0 +2015-10-26,hollande,BVA,1096,internet,25.0,75.0 +2015-11-15,hollande,Ifop,908,phone,27.0,73.0 +2015-11-20,hollande,Odoxa,1012,internet,32.0,67.0 +2015-11-22,hollande,Ipsos,911,phone,41.0,55.0 +2015-11-24,hollande,BVA,1048,internet,33.0,65.0 +2015-11-24,hollande,Kantar,1032,face to face,35.0,63.0 +2015-12-17,hollande,Ifop,1006,phone,27.0,73.0 +2015-12-18,hollande,Odoxa,1063,internet,27.0,71.0 +2015-12-22,hollande,BVA,1088,internet,30.0,69.0 +2015-12-26,hollande,Kantar,1029,face to face,23.0,74.0 +2016-01-16,hollande,Ifop,922,phone,24.0,75.0 +2016-01-19,hollande,BVA,1012,internet,25.0,74.0 +2016-01-19,hollande,Ipsos,961,phone,29.0,66.0 +2016-01-20,hollande,Kantar,930,face to face,15.0,82.0 +2016-01-22,hollande,Odoxa,1028,internet,22.0,78.0 +2016-02-10,hollande,Ipsos,973,phone,20.0,75.0 +2016-02-16,hollande,Ifop,935,phone,19.0,81.0 +2016-02-18,hollande,BVA,905,internet,22.0,77.0 +2016-02-19,hollande,Odoxa,985,internet,20.0,80.0 +2016-02-21,hollande,Kantar,917,face to face,16.0,82.0 +2016-03-19,hollande,Ifop,1040,phone,17.0,82.0 +2016-03-20,hollande,Ipsos,1040,phone,15.0,80.0 +2016-03-20,hollande,Kantar,968,face to face,15.0,83.0 +2016-03-21,hollande,BVA,1071,internet,21.0,79.0 +2016-03-25,hollande,Odoxa,1020,internet,18.0,81.0 +2016-04-10,hollande,Ipsos,933,phone,16.0,80.0 +2016-04-17,hollande,Ifop,988,phone,14.0,85.0 +2016-04-21,hollande,BVA,1027,internet,19.0,80.0 +2016-04-22,hollande,Odoxa,1020,internet,17.0,83.0 +2016-04-27,hollande,Kantar,1099,face to face,13.0,84.0 +2016-05-14,hollande,Ipsos,935,phone,18.0,79.0 +2016-05-20,hollande,Ifop,977,phone,15.0,84.0 +2016-05-20,hollande,Odoxa,944,internet,16.0,83.0 +2016-05-22,hollande,BVA,906,internet,19.0,80.0 +2016-05-25,hollande,Kantar,1095,face to face,13.0,84.0 +2016-06-14,hollande,Ipsos,916,phone,16.0,80.0 +2016-06-17,hollande,Odoxa,961,internet,16.0,84.0 +2016-06-19,hollande,Ifop,1063,phone,14.0,85.0 +2016-06-25,hollande,BVA,1075,internet,18.0,81.0 +2016-06-27,hollande,Kantar,1052,face to face,12.0,86.0 +2016-07-15,hollande,Ifop,1001,phone,17.0,82.0 +2016-07-23,hollande,BVA,1095,internet,19.0,79.0 +2016-08-14,hollande,Ipsos,931,phone,18.0,75.0 +2016-08-15,hollande,Ifop,995,phone,16.0,82.0 +2016-08-23,hollande,Kantar,986,face to face,17.0,80.0 +2016-09-10,hollande,Ipsos,1051,phone,15.0,80.0 +2016-09-16,hollande,Ifop,929,phone,15.0,84.0 +2016-09-16,hollande,Odoxa,1055,internet,16.0,84.0 +2016-09-17,hollande,BVA,1054,internet,18.0,80.0 +2016-09-22,hollande,Kantar,1056,face to face,13.0,84.0 +2016-10-14,hollande,Odoxa,995,internet,16.0,84.0 +2016-10-18,hollande,Ipsos,1065,phone,18.0,79.0 +2016-10-20,hollande,Ifop,1058,phone,14.0,85.0 +2016-10-23,hollande,Kantar,1071,face to face,11.0,87.0 +2016-10-29,hollande,BVA,966,internet,15.0,83.0 +2016-11-14,hollande,Ipsos,1003,phone,18.0,80.0 +2016-11-17,hollande,Ifop,1045,phone,15.0,84.0 +2016-11-19,hollande,BVA,989,internet,18.0,81.0 +2016-11-26,hollande,Kantar,958,face to face,13.0,85.0 +2016-11-29,hollande,Odoxa,972,internet,17.0,83.0 +2016-12-11,hollande,Ipsos,1058,phone,21.0,76.0 +2016-12-15,hollande,Odoxa,1009,internet,18.0,82.0 +2016-12-19,hollande,Ifop,927,phone,19.0,81.0 +2016-12-20,hollande,Kantar,935,face to face,19.0,78.0 +2017-01-13,hollande,Odoxa,982,internet,20.0,80.0 +2017-01-17,hollande,Ifop,975,phone,20.0,80.0 +2017-01-23,hollande,Kantar,1097,face to face,18.0,80.0 +2017-01-24,hollande,BVA,995,internet,24.0,76.0 +2017-01-24,hollande,Ipsos,921,phone,22.0,73.0 +2017-02-09,hollande,Odoxa,1079,internet,21.0,79.0 +2017-02-13,hollande,Ipsos,980,phone,20.0,75.0 +2017-02-17,hollande,BVA,1084,internet,22.0,77.0 +2017-02-19,hollande,Ifop,915,phone,19.0,81.0 +2017-02-22,hollande,Kantar,983,face to face,16.0,82.0 +2017-03-15,hollande,BVA,1057,internet,24.0,74.0 +2017-03-15,hollande,Ifop,1036,phone,22.0,77.0 +2017-03-20,hollande,Ipsos,1042,phone,25.0,71.0 +2017-03-23,hollande,Kantar,964,face to face,21.0,76.0 +2017-03-23,hollande,Odoxa,933,internet,21.0,79.0 +2017-04-15,hollande,Ifop,921,phone,22.0,77.0 +2017-04-20,hollande,Ipsos,918,phone,23.0,73.0 +2017-04-20,hollande,Odoxa,1016,internet,22.0,78.0 +2017-04-27,hollande,Kantar,934,face to face,14.0,83.0 +2017-04-30,hollande,BVA,985,internet,25.0,75.0 +2017-05-17,macron,Elabe,999,internet,45.0,46.0 +2017-05-20,macron,Ifop,973,phone,62.0,31.0 +2017-05-20,macron,Ipsos,1015,internet,46.0,27.0 +2017-05-21,macron,Viavoice,1006,internet,49.0,30.0 +2017-05-23,macron,BVA,1011,internet,62.0,35.0 +2017-05-23,macron,Odoxa,1014,internet,58.0,41.0 +2017-05-24,macron,Elabe,1051,internet,67.0,31.0 +2017-05-25,macron,YouGov,1008,internet,39.0,32.0 +2017-05-27,macron,Ipsos,2138,internet,58.0,42.0 +2017-05-27,macron,Kantar,1008,face to face,57.0,38.0 +2017-06-04,macron,BVA,4772,internet,68.0,31.0 +2017-06-06,macron,Elabe,1001,internet,45.0,45.0 +2017-06-07,macron,Elabe,1000,internet,66.0,33.0 +2017-06-09,macron,Ipsos,4003,internet,58.0,42.0 +2017-06-19,macron,Ifop,1883,phone&internet,64.0,35.0 +2017-06-20,macron,BVA,1187,internet,59.0,39.0 +2017-06-22,macron,Odoxa,1008,internet,58.0,41.0 +2017-06-24,macron,Ipsos,1058,internet,45.0,27.0 +2017-06-24,macron,Kantar,1000,face to face,54.0,39.0 +2017-06-25,macron,Viavoice,1011,internet,53.0,27.0 +2017-06-29,macron,YouGov,1016,internet,43.0,36.0 +2017-07-05,macron,Elabe,999,internet,45.0,46.0 +2017-07-18,macron,BVA,1007,internet,54.0,44.0 +2017-07-20,macron,Ifop,1947,phone&internet,54.0,43.0 +2017-07-22,macron,Ipsos,1022,internet,42.0,42.0 +2017-07-27,macron,YouGov,1003,internet,36.0,49.0 +2017-08-02,macron,Elabe,1000,internet,40.0,55.0 +2017-08-08,macron,Ifop,1001,internet,36.0,64.0 +2017-08-26,macron,Ifop,1023,phone&internet,40.0,57.0 +2017-08-26,macron,Kantar,983,face to face,41.0,52.0 +2017-08-29,macron,BVA,1162,internet,43.0,55.0 +2017-08-29,macron,Yougov,1003,internet,30.0,54.0 +2017-09-06,macron,Elabe,1002,internet,37.0,58.0 +2017-09-09,macron,Ipsos,988,internet,32.0,54.0 +2017-09-13,macron,Viavoice,1007,internet,38.0,47.0 +2017-09-14,macron,Odoxa,992,internet,44.0,56.0 +2017-09-19,macron,Ifop,1989,phone&internet,45.0,53.0 +2017-09-26,macron,BVA,1092,internet,45.0,51.0 +2017-09-28,macron,Yougov,1002,internet,32.0,56.0 +2017-09-30,macron,Kantar,1000,face to face,39.0,56.0 +2017-10-04,macron,Elabe,1001,internet,40.0,54.0 +2017-10-14,macron,Ipsos,957,internet,34.0,54.0 +2017-10-17,macron,Ifop,1938,phone&internet,42.0,56.0 +2017-10-19,macron,Odoxa,995,internet,44.0,56.0 +2017-10-25,macron,BVA,1193,internet,42.0,56.0 +2017-10-26,macron,Yougov,1034,internet,32.0,55.0 +2017-10-27,macron,Kantar,983,face to face,38.0,57.0 +2017-10-31,macron,Elabe,1152,internet,38.0,56.0 +2017-11-01,macron,Viavoice,1002,internet,40.0,46.0 +2017-11-11,macron,Ipsos,1043,internet,37.0,53.0 +2017-11-14,macron,Ifop,1964,phone&internet,46.0,52.0 +2017-11-23,macron,Odoxa,1009,internet,45.0,55.0 +2017-11-25,macron,Kantar,1000,face to face,42.0,54.0 +2017-11-28,macron,BVA,972,internet,46.0,51.0 +2017-11-29,macron,Elabe,1001,internet,40.0,54.0 +2017-11-30,macron,Yougov,1006,internet,35.0,50.0 +2017-12-09,macron,Ipsos,1016,internet,39.0,50.0 +2017-12-12,macron,Ifop,1942,phone&internet,52.0,46.0 +2017-12-14,macron,Odoxa,1028,internet,54.0,46.0 +2017-12-19,macron,BVA,1199,internet,52.0,45.0 +2018-01-03,macron,Elabe,1001,internet,42.0,50.0 +2018-01-06,macron,Kantar,1000,face to face,44.0,51.0 +2018-01-13,macron,Ipsos,1050,internet,40.0,49.0 +2018-01-16,macron,Ifop,1947,phone&internet,50.0,49.0 +2018-01-18,macron,Odoxa,1006,internet,49.0,50.0 +2018-01-25,macron,Yougov,1008,internet,41.0,45.0 +2018-01-27,macron,Kantar,1000,face to face,44.0,51.0 +2018-01-30,macron,BVA,1101,internet,47.0,48.0 +2018-01-31,macron,Elabe,1000,internet,38.0,56.0 +2018-02-10,macron,Ipsos,1001,internet,35.0,55.0 +2018-02-13,macron,Ifop,1953,phone&internet,44.0,55.0 +2018-02-22,macron,Odoxa,973,internet,43.0,57.0 +2018-02-22,macron,Yougov,1026,internet,30.0,58.0 +2018-02-23,macron,Viavoice,1010,internet,41.0,45.0 +2018-02-24,macron,Kantar,1000,face to face,43.0,53.0 +2018-02-27,macron,BVA,1019,internet,43.0,53.0 +2018-02-28,macron,Elabe,999,internet,41.0,52.0 +2018-03-13,macron,Ifop,1946,phone&internet,42.0,57.0 +2018-03-17,macron,Ipsos,1011,internet,37.0,55.0 +2018-03-22,macron,BVA,1053,internet,40.0,57.0 +2018-03-23,macron,Odoxa,1018,internet,45.0,54.0 +2018-03-28,macron,Yougov,1004,internet,32.0,56.0 +2018-03-30,macron,Kantar,1000,face to face,40.0,56.0 +2018-04-04,macron,Elabe,1008,internet,39.0,55.0 +2018-04-14,macron,Ifop,1201,internet,42.0,58.0 +2018-04-17,macron,Ifop,1949,phone&internet,44.0,55.0 +2018-04-17,macron,Viavoice,1000,internet,41.0,46.0 +2018-04-19,macron,BVA,1011,internet,43.0,54.0 +2018-04-19,macron,Odoxa,1017,internet,47.0,53.0 +2018-04-21,macron,Ipsos,1013,internet,40.0,52.0 +2018-04-25,macron,Kantar,1000,face to face,41.0,56.0 +2018-04-26,macron,Yougov,1013,internet,33.0,54.0 +2018-05-01,macron,Elabe,1008,internet,41.0,53.0 +2018-05-16,macron,Odoxa,1015,internet,46.0,54.0 +2018-05-19,macron,Ipsos,1025,internet,37.0,58.0 +2018-05-24,macron,BVA,1000,internet,40.0,56.0 +2018-05-26,macron,Kantar,1000,face to face,38.0,57.0 +2018-06-06,macron,Elabe,1002,internet,40.0,55.0 +2018-06-19,macron,Ifop,1963,phone&internet,40.0,58.0 +2018-06-21,macron,BVA,1000,internet,41.0,53.0 +2018-06-22,macron,Odoxa,1007,internet,41.0,59.0 +2018-06-23,macron,Ipsos,996,internet,36.0,59.0 +2018-06-28,macron,Ifop,1008,internet,41.0,59.0 +2018-06-28,macron,Yougov,1028,internet,32.0,59.0 +2018-06-30,macron,Kantar,923,face to face,32.0,64.0 +2018-07-04,macron,Elabe,1001,internet,34.0,60.0 +2018-07-16,macron,Odoxa,1005,internet,39.0,61.0 +2018-07-19,macron,BVA,1003,internet,39.0,59.0 +2018-07-21,macron,Ipsos,999,internet,32.0,60.0 +2018-07-23,macron,Ifop,1981,internet,39.0,61.0 +2018-07-25,macron,Harris,966,internet,42.0,58.0 +2018-07-26,macron,Yougov,1017,internet,27.0,62.0 +2018-08-01,macron,Elabe,1007,internet,36.0,60.0 +2018-08-21,macron,Viavoice,1008,internet,36.0,51.0 +2018-08-24,macron,Ifop,995,internet,34.0,66.0 +2018-08-25,macron,Kantar,1000,face to face,33.0,64.0 +2018-08-29,macron,Harris,977,internet,36.0,64.0 +2018-08-30,macron,BVA,1040,internet,34.0,66.0 +2018-08-30,macron,Yougov,1099,internet,23.0,69.0 +2018-08-31,macron,Ifop,1015,internet,31.0,69.0 +2018-09-05,macron,Elabe,1000,internet,31.0,64.0 +2018-09-06,macron,Odoxa,1004,internet,29.0,71.0 +2018-09-08,macron,Ipsos,998,internet,25.0,69.0 +2018-09-18,macron,Ifop,1964,phone&internet,29.0,70.0 +2018-09-20,macron,OpinionWay,1061,internet,28.0,70.0 +2018-09-26,macron,Harris,1022,internet,34.0,66.0 +2018-09-27,macron,BVA,1011,internet,32.0,67.0 +2018-09-27,macron,Yougov,1006,internet,25.0,67.0 +2018-09-28,macron,Ifop,1008,internet,33.0,67.0 +2018-09-29,macron,Kantar,1000,face to face,30.0,67.0 +2018-10-03,macron,Elabe,1001,internet,30.0,66.0 +2018-10-05,macron,Odoxa,1014,internet,33.0,66.0 +2018-10-17,macron,Ifop,1968,phone&internet,29.0,70.0 +2018-10-18,macron,OpinionWay,1063,internet,29.0,68.0 +2018-10-20,macron,Ipsos,1003,internet,26.0,70.0 +2018-10-21,macron,Viavoice,1007,internet,26.0,65.0 +2018-10-24,macron,Harris,989,internet,33.0,67.0 +2018-10-25,macron,BVA,1090,internet,29.0,70.0 +2018-10-25,macron,Yougov,1010,internet,21.0,69.0 +2018-10-26,macron,Ifop,1024,internet,29.0,71.0 +2018-10-26,macron,Kantar,1000,face to face,26.0,71.0 +2018-11-07,macron,Elabe,1002,internet,27.0,69.0 +2018-11-13,macron,Ifop,1957,phone&internet,25.0,73.0 +2018-11-15,macron,OpinionWay,1064,internet,29.0,69.0 +2018-11-16,macron,Odoxa,1005,internet,32.0,68.0 +2018-11-17,macron,Ipsos,1000,internet,26.0,70.0 +2018-11-22,macron,BVA,1258,internet,26.0,73.0 +2018-11-28,macron,Harris,908,internet,32.0,68.0 +2018-11-29,macron,Viavoice,1021,internet,23.0,69.0 +2018-11-29,macron,Yougov,1006,internet,18.0,76.0 +2018-11-30,macron,Ifop,1004,internet,23.0,76.0 +2018-12-01,macron,Kantar,1000,face to face,21.0,77.0 +2018-12-05,macron,Elabe,1002,internet,23.0,74.0 +2018-12-08,macron,Ipsos,971,internet,20.0,76.0 +2018-12-11,macron,Ifop,1943,phone&internet,23.0,76.0 +2018-12-13,macron,OpinionWay,1029,internet,31.0,67.0 +2018-12-14,macron,Odoxa,990,internet,27.0,73.0 +2018-12-19,macron,BVA,1105,internet,27.0,72.0 +2018-12-24,macron,Harris,1028,internet,31.0,69.0 +2019-01-04,macron,Ifop,1004,internet,28.0,72.0 +2019-01-05,macron,Kantar,1000,face to face,22.0,75.0 +2019-01-09,macron,Elabe,1003,internet,25.0,71.0 +2019-01-12,macron,Ipsos,1005,internet,23.0,74.0 +2019-01-15,macron,Ifop,1928,phone&internet,27.0,72.0 +2019-01-18,macron,OpinionWay,1042,internet,30.0,68.0 +2019-01-23,macron,Harris,1039,internet,35.0,65.0 +2019-01-23,macron,Odoxa,1003,internet,30.0,69.0 +2019-01-24,macron,BVA,1023,internet,31.0,69.0 +2019-01-26,macron,Kantar,1000,face to face,24.0,73.0 +2019-01-31,macron,Yougov,1037,internet,21.0,73.0 +2019-02-01,macron,Ifop,1004,internet,34.0,66.0 +2019-02-06,macron,Elabe,1000,internet,27.0,69.0 +2019-02-12,macron,Ifop,1891,phone&internet,28.0,71.0 +2019-02-14,macron,OpinionWay,1027,internet,29.0,69.0 +2019-02-20,macron,Viavoice,1004,internet,28.0,61.0 +2019-02-21,macron,BVA,1012,internet,30.0,69.0 +2019-02-21,macron,Harris,897,internet,39.0,61.0 +2019-02-21,macron,Odoxa,1004,internet,32.0,68.0 +2019-02-23,macron,Kantar,1000,face to face,26.0,71.0 +2019-02-28,macron,Yougov,1004,internet,24.0,70.0 +2019-03-01,macron,Ifop,1009,internet,31.0,69.0 +2019-03-02,macron,Ipsos,1035,internet,28.0,67.0 +2019-03-06,macron,Elabe,1003,internet,31.0,66.0 +2019-03-14,macron,OpinionWay,1070,internet,32.0,66.0 +2019-03-19,macron,Ifop,1929,phone&internet,29.0,69.0 +2019-03-21,macron,BVA,1001,internet,29.0,70.0 +2019-03-21,macron,Odoxa,1001,internet,30.0,70.0 +2019-03-21,macron,OpinionWay,1009,internet,29.0,69.0 +2019-03-27,macron,Harris,933,internet,38.0,62.0 +2019-03-28,macron,OpinionWay,1051,internet,29.0,70.0 +2019-03-28,macron,Yougov,1001,internet,25.0,68.0 +2019-03-29,macron,Ifop,1001,internet,29.0,71.0 +2019-03-30,macron,Kantar,1000,face to face,26.0,71.0 +2019-04-03,macron,Elabe,1004,internet,28.0,69.0 +2019-04-06,macron,Ipsos,1001,internet,27.0,69.0 +2019-04-16,macron,Ifop,1921,phone&internet,29.0,69.0 +2019-04-18,macron,BVA,1002,internet,32.0,67.0 +2019-04-18,macron,Odoxa,1003,internet,32.0,67.0 +2019-04-18,macron,OpinionWay,1057,internet,27.0,70.0 +2019-04-24,macron,Harris,934,internet,38.0,62.0 +2019-04-26,macron,Kantar,1000,face to face,25.0,72.0 +2019-04-28,macron,Viavoice,1002,internet,26.0,65.0 +2019-05-03,macron,Ifop,1008,internet,30.0,70.0 +2019-05-07,macron,Elabe,1583,internet,27.0,67.0 +2019-05-11,macron,Ipsos,1001,internet,27.0,68.0 +2019-05-14,macron,Ifop,1946,phone&internet,30.0,67.0 +2019-05-16,macron,BVA,1000,internet,32.0,68.0 +2019-05-27,macron,Odoxa,980,internet,30.0,70.0 +2019-05-29,macron,Harris,922,internet,40.0,60.0 +2019-05-29,macron,Ifop,1005,internet,32.0,68.0 +2019-05-30,macron,Kantar,1000,face to face,29.0,68.0 +2019-06-05,macron,Elabe,1007,internet,32.0,63.0 +2019-06-06,macron,OpinionWay,1014,internet,33.0,65.0 +2019-06-15,macron,Ipsos,1002,internet,32.0,64.0 +2019-06-18,macron,Ifop,1910,phone&internet,30.0,67.0 +2019-06-20,macron,BVA,1003,internet,35.0,65.0 +2019-06-20,macron,Odoxa,1002,internet,36.0,64.0 +2019-06-26,macron,Harris,894,internet,40.0,60.0 +2019-06-27,macron,Ifop,1002,internet,38.0,62.0 +2019-06-29,macron,Kantar,1000,face to face,27.0,69.0 +2019-07-02,macron,Viavoice,1002,internet,32.0,57.0 +2019-07-02,macron,Yougov,1045,internet,26.0,66.0 +2019-07-03,macron,Elabe,1009,internet,31.0,64.0 +2019-07-04,macron,OpinionWay,1002,internet,33.0,65.0 +2019-07-18,macron,BVA,1000,internet,34.0,66.0 +2019-07-18,macron,Ifop,996,internet,32.0,68.0 +2019-07-20,macron,Ipsos,1002,internet,31.0,64.0 +2019-07-24,macron,Harris,930,internet,41.0,59.0 +2019-07-31,macron,Elabe,1002,internet,28.0,67.0 +2019-08-22,macron,BVA,966,internet,34.0,66.0 +2019-08-22,macron,Ifop,988,internet,34.0,66.0 +2019-08-28,macron,Harris,910,internet,43.0,57.0 +2019-08-30,macron,Ifop,1010,internet,38.0,62.0 +2019-08-31,macron,Kantar,1000,face to face,32.0,66.0 +2019-09-04,macron,Elabe,1002,internet,33.0,61.0 +2019-09-11,macron,Viavoice,1008,internet,32.0,54.0 +2019-09-14,macron,Ipsos,1009,internet,36.0,59.0 +2019-09-17,macron,Ifop,1960,phone&internet,33.0,64.0 +2019-09-19,macron,BVA,1004,internet,37.0,63.0 +2019-09-19,macron,Odoxa,1005,internet,36.0,63.0 +2019-09-25,macron,Harris,905,internet,42.0,58.0 +2019-09-28,macron,Kantar,1000,face to face,29.0,67.0 +2019-10-02,macron,Elabe,1000,internet,33.0,60.0 +2019-10-12,macron,Ipsos,1008,internet,33.0,62.0 +2019-10-15,macron,Ifop,1953,phone&internet,34.0,64.0 +2019-10-17,macron,BVA,1000,internet,37.0,62.0 +2019-10-23,macron,Harris,905,internet,40.0,60.0 +2019-10-24,macron,Odoxa,1005,internet,35.0,65.0 +2019-10-25,macron,Kantar,1000,face to face,30.0,67.0 +2019-10-29,macron,Yougov,1031,internet,27.0,65.0 +2019-11-06,macron,Elabe,1002,internet,28.0,65.0 +2019-11-12,macron,Ifop,1911,phone&internet,33.0,65.0 +2019-11-14,macron,BVA,968,internet,36.0,64.0 +2019-11-16,macron,Ipsos,1053,internet,33.0,63.0 +2019-11-17,macron,Viavoice,1003,internet,31.0,57.0 +2019-11-21,macron,Odoxa,1002,internet,34.0,65.0 +2019-11-27,macron,Harris,900,internet,39.0,61.0 +2019-11-28,macron,Kantar,1000,face to face,27.0,70.0 +2019-12-10,macron,Ifop,1899,phone&internet,34.0,65.0 +2019-12-12,macron,BVA,968,internet,34.0,66.0 +2019-12-13,macron,Elabe,1003,internet,30.0,65.0 +2019-12-14,macron,Ipsos,1001,internet,29.0,67.0 +2019-12-19,macron,Odoxa,1002,internet,33.0,67.0 +2019-12-26,macron,Harris,915,internet,40.0,60.0 +2020-01-15,macron,Elabe,1006,internet,32.0,63.0 +2020-01-18,macron,Ipsos,1004,internet,30.0,64.0 +2020-01-21,macron,Ifop,1952,phone&internet,30.0,68.0 +2020-01-22,macron,Harris,934,internet,40.0,60.0 +2020-01-23,macron,BVA,1005,internet,33.0,66.0 +2020-01-23,macron,Odoxa,1002,internet,36.0,64.0 +2020-01-30,macron,Ifop,1000,internet,34.0,66.0 +2020-02-01,macron,Kantar,1000,face to face,24.0,72.0 +2020-02-05,macron,Elabe,1005,internet,31.0,63.0 +2020-02-18,macron,Ifop,1947,phone&internet,32.0,66.0 +2020-02-19,macron,Harris,909,internet,38.0,62.0 +2020-02-20,macron,BVA,1000,internet,33.0,67.0 +2020-02-20,macron,Odoxa,1005,internet,33.0,66.0 +2020-02-22,macron,Ipsos,1005,internet,30.0,63.0 +2020-02-23,macron,Viavoice,1000,internet,28.0,59.0 +2020-02-29,macron,Kantar,1000,face to face,28.0,69.0 +2020-03-04,macron,Elabe,1007,internet,29.0,66.0 +2020-03-18,macron,Harris,917,internet,51.0,49.0 +2020-03-21,macron,Ipsos,1000,internet,44.0,51.0 +2020-03-21,macron,Viavoice,1000,internet,34.0,51.0 +2020-03-23,macron,Ifop,1930,phone&internet,43.0,56.0 +2020-03-25,macron,Odoxa,1005,internet,38.0,62.0 +2020-03-26,macron,BVA,1010,internet,40.0,59.0 +2020-03-28,macron,Kantar,1000,internet,47.0,47.0 +2020-03-31,macron,Elabe,1003,internet,39.0,57.0 +2020-04-13,macron,Ifop,1942,phone&internet,42.0,57.0 +2020-04-23,macron,BVA,976,internet,38.0,61.0 +2020-04-23,macron,Odoxa,1005,internet,42.0,58.0 +2020-04-24,macron,Ipsos,1002,internet,38.0,58.0 +2020-04-29,macron,Harris,947,internet,43.0,57.0 +2020-05-05,macron,Elabe,1009,internet,34.0,61.0 +2020-05-19,macron,BVA,980,internet,37.0,62.0 +2020-05-19,macron,Ifop,1918,phone&internet,39.0,60.0 +2020-05-20,macron,Odoxa,1004,internet,35.0,65.0 +2020-05-27,macron,Harris,961,internet,44.0,56.0 +2020-05-30,macron,Ipsos,1013,internet,38.0,59.0 +2020-05-31,macron,Viavoice,1000,internet,33.0,53.0 +2020-06-02,macron,Elabe,1002,internet,33.0,62.0 +2020-06-16,macron,Ifop,1865,phone&internet,38.0,60.0 +2020-06-18,macron,BVA,1003,internet,38.0,62.0 +2020-06-18,macron,Odoxa,1004,internet,39.0,61.0 +2020-06-24,macron,Harris,975,internet,44.0,56.0 +2020-06-27,macron,Kantar,1000,face to face,33.0,64.0 +2020-06-30,macron,Yougov,1024,internet,29.0,64.0 +2020-07-01,macron,Elabe,1004,internet,35.0,65.0 +2020-07-10,macron,Ifop,1018,internet,38.0,62.0 +2020-07-16,macron,BVA,1000,internet,39.0,61.0 +2020-07-16,macron,Ifop,974,internet,37.0,63.0 +2020-07-22,macron,Harris,960,internet,50.0,50.0 +2020-08-04,macron,Yougov,1041,internet,30.0,61.0 +2020-08-05,macron,Elabe,1002,internet,39.0,56.0 +2020-08-13,macron,Viavoice,1001,internet,32.0,53.0 +2020-08-26,macron,Harris,994,internet,45.0,55.0 +2020-08-27,macron,BVA,1002,internet,44.0,55.0 +2020-08-28,macron,Ifop,1016,internet,39.0,61.0 +2020-08-29,macron,Kantar,1000,face to face,35.0,61.0 +2020-09-01,macron,Yougov,1024,internet,31.0,61.0 +2020-09-09,macron,Elabe,1001,internet,35.0,57.0 +2020-09-23,macron,Harris,994,internet,45.0,55.0 +2020-09-23,macron,Odoxa,1005,internet,38.0,62.0 +2020-09-24,macron,BVA,1001,internet,38.0,62.0 +2020-09-26,macron,Kantar,1000,face to face,29.0,68.0 +2020-09-29,macron,Yougov,1034,internet,29.0,63.0 +2020-10-07,macron,Elabe,1000,internet,32.0,63.0 +2020-10-10,macron,Ipsos,1000,internet,40.0,54.0 +2020-10-11,macron,Ifop,1937,phone&internet,38.0,60.0 +2020-10-22,macron,BVA,1002,internet,42.0,57.0 +2020-10-22,macron,Odoxa,1001,internet,41.0,58.0 +2020-10-25,macron,Viavoice,1001,internet,34.0,52.0 +2020-10-28,macron,Harris,961,internet,46.0,54.0 +2020-10-30,macron,Ifop,1028,internet,46.0,54.0 +2020-10-30,macron,Kantar,1000,face to face,40.0,55.0 +2020-11-03,macron,Yougov,1004,internet,34.0,58.0 +2020-11-04,macron,Elabe,1003,internet,35.0,61.0 +2020-11-11,macron,Odoxa,1005,internet,43.0,57.0 +2020-11-14,macron,Ipsos,1000,internet,37.0,58.0 +2020-11-16,macron,Ifop,1924,phone&internet,41.0,57.0 +2020-11-19,macron,BVA,921,internet,42.0,58.0 +2020-11-25,macron,Harris,970,internet,49.0,51.0 +2020-11-27,macron,Ifop,1013,internet,41.0,59.0 +2020-11-28,macron,Kantar,1000,face to face,38.0,58.0 +2020-12-01,macron,Yougov,1008,internet,32.0,61.0 +2020-12-02,macron,Elabe,1000,internet,32.0,64.0 +2020-12-11,macron,Odoxa,990,internet,42.0,58.0 +2020-12-13,macron,Ifop,1936,phone&internet,38.0,60.0 +2020-12-17,macron,BVA,1005,internet,40.0,60.0 +2020-12-23,macron,Harris,1000,internet,49.0,51.0 +2021-01-06,macron,Elabe,1001,internet,35.0,61.0 +2021-01-06,macron,Yougov,1061,internet,32.0,61.0 +2021-01-08,macron,Ifop,1028,internet,45.0,55.0 +2021-01-09,macron,Kantar,1000,face to face,36.0,61.0 +2021-01-14,macron,Odoxa,1003,internet,40.0,60.0 +2021-01-15,macron,Ifop,1913,phone&internet,40.0,58.0 +2021-01-21,macron,BVA,1002,internet,37.0,63.0 +2021-01-21,macron,Viavoice,1001,internet,34.0,58.0 +2021-01-23,macron,Ipsos,1000,internet,35.0,60.0 +2021-01-27,macron,Harris,1017,internet,45.0,55.0 +2021-01-31,macron,Kantar,2000,face-to-face&internet,39.0,56.0 +2021-02-02,macron,Yougov,1013,internet,34.0,59.0 +2021-02-03,macron,Elabe,1001,internet,36.0,60.0 +2021-02-05,macron,Ifop,1004,internet,41.0,59.0 +2021-02-15,macron,Ifop,1954,phone&internet,41.0,56.0 +2021-02-18,macron,BVA,1003,internet,42.0,58.0 +2021-02-18,macron,Odoxa,1005,internet,41.0,59.0 +2021-02-24,macron,Harris,1037,internet,48.0,52.0 +2021-02-26,macron,Ifop,1012,internet,41.0,58.0 +2021-03-02,macron,Kantar,1000,internet,39.0,54.0 +2021-03-02,macron,Yougov,1084,internet,33.0,58.0 +2021-03-03,macron,Elabe,1003,internet,34.0,60.0 +2021-03-06,macron,Ipsos,1000,internet,41.0,53.0 +2021-03-15,macron,Ifop,1911,phone&internet,37.0,60.0 +2021-03-18,macron,BVA,1001,internet,39.0,61.0 +2021-03-20,macron,Viavoice,1000,internet,33.0,58.0 +2021-03-24,macron,Harris,1023,internet,46.0,54.0 +2021-03-25,macron,Odoxa,1005,internet,39.0,61.0 +2021-03-26,macron,Ifop,1011,internet,39.0,61.0 +2021-03-29,macron,Kantar,1000,internet,36.0,58.0 +2021-03-30,macron,Yougov,1068,internet,30.0,61.0 +2021-04-07,macron,Elabe,1003,internet,33.0,63.0 +2021-04-10,macron,Ipsos,1002,internet,37.0,58.0 +2021-04-22,macron,BVA,1002,internet,39.0,60.0 +2021-04-22,macron,Odoxa,1005,internet,38.0,61.0 +2021-04-26,macron,Kantar,1000,internet,35.0,58.0 +2021-04-28,macron,Harris,1041,internet,46.0,54.0 +2021-04-29,macron,Ifop,1002,internet,41.0,59.0 +2021-05-04,macron,Yougov,1001,internet,31.0,62.0 +2021-05-05,macron,Elabe,1000,internet,33.0,62.0 +2021-05-16,macron,Ifop,1928,phone&internet,40.0,58.0 +2021-05-20,macron,BVA,1004,internet,42.0,58.0 +2021-05-21,macron,Odoxa,1005,internet,41.0,58.0 +2021-05-27,macron,Harris,1025,internet,48.0,52.0 +2021-05-28,macron,Ifop,1015,internet,41.0,59.0 +2021-05-29,macron,Ipsos,1000,internet,40.0,57.0 +2021-06-01,macron,Kantar,1000,internet,35.0,57.0 +2021-06-02,macron,Elabe,1002,internet,36.0,58.0 +2021-06-07,macron,Yougov,1003,internet,30.0,61.0 +2021-06-24,macron,Odoxa,1005,internet,41.0,58.0 +2021-06-24,macron,Harris,1050,internet,50.0,50.0 +2021-06-25,macron,Ifop,1006,internet,41.0,59.0 +2021-06-28,macron,Kantar,1000,internet,39.0,55.0 +2021-06-30,macron,Yougov,1081,internet,31.0,59.0 +2021-07-01,macron,BVA,1004,internet,39.0,60.0 +2021-07-07,macron,Elabe,1003,internet,36.0,59.0 +2021-07-10,macron,Ipsos,1000,internet,39.0,55.0 +2021-07-16,macron,Odoxa,1005,internet,39.0,61.0 +2021-07-29,macron,Harris,1044,internet,47.0,53.0 +2021-08-04,macron,Elabe,1003,internet,34.0,61.0 +2021-08-12,macron,Yougov,1107,internet,28.0,72.0 +2021-08-21,macron,Ifop,992,phone&internet,41.0,59.0 +2021-08-26,macron,Harris,1054,internet,48.0,52.0 +2021-08-27,macron,BVA,1003,internet,40.0,60.0 +2021-08-30,macron,Kantar,1000,internet,38.0,55.0 +2021-09-01,macron,Elabe,1000,internet,37.0,57.0 +2021-09-01,macron,Ifop,1003,phone&internet,38.0,62.0 +2021-09-04,macron,Ipsos,1000,internet,40.0,53.0 +2021-09-16,macron,Ifop,1939,internet,38.0,59.0 +2021-09-23,macron,BVA,1000,internet,46.0,53.0 +2021-09-23,macron,Odoxa,1005,internet,42.0,58.0 +2021-09-27,macron,Kantar,1000,internet,34.0,57.0 +2021-10-01,macron,Ifop,1018,internet,39.0,61.0 +2021-10-06,macron,Elabe,1309,internet,35.0,58.0 +2021-10-09,macron,Ipsos,1000,internet,40.0,56.0 +2021-10-11,macron,Ifop,1887,phone&internet,40.0,58.0 +2021-10-21,macron,BVA,1007,internet,42.0,58.0 +2021-10-21,macron,Odoxa,1005,internet,40.0,60.0 +2021-11-01,macron,Kantar,1000,internet,36.0,57.0 +2021-11-03,macron,Elabe,1001,internet,34.0,60.0 +2021-11-25,macron,BVA,1001,internet,42.0,58.0 +2021-11-18,macron,Odoxa,1005,internet,44.0,56.0 +2021-11-13,macron,Ifop,1891,phone&internet,40.0,57.0 +2021-11-25,macron,Harris,1078,internet,51.0,49.0 +2021-12-06,macron,Kantar,1000,internet,37.0,55.0 +2021-12-07,macron,Elabe,1480,internet,36.0,58.0 +2021-12-16,macron,BVA,1000,internet,44.0,56.0 +2021-12-11,macron,Ipsos,1000,internet,41.0,52.0 +2021-12-08,macron,Odoxa,1005,internet,44.0,56.0 +2021-12-13,macron,Ifop,1947,phone&internet,41.0,55.0 +2021-12-22,macron,Harris,1211,internet,51.0,49.0 +2022-01-08,macron,Ipsos,1000,internet,40.0,56.0 +2022-01-10,macron,Kantar,1000,internet,38.0,56.0 +2022-01-11,macron,Elabe,1465,internet,32.0,65.0 +2022-01-17,macron,Ifop,1952,phone&internet,37.0,60.0 +2022-01-20,macron,BVA,1000,internet,38.0,62.0 +2022-01-20,macron,Odoxa,1005,internet,39.0,61.0 +2022-01-31,macron,Kantar,1000,internet,39.0,55.0 +2022-02-01,macron,Elabe,1482,internet,35.0,60.0 +2022-02-12,macron,Ipsos,1000,internet,43.0,54.0 +2022-02-13,macron,Ifop,1936,phone&internet,39.0,55.0 +2022-02-16,macron,Odoxa,1005,internet,41.0,57.0 +2022-02-24,macron,BVA,1000,internet,42.0,58.0 +2022-02-28,macron,Kantar,1000,internet,45.0,48.0 +2022-02-28,macron,Elabe,1431,internet,40.0,55.0 +2022-03-11,macron,Ifop,1913,phone&internet,41.0,58.0 +2022-03-12,macron,Ipsos,1000,internet,47.0,49.0 +2022-03-13,macron,Ifop,1925,phone&internet,42.0,56.0 +2022-03-31,macron,Harris,1065,internet,51.0,49.0 +2022-03-22,macron,BVA,1004,internet,46.0,54.0 +2022-03-24,macron,Odoxa,1005,internet,46.0,54.0 +2022-03-28,macron,Kantar,1000,internet,43.0,51.0 +2022-03-29,macron,Elabe,1531,internet,38.0,55.0 +2022-04-14,macron,Odoxa,1005,internet,40.0,59.0 +2022-04-27,macron2,BVA,1005,internet,42.0,58.0 +2022-04-27,macron2,Harris,1027,internet,49.0,51.0 +2022-05-02,macron2,Kantar,1000,internet,41.0,59.0 +2022-05-04,macron2,Elabe,1000,internet,34.0,58.0 +2022-05-12,macron2,Ipsos,1000,internet,42.0,54.0 +2022-05-19,macron2,BVA,1022,internet,42.0,57.0 +2022-05-21,macron2,Ifop,1946,phone&internet,41.0,58.0 +2022-05-25,macron2,Odoxa,1005,internet,44.0,56.0 +2022-05-26,macron2,Harris,1002,internet,49.0,51.0 +2022-05-30,macron2,Kantar,1000,internet,37.0,56.0 +2022-06-01,macron2,Elabe,2000,internet,32.0,59.0 diff --git a/pymc_extras/statespace/core/representation.py b/pymc_extras/statespace/core/representation.py index 450108d38..494805309 100644 --- a/pymc_extras/statespace/core/representation.py +++ b/pymc_extras/statespace/core/representation.py @@ -60,12 +60,12 @@ class PytensorRepresentation: .. math:: \begin{align} - x_t &= A_t x_{t-1} + c_t + R_t \varepsilon_t \tag{1} \\ + x_t &= T_t x_{t-1} + c_t + R_t \varepsilon_t \tag{1} \\ y_t &= Z_t x_t + d_t + \eta_t \tag{2} \\ \end{align} Where :math:`\{x_t\}_{t=0}^T` is a trajectory of hidden states, and :math:`\{y_t\}_{t=0}^T` is a trajectory of - observable states. Equation 1 is known as the "state transition equation", while describes how the system evolves + observable states. Equation 1 is known as the "state transition equation", which describes how the system evolves over time. Equation 2 is the "observation equation", and maps the latent state processes to observed data. The system is Gaussian when the innovations, :math:`\varepsilon_t`, and the measurement errors, :math:`\eta_t`, are normally distributed. The definition is completed by specification of these distributions, as diff --git a/pymc_extras/statespace/core/statespace.py b/pymc_extras/statespace/core/statespace.py index 778376720..f77a6ad19 100644 --- a/pymc_extras/statespace/core/statespace.py +++ b/pymc_extras/statespace/core/statespace.py @@ -1,5 +1,6 @@ import logging +from ast import Dict from collections.abc import Callable, Sequence from typing import Any @@ -15,6 +16,7 @@ from pymc.util import RandomState from pytensor import Variable, graph_replace from pytensor.compile import get_mode +from pytensor.graph.replace import vectorize_graph from rich.box import SIMPLE_HEAD from rich.console import Console from rich.table import Table @@ -37,6 +39,7 @@ FILTER_OUTPUT_DIMS, FILTER_OUTPUT_TYPES, JITTER_DEFAULT, + LONG_MATRIX_NAMES, MATRIX_DIMS, MATRIX_NAMES, OBS_STATE_DIM, @@ -60,7 +63,7 @@ def _validate_filter_arg(filter_arg): if filter_arg.lower() not in FILTER_OUTPUT_TYPES: raise ValueError( - f'filter_output should be one of {", ".join(FILTER_OUTPUT_TYPES)}, received {filter_arg}' + f"filter_output should be one of {', '.join(FILTER_OUTPUT_TYPES)}, received {filter_arg}" ) @@ -221,6 +224,7 @@ def __init__( filter_type: str = "standard", verbose: bool = True, measurement_error: bool = False, + batch_coords: dict[str, Sequence[str]] | None = None, ): self._fit_mode: str | None = None self._fit_coords: dict[str, Sequence[str]] | None = None @@ -237,6 +241,7 @@ def __init__( self.k_states = k_states self.k_posdef = k_posdef self.measurement_error = measurement_error + self.batch_coords = batch_coords # All models contain a state space representation and a Kalman filter self.ssm = PytensorRepresentation(k_endog, k_states, k_posdef) @@ -726,7 +731,9 @@ def _insert_random_variables(self): matrices = list(self._unpack_statespace_with_placeholders()) replacement_dict = {var: pymc_model[name] for name, var in self._name_to_variable.items()} - self.subbed_ssm = graph_replace(matrices, replace=replacement_dict, strict=True) + self.subbed_ssm = vectorize_graph(matrices, replace=replacement_dict) + for name, matrix in zip(MATRIX_NAMES, self.subbed_ssm): + matrix.name = name def _insert_data_variables(self): """ @@ -884,6 +891,7 @@ def build_statespace_graph( obs_coords=obs_coords, register_data=register_data, missing_fill_value=missing_fill_value, + batch_coords=self.batch_coords, ) filter_outputs = self.kalman_filter.build_graph( @@ -907,6 +915,8 @@ def build_statespace_graph( obs_dims = FILTER_OUTPUT_DIMS["predicted_observed_state"] obs_dims = obs_dims if all([dim in pm_mod.coords.keys() for dim in obs_dims]) else None + if self.batch_coords is not None: + obs_dims = (*self.batch_coords.keys(), *obs_dims) SequenceMvNormal( "obs", diff --git a/pymc_extras/statespace/filters/distributions.py b/pymc_extras/statespace/filters/distributions.py index 1e4f2b153..eec2b36b0 100644 --- a/pymc_extras/statespace/filters/distributions.py +++ b/pymc_extras/statespace/filters/distributions.py @@ -374,33 +374,36 @@ def dist(cls, mus, covs, logp, **kwargs): @classmethod def rv_op(cls, mus, covs, logp, size=None): # Batch dimensions (if any) will be on the far left, but scan requires time to be there instead - if mus.ndim > 2: - mus = pt.moveaxis(mus, -2, 0) - if covs.ndim > 3: - covs = pt.moveaxis(covs, -3, 0) - mus_, covs_ = mus.type(), covs.type() logp_ = logp.type() rng = pytensor.shared(np.random.default_rng()) - def step(mu, cov, rng): - new_rng, mvn = pm.MvNormal.dist(mu=mu, cov=cov, rng=rng, method="svd").owner.outputs - return mvn, {rng: new_rng} + def recursion(mus, covs, rng): + if mus.ndim > 2: + mus = pt.moveaxis(mus, -2, 0) + if covs.ndim > 3: + covs = pt.moveaxis(covs, -3, 0) - mvn_seq, updates = pytensor.scan( - step, sequences=[mus_, covs_], non_sequences=[rng], strict=True, n_steps=mus_.shape[0] - ) - mvn_seq = pt.specify_shape(mvn_seq, mus.type.shape) + def step(mu, cov, rng): + new_rng, mvn = pm.MvNormal.dist(mu=mu, cov=cov, rng=rng, method="svd").owner.outputs + return mvn, {rng: new_rng} + + mvn_seq, updates = pytensor.scan( + step, sequences=[mus, covs], non_sequences=[rng], strict=True, n_steps=mus.shape[0] + ) + mvn_seq = pt.specify_shape(mvn_seq, mus.type.shape) + + # Move time axis back to position -2 so batches are on the left + if mvn_seq.ndim > 2: + mvn_seq = pt.moveaxis(mvn_seq, 0, -2) - # Move time axis back to position -2 so batches are on the left - if mvn_seq.ndim > 2: - mvn_seq = pt.moveaxis(mvn_seq, 0, -2) + (seq_mvn_rng,) = tuple(updates.values()) - (seq_mvn_rng,) = tuple(updates.values()) + return [seq_mvn_rng, mvn_seq] mvn_seq_op = KalmanFilterRV( - inputs=[mus_, covs_, logp_, rng], outputs=[seq_mvn_rng, mvn_seq], ndim_supp=2 + inputs=[mus_, covs_, logp_, rng], outputs=recursion(mus_, covs_, rng), ndim_supp=2 ) mvn_seq = mvn_seq_op(mus, covs, logp, rng) @@ -411,7 +414,7 @@ def step(mu, cov, rng): def sequence_mvnormal_logp(op, values, mus, covs, logp, rng, **kwargs): return check_parameters( logp, - pt.eq(values[0].shape[0], mus.shape[0]), - pt.eq(covs.shape[0], mus.shape[0]), - msg="Observed data and parameters must have the same number of timesteps (dimension 0)", + pt.eq(values[0].shape[-2], mus.shape[-2]), + pt.eq(covs.shape[-3], mus.shape[-2]), + msg="Observed data and parameters must have the same number of timesteps", ) diff --git a/pymc_extras/statespace/filters/kalman_filter.py b/pymc_extras/statespace/filters/kalman_filter.py index 0ca47b50e..402a13f5d 100644 --- a/pymc_extras/statespace/filters/kalman_filter.py +++ b/pymc_extras/statespace/filters/kalman_filter.py @@ -1,4 +1,5 @@ from abc import ABC +from functools import partial import numpy as np import pytensor @@ -16,10 +17,11 @@ split_vars_into_seq_and_nonseq, stabilize, ) -from pymc_extras.statespace.utils.constants import JITTER_DEFAULT, MISSING_FILL +from pymc_extras.statespace.utils.constants import ALL_KF_OUTPUT_NAMES, JITTER_DEFAULT, MISSING_FILL MVN_CONST = pt.log(2 * pt.constant(np.pi, dtype="float64")) PARAM_NAMES = ["c", "d", "T", "Z", "R", "H", "Q"] +CORE_NDIM = (2, 1, 2, 1, 1, 2, 2, 2, 2, 2) assert_time_varying_dim_correct = Assert( "The first dimension of a time varying matrix (the time dimension) must be " @@ -73,6 +75,66 @@ def check_params(self, data, a0, P0, c, d, T, Z, R, H, Q): """ return data, a0, P0, c, d, T, Z, R, H, Q + def _make_gufunc_signature(self, inputs): + states = "s" + obs = "p" + exog = "r" + time = "t" + + matrix_to_shape = { + "data": (time, obs), + "a0": (states,), + "x0": (states,), + "initial_state": (states,), + "P0": (states, states), + "initial_state_cov": (states, states), + "c": (states,), + "state_intercept": (states,), + "d": (obs,), + "obs_intercept": (obs,), + "T": (states, states), + "transition": (states, states), + "Z": (obs, states), + "design": (obs, states), + "R": (states, exog), + "selection": (states, exog), + "H": (obs, obs), + "obs_cov": (obs, obs), + "Q": (exog, exog), + "state_cov": (exog, exog), + "filtered_states": (time, states), + "filtered_covariances": (time, states, states), + "predicted_states": (time, states), + "predicted_covariances": (time, states, states), + "observed_states": (time, obs), + "observed_covariances": (time, obs, obs), + "smoothed_states": (time, states), + "smoothed_covariances": (time, states, states), + "loglike_obs": (time,), + } + input_shapes = [] + output_shapes = [] + + for matrix in inputs: + name = matrix.name + input_shapes.append(matrix_to_shape[name]) + + for name in [ + "filtered_states", + "predicted_states", + "smoothed_states", + "filtered_covariances", + "predicted_covariances", + "smoothed_covariances", + "loglike_obs", + ]: + output_shapes.append(matrix_to_shape[name]) + + input_signature = ",".join(["(" + ",".join(shapes) + ")" for shapes in input_shapes]) + output_signature = ",".join(["(" + ",".join(shapes) + ")" for shapes in output_shapes]) + + return f"{input_signature} -> {output_signature}" + @staticmethod def add_check_on_time_varying_shapes( data: TensorVariable, sequence_params: list[TensorVariable] @@ -141,7 +203,7 @@ def unpack_args(self, args) -> tuple: return y, a0, P0, c, d, T, Z, R, H, Q - def build_graph( + def _build_graph( self, data, a0, @@ -235,8 +297,46 @@ def build_graph( if return_updates: return filter_results, updates + return filter_results + def build_graph( + self, + data, + a0, + P0, + c, + d, + T, + Z, + R, + H, + Q, + mode=None, + return_updates=False, + missing_fill_value=None, + cov_jitter=None, + ) -> list[TensorVariable] | tuple[list[TensorVariable], dict]: + """ + Build the vectorized computation graph for the Kalman filter. + """ + signature = self._make_gufunc_signature( + [data, a0, P0, c, d, T, Z, R, H, Q], + ) + fn = partial( + self._build_graph, + mode=mode, + return_updates=return_updates, + missing_fill_value=missing_fill_value, + cov_jitter=cov_jitter, + ) + filter_outputs = pt.vectorize(fn, signature=signature)(data, a0, P0, c, d, T, Z, R, H, Q) + # filter_outputs = fn(data, a0, P0, c, d, T, Z, R, H, Q) + for output, name in zip(filter_outputs, ALL_KF_OUTPUT_NAMES): + output.name = name + + return filter_outputs + def _postprocess_scan_results(self, results, a0, P0, n) -> list[TensorVariable]: """ Transform the values returned by the Kalman Filter scan into a form expected by users. In particular: diff --git a/pymc_extras/statespace/filters/kalman_smoother.py b/pymc_extras/statespace/filters/kalman_smoother.py index f15913b86..01dbc32d1 100644 --- a/pymc_extras/statespace/filters/kalman_smoother.py +++ b/pymc_extras/statespace/filters/kalman_smoother.py @@ -1,3 +1,5 @@ +from functools import partial + import pytensor import pytensor.tensor as pt @@ -11,6 +13,8 @@ ) from pymc_extras.statespace.utils.constants import JITTER_DEFAULT +SMOOTHER_CORE_NDIM = (2, 2, 2, 2, 3) + class KalmanSmoother: """ @@ -63,7 +67,62 @@ def unpack_args(self, args): return a, P, a_smooth, P_smooth, T, R, Q - def build_graph( + def _make_gufunc_signature(self, inputs): + states = "s" + obs = "p" + exog = "r" + time = "t" + + matrix_to_shape = { + "data": (time, obs), + "a0": (states,), + "x0": (states,), + "initial_state": (states,), + "P0": (states, states), + "initial_state_cov": (states, states), + "c": (states,), + "state_intercept": (states,), + "d": (obs,), + "obs_intercept": (obs,), + "T": (states, states), + "transition": (states, states), + "Z": (obs, states), + "design": (obs, states), + "R": (states, exog), + "selection": (states, exog), + "H": (obs, obs), + "obs_cov": (obs, obs), + "Q": (exog, exog), + "state_cov": (exog, exog), + "filtered_states": (time, states), + "filtered_covariances": (time, states, states), + "predicted_states": (time, states), + "predicted_covariances": (time, states, states), + "observed_states": (time, obs), + "observed_covariances": (time, obs, obs), + "smoothed_states": (time, states), + "smoothed_covariances": (time, states, states), + "loglike_obs": (time,), + } + input_shapes = [] + output_shapes = [] + + for matrix in inputs: + name = matrix.name + input_shapes.append(matrix_to_shape[name]) + + for name in [ + "smoothed_states", + "smoothed_covariances", + ]: + output_shapes.append(matrix_to_shape[name]) + + input_signature = ",".join(["(" + ",".join(shapes) + ")" for shapes in input_shapes]) + output_signature = ",".join(["(" + ",".join(shapes) + ")" for shapes in output_shapes]) + + return f"{input_signature} -> {output_signature}" + + def _build_graph( self, T, R, Q, filtered_states, filtered_covariances, mode=None, cov_jitter=JITTER_DEFAULT ): self.mode = mode @@ -104,6 +163,23 @@ def build_graph( return smoothed_states, smoothed_covariances + def build_graph( + self, T, R, Q, filtered_states, filtered_covariances, mode=None, cov_jitter=JITTER_DEFAULT + ): + """ + Build the vectorized computation graph for the Kalman smoother. + """ + signature = self._make_gufunc_signature( + [T, R, Q, filtered_states, filtered_covariances], + ) + fn = partial( + self._build_graph, + mode=mode, + cov_jitter=cov_jitter, + ) + return pt.vectorize(fn, signature=signature)(T, R, Q, filtered_states, filtered_covariances) + # return fn(T, R, Q, filtered_states, filtered_covariances) + def smoother_step(self, *args): a, P, a_smooth, P_smooth, T, R, Q = self.unpack_args(args) a_hat, P_hat = self.predict(a, P, T, R, Q) diff --git a/pymc_extras/statespace/filters/utilities.py b/pymc_extras/statespace/filters/utilities.py index d61537b62..ef254df51 100644 --- a/pymc_extras/statespace/filters/utilities.py +++ b/pymc_extras/statespace/filters/utilities.py @@ -2,7 +2,14 @@ from pytensor.tensor.nlinalg import matrix_dot -from pymc_extras.statespace.utils.constants import JITTER_DEFAULT, NEVER_TIME_VARYING, VECTOR_VALUED +from pymc_extras.statespace.utils.constants import ( + JITTER_DEFAULT, + NEVER_TIME_VARYING, + VECTOR_VALUED, +) + +CORE_NDIM = (2, 1, 2, 1, 1, 2, 2, 2, 2, 2) +SMOOTHER_CORE_NDIM = (2, 2, 2, 2, 3) def decide_if_x_time_varies(x, name): @@ -57,3 +64,40 @@ def stabilize(cov, jitter=JITTER_DEFAULT): def quad_form_sym(A, B): out = matrix_dot(A, B, A.T) return 0.5 * (out + out.T) + + +def has_batched_input_smoother(T, R, Q, filtered_states, filtered_covariances): + """ + Check if any of the inputs are batched. + """ + return any( + x.ndim > SMOOTHER_CORE_NDIM[i] + for i, x in enumerate([T, R, Q, filtered_states, filtered_covariances]) + ) + + +def get_dummy_core_inputs_smoother(T, R, Q, filtered_states, filtered_covariances): + """ + Get dummy inputs for the core parameters. + """ + out = [] + for x, core_ndim in zip([T, R, Q, filtered_states, filtered_covariances], SMOOTHER_CORE_NDIM): + out.append(pt.tensor(f"{x.name}_core_case", dtype=x.dtype, shape=x.type.shape[-core_ndim:])) + return out + + +def has_batched_input_filter(data, a0, P0, c, d, T, Z, R, H, Q): + """ + Check if any of the inputs are batched. + """ + return any(x.ndim > CORE_NDIM[i] for i, x in enumerate([data, a0, P0, c, d, T, Z, R, H, Q])) + + +def get_dummy_core_inputs_filter(data, a0, P0, c, d, T, Z, R, H, Q): + """ + Get dummy inputs for the core parameters. + """ + out = [] + for x, core_ndim in zip([data, a0, P0, c, d, T, Z, R, H, Q], CORE_NDIM): + out.append(pt.tensor(f"{x.name}_core_case", dtype=x.dtype, shape=x.type.shape[-core_ndim:])) + return out diff --git a/pymc_extras/statespace/models/SARIMAX.py b/pymc_extras/statespace/models/SARIMAX.py index f8a420375..35e9819b5 100644 --- a/pymc_extras/statespace/models/SARIMAX.py +++ b/pymc_extras/statespace/models/SARIMAX.py @@ -180,6 +180,7 @@ def __init__( state_structure: str = "fast", measurement_error: bool = False, verbose=True, + batch_coords=None, ): # Model order self.p, self.d, self.q = order @@ -202,7 +203,7 @@ def __init__( if state_structure not in SARIMAX_STATE_STRUCTURES: raise ValueError( f"Got invalid argument {state_structure} for state structure, expected one of " - f'{", ".join(SARIMAX_STATE_STRUCTURES)}' + f"{', '.join(SARIMAX_STATE_STRUCTURES)}" ) if state_structure == "interpretable" and (self.d + self.D) > 0: @@ -228,6 +229,7 @@ def __init__( filter_type, verbose=verbose, measurement_error=measurement_error, + batch_coords=batch_coords, ) @property diff --git a/pymc_extras/statespace/models/structural.py b/pymc_extras/statespace/models/structural.py index 40d1dedff..c7f0ff53a 100644 --- a/pymc_extras/statespace/models/structural.py +++ b/pymc_extras/statespace/models/structural.py @@ -81,6 +81,7 @@ def __init__( name: str | None = None, verbose: bool = True, filter_type: str = "standard", + batch_coords: dict[str, Sequence] | None = None, ): # Add the initial state covariance to the parameters if name is None: @@ -112,6 +113,7 @@ def __init__( filter_type=filter_type, verbose=verbose, measurement_error=measurement_error, + batch_coords=batch_coords, ) self.ssm = ssm.copy() @@ -298,7 +300,7 @@ def _extract_and_transform_variable(idata, new_state_names): dropped_vars = set(var_names) - set(latent_names) if len(dropped_vars) > 0: _log.warning( - f'Variables {", ".join(dropped_vars)} do not contain all hidden states (their last dimension ' + f"Variables {', '.join(dropped_vars)} do not contain all hidden states (their last dimension " f"is not {self.k_states}). They will not be present in the modified idata." ) if len(dropped_vars) == len(var_names): @@ -590,7 +592,7 @@ def _combine_component_info(self, other): def _make_combined_name(self): components = self._component_info.keys() - name = f'StateSpace[{", ".join(components)}]' + name = f"StateSpace[{', '.join(components)}]" return name def __add__(self, other): @@ -644,7 +646,7 @@ def __add__(self, other): return new_comp - def build(self, name=None, filter_type="standard", verbose=True): + def build(self, name=None, filter_type="standard", verbose=True, batch_coords=None): """ Build a StructuralTimeSeries statespace model from the current component(s) @@ -685,6 +687,7 @@ def build(self, name=None, filter_type="standard", verbose=True): name_to_data=self._name_to_data, filter_type=filter_type, verbose=verbose, + batch_coords=batch_coords, ) diff --git a/pymc_extras/statespace/utils/constants.py b/pymc_extras/statespace/utils/constants.py index c4064858d..20f92d155 100644 --- a/pymc_extras/statespace/utils/constants.py +++ b/pymc_extras/statespace/utils/constants.py @@ -47,6 +47,16 @@ SMOOTHER_OUTPUT_NAMES = ["smoothed_state", "smoothed_covariance"] OBSERVED_OUTPUT_NAMES = ["predicted_observed_state", "predicted_observed_covariance"] +ALL_KF_OUTPUT_NAMES = [ + "filtered_states", + "predicted_states", + "observed_states", + "filtered_covariances", + "predicted_covariances", + "observed_covariances", + "loglike_obs", +] + MATRIX_DIMS = { "x0": (ALL_STATE_DIM,), "P0": (ALL_STATE_DIM, ALL_STATE_AUX_DIM), diff --git a/pymc_extras/statespace/utils/data_tools.py b/pymc_extras/statespace/utils/data_tools.py index 8c8284c56..1f1f80432 100644 --- a/pymc_extras/statespace/utils/data_tools.py +++ b/pymc_extras/statespace/utils/data_tools.py @@ -35,12 +35,16 @@ def get_data_dims(data): return data_dims -def _validate_data_shape(data_shape, n_obs, obs_coords=None, check_col_names=False, col_names=None): +def _validate_data_shape( + data_shape, n_obs, obs_coords=None, check_col_names=False, col_names=None, batch_ndim=0 +): if col_names is None: col_names = [] - if len(data_shape) != 2: - raise ValueError("Data must be a 2d matrix") + if len(data_shape) != 2 + batch_ndim: + raise ValueError( + f"Data must be a {2 + batch_ndim}d tensor, found {len(data_shape)}d tensor." + ) if data_shape[-1] != n_obs: raise ValueError( @@ -53,14 +57,16 @@ def _validate_data_shape(data_shape, n_obs, obs_coords=None, check_col_names=Fal if len(missing_cols) > 0: raise ValueError( "Columns of DataFrame provided as data do not match state names. The following states were" - f'not found: {", ".join(missing_cols)}. This may result in unexpected results in complex' + f"not found: {', '.join(missing_cols)}. This may result in unexpected results in complex" f"statespace models" ) -def preprocess_tensor_data(data, n_obs, obs_coords=None): +def preprocess_tensor_data(data, n_obs, batch_ndim, obs_coords=None): data_shape = data.shape.eval() - _validate_data_shape(data_shape, n_obs, obs_coords) + _validate_data_shape( + data_shape=data_shape, n_obs=n_obs, obs_coords=obs_coords, batch_ndim=batch_ndim + ) if obs_coords is not None: warnings.warn(NO_TIME_INDEX_WARNING) index = np.arange(data_shape[0], dtype="int") @@ -68,24 +74,33 @@ def preprocess_tensor_data(data, n_obs, obs_coords=None): return data.eval(), index -def preprocess_numpy_data(data, n_obs, obs_coords=None): - _validate_data_shape(data.shape, n_obs, obs_coords) +def preprocess_numpy_data(data, n_obs, batch_ndim, obs_coords=None): + _validate_data_shape( + data_shape=data.shape, n_obs=n_obs, obs_coords=obs_coords, batch_ndim=batch_ndim + ) if obs_coords is not None: warnings.warn(NO_TIME_INDEX_WARNING) - index = np.arange(data.shape[0], dtype="int") + index = np.arange(data.shape[-2], dtype="int") return data, index -def preprocess_pandas_data(data, n_obs, obs_coords=None, check_column_names=False): +def preprocess_pandas_data(data, n_obs, batch_ndim, obs_coords=None, check_column_names=False): if isinstance(data, pd.Series): if data.name is None: data.name = "data" data = data.to_frame() col_names = data.columns - _validate_data_shape(data.shape, n_obs, obs_coords, check_column_names, col_names) + _validate_data_shape( + data_shape=data.shape, + n_obs=n_obs, + check_column_names=check_column_names, + col_names=col_names, + obs_coords=obs_coords, + batch_ndim=batch_ndim, + ) if isinstance(data.index, pd.DatetimeIndex): if data.index.freq is None: @@ -121,11 +136,13 @@ def preprocess_pandas_data(data, n_obs, obs_coords=None, check_column_names=Fals return preprocess_numpy_data(data.values, n_obs, obs_coords) -def add_data_to_active_model(values, index, data_dims=None): +def add_data_to_active_model(values, index, batch_dims=None, data_dims=None): pymc_mod = modelcontext(None) if data_dims is None: data_dims = [TIME_DIM, OBS_STATE_DIM] - time_dim = data_dims[0] + if batch_dims is not None: + data_dims = list(batch_dims) + data_dims + time_dim = data_dims[-2] if time_dim not in pymc_mod.coords: pymc_mod.add_coord(time_dim, index) @@ -144,6 +161,8 @@ def add_data_to_active_model(values, index, data_dims=None): data_shape = None if values.shape[-1] == 1: data_shape = (None, 1) + if batch_dims is not None: + data_shape = (None,) * len(batch_dims) + data_shape data = pm.Data("data", values, dims=data_dims, shape=data_shape) @@ -177,21 +196,39 @@ def mask_missing_values_in_data(values, missing_fill_value=None): def register_data_with_pymc( - data, n_obs, obs_coords, register_data=True, missing_fill_value=None, data_dims=None + data, + n_obs, + obs_coords, + batch_coords=None, + register_data=True, + missing_fill_value=None, + data_dims=None, ): + if batch_coords is None: + batch_coords = {} + batch_ndim = len(batch_coords) + if isinstance(data, pt.TensorVariable | TensorSharedVariable): - values, index = preprocess_tensor_data(data, n_obs, obs_coords) + values, index = preprocess_tensor_data( + data=data, n_obs=n_obs, obs_coords=obs_coords, batch_ndim=batch_ndim + ) elif isinstance(data, np.ndarray): - values, index = preprocess_numpy_data(data, n_obs, obs_coords) + values, index = preprocess_numpy_data( + data=data, n_obs=n_obs, obs_coords=obs_coords, batch_ndim=batch_ndim + ) elif isinstance(data, pd.DataFrame | pd.Series): - values, index = preprocess_pandas_data(data, n_obs, obs_coords) + values, index = preprocess_pandas_data( + data=data, n_obs=n_obs, obs_coords=obs_coords, batch_ndim=batch_ndim + ) else: raise ValueError("Data should be one of pytensor tensor, numpy array, or pandas dataframe") data, nan_mask = mask_missing_values_in_data(values, missing_fill_value) if register_data: - data = add_data_to_active_model(data, index, data_dims) + data = add_data_to_active_model( + values=data, index=index, batch_dims=batch_coords.keys(), data_dims=data_dims + ) else: data = pytensor.shared(data, name="data") return data, nan_mask diff --git a/tests/statespace/test_kalman_filter.py b/tests/statespace/test_kalman_filter.py index 6c0bc18c6..c04278144 100644 --- a/tests/statespace/test_kalman_filter.py +++ b/tests/statespace/test_kalman_filter.py @@ -31,19 +31,22 @@ RTOL = 1e-6 if floatX.endswith("64") else 1e-3 standard_inout = initialize_filter(StandardFilter()) +# standard_inout_batched = initialize_filter(StandardFilter(), batched=True) cholesky_inout = initialize_filter(SquareRootFilter()) univariate_inout = initialize_filter(UnivariateFilter()) f_standard = pytensor.function(*standard_inout, on_unused_input="ignore") +# f_standard_batched = pytensor.function(*standard_inout_batched, on_unused_input="ignore") f_cholesky = pytensor.function(*cholesky_inout, on_unused_input="ignore") f_univariate = pytensor.function(*univariate_inout, on_unused_input="ignore") -filter_funcs = [f_standard, f_cholesky, f_univariate] +filter_funcs = [f_standard] # , f_cholesky, f_univariate] filter_names = [ "StandardFilter", - "CholeskyFilter", - "UnivariateFilter", + # "StandardFilterBatched", + # "CholeskyFilter", + # "UnivariateFilter", ] output_names = [ @@ -65,17 +68,20 @@ def test_base_class_update_raises(): filter.update(*inputs) -@pytest.mark.parametrize("filter_func", filter_funcs, ids=filter_names) -def test_output_shapes_one_state_one_observed(filter_func, rng): +@pytest.mark.parametrize( + "filter_func, filter_name", zip(filter_funcs, filter_names), ids=filter_names +) +def test_output_shapes_one_state_one_observed(filter_func, filter_name, rng): + batch_size = 3 if "batched" in filter_name.lower() else 0 p, m, r, n = 1, 1, 1, 10 - inputs = make_test_inputs(p, m, r, n, rng) + inputs = make_test_inputs(p, m, r, n, rng, batch_size=batch_size) outputs = filter_func(*inputs) for output_idx, name in enumerate(output_names): - expected_output = get_expected_shape(name, p, m, r, n) - assert ( - outputs[output_idx].shape == expected_output - ), f"Shape of {name} does not match expected" + expected_shape = get_expected_shape(name, p, m, r, n, batch_size) + assert outputs[output_idx].shape == expected_shape, ( + f"Shape of {name} does not match expected" + ) @pytest.mark.parametrize("filter_func", filter_funcs, ids=filter_names) @@ -86,9 +92,9 @@ def test_output_shapes_when_all_states_are_stochastic(filter_func, rng): outputs = filter_func(*inputs) for output_idx, name in enumerate(output_names): expected_output = get_expected_shape(name, p, m, r, n) - assert ( - outputs[output_idx].shape == expected_output - ), f"Shape of {name} does not match expected" + assert outputs[output_idx].shape == expected_output, ( + f"Shape of {name} does not match expected" + ) @pytest.mark.parametrize("filter_func", filter_funcs, ids=filter_names) @@ -99,9 +105,9 @@ def test_output_shapes_when_some_states_are_deterministic(filter_func, rng): outputs = filter_func(*inputs) for output_idx, name in enumerate(output_names): expected_output = get_expected_shape(name, p, m, r, n) - assert ( - outputs[output_idx].shape == expected_output - ), f"Shape of {name} does not match expected" + assert outputs[output_idx].shape == expected_output, ( + f"Shape of {name} does not match expected" + ) @pytest.fixture @@ -161,9 +167,9 @@ def test_output_shapes_with_time_varying_matrices(f_standard_nd, rng): for output_idx, name in enumerate(output_names): expected_output = get_expected_shape(name, p, m, r, n) - assert ( - outputs[output_idx].shape == expected_output - ), f"Shape of {name} does not match expected" + assert outputs[output_idx].shape == expected_output, ( + f"Shape of {name} does not match expected" + ) @pytest.mark.parametrize("filter_func", filter_funcs, ids=filter_names) @@ -175,9 +181,9 @@ def test_output_with_deterministic_observation_equation(filter_func, rng): for output_idx, name in enumerate(output_names): expected_output = get_expected_shape(name, p, m, r, n) - assert ( - outputs[output_idx].shape == expected_output - ), f"Shape of {name} does not match expected" + assert outputs[output_idx].shape == expected_output, ( + f"Shape of {name} does not match expected" + ) @pytest.mark.parametrize( @@ -190,9 +196,9 @@ def test_output_with_multiple_observed(filter_func, filter_name, rng): outputs = filter_func(*inputs) for output_idx, name in enumerate(output_names): expected_output = get_expected_shape(name, p, m, r, n) - assert ( - outputs[output_idx].shape == expected_output - ), f"Shape of {name} does not match expected" + assert outputs[output_idx].shape == expected_output, ( + f"Shape of {name} does not match expected" + ) @pytest.mark.parametrize( @@ -206,9 +212,9 @@ def test_missing_data(filter_func, filter_name, p, rng): outputs = filter_func(*inputs) for output_idx, name in enumerate(output_names): expected_output = get_expected_shape(name, p, m, r, n) - assert ( - outputs[output_idx].shape == expected_output - ), f"Shape of {name} does not match expected" + assert outputs[output_idx].shape == expected_output, ( + f"Shape of {name} does not match expected" + ) @pytest.mark.parametrize("filter_func", filter_funcs, ids=filter_names) @@ -324,3 +330,34 @@ def test_kalman_filter_jax(filter): for name, jax_res, pt_res in zip(output_names, jax_outputs, pt_outputs): assert_allclose(jax_res, pt_res, atol=ATOL, rtol=RTOL, err_msg=f"{name} failed!") + + +def test_batched_standard_filter(): + p, m, r, n = 1, 5, 1, 10 + input_names = ["data", "x0", "P0", "c", "d", "T", "Z", "R", "H", "Q"] + inputs = [ + pt.as_tensor(x, name=name) + for x, name in zip(make_test_inputs(p, m, r, n, rng, batch_size=8), input_names) + ] + kf = StandardFilter() + outputs = kf.build_graph(*inputs) + np.testing.assert_equal(outputs[0].shape.eval(), (8, n, m)) + + +def test_batched_kalman_smoother(): + p, m, r, n = 1, 5, 1, 10 + filter_input_names = ["data", "x0", "P0", "c", "d", "T", "Z", "R", "H", "Q"] + smoother_input_names = ["T", "R", "Q", "filtered_states", "filtered_covs"] + + kf_inputs = data, x0, P0, c, d, T, Z, R, H, Q = [ + pt.as_tensor(x, name=name) + for x, name in zip(make_test_inputs(p, m, r, n, rng, batch_size=8), filter_input_names) + ] + kf = StandardFilter() + kf_outputs = kf.build_graph(*kf_inputs) + + ks = KalmanSmoother() + ks_inputs = T, R, Q, kf_outputs[0], kf_outputs[3] + ks_outputs = ks.build_graph(*ks_inputs) + + np.testing.assert_equal(ks_outputs[0].shape.eval(), (8, n, m)) diff --git a/tests/statespace/test_statespace.py b/tests/statespace/test_statespace.py index 2b0a11409..c195ea75f 100644 --- a/tests/statespace/test_statespace.py +++ b/tests/statespace/test_statespace.py @@ -11,6 +11,8 @@ from numpy.testing import assert_allclose from pymc_extras.statespace.core.statespace import FILTER_FACTORY, PyMCStateSpace +from pymc_extras.statespace.filters.kalman_filter import StandardFilter +from pymc_extras.statespace.filters.kalman_smoother import KalmanSmoother from pymc_extras.statespace.models import structural as st from pymc_extras.statespace.models.utilities import make_default_coords from pymc_extras.statespace.utils.constants import ( @@ -710,8 +712,7 @@ def test_invalid_scenarios(): # Giving a list, tuple, or Series when a matrix of data is expected should always raise with pytest.raises( ValueError, - match="Scenario data for variable 'a' has the wrong number of columns. " - "Expected 2, got 1", + match="Scenario data for variable 'a' has the wrong number of columns. Expected 2, got 1", ): for data_type in [list, tuple, pd.Series]: ss_mod._validate_scenario_data(data_type(np.zeros(10))) @@ -720,15 +721,14 @@ def test_invalid_scenarios(): # Providing irrevelant data raises with pytest.raises( ValueError, - match="Scenario data provided for variable 'jk lol', which is not an exogenous " "variable", + match="Scenario data provided for variable 'jk lol', which is not an exogenous variable", ): ss_mod._validate_scenario_data({"jk lol": np.zeros(10)}) # Incorrect 2nd dimension of a non-dataframe with pytest.raises( ValueError, - match="Scenario data for variable 'a' has the wrong number of columns. Expected " - "2, got 1", + match="Scenario data for variable 'a' has the wrong number of columns. Expected 2, got 1", ): scenario = np.zeros(10).tolist() ss_mod._validate_scenario_data(scenario) @@ -870,3 +870,57 @@ def test_forecast_with_exog_data(rng, exog_ss_mod, idata_exog, start): regression_effect_expected = (betas * scenario_xr).sum(dim=["state"]) assert_allclose(regression_effect, regression_effect_expected) + + +@pytest.mark.parametrize("batch_size", [(10,), (10, 3, 5)]) +def test_insert_batched_rvs(ss_mod, batch_size): + with pm.Model(): + rho = pm.Normal("rho", shape=batch_size) + zeta = pm.Normal("zeta", shape=batch_size) + ss_mod._insert_random_variables() + matrices = ss_mod.unpack_statespace() + assert matrices[4].type.shape == (*batch_size, 2, 2) + + +@pytest.mark.parametrize("batch_size", [(10,), (10, 3, 5)]) +def test_insert_batched_rvs_in_kf(ss_mod, batch_size): + data = pt.as_tensor(np.random.normal(size=(*batch_size, 7, 1)).astype(floatX)) + data.name = "data" + kf = StandardFilter() + + with pm.Model(): + rho = pm.Normal("rho", shape=batch_size) + zeta = pm.Normal("zeta", shape=batch_size) + ss_mod._insert_random_variables() + + matrices = x0, P0, c, d, T, Z, R, H, Q = ss_mod.unpack_statespace() + outputs = kf.build_graph(data, *matrices) + + logp = outputs.pop(-1) + states, covs = outputs[:3], outputs[3:] + filtered_states, predicted_states, observed_states = states + filtered_covariances, predicted_covariances, observed_covariances = covs + + assert logp.type.shape == (*batch_size, 7) + assert filtered_states.type.shape == (*batch_size, 7, 2) + assert predicted_states.type.shape == (*batch_size, 7, 2) + assert observed_states.type.shape == (*batch_size, 7, 1) + assert filtered_covariances.type.shape == (*batch_size, 7, 2, 2) + assert predicted_covariances.type.shape == (*batch_size, 7, 2, 2) + assert observed_covariances.type.shape == (*batch_size, 7, 1, 1) + + ks = KalmanSmoother() + smoothed_states, smoothed_covariances = ks.build_graph( + T, R, Q, filtered_states, filtered_covariances + ) + assert smoothed_states.type.shape == ( + *batch_size, + None, + 2, + ) # TODO: why do we lose the time dimension here? + assert smoothed_covariances.type.shape == ( + *batch_size, + None, + 2, + 2, + ) # TODO: why do we lose the time dimension here? diff --git a/tests/statespace/utilities/test_helpers.py b/tests/statespace/utilities/test_helpers.py index c6170f880..fa970f146 100644 --- a/tests/statespace/utilities/test_helpers.py +++ b/tests/statespace/utilities/test_helpers.py @@ -34,18 +34,18 @@ def load_nile_test_data(): return nile -def initialize_filter(kfilter, mode=None, p=None, m=None, r=None, n=None): +def initialize_filter(kfilter, mode=None, p=None, m=None, r=None, n=None, batched=False): ksmoother = KalmanSmoother() - data = pt.tensor(name="data", dtype=floatX, shape=(n, p)) - a0 = pt.tensor(name="x0", dtype=floatX, shape=(m,)) - P0 = pt.tensor(name="P0", dtype=floatX, shape=(m, m)) - c = pt.tensor(name="c", dtype=floatX, shape=(m,)) - d = pt.tensor(name="d", dtype=floatX, shape=(p,)) - Q = pt.tensor(name="Q", dtype=floatX, shape=(r, r)) - H = pt.tensor(name="H", dtype=floatX, shape=(p, p)) - T = pt.tensor(name="T", dtype=floatX, shape=(m, m)) - R = pt.tensor(name="R", dtype=floatX, shape=(m, r)) - Z = pt.tensor(name="Z", dtype=floatX, shape=(p, m)) + data = pt.tensor(name="data", dtype=floatX, shape=(None, n, p) if batched else (n, p)) + a0 = pt.tensor(name="x0", dtype=floatX, shape=(None, m) if batched else (m,)) + P0 = pt.tensor(name="P0", dtype=floatX, shape=(None, m, m) if batched else (m, m)) + c = pt.tensor(name="c", dtype=floatX, shape=(None, m) if batched else (m,)) + d = pt.tensor(name="d", dtype=floatX, shape=(None, p) if batched else (p,)) + Q = pt.tensor(name="Q", dtype=floatX, shape=(None, r, r) if batched else (r, r)) + H = pt.tensor(name="H", dtype=floatX, shape=(None, p, p) if batched else (p, p)) + T = pt.tensor(name="T", dtype=floatX, shape=(None, m, m) if batched else (m, m)) + R = pt.tensor(name="R", dtype=floatX, shape=(None, m, r) if batched else (m, r)) + Z = pt.tensor(name="Z", dtype=floatX, shape=(None, p, m) if batched else (p, m)) inputs = [data, a0, P0, c, d, T, Z, R, H, Q] @@ -68,7 +68,7 @@ def initialize_filter(kfilter, mode=None, p=None, m=None, r=None, n=None): filtered_covs, predicted_covs, smoothed_covs, - ll_obs.sum(), + ll_obs.sum(axis=-1), ll_obs, ] @@ -83,7 +83,7 @@ def add_missing_data(data, n_missing, rng): return data -def make_test_inputs(p, m, r, n, rng, missing_data=None, H_is_zero=False): +def make_1d_test_inputs(p, m, r, n, rng, missing_data=None, H_is_zero=False): data = np.arange(n * p, dtype=floatX).reshape(-1, p) if missing_data is not None: data = add_missing_data(data, missing_data, rng) @@ -106,16 +106,34 @@ def make_test_inputs(p, m, r, n, rng, missing_data=None, H_is_zero=False): return data, a0, P0, c, d, T, Z, R, H, Q -def get_expected_shape(name, p, m, r, n): +def make_test_inputs(p, m, r, n, rng, missing_data=None, H_is_zero=False, batch_size=0): + if batch_size == 0: + return make_1d_test_inputs(p, m, r, n, rng, missing_data, H_is_zero) + + # Create individual inputs for each batch + np_batch_inputs = [] + for i in range(batch_size): + inputs = make_1d_test_inputs(p, m, r, n, rng, missing_data, H_is_zero) + np_batch_inputs.append(inputs) + + return [np.stack(x, axis=0) for x in zip(*np_batch_inputs)] + + +def get_expected_shape(name, p, m, r, n, batch_size=0): if name == "log_likelihood": - return () + shape = () elif name == "ll_obs": - return (n,) + shape = (n,) filter_type, variable = name.split("_") if variable == "states": - return n, m + shape = n, m if variable == "covs": - return n, m, m + shape = n, m, m + + if batch_size != 0: + shape = (batch_size, *shape) + + return shape def get_sm_state_from_output_name(res, name):