Soo-Wee!

May 3, 2009 at 2:57 pm

| Gabriel |

In the face of the swine flu France has suggested suspending all EU flights to Mexico and you likewise occasionally hear calls for the US to temporarily close the border as a public health measure. Of course France has nothing close to the levels of social and economic integration with Mexico that we do so it’s a little easier for them to consider this than it would be for us. President Obama was asked about closing the border and said it would be “akin to closing the barn door after the horses are out, because we already have cases here in the United States.” Instead the US government has emphasized measures to curtail the domestic transmission of this disease through things like public transportation, schools, etc.

Having a completely one-track mind, I heard all this and thought it’s all about diffusion from without vs within a bounded population, I know this! Assume for the sake of argument that (absent action by American authorities) Mexico has a constant impact on the hazard rate of infection for Americans. This can either be because Mexico has a stable number of infections or, more realistically, because an increasing number of infections in Mexico are offset by a completely voluntary reduction in border traffic. We can thus treat Mexico as an exogenous influence. Of course Americans infecting each other is an endogenous influence. Now assume that there are two public health measures available, close the border and reduce the (domestic) transmission rate. The latter would involve things like face masks, encouraging sick people to stay home, closing schools that have an infection, etc. Further imagine that each measure would respectively cut the effect of exogenous and endogenous diffusion in half. What is the projected trajectory of the disease under various scenarios?

I’ve plotted some projections below, but first a few caveats:

  • For simplicity, I’ve assumed a linear baseline hazard rather than the more realistic Gompertz hazard. The projection is basically robust to this.
  • I’m assuming “no exit,” i.e. once infected, people remain contagious rather than getting better, being quarantined, or dying. This assumption is realistic over the short-run but absurd over the medium- to long-run.
  • I’m assuming that at this point 1% of the potential American risk pool is already infected. I also tried it with 5% and it works out the same.
  • Most importantly of all, I know nothing at all about the substantive issues of infectious disease, the efficacy of public health measures, and all of that sort of thing. Both the baseline numbers and the projected impacts of the public health measures are totally made up, and not even on made up an informed basis. I’m more interested in the math (which I know) than plausible assumptions to feed into it (which I don’t know).

Anyway, here are the projected number of infections, which again assume that public health measures suppress the relevant disease vector by 50%.

hypotheticals

As can be seen, in the very short run closing the border is more effective but in the medium-run, measures to reduce domestic transmission are more effective. This is just efficacy, not efficiency (i.e., cost-benefit).

The code is below the fold.

