1
$\begingroup$

i have done this coding to plot the data. the problem is some value is missing for certain date and the graph is not smooth and noisy. one way to smooth the data is by interpolation but i dont know how to do it in mathematica.pls help me

this is the graph enter image description here

$\endgroup$
2
  • 3
    $\begingroup$ Please post actual code instead of pictures of code and add some example data. $\endgroup$
    – Karsten7
    Mar 5, 2015 at 5:20
  • $\begingroup$ Have a look at ListInterpolation $\endgroup$
    – Verbeia
    Mar 5, 2015 at 6:48

1 Answer 1

1
$\begingroup$

Daily rates are noisy, but maybe you can find a function that fits the accumulated values. This is an example to get you started using the deaths.

I downloaded the statistical data from the web into my hard drive (https://data.hdx.rwlabs.org/dataset/rowca-ebola-cases#)

Increase memory stack

Needs["JLink`"];
ReinstallJava[JVMArguments -> "-Xmx2048m"];

Read the file

    data = Import[
       "C:\\Users\\myUser\\Downloads\\Data Ebola (Public).xlsx", {"Data", 
        2}];
titles = data[[1, All]];
data = Rest@data;
iberiaValues = 
  DeleteCases[
   Cases[data, {"Liberia", "National", "Deaths", number_, 
      date_, ___} -> {date, number}], {_, ""}];
ListPlot[Tooltip[liberiaValues[[All, 2]]]]

Mathematica graphics

Some datapoints seem erroneous. Eliminate from the dataset.

liberia = 
  DeleteCases[
   liberiaValues, {_, 
    a_ /; Or[a == 2168, a == 2106, a == 2014, a == 2104, a == 4181, 
      a == 2403, a == 2443, a == 2446]}];

Data looks like the logistics curve. Lets find a model based on date. Use whatever model curve is best for you. First make the x axis the number of days since the first recorded death.

    liberia[[All, 1]] = 
      QuantityMagnitude[DateDifference[{2014, 4, 8}, #, "Day"]] & /@ 
       liberia[[All, 1]];
nlm = NonlinearModelFit[liberia, 
  L / (1 + Exp[-k (x - x0)]), {L, k, x0}, x]

Show[ListPlot[liberia], 
 Plot[nlm[x], {x, 0, 305}, PlotStyle -> {Black, Dashed}]]

Mathematica graphics

Then use model to interpolate data as needed.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.