function(alpha.level = 1, iota = 0.001, kappa = 0.01, theta = 1.28, start.change = 9, stop.change = 10, location = 8) { #Program uganda.fit() # #iota = 0.001 #kappa = 0.01 #theta = 1.28 # iota <- x[1] # kappa <- x[2] # theta <- x[3] # start.change <- 9 # stop.change <- 10 # location <- 8 # # # #Program for fitting model to Uganda prevalence data by varying # #iota, kappa and theta paramters. input.routine.1() will be run # #first to set up most objects. This program will overwrite iota.f # #iota.m, kappa.f, kappa.m, theta.f and theta.m and then run # #project() followed by compute.prevalence() to display graph of # #observed and fitted values. # # #overwrite alpha with alpha * alpha.level; this raises hiv mortality # #and may enable more reasonable parameter values to give best fit. # #Restore original value at end of program to keep it from being mad # #successively lower in further runs of this program. # alpha <<- alpha.level * array(data = get.alpha( )[1:aa, 1:dd], dim = dim(alpha)) # # #overwrite iota, kappa and theta arrays using argument values # iota.f <<- array(data = iota * phi.f, dim = dim( iota.f)) # iota.m <<- array(data = iota * phi.m, dim = dim( iota.m)) # # kappa.f <<- kappa * phi.f # kappa.m <<- kappa * phi.m # # level.f <- compute.theta.time.trend( initial.level = theta, start.change, stop.change) # level.m <- compute.theta.time.trend( initial.level = theta, start.change, stop.change) # # theta.f <<- phi.f %o% level.f # theta.m <<- phi.m %o% level.m # # # #run project() ) # project() # # # #compute prevalence (see code for compute.prevalence()) # num <- apply(zf + zm, c(1, 3), sum) # den <- xf + xm + yf + num # sex <- "Both sexes" # prev <- apply(num[16:50, ], 2, sum)/apply(den[ 16:50, ], 2, sum) # # # #plot model prevalence # times <- 0:(tt - 1) # par(pch = 1) # plot(times, 100 * prev, xlab = "Time", ylab = paste(sex, "prevalence (%)"), ylim = c( 0, 35)) # # # #Plot observed prevalence, values for 1985-1998 from anoymous unlinked # #surveillance of pregnant women. Location allows for changing the year # #in which the epidemic begins. # obs.p <- c(10.7, 13.5, 24, 23.5, 24.5, 25, 27.82, 29.5, 24.4, 19.2, 18.5, 15.3, 14.65, 13.8) # times <- location:(location + length(obs.p) - 1 ) # names(obs.p) <- times # fit.p <- 100 * prev[times + 1] # par(pch = 18) # points(times, obs.p) # # write.ascii(uganda.fit) list(obs.p = obs.p, fit.p = fit.p) sum((obs.p - fit.p)^2) }