cd ~/Desktop/soowee
global images “~/Desktop/soowee”
shell cd “~/Desktop/soowee/”
shell rm *.pdf
shell rm *.dta
shell rm *.png
ssc install graphexportpdf, replace
capture program drop nospaces
program define nospaces
set more off
local x=lower(“`1′”)
local char “”
local char “`2′”
local nspaces=wordcount(“`x'”)-1
forvalues ns=1/`nspaces’ {
quietly disp regexm(“`x'”,”(.+) (.+)”)
local x=regexs(1)+”`char'”+regexs(2)
}
quietly disp “`x'”
global x = “`x'”
end
capture program drop bassproject
program define bassproject
set more off
syntax anything(name=commandinput) [, graphoff nosave axes]
disp “`commandinput'”
local match=regexm(“`commandinput'”,”a ?\(([^\)]+)\) ?”)
if `match’==1 {
local a=regexs(1)
}
else {
local a=0
}
local match=regexm(“`commandinput'”,”b ?\(([0-9]*\.?[0-9]*)\) ?”)
if `match’==1 {
local b=regexs(1)
}
else {
local b=0
}
local match=regexm(“`commandinput'”,”[nN]?max ?\(([0-9]*\.?[0-9]*)\) ?”)
if `match’==1 {
local nmax=regexs(1)
}
else {
local nmax=1
}
local match=regexm(“`commandinput'”,”seed ?\(([0-9]*\.?[0-9]*)\) ?”)
if `match’==1 {
local seed=regexs(1)
}
else {
local seed=0.01
}
local match=regexm(“`commandinput'”,”periods ?\(([0-9]*\.?[0-9]*)\) ?”)
if `match’==1 {
local periods=regexs(1)
}
else {
local periods=20
}
local match=regexm(“`commandinput'”,”modeln?a?m?e? ?\(([^\)]+)\)”)
if `match’==1 {
local modelname=regexs(1)
}
else {
local model=”model”
}
disp “model named(`modelname’).”
disp “delta_Nt=(`a’ + `b’ * Nt) * (`nmax’ – Nt)”
disp “projected over `periods’ spells with N_0=`seed'”
preserve
clear
set obs `periods’
quietly gen t=[_n]-1
quietly gen Nt=.
quietly gen deltan=.
quietly replace Nt=`seed’ in 1
quietly replace deltan=(`a’ + (`b’ * Nt)) * (`nmax’ – Nt) in 1
forvalues period=2/`periods’ {
quietly replace Nt=Nt[_n-1]+deltan[_n-1] in `period’
quietly replace deltan=(`a’ + (`b’ * Nt)) * (`nmax’ – Nt) in `period’
}
sort t
ren Nt nt_`modelname’
drop deltan
if “`nosave'”~=”nosave” {
save projection_`modelname’, replace
}
*add “axes” option
if “`graphoff'”~=”graphoff” {
if “`axes'”~=”axes” {
twoway (line nt_`modelname’ t), ytitle(Adoptions to Date) ylabel(none, nolabels) xtitle(Time) xlabel(none, nolabels)
graphexportpdf projection_`modelname’, dropeps
shell mv “projection_`modelname’.pdf” “$images”
}
if “`axes'”==”axes” {
twoway (line nt_`modelname’ t), ytitle(Adoptions to Date) ylabel(none, nolabels) xtitle(Time) xlabel(none, nolabels)
graphexportpdf projection_`modelname’, dropeps
shell mv “projection_`modelname’.pdf” “$images”
}
}
clear
restore
end
bassproject modelname(donothing) a(.04) b(.3) nmax(1) seed(.01)
bassproject modelname(reducedcontagion) a(.04) b(.15) nmax(1) seed(.01)
bassproject modelname(closeborder) a(.02) b(.3) nmax(1) seed(.01)
bassproject modelname(doboth) a(.02) b(.15) nmax(1) seed(.01)
clear
use projection_donothing
foreach file in reducedcontagion closeborder doboth {
append using projection_`file’
}
lab var nt_donothing “Do nothing”
lab var nt_reducedcontagion “Reduce Transmission Rate”
lab var nt_closeborder “Close the Border”
lab var nt_doboth “Reduce Transmission + Close the Border”
twoway (line nt_donothing t) (line nt_reducedcontagion t) (line nt_closeborder t) (line nt_doboth t), xtitle(Time) ytitle(Cumulative Infections)
graph export hypotheticals.png, replace
*have a nice day
cd ~/Desktop/soowee
global images "~/Desktop/soowee"

shell cd "~/Desktop/soowee/"
shell rm *.pdf
shell rm *.dta
shell rm *.png

ssc install graphexportpdf, replace

capture program drop nospaces
program define nospaces
	set more off
	local x=lower("`1'")
	local char ""
	local char "`2'"
	local nspaces=wordcount("`x'")-1
	forvalues ns=1/`nspaces' {
		quietly disp regexm("`x'","(.+) (.+)")
		local x=regexs(1)+"`char'"+regexs(2)
	}
	quietly disp "`x'"
	global x = "`x'"
end

