diff options
| author | Ben Green <bgreen@g.harvard.edu> | 2015-09-09 20:27:12 -0400 |
|---|---|---|
| committer | Ben Green <bgreen@g.harvard.edu> | 2015-09-09 20:27:15 -0400 |
| commit | 717e7f2edda52100406d17826bd617b7915c5daf (patch) | |
| tree | a3501a0132e2d9024d8a0eb5afe0771311404b34 /R Scripts/fit-background.R | |
| parent | 26c65bfeeb22a46e6b688ea3765b9a6e0479f748 (diff) | |
| download | criminal_cascades-717e7f2edda52100406d17826bd617b7915c5daf.tar.gz | |
updated R scripts
Diffstat (limited to 'R Scripts/fit-background.R')
| -rw-r--r-- | R Scripts/fit-background.R | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/R Scripts/fit-background.R b/R Scripts/fit-background.R index d385e7f..d1799cd 100644 --- a/R Scripts/fit-background.R +++ b/R Scripts/fit-background.R @@ -17,16 +17,16 @@ counts = as.vector(t) infs = data.frame(days,counts) # define background function -fit = function(x, mu, A, phi) {mu + A*(sin((pi/365)*x+phi))^2} -fit_form = counts ~ mu + A*(sin((pi/365)*days+phi))^2 +fit = function(x, lambda, A, phi) {lambda + A*(sin((pi/365)*x+phi))^2} +fit_form = counts ~ lambda + A*(sin((pi/365)*days+phi))^2 # explore data plot(days,counts) -curve(fit(x, mu=1, A=12, phi=2.8), add=TRUE ,lwd=2, col="steelblue") +curve(fit(x, lambda=1, A=12, phi=2.8), add=TRUE ,lwd=2, col="steelblue") -res = nls(formula=fit_form, data=infs, start=list(mu=1, A=12, phi=2.8)) +res = nls(formula=fit_form, data=infs, start=list(lambda=1, A=12, phi=2.8)) co = coef(res); co plot(t) plot(days,counts,pch=20,cex=0.4,xlab='Day',ylab='Number of Infections') -curve(fit(x, mu=co["mu"], A=co["A"], phi=co["phi"]), add=TRUE ,lwd=5, col="steelblue") +curve(fit(x, lambda=co["lambda"], A=co["A"], phi=co["phi"]), add=TRUE ,lwd=5, col="steelblue") |
