Directions: You know the routine by now. Agenda: Fitting models by optimization; transforming data from
one representation to another; handling missing data
Many theories of the diffusion of innovations (new technologies, practices,
beliefs, etc.) suggest that the fraction of members of a group who have adoptedthe innovation by time t, p(t), should follow a logistic curve or logistic func-tion,
Today and in the homework, we will look at a classic data set on the diffusion
of innovations, which is supposed to show such a curve. It concerns a survey of246 doctors in four towns in Illinois in the early 1950s, and when they beganprescribing (adopted) a then-new antibiotic, tetracycline, and how they becameconvinced that they should do so (from medical journals, from colleagues, etc.).
is a doctor. The column adoption date shows how many months, after itbecame available, each doctor began prescribing tetracycline. Doctors who hadnot done so by the end of the survey, i.e., after month 17, have a value of Infin this column. This information is not available (NA) for some doctors. Thereare twelve other variables, others of which may also be NA
(a) (10) Write a function, logistic, which calculates the logistic func-
tion (Eq. It should take two arguments, t and theta. The thetaargument should be a vector of length two, the first component beingthe parameter b and the second component being t0. Your functionmay not use any loops. Plot the curve of the logistic function withb = 0.05, t0 = 3 from t = −30 to t = 30.
(b) (10) Explain why p(t0) = 0.5, no matter what b is. Use this to check
your logistic function at multiple combinations of b and t0.
1For some of the other 12 variables, and the context, see
or Coleman, Katz and Menzel, Medical Innovation: A Diffusion Study (1966).
(c) (10) Explain why the slope of p(t) at t = t0 is b/4. (Hint: calculus.)
Use this to check your logistic function at multiple combinationsof b and t0.
(a) (10) How many doctors in the survey had adopted tetracycline by
(b) (5) What proportion of doctors, for whom adoption dates are avail-
able, had adopted tetracycline by month 5?
(c) (10) Create a vector, prop adopters, storing the proportion of doc-
tors who have adopted by each month. (Be careful about Inf andNA.)
(d) (5) Make a scatter-plot of the proportion of adopters over time .
(e) (10) Make rough guesses about t0 and b from the plot, and from your
(a) (10) Write a function, logistic mse, which calculates the mean
squared error of the logistic model on this data set. It should takea single vector, theta, and return a single number. This functioncannot contain any loops, and must use your logistic function.
(b) (10) Use optim to minimize logistic mse, starting from your rough
guess in problem Report the location and value of the optimumto reasonable precision. (By default, R prints to very unreasonableprecision.)
(c) (10) Add a curve of the fitted logistic function to your scatterplot
from Problem Does it seem like a reasonable match?
Massachusetts Department of Public Health Emergency Preparedness Bureau May 6, 2009 Situation Report: Massachusetts Swine Flu Response Situation Report: Massachusetts Swine Flu Response Massachusetts : 45 confirmed cases as of May 6, 2009 at 1100 hrs **Please see the end of this report for a detailed listing of confirmed cases New England : 54 confirmed case