capture program drop bassproject
program define bassproject
	set more off
	syntax anything(name=commandinput) [, graphoff nosave axes]
	disp "`commandinput'"
	local match=regexm("`commandinput'","a ?\(([^\)]+)\) ?")
	if `match'==1 {
		local a=regexs(1)
	}
	else {
		local a=0
	}
	local match=regexm("`commandinput'","b ?\(([0-9]*\.?[0-9]*)\) ?")
	if `match'==1 {
		local b=regexs(1)
	}
	else {
		local b=0
	}
	local match=regexm("`commandinput'","[nN]?max ?\(([0-9]*\.?[0-9]*)\) ?")
	if `match'==1 {
		local nmax=regexs(1)
	}
	else {
		local nmax=1
	}
	local match=regexm("`commandinput'","seed ?\(([0-9]*\.?[0-9]*)\) ?")
	if `match'==1 {
		local seed=regexs(1)
	}
	else {
		local seed=0.01
	}
	local match=regexm("`commandinput'","periods ?\(([0-9]*\.?[0-9]*)\) ?")
	if `match'==1 {
		local periods=regexs(1)
 	}
	else {
		local periods=20
	}
	local match=regexm("`commandinput'","modeln?a?m?e? ?\(([^\)]+)\)")
	if `match'==1 {
		local modelname=regexs(1)
	}
	else {
		local model="model"
	}
	disp "model named(`modelname')."
	disp "delta_Nt=(`a' + `b' * Nt) * (`nmax' - Nt)"
	disp "projected over `periods' spells with N_0=`seed'"
	preserve
	clear
	set obs `periods'
	quietly gen t=[_n]-1
	quietly gen Nt=.
	quietly gen deltan=.
	quietly replace Nt=`seed' in 1
	quietly replace deltan=(`a' + (`b' * Nt)) * (`nmax' - Nt) in 1
	forvalues period=2/`periods' {
		quietly replace Nt=Nt[_n-1]+deltan[_n-1] in `period'
		quietly replace deltan=(`a' + (`b' * Nt)) * (`nmax' - Nt) in `period'
	}
	sort t
	ren Nt nt_`modelname'
	drop deltan
	if "`nosave'"~="nosave" {
		save projection_`modelname', replace
	}
	*add "axes" option
	if "`graphoff'"~="graphoff" {
		if "`axes'"~="axes" {
			twoway (line nt_`modelname' t), ytitle(Adoptions to Date) ylabel(none, nolabels) xtitle(Time) xlabel(none, nolabels)
			graphexportpdf projection_`modelname', dropeps
			shell mv "projection_`modelname'.pdf" "$images"
		}
		if "`axes'"=="axes" {
			twoway (line nt_`modelname' t), ytitle(Adoptions to Date) ylabel(none, nolabels) xtitle(Time) xlabel(none, nolabels)
			graphexportpdf projection_`modelname', dropeps
			shell mv "projection_`modelname'.pdf" "$images"
		}
	}
	clear
	restore
end

bassproject modelname(donothing) a(.04) b(.3) nmax(1) seed(.01)
bassproject modelname(reducedcontagion) a(.04) b(.15) nmax(1) seed(.01)
bassproject modelname(closeborder) a(.02) b(.3) nmax(1) seed(.01)
bassproject modelname(doboth) a(.02) b(.15) nmax(1) seed(.01)  

clear
use projection_donothing
foreach file in reducedcontagion closeborder doboth {
	append using projection_`file'
}

lab var nt_donothing "Do nothing"
lab var nt_reducedcontagion "Reduce Transmission Rate"
lab var nt_closeborder "Close the Border"
lab var nt_doboth "Reduce Transmission + Close the Border"
twoway (line nt_donothing t) (line nt_reducedcontagion t) (line nt_closeborder t) (line nt_doboth t), xtitle(Time) ytitle(Cumulative Infections)

graph export hypotheticals.png, replace

*have a nice day

Entry filed under: Uncategorized. Tags: , .

A threshold model for gay marriage Strip the spaces from a string


The Culture Geeks


%d bloggers like this: