Dear Wiz[R]ds, I am deeply grateful for the help from Duncan Murdoch, Gray Calhoun, and others. We are almost there. For whatever reason, I can't change the symbol from a circle to a triangle in the upright posture plots. Any ideas? I have included the problem in full.
# tritiated (3H)-Norepinephrine(NE) disappearance from plasma # concentrations supine and upright # supine datasu <- data.frame( time=c(0,1,2,4,6,8,10,15,20), concsu=c(385.61,265.88,173.87,99.47,66.7,55.27,48.29,39.85,40.66) ) # upright dataup <- data.frame( time=c(0,1,2,4,6,8,10,15,20), concup=c(767.27,529.03,328.13,225.94,164,151.1,132.02,121.15,70.88) ) # fit supine wt.su<- function(resp, time,A1,a1,A2,a2) { pred <- A1*exp(-a1*time)+A2*exp(-a2*time) (resp - pred) / sqrt(pred) } fit.wt.su <- nls( ~ wt.su(concsu, time,A1,a1,A2,a2), data=datasu, start=list(A1=500,a1=1,A2=100,a2=0.2), trace = TRUE) summary(fit.wt.su) # fit upright wt.up<- function(resp, time,B1,b1,B2,b2) { pred <- B1*exp(-b1*time)+B2*exp(-b2*time) (resp - pred) / sqrt(pred) } fit.wt.up <- nls( ~ wt.up(concup, time,B1,b1,B2,b2), data=dataup, start=list(B1=500,b1=1,B2=100,b2=0.1), trace = TRUE) summary(fit.wt.up) # Function that returns predicted values and graphics # by Duncan Murdoch predictionssu <- function(fit, time) { params <- summary(fit)$coefficients[, 1] A1 <- params["A1"] a1 <- params["a1"] A2 <- params["A2"] a2 <- params["a2"] A1*exp(-a1*time)+A2*exp(-a2*time) } predictionsup <- function(fit, time) { params <- summary(fit)$coefficients[, 1] B1 <- params["B1"] b1 <- params["b1"] B2 <- params["B2"] b2 <- params["b2"] B1*exp(-b1*time)+B2*exp(-b2*time) } # plot observed and predicted values supine and upright in # each plot type (linear and smi-log) # Need upright in same plots (e.g., dashed line) par(cex.lab=1.2,cex.axis=1.3) par(mfrow=c(2,1)) plot(c(datasu$concsu, dataup$concup) ~ c(datasu$time, dataup$time), xlab = "Time (minutes)", ylab = "3H-NE (dpm/ml)", main="3H-NE Post-infusion Plasma Disappearance Curves", ylim=c(0,1000),cex=1.25, pch=16,col=1) lines(times, predictionssu(fit.wt.su, times)) lines(times, predictionsup(fit.wt.up, times), lty = "dashed") plot(c(datasu$concsu, dataup$concup) ~ c(datasu$time, dataup$time), xlab = "Time (minutes)", ylab = "3H-NE (dpm/ml)", log = "y", ylim=c(1,1000),cex=1.25, pch=16,col=1) lines(times, predictionssu(fit.wt.su, times)) lines(times, predictionsup(fit.wt.up, times), lty = "dashed") Deeply grateful in advance... -- Oscar Oscar A. Linares, MD Translational Medicine Unit LaPlaisance Bay, Bolles Harbor Monroe, Michigan 48161 Department of Medicine, University of Toledo College of Medicine Toledo, OH 43606-3390 Department of Internal Medicine, The Detroit Medical Center (DMC) Harper University Hospital Wayne State University School of Medicine Detroit, Michigan 48201 [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.