|
|
@ -1,623 +0,0 @@ |
|
|
|
{ |
|
|
|
"cells": [ |
|
|
|
{ |
|
|
|
"cell_type": "code", |
|
|
|
"execution_count": 2, |
|
|
|
"metadata": {}, |
|
|
|
"outputs": [], |
|
|
|
"source": [ |
|
|
|
"using Pkg\n", |
|
|
|
"Pkg.activate(\".\")\n", |
|
|
|
"using SemanticModels\n", |
|
|
|
"using SemanticModels.Unitful: DomainError, s, d, C, uconvert, NoUnits\n", |
|
|
|
"using DifferentialEquations\n", |
|
|
|
"using DataFrames\n", |
|
|
|
"using Unitful\n", |
|
|
|
"using Test\n", |
|
|
|
"\n", |
|
|
|
"using Distributions: Uniform\n", |
|
|
|
"using GLM\n", |
|
|
|
"using DataFrames\n" |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
"cell_type": "code", |
|
|
|
"execution_count": 3, |
|
|
|
"metadata": {}, |
|
|
|
"outputs": [], |
|
|
|
"source": [ |
|
|
|
"using Plots" |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
"cell_type": "code", |
|
|
|
"execution_count": 4, |
|
|
|
"metadata": {}, |
|
|
|
"outputs": [ |
|
|
|
{ |
|
|
|
"data": { |
|
|
|
"text/plain": [ |
|
|
|
"stripunits (generic function with 1 method)" |
|
|
|
] |
|
|
|
}, |
|
|
|
"execution_count": 4, |
|
|
|
"metadata": {}, |
|
|
|
"output_type": "execute_result" |
|
|
|
} |
|
|
|
], |
|
|
|
"source": [ |
|
|
|
"stripunits(x) = uconvert(NoUnits, x)" |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
"cell_type": "code", |
|
|
|
"execution_count": 5, |
|
|
|
"metadata": {}, |
|
|
|
"outputs": [ |
|
|
|
{ |
|
|
|
"data": { |
|
|
|
"text/plain": [ |
|
|
|
"CombinedModel{Array{CombinedModel{Array{SpringModel{Array{Quantity{Float64,𝐓^-2,Unitful.FreeUnits{(d^-2,),𝐓^-2,nothing}},1},Tuple{Quantity{Int64,𝐓,Unitful.FreeUnits{(d,),𝐓,nothing}},Quantity{Float64,𝐓,Unitful.FreeUnits{(d,),𝐓,nothing}}},Array{Quantity{Float64,D,U} where U where D,1}},1},getfield(Main, Symbol(\"#create_sir#3\"))},1},getfield(Main, Symbol(\"#create_flu#4\"))}(CombinedModel{Array{SpringModel{Array{Quantity{Float64,𝐓^-2,Unitful.FreeUnits{(d^-2,),𝐓^-2,nothing}},1},Tuple{Quantity{Int64,𝐓,Unitful.FreeUnits{(d,),𝐓,nothing}},Quantity{Float64,𝐓,Unitful.FreeUnits{(d,),𝐓,nothing}}},Array{Quantity{Float64,D,U} where U where D,1}},1},getfield(Main, Symbol(\"#create_sir#3\"))}[CombinedModel{Array{SpringModel{Array{Quantity{Float64,𝐓^-2,FreeUnits{(d^-2,),𝐓^-2,nothing}},1},Tuple{Quantity{Int64,𝐓,FreeUnits{(d,),𝐓,nothing}},Quantity{Float64,𝐓,FreeUnits{(d,),𝐓,nothing}}},Array{Quantity{Float64,D,U} where U where D,1}},1},#create_sir#3}(SpringModel{Array{Quantity{Float64,𝐓^-2,Unitful.FreeUnits{(d^-2,),𝐓^-2,nothing}},1},Tuple{Quantity{Int64,𝐓,Unitful.FreeUnits{(d,),𝐓,nothing}},Quantity{Float64,𝐓,Unitful.FreeUnits{(d,),𝐓,nothing}}},Array{Quantity{Float64,D,U} where U where D,1}}[SpringModel{Array{Quantity{Float64,𝐓^-2,FreeUnits{(d^-2,),𝐓^-2,nothing}},1},Tuple{Quantity{Int64,𝐓,FreeUnits{(d,),𝐓,nothing}},Quantity{Float64,𝐓,FreeUnits{(d,),𝐓,nothing}}},Array{Quantity{Float64,D,U} where U where D,1}}(Quantity{Float64,𝐓^-2,Unitful.FreeUnits{(d^-2,),𝐓^-2,nothing}}[0.000342466 d^-2], (0 d, 753.982 d), Quantity{Float64,D,U} where U where D[25.0 C, 0.0 C d^-1])], #create_sir#3())], getfield(Main, Symbol(\"#create_flu#4\"))())" |
|
|
|
] |
|
|
|
}, |
|
|
|
"execution_count": 5, |
|
|
|
"metadata": {}, |
|
|
|
"output_type": "execute_result" |
|
|
|
} |
|
|
|
], |
|
|
|
"source": [ |
|
|
|
"function flusim(tfinal)\n", |
|
|
|
" # annual cycle of temperature control flu infectiousness\n", |
|
|
|
" springmodel = SpringModel([u\"(1.0/(365*8))d^-2\"], # parameters (frequency)\n", |
|
|
|
" (u\"0d\",tfinal), # time domain\n", |
|
|
|
" [u\"25.0C\", u\"0C/d\"]) # initial_conditions T, T'\n", |
|
|
|
" function create_sir(m, solns)\n", |
|
|
|
" sol = solns[1]\n", |
|
|
|
" initialS = u\"10000person\"\n", |
|
|
|
" initialI = u\"1person\" \n", |
|
|
|
" initialpop = [initialS, initialI, u\"0.0person\"]\n", |
|
|
|
" β = u\"1.0/18\"/u\"d*C\" * sol(sol.t[end-2])[1] #infectiousness\n", |
|
|
|
" @show β\n", |
|
|
|
" sirprob = SIRSimulation(initialpop, #initial_conditions S,I,R\n", |
|
|
|
" (u\"0.0d\", u\"20d\"), #time domain\n", |
|
|
|
" SIRParams(β, u\"40.0person/d\")) # parameters β, γ\n", |
|
|
|
" return sirprob\n", |
|
|
|
" end\n", |
|
|
|
"\n", |
|
|
|
" function create_flu(cm, solns)\n", |
|
|
|
" sol = solns[1]\n", |
|
|
|
" finalI = stripunits(sol(u\"8.0d\")[2]) # X\n", |
|
|
|
" population = stripunits(sol(sol.t[end])[2])\n", |
|
|
|
" # population = stripunits(sum(sol.u[end]))\n", |
|
|
|
" df = SemanticModels.generate_synthetic_data(population, 0,100)\n", |
|
|
|
" f = @formula(vaccines_produced ~ flu_patients)\n", |
|
|
|
" model = lm(f,\n", |
|
|
|
" df[2:length(df.year),\n", |
|
|
|
" [:year, :flu_patients, :vaccines_produced]])\n", |
|
|
|
" println(\"GLM Model:\")\n", |
|
|
|
" println(model)\n", |
|
|
|
"\n", |
|
|
|
" year_to_predict = 1\n", |
|
|
|
" num_flu_patients_from_sim = finalI\n", |
|
|
|
" vaccines_produced = missing\n", |
|
|
|
" targetDF = DataFrame(year=year_to_predict,\n", |
|
|
|
" flu_patients=num_flu_patients_from_sim, \n", |
|
|
|
" vaccines_produced=missing)\n", |
|
|
|
" @show targetDF\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
" return RegressionProblem(f, model, targetDF, missing)\n", |
|
|
|
" end\n", |
|
|
|
" cm = CombinedModel([springmodel], create_sir)\n", |
|
|
|
" flumodel = CombinedModel([cm], create_flu)\n", |
|
|
|
" return flumodel\n", |
|
|
|
"end\n", |
|
|
|
"\n", |
|
|
|
"tfinal = 240π*u\"d\" #(~2 yrs)\n", |
|
|
|
"flumodel = flusim(tfinal)\n" |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
"cell_type": "code", |
|
|
|
"execution_count": 6, |
|
|
|
"metadata": {}, |
|
|
|
"outputs": [ |
|
|
|
{ |
|
|
|
"data": { |
|
|
|
"image/svg+xml": [ |
|
|
|
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n", |
|
|
|
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 2400 1600\">\n", |
|
|
|
"<defs>\n", |
|
|
|
" <clipPath id=\"clip9700\">\n", |
|
|
|
" <rect x=\"0\" y=\"0\" width=\"2000\" height=\"2000\"/>\n", |
|
|
|
" </clipPath>\n", |
|
|
|
"</defs>\n", |
|
|
|
"<defs>\n", |
|
|
|
" <clipPath id=\"clip9701\">\n", |
|
|
|
" <rect x=\"0\" y=\"0\" width=\"2400\" height=\"1600\"/>\n", |
|
|
|
" </clipPath>\n", |
|
|
|
"</defs>\n", |
|
|
|
"<polygon clip-path=\"url(#clip9701)\" points=\"\n", |
|
|
|
"0,1600 2400,1600 2400,0 0,0 \n", |
|
|
|
" \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n", |
|
|
|
"<defs>\n", |
|
|
|
" <clipPath id=\"clip9702\">\n", |
|
|
|
" <rect x=\"480\" y=\"0\" width=\"1681\" height=\"1600\"/>\n", |
|
|
|
" </clipPath>\n", |
|
|
|
"</defs>\n", |
|
|
|
"<polygon clip-path=\"url(#clip9701)\" points=\"\n", |
|
|
|
"176.123,1503.47 2321.26,1503.47 2321.26,47.2441 176.123,47.2441 \n", |
|
|
|
" \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n", |
|
|
|
"<defs>\n", |
|
|
|
" <clipPath id=\"clip9703\">\n", |
|
|
|
" <rect x=\"176\" y=\"47\" width=\"2146\" height=\"1457\"/>\n", |
|
|
|
" </clipPath>\n", |
|
|
|
"</defs>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9703)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 236.834,1503.47 236.834,47.2441 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9703)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 773.641,1503.47 773.641,47.2441 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9703)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 1310.45,1503.47 1310.45,47.2441 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9703)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 1847.25,1503.47 1847.25,47.2441 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9703)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 176.123,1333.66 2321.26,1333.66 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9703)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 176.123,1056.95 2321.26,1056.95 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9703)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 176.123,780.236 2321.26,780.236 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9703)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 176.123,503.525 2321.26,503.525 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9703)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 176.123,226.814 2321.26,226.814 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9701)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 176.123,1503.47 2321.26,1503.47 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9701)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 176.123,1503.47 176.123,47.2441 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9701)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 236.834,1503.47 236.834,1481.63 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9701)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 773.641,1503.47 773.641,1481.63 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9701)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 1310.45,1503.47 1310.45,1481.63 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9701)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 1847.25,1503.47 1847.25,1481.63 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9701)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 176.123,1333.66 208.3,1333.66 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9701)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 176.123,1056.95 208.3,1056.95 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9701)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 176.123,780.236 208.3,780.236 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9701)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 176.123,503.525 208.3,503.525 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9701)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 176.123,226.814 208.3,226.814 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<g clip-path=\"url(#clip9701)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 236.834, 1557.47)\" x=\"236.834\" y=\"1557.47\">0</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9701)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 773.641, 1557.47)\" x=\"773.641\" y=\"1557.47\">200</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9701)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1310.45, 1557.47)\" x=\"1310.45\" y=\"1557.47\">400</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9701)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1847.25, 1557.47)\" x=\"1847.25\" y=\"1557.47\">600</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9701)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 152.123, 1351.16)\" x=\"152.123\" y=\"1351.16\">-20</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9701)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 152.123, 1074.45)\" x=\"152.123\" y=\"1074.45\">-10</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9701)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 152.123, 797.736)\" x=\"152.123\" y=\"797.736\">0</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9701)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 152.123, 521.025)\" x=\"152.123\" y=\"521.025\">10</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9701)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 152.123, 244.314)\" x=\"152.123\" y=\"244.314\">20</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9703)\" style=\"stroke:#009af9; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 236.834,88.4582 237.148,88.4598 240.283,88.6537 266.677,103.051 328.128,221.037 416.15,553.155 516.443,1022.02 620.684,1388.97 749.289,1419.63 872.032,1006.26 \n", |
|
|
|
" 1018.94,345.213 1158.63,90.2708 1314.44,495.532 1471.5,1203.71 1628.17,1462.26 1793.71,958.911 1961.71,239.619 2129.05,166.646 2260.55,653.591 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polygon clip-path=\"url(#clip9701)\" points=\"\n", |
|
|
|
"1958.43,251.724 2249.26,251.724 2249.26,130.764 1958.43,130.764 \n", |
|
|
|
" \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9701)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 1958.43,251.724 2249.26,251.724 2249.26,130.764 1958.43,130.764 1958.43,251.724 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9701)\" style=\"stroke:#009af9; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 1982.43,191.244 2126.43,191.244 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<g clip-path=\"url(#clip9701)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:start;\" transform=\"rotate(0, 2150.43, 208.744)\" x=\"2150.43\" y=\"208.744\">y1</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"</svg>\n" |
|
|
|
] |
|
|
|
}, |
|
|
|
"execution_count": 6, |
|
|
|
"metadata": {}, |
|
|
|
"output_type": "execute_result" |
|
|
|
} |
|
|
|
], |
|
|
|
"source": [ |
|
|
|
"springmodel = flumodel.deps[1].deps[1]\n", |
|
|
|
"sirmodel = flumodel.deps[1]\n", |
|
|
|
"sol = solve(springmodel)\n", |
|
|
|
"plot(sol.t./d, map(x->x[1], sol.u) ./ C)" |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
"cell_type": "code", |
|
|
|
"execution_count": 7, |
|
|
|
"metadata": {}, |
|
|
|
"outputs": [ |
|
|
|
{ |
|
|
|
"name": "stdout", |
|
|
|
"output_type": "stream", |
|
|
|
"text": [ |
|
|
|
"β = 1.0854014119706108 d^-1\n" |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
"data": { |
|
|
|
"text/plain": [ |
|
|
|
"retcode: Success\n", |
|
|
|
"Interpolation: specialized 9th order lazy interpolation\n", |
|
|
|
"t: 16-element Array{Quantity{Float64,𝐓,Unitful.FreeUnits{(d,),𝐓,nothing}},1}:\n", |
|
|
|
" 0.0 d\n", |
|
|
|
" 0.2503747748877873 d\n", |
|
|
|
" 0.9420079061012359 d\n", |
|
|
|
" 1.9002912698756584 d\n", |
|
|
|
" 2.972126338526902 d\n", |
|
|
|
" 4.147568957524303 d\n", |
|
|
|
" 5.418240373678765 d\n", |
|
|
|
" 6.7948860959760315 d\n", |
|
|
|
" 8.400900825017708 d\n", |
|
|
|
" 10.236958450599571 d\n", |
|
|
|
" 12.30882380127413 d\n", |
|
|
|
" 13.728455901957311 d\n", |
|
|
|
" 15.710893594828972 d\n", |
|
|
|
" 17.26796601078083 d\n", |
|
|
|
" 19.522036174270298 d\n", |
|
|
|
" 20.0 d\n", |
|
|
|
"u: 16-element Array{Array{Quantity{Float64,NoDims,Unitful.FreeUnits{(person,),NoDims,nothing}},1},1}:\n", |
|
|
|
" [10000.0 person, 1.0 person, 0.0 person] \n", |
|
|
|
" [9999.69 person, 1.31091 person, 0.00115006 person]\n", |
|
|
|
" [9998.22 person, 2.76907 person, 0.0065442 person] \n", |
|
|
|
" [9993.17 person, 7.80133 person, 0.0251661 person] \n", |
|
|
|
" [9976.09 person, 24.8203 person, 0.0882149 person] \n", |
|
|
|
" [9912.76 person, 87.9172 person, 0.322914 person] \n", |
|
|
|
" [9661.17 person, 338.559 person, 1.27032 person] \n", |
|
|
|
" [8652.58 person, 1343.08 person, 5.33359 person] \n", |
|
|
|
" [5308.5 person, 4669.16 person, 23.338 person] \n", |
|
|
|
" [1351.18 person, 8576.06 person, 73.7647 person] \n", |
|
|
|
" [166.552 person, 9683.51 person, 150.933 person] \n", |
|
|
|
" [37.1606 person, 9757.62 person, 206.214 person] \n", |
|
|
|
" [4.57084 person, 9712.98 person, 283.447 person] \n", |
|
|
|
" [0.889612 person, 9656.35 person, 343.763 person] \n", |
|
|
|
" [0.0847902 person, 9570.48 person, 430.432 person] \n", |
|
|
|
" [0.0516352 person, 9552.24 person, 448.71 person] " |
|
|
|
] |
|
|
|
}, |
|
|
|
"execution_count": 7, |
|
|
|
"metadata": {}, |
|
|
|
"output_type": "execute_result" |
|
|
|
} |
|
|
|
], |
|
|
|
"source": [ |
|
|
|
"sirsol = solve(sirmodel)" |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
"cell_type": "code", |
|
|
|
"execution_count": 8, |
|
|
|
"metadata": {}, |
|
|
|
"outputs": [ |
|
|
|
{ |
|
|
|
"data": { |
|
|
|
"image/svg+xml": [ |
|
|
|
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n", |
|
|
|
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 2400 1600\">\n", |
|
|
|
"<defs>\n", |
|
|
|
" <clipPath id=\"clip9900\">\n", |
|
|
|
" <rect x=\"0\" y=\"0\" width=\"2000\" height=\"2000\"/>\n", |
|
|
|
" </clipPath>\n", |
|
|
|
"</defs>\n", |
|
|
|
"<defs>\n", |
|
|
|
" <clipPath id=\"clip9901\">\n", |
|
|
|
" <rect x=\"0\" y=\"0\" width=\"2400\" height=\"1600\"/>\n", |
|
|
|
" </clipPath>\n", |
|
|
|
"</defs>\n", |
|
|
|
"<polygon clip-path=\"url(#clip9901)\" points=\"\n", |
|
|
|
"0,1600 2400,1600 2400,0 0,0 \n", |
|
|
|
" \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n", |
|
|
|
"<defs>\n", |
|
|
|
" <clipPath id=\"clip9902\">\n", |
|
|
|
" <rect x=\"480\" y=\"0\" width=\"1681\" height=\"1600\"/>\n", |
|
|
|
" </clipPath>\n", |
|
|
|
"</defs>\n", |
|
|
|
"<polygon clip-path=\"url(#clip9901)\" points=\"\n", |
|
|
|
"228.3,1503.47 2321.26,1503.47 2321.26,47.2441 228.3,47.2441 \n", |
|
|
|
" \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n", |
|
|
|
"<defs>\n", |
|
|
|
" <clipPath id=\"clip9903\">\n", |
|
|
|
" <rect x=\"228\" y=\"47\" width=\"2094\" height=\"1457\"/>\n", |
|
|
|
" </clipPath>\n", |
|
|
|
"</defs>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9903)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 287.535,1503.47 287.535,47.2441 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9903)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 781.157,1503.47 781.157,47.2441 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9903)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 1274.78,1503.47 1274.78,47.2441 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9903)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 1768.4,1503.47 1768.4,47.2441 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9903)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 2262.03,1503.47 2262.03,47.2441 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9903)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 228.3,1462.4 2321.26,1462.4 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9903)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 228.3,1110.38 2321.26,1110.38 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9903)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 228.3,758.366 2321.26,758.366 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9903)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 228.3,406.348 2321.26,406.348 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9903)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n", |
|
|
|
" 228.3,54.33 2321.26,54.33 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9901)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 228.3,1503.47 2321.26,1503.47 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9901)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 228.3,1503.47 228.3,47.2441 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9901)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 287.535,1503.47 287.535,1481.63 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9901)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 781.157,1503.47 781.157,1481.63 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9901)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 1274.78,1503.47 1274.78,1481.63 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9901)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 1768.4,1503.47 1768.4,1481.63 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9901)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 2262.03,1503.47 2262.03,1481.63 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9901)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 228.3,1462.4 259.694,1462.4 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9901)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 228.3,1110.38 259.694,1110.38 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9901)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 228.3,758.366 259.694,758.366 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9901)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 228.3,406.348 259.694,406.348 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9901)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 228.3,54.33 259.694,54.33 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<g clip-path=\"url(#clip9901)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 287.535, 1557.47)\" x=\"287.535\" y=\"1557.47\">0</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9901)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 781.157, 1557.47)\" x=\"781.157\" y=\"1557.47\">5</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9901)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1274.78, 1557.47)\" x=\"1274.78\" y=\"1557.47\">10</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9901)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1768.4, 1557.47)\" x=\"1768.4\" y=\"1557.47\">15</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9901)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 2262.03, 1557.47)\" x=\"2262.03\" y=\"1557.47\">20</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9901)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 204.3, 1479.9)\" x=\"204.3\" y=\"1479.9\">0</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9901)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 204.3, 1127.88)\" x=\"204.3\" y=\"1127.88\">2500</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9901)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 204.3, 775.866)\" x=\"204.3\" y=\"775.866\">5000</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9901)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 204.3, 423.848)\" x=\"204.3\" y=\"423.848\">7500</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<g clip-path=\"url(#clip9901)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 204.3, 71.83)\" x=\"204.3\" y=\"71.83\">10000</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9903)\" style=\"stroke:#009af9; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 287.535,1462.26 312.253,1462.22 380.534,1462.01 475.14,1461.3 580.956,1458.91 697.001,1450.02 822.448,1414.73 958.357,1273.29 1116.91,804.95 1298.17,254.831 \n", |
|
|
|
" 1502.72,98.8934 1642.87,88.4582 1838.59,94.7442 1992.31,102.719 2214.84,114.809 2262.03,117.378 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polygon clip-path=\"url(#clip9901)\" points=\"\n", |
|
|
|
"1958.43,251.724 2249.26,251.724 2249.26,130.764 1958.43,130.764 \n", |
|
|
|
" \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9901)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 1958.43,251.724 2249.26,251.724 2249.26,130.764 1958.43,130.764 1958.43,251.724 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<polyline clip-path=\"url(#clip9901)\" style=\"stroke:#009af9; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n", |
|
|
|
" 1982.43,191.244 2126.43,191.244 \n", |
|
|
|
" \"/>\n", |
|
|
|
"<g clip-path=\"url(#clip9901)\">\n", |
|
|
|
"<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:start;\" transform=\"rotate(0, 2150.43, 208.744)\" x=\"2150.43\" y=\"208.744\">y1</text>\n", |
|
|
|
"</g>\n", |
|
|
|
"</svg>\n" |
|
|
|
] |
|
|
|
}, |
|
|
|
"execution_count": 8, |
|
|
|
"metadata": {}, |
|
|
|
"output_type": "execute_result" |
|
|
|
} |
|
|
|
], |
|
|
|
"source": [ |
|
|
|
"plot(sirsol.t./d,map(x->stripunits.(x)[2], sirsol.u))" |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
"cell_type": "code", |
|
|
|
"execution_count": 9, |
|
|
|
"metadata": {}, |
|
|
|
"outputs": [ |
|
|
|
{ |
|
|
|
"name": "stdout", |
|
|
|
"output_type": "stream", |
|
|
|
"text": [ |
|
|
|
"β = 1.0854014119706108 d^-1\n" |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
"name": "stderr", |
|
|
|
"output_type": "stream", |
|
|
|
"text": [ |
|
|
|
"┌ Warning: In the future eachcol will have names argument set to false by default\n", |
|
|
|
"│ caller = evalcontrasts(::DataFrame, ::Dict{Any,Any}) at modelframe.jl:124\n", |
|
|
|
"└ @ StatsModels /Users/jamesfairbanks/.julia/packages/StatsModels/AYB2E/src/modelframe.jl:124\n" |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
"name": "stdout", |
|
|
|
"output_type": "stream", |
|
|
|
"text": [ |
|
|
|
"GLM Model:\n", |
|
|
|
"StatsModels.DataFrameRegressionModel{LinearModel{LmResp{Array{Float64,1}},DensePredChol{Float64,LinearAlgebra.Cholesky{Float64,Array{Float64,2}}}},Array{Float64,2}}\n", |
|
|
|
"\n", |
|
|
|
"Formula: vaccines_produced ~ 1 + flu_patients\n", |
|
|
|
"\n", |
|
|
|
"Coefficients:\n", |
|
|
|
" Estimate Std.Error t value Pr(>|t|)\n", |
|
|
|
"(Intercept) 4892.06 342.292 14.2921 <1e-24\n", |
|
|
|
"flu_patients -0.00529781 0.0655031 -0.0808788 0.9357\n", |
|
|
|
"\n", |
|
|
|
"targetDF = 1×3 DataFrame\n", |
|
|
|
"│ Row │ year │ flu_patients │ vaccines_produced │\n", |
|
|
|
"│ │ Int64 │ Float64 │ Missing │\n", |
|
|
|
"├─────┼───────┼──────────────┼───────────────────┤\n", |
|
|
|
"│ 1 │ 1 │ 3627.46 │ missing │\n" |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
"name": "stderr", |
|
|
|
"output_type": "stream", |
|
|
|
"text": [ |
|
|
|
"┌ Warning: In the future eachcol will have names argument set to false by default\n", |
|
|
|
"│ caller = evalcontrasts(::DataFrame, ::Dict{Symbol,StatsModels.ContrastsMatrix}) at modelframe.jl:124\n", |
|
|
|
"└ @ StatsModels /Users/jamesfairbanks/.julia/packages/StatsModels/AYB2E/src/modelframe.jl:124\n" |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
"data": { |
|
|
|
"text/plain": [ |
|
|
|
"1-element Array{Union{Missing, Float64},1}:\n", |
|
|
|
" 4872.838053691122" |
|
|
|
] |
|
|
|
}, |
|
|
|
"execution_count": 9, |
|
|
|
"metadata": {}, |
|
|
|
"output_type": "execute_result" |
|
|
|
} |
|
|
|
], |
|
|
|
"source": [ |
|
|
|
"sol = solve(flumodel)" |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
"cell_type": "code", |
|
|
|
"execution_count": 10, |
|
|
|
"metadata": {}, |
|
|
|
"outputs": [ |
|
|
|
{ |
|
|
|
"ename": "ErrorException", |
|
|
|
"evalue": "type Array has no field u", |
|
|
|
"output_type": "error", |
|
|
|
"traceback": [ |
|
|
|
"type Array has no field u", |
|
|
|
"", |
|
|
|
"Stacktrace:", |
|
|
|
" [1] getproperty(::Any, ::Symbol) at ./sysimg.jl:18", |
|
|
|
" [2] top-level scope at In[10]:1" |
|
|
|
] |
|
|
|
} |
|
|
|
], |
|
|
|
"source": [ |
|
|
|
"print(typeof(sol.u))" |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
"cell_type": "code", |
|
|
|
"execution_count": null, |
|
|
|
"metadata": {}, |
|
|
|
"outputs": [], |
|
|
|
"source": [] |
|
|
|
} |
|
|
|
], |
|
|
|
"metadata": { |
|
|
|
"jupytext": { |
|
|
|
"formats": "ipynb,jl:light", |
|
|
|
"text_representation": { |
|
|
|
"extension": ".jl", |
|
|
|
"format_name": "light", |
|
|
|
"format_version": "1.3", |
|
|
|
"jupytext_version": "0.8.6" |
|
|
|
} |
|
|
|
}, |
|
|
|
"kernel_info": { |
|
|
|
"name": "julia-1.0" |
|
|
|
}, |
|
|
|
"kernelspec": { |
|
|
|
"display_name": "Julia 1.0.0", |
|
|
|
"language": "julia", |
|
|
|
"name": "julia-1.0" |
|
|
|
}, |
|
|
|
"language_info": { |
|
|
|
"file_extension": ".jl", |
|
|
|
"mimetype": "application/julia", |
|
|
|
"name": "julia", |
|
|
|
"version": "1.0.2" |
|
|
|
}, |
|
|
|
"nteract": { |
|
|
|
"version": "0.12.3" |
|
|
|
} |
|
|
|
}, |
|
|
|
"nbformat": 4, |
|
|
|
"nbformat_minor": 2 |
|
|
|
} |