Thank you all! This approach, using the 'polynom' library, did the trick.
library(polynom) # -6 + 11*x - 6*x^2 + x^3
p0 - polynomial(c(-6, 11, -6, 1)) # has zeros at 1, 2, and 3
p1 - deriv(p0); p2 - deriv(p1) # first and second derivative
xm - solve(p1) # maxima and minima of p0
xmax =
My script fits a third-order polynomial to my data with something like this:
model - lm( y ~ poly(x, 3) )
What I'd like to do is find the theoretical maximum of the polynomial (i.e. the
x at which model predicts the highest y). Specifically, I'd like to predict
the maximum between 0 = x = 1.
Hi all:I found some great demonstrations of interactive presentation graphics
generated in R with the SVGAnnotation package,
here:http://www.omegahat.org/SVGAnnotation/http://www.omegahat.org/SVGAnnotation/SVGAnnotationPaper/SVGAnnotationPaper.htmlI
tried to install the package available at
Date: Fri, 1 Mar 2013 10:21:02 -0800
From: mtmor...@fhcrc.org
likely you will be able to install with
install.packages(path/to/SVGAnnotation_0.93-1.tar.gz, repos=NULL,
type=source)
Thanks, I think you're on the right track but it still didn't work for me.
Perhaps there's something
I typically use the function plotCI from the plotrix package for confidence
intervals or error bars.The code would be: library(plotrix)plotCI( x=1:15,
y=fit, ui=upr, li=lwr)
// joseph w. clark , visiting research associate
\\ university of nebraska at omaha - school of IST
To:
the Confidence Interval curves around the fitted
values (fit)
but I got the following wrong message
while I tried plotCI?
Error in plotCI(x = 1:15, y = fit, ui
= upr, li = lwr) :
object 'upr' not found
From:
Joseph Clark joeclar...@hotmail.com
To:
Liang Che/US/TLS
error message:
Error in xy.coords(x, y, xlabel, ylabel,
log) :
'x' and 'y' lengths differ
In addition: Warning message:
In if (err == y) z -
y else z - x :
the condition has length
1 and only the first element will be used
From:
Joseph Clark joeclar...@hotmail.com
() or some other function for regression prediction
with 2 IVs
From: pda...@gmail.com
Date: Tue, 10 Jul 2012 08:46:42 +0200
CC: michael.weyla...@gmail.com; r-help@r-project.org
To: joeclar...@hotmail.com
On Jul 10, 2012, at 05:35 , Joseph Clark wrote:
Thanks. I was able to get what I
With base graphics, you could use par(mfrow) or par(mfcol) to define a simple
layout.
I don't know anything about heatmap.2, but I have used image() to make heatmaps
and have laid them out with par(mfrow).
Two ways to get a 2 row by 3 column layout, for example:
par(mfrow = c(3,2)) # 3
Hi there, I'm trying to prep some data for a persp() surface plot
representing the predictions from a regression with two inddependent
variables. The regression model m3 has an intercept, 2 linear terms,
and 2 squared terms. The coefficients are given by coef(m3).
My approach to
Thanks. I was able to get what I wanted by doing this:
predxn - function(s,d) { coef(m3)[1] + coef(m3)[2]*s + coef(m3)[3]*s^2 +
coef(m3)[4]*d + coef(m3)[5]*d^2 }
But it's not very elegant...
// joseph w. clark , phd candidate
\\ usc marshall school of business
the image function should do it, something like this: image( x, y,
outer(x,y,u), col=[some vector of colors] ) You can add a breaks parameter
but you need one more break than you have colors (include the start and end
point). Or just let it be automatic.I have used colorpanel() from the
u - function(x, y) x^0.5 + y^0.5
x - seq(0, 1000, by=1)
y - seq(0, 1000, by=1)
z - outer(x,y,u)
a - c(10, 20, 30)
image(x,y,z)
par(new=TRUE)
contour(x,y,z,levels=a,xaxs=i,yaxs=i)
You need xaxs=i,yaxs=i because image() and contour() treat the axes
differently by default.
In my opinion, the
These carpet plots are also called heat maps and there's a current thread
with the subject line Heat Maps in which I've given a couple of examples of
code for them. The R function image() is very easy to use:
image( x=(x values), y=(y values), z=(matrix of z values with x rows and y
14 matches
Mail list logo