Here is one way of getting a reasonable fit:
1. Scale your y's by dividing all values by 1e6.
2. Plot x vs. y. The plot looks like a quadratic function.
3. Fit a quadratic const. + B*x^2 - this a linear regression problem so
use lm.
4. Plot the predictions.
5. Eyball the necessary shift - MA
As Duncan Murdoch mentioned in his reply, the problem is with the fact that
your function is not really a properly defined function in the sense of
"assigning a unique y to each x". The integrate function uses an adaptive
quadrature routine which probably makes multiple calls to the function
being
Walter,
Here is what I do in similar situations. I am on WinXP but this should be
similar on other systems (I hope).
1. I start R with the new .RData workspace (usually by double-clicking on
it).
2. I go to File < Change Dir menu item.
3. I change the directory to where the old .RData is.
4.
Walter,
There is a betareg package in CRAN.
Cheers,
Andy
__
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Research Laboratory
-
E-mail: [EMAIL PROTECTED]
Tel: (651) 733-6092
Fax: (651) 736-3122
Paul,
I think the problem is the starting point. I do not remember the details
of the BFGS method, but I am almost sure the (.5, .5) starting point is
suspect, since the abs function is not differentiable at 0. If you perturb
the starting point even slightly you will have no problem.
Andy
Similar thing here. Happens in 2.5.0 patched and 2.6.0 (both
April-25-2007) and svIDE 0.9-5
The only difference is that the warnings are:
1: '\A' is an unrecognized escape in a character string
2: unrecognized escape removed from ";for Options\AutoIndent: 0=Off,
1=follow language scoping and 2=co
How about
qr(A)$rank
or perhaps
qr(A, LAPACK=TRUE)$rank
Cheers,
Andy
__
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Research Laboratory
-
E-mail: [EMAIL PROTECTED]
Tel: (651) 733-6092
Fax: (651) 736-3122
Dimitri,
I am assuming you mean integer linear optimization problem. Try lpSolve.
I think you will find it much easier to use.
Cheers,
Andy
__
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Research Laboratory
-
E-mail: [EMAIL PROTECTED]
Tel: (651)
Hi,
I have a problem of estimating a mixture of two normal distributions. I
need to find the starting points automatically, since this is a part of a
larger piece of image processing code.
I found the mix2normal1 function in VGAM package that mentions a method of
finding starting values for mu1
Rob,
Try
a[a>5]<-0
Yup. It works for matrices (and for arrays). It also works with the
replacement value being a vector. For example, try
b <- array(1:24, dim=c(3, 4, 2))
b[(b>8) & (b<17)] <- 101:108
I think the reason it works like this is that internally array are stored
as vectors.
Chee
This is interesting. I am on Win2000 running R version 2.4.0 Patched
(2006-11-15 r39915) and plotrix 2.1.5. I get the plot that scaled a little
differently that the 2.3.1 example but the dates look fine. I ran the
original code posted by John cane with no changes (copy and paste). I used
the wi
Lalitha,
Try something like
with(data, table(cut(age, n), member_FLAG))
where data is a data frame with columns named age and member_FLAG and n is
the number of age categories (bins) you want. This will give you the
number of Ys and Ns in each bin, that you will need to convert to
percentages.
I just tried the Packages>Install package(s).. menu item on my fresh
R-2.4.0-patched and rgdal just shows up on the list of packages to install,
so I am not sure what the problem is. Alternatively, you can download the
Windows *.zip file from any CRAN repository and install it from your hard
driv
I am guessing you are starting Rcmdr using
> library(Rcmdr).
If this is the case, repeating the library command does nothing, since
Rcmdr package is already attached. Try
> Commander()
instead. Make sure you use capital C.
Cheers,
Andy
__
Andy Jaworski
518-1
I am sure there are several ways of doing this but how about something like
this:
y <- c(NA,NA,10,NA,2,NA,NA,1,NA,NA)
x <- c(10,20,30,40,50,60,70,80,85,100)
tail(x[!is.na(y)], 1)
or
rev(x[!is.na(y)])[1]
Rudimentary checks indicate that the second expression is much faster than
the first. Also
It looks like there might be a bug in the symmetry detection routine of
eigen. When I do
eigen(M, symmetric=FALSE)
it works fine. Eigenvalues (after omitting their imaginary parts, which
are essentially zeros) are the same as the ones obtained with EISPACK to
within a small multiple of machine
Check out the mvtnorm package.
Cheers,
Andy
__
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Research Laboratory
-
E-mail: [EMAIL PROTECTED]
Tel: (651) 733-6092
Fax: (651) 736-3122
Mark,
The parameter of your model (gamma) should not be a part of the dataframe.
In addition, the start argument should be a named list.
Something like this works
nls.dataframe <- data.frame(p.kum,felt.prob.kum)
nls.kurve <- nls( formula = felt.prob.kum ~
p.kum^gamma/(p.kum^gamma+(1-p.kum)^gamma
There may be a simpler way, but this
is.na(match("X", names(df)))
should return TRUE if the column name exists and FALSE otherwise.
Cheers,
Andy
__
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Research Laboratory
-
E-mail: [EMAIL PROTECTED]
Te
Matt,
There is nothing wrong here. I rerun your example and got the same
parameters. Your only "problem" is that you let the density plot use the
default limits on x, which are not reasonable here since your data extends
to over 200. Try this:
hist(dd, freq=FALSE) #dd is your original da
Thanks for the quick response and apologies for my sloppy post (nor
mentioning the device) and sloppy example (the use of date()).
Indeed, I was using the windows device. There is no timing problem with
the postscript device.
I just installed the R-devel May-9 and the problem went away. He
A couple of days ago a few messages indicated that something changed in the
basic plot routine that made plot(*, type='l') slow for large data sets.
Some people even reported crashes for very large data sets. As far as I
remember, this was not reported as a formal bug.
I am still not sure if
I have one comment, although it is a little off topic.
I have the gregmisc package installed (R-2.0.1 on Win2000). Whenever I use
the help.search function it comes back with the following warning:
Warning message:
no Rd contents for package 'gregmisc' in 'C:/local/R/rw210/library' in:
help.
Anna,
It looks like the mshapiro.test wants its data in the row format, that is,
for a k-variate sample of size n you need the data in a k-by-n matrix.
Try
a <- t(mvrnorm(1000, c(1,2,3,4,5), diag(5)))
mshapiro.test(a)
and it should work fine.
Cheers,
Andy
___
There is a halfnorm function in the faraway package.
Andy
__
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Research Laboratory
-
E-mail: [EMAIL PROTECTED]
Tel: (651) 733-6092
Fax: (651) 736-3122
I am not sure about the scaling, but doing simply
matplot(xa, t(dfr), type="b")
does most of what you want.
Andy
__
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Research Laboratory
-
E-mail: [EMAIL PROTECTED]
Tel: (651) 733-6092
Fax: (651) 7
Bert,
This works fine and and seems a little simpler:
x<-seq(-3,to=3,by=.01)
y<-dnorm(x)
plot(x,y,type='h',col='lightblue',axes=FALSE)
lines(x,y,col='darkblue')
axis(2)
ll <- expression(mu-3*sigma, mu-2*sigma, mu-sigma, mu, mu+sigma,
mu+2*sigma, mu+3*sigma)
axis(1, at=-3:3, lab=ll)
box()
Could somebody please tell me what does the r-help-bounce address do?
When I try to respond to an r-help post, my mailer (Lotus Notes) generates
the r-help bounce return address automatically in addition to the original
sender address and the r-help address. I responded to an r-help message
The outer two lines could also be done more easily (?) by:
library(gplots) #part of gregmisc bundle
textplot(txt)
Check ?textplot for additional options.
Andy
__
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Research Laboratory
-
E-mail: [EMAIL
Muhammad,
Try
tapply(prevRND.dat$Z, list(X=prevRND.dat$X, Y=prevRND.dat$Y), mean)
Cheers,
Andy
__
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Research Laboratory
-
E-mail: [EMAIL PROTECTED]
Tel: (651) 733-6092
Fax: (651) 736-3122
The newest "production" release of Fedora is Core 3. I would use this one
if I were you.
Andy
__
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Research Laboratory
-
E-mail: [EMAIL PROTECTED]
Tel: (651) 733-6092
Fax: (651) 736-3122
If your "non-linear function (A, B)" is parametric nls should do it for
you. If you have R version 2 (perhaps even 1.9) do ?nls to see the help
page. Older versions of R require library(nls) first.
Hope this helps,
Andy
__
Andy Jaworski
518-1-01
Process Lab
Dave,
I think inside the loop you have to explicitly "print" a trellis object,
i.e. say
print(yplot(tmp.df$y.tmp ~ tmp.df[,i]))
If you read the help page for xyplot, look under "Value".
Hope this helps,
Andy
__
Andy Jaworski
518-1-01
Process Laboratory
3M
Ajay,
I beleve there is an error in your hand-calculated derivatives.
model = function(beta1, beta2, beta3, time) {
m = beta1/(1+exp(beta2+beta3*time))
term = exp(beta2 + beta3*time)
gradient = cbind((1+term)^-2, < the exponent should be -1
-beta1*(1+term)^-2 * term,
Gideon,
Eigenvectors are normalized to unit length. The first eigenvector
calculated by R is equal (ignoring the signs of course) to your stable
distribution vector divided by its length.
Andy
__
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Researc
First of all thanks to Peter Dalgaard, Thomas Lumley and Prof Brian Ripley
for quick responses.
Indeed, I will be running Windows2000 on this machine (my company's
standard). I will also install the full version of cygwin on it.
When I asked my original question I thought about just copying
I am about to get a new machine at work - an IBM Intellistation with the
Xeon 2.8 GB processor. It will run Windows 2000. I would like to install
the proper ATLAS dll for this machine, but I am not sure if Xeon is P4?
Does anybody have any experience with Xeon?
Thanks in advance,
Andy
Check out the uniroot function. It will solve a single equation.
There is also a packge RMinpack. It implements the original Fortran
Minpack library and will solve systems of nonlinear equations. It is only
available in source form (search Google for it).
Andy
___
I am trying to test whether I can post to the list. I responded to a
couple of messages recently and I have not seen my response posted.
__
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Research Laboratory
-
E-mail: [EMAIL PROTECTED]
Tel: (651) 73
A new package named qcc just appeared on CRAN. It has standard QC charts,
OC curves and process capability stuff. It even has a Minitab-like process
capability sixpack. It looks like it is pretty nicely done.
Andy
__
Andy Jaworski
518-1-01
Process Laborator
Peter,
These things can be a little mysterious at the beginning. Lots of things
in R are arranged in groups called packages (or libraries). Some basic
ones come preinstalled with R, some you have to install yourself. If you
type
library()
at your R prompt you should get a list of all p
In general there will be no closed form solution. In fact, for a general
curve in N dimensions one can have multiple discrete solutions or even a
continuum of solutions. A trivial example of this is a problem of finding
a point on a circle in 2D closest to its center.
A curve in N dimensions ca
Thanks very much for your response and the earlier one by Professor Ripley.
The general problem is indeed a tricky one.
My particular problem was much simpler. I had a bunch of data from a data
acquisition system with sampling interval of 1 minute. The system used a
simple compression scheme,
I think that there is a bug in the as.POSIXct function on Windows.
Here is what I get on Win2000, Pentium III machine in R 1.8.1.
> dd1 <- ISOdatetime(2003, 10, 26, 0, 59, 59)
> dd2 <- ISOdatetime(2003, 10, 26, 1, 0, 0)
> dd2 - dd1
Time difference of 1.000278 hours
Now, the 26th of October was
Your starting values for the parameters are no even in the general
ballpark. Here is what I got for the final fit:
Parameters:
Estimate Std. Error t value Pr(>|t|)
a 3.806e+07 1.732e+06 21.971 <2e-16 ***
k -3.391e-02 6.903e-02 -0.4910.628
b 9.000e-01 1.240e-02 72.612 <2e-16 *
I believe in R you need
library(maps)
before using usa(). Of course, the library has to be installed first.
Cheers,
Andy
__
Andy Jaworski
Engineering Systems Technology Center
3M Center, 518-1-01
St. Paul, MN 55144-1000
-
E-mail: [EMAIL PROTECTED]
Tel: (6
You need paste and assign functions. Paste will create a sequence of names
and assign will give values to the variables with these names.
This modification of your loop should work
for(i in 1:N)
{
assign(paste("Random.Data.", i, sep=''), rnorm(10, 0, 1))
}
Cheers,
Andy
__
I am not sure if this is a proper way, but here is what I did recently
installing consecutive alpha and beta releases of 1.8.0 on a Win2000
machine:
(1) I uninstalled previous version using the uninstall provided with R.
This leaves all the additional packages in the library folder
(2) I reinstall
I am posting it here because I am not sure if the behavior described below
is actually a bug.
If I do something like this:
> x1 <- 1:3
> x2 <- 5:9
> x3 <- 21:27
> ll <- list(x1, x2, x3)
> stack(x1,x2,x3)
I get the following error:
Error in rep.int(names(x), lapply(x, length)) :
invalid
Here is a brute force way:
mm <- NULL
for(i in unique(ID)){
zz <- data.frame[ID==i, 3]
mm <- rbind(mm, c(i, zz))
}
It will work as long as you have the same number of tests for each ID. If
not, you would need to pad shorter zz vectors with NAs.
Cheers,
Andy
I am not sure if this is the easiest way, but you can do something like
this:
library(gregmisc)
combinations(N, n, x, repeats=TRUE)
where x is an atomic vector of size N. The only restriction is that the x
vector has to have N unique elements. The combinations function will
return a matrix wit
Robin,
This is not a direct answer to your question, but there exists a pretty
good linear, mixted and integer programming package called lp_solve. I
have used it successfully on a couple of projects. As far as I know it is
in the public domain and there is source code available. There is als
David,
I am not sure if it can be done in a vectorized form, but this should work
y <- NULL
for(i in 1:ncol(x)) y <- c(y, cor(x[,i],apply(x[,-i],1,sum)))
Cheers,
Andy
__
Andy Jaworski
Engineering Systems Technology Center
3M Center, 518-1-01
St. Paul, MN 55144-
This is what I would do:
cc <- NULL
for(i in 1:ncol(x)) cc <- c(cc, paste("X", i, sep=''))
colnames(x) <- cc
where x is your matrix.
Hope this helps,
Andy
__
Andy Jaworski
Engineering Systems Technology Center
3M Center, 518-1-01
St. Paul, MN 55144-1000
-
E
Anna,
I found this quite useful in positioning a legend:
plot(1:10, 1:10)
legend(locator(1), "A legend")
Now, go to the plot window and click your left mouse where you want the
upper left corner of the legend to appear. Ithink, this should work no
matter what your coordinate system is.
Hope t
Hi,
This seems a very basic problem, but I cannot seem to find the solution to
it.
I am trying to use Rcmdr on a data frame I created in my current R session.
More specifically, I did
x <- data.frame(matrix(0, ncol=3, nrow=5))
library(Rcmdr)
Now I would like to be able to edit, view and perhap
There is a contributed package called SparseM. It looks like it will do
what you need.
Cheers,
Andy
__
Andy Jaworski
Engineering Systems Technology Center
3M Center, 518-1-01
St. Paul, MN 55144-1000
-
E-mail: [EMAIL PROTECTED]
Tel: (651) 733-6092
Fax: (651
Simint is in the multcomp package.
Cheers,
Andy
__
Andy Jaworski
Engineering Systems Technology Center
3M Center, 518-1-01
St. Paul, MN 55144-1000
-
E-mail: [EMAIL PROTECTED]
Tel: (651) 733-6092
Fax: (651) 736-3122
|-+-
If you are on a Windows machine try to invoke R with the --internet2
switch.
Cheers,
Andy
__
Andy Jaworski
Engineering Systems Technology Center
3M Center, 518-1-01
St. Paul, MN 55144-1000
-
E-mail: [EMAIL PROTECTED]
Tel: (651) 733-6092
Fax: (651) 736-3122
I just r-sync'ed the r-devel version of R-1.7.0 (2003-03-11), compiled it
under RH-8.0 and ran make check. The reg-tests-2 fails at the very end
with the message stating that "object cement was not found". It looks like
this piece of the regression test is new to version 1.7. The the piece of
co
Yesterday I installed R-1.6.2 on a Win2000 laptop from a binary downloaded
from the Wisconsin mirror. No problems.
Andy
__
Andy Jaworski
Engineering Systems Technology Center
3M Center, 518-1-01
St. Paul, MN 55144-1000
-
E-mail: [EMAIL PROTECTED]
Tel: (651)
I have been going through Lattice documentation and I just noticed that at
the bottom of the panel.functions help page there was a link called
lowess.smooth pointing to .../library/modreg/html/loess.smooth.html. This
file does not seem to exist in R-1.6.1 or in 1.7.0 (dev) - there are only
loess.h
I have a feeling that this was already discussed here, but I cannot
remember the outcome of the discussion.
I would like to have the col.whitebg theme as a default and I cannot figure
out how to do it. Functions like lset or trellis.par.set require that the
device be active, so how does one set a
|
>-|
Hi Andy,
Thanks! glm and dose.p can do exaclty what I want to do. Just a quick
question,
how can I extract the numbers in the glm.dose object created by the
Jacqueline,
This should be a simple application of GLM. Check the help pages for glm,
family and dose.p in library MASS. Look at the example at the bottom of
the dose.p help page - it does almost exactly what you need.
Hope this helps,
Andy
__
Andy Jaworski
En
Here is one way of doing this.
(1) read the whole file in as a vector of strings one line at a time
x <- readLines("")
(2) find the position of the "@DATA" string in your vector
s <- which(x == "@DATA")
(3) scan the file again skipping s lines
scan("", skip=s, sep=",", ...)
You
I just ran package update on my Win2000 R-1.6.1 and it installed new
versions of lattice and grid (0.6-7 and 0.7-3 respectively). Then I ran
demo(lattice) and noticed that the last plot, which is supposed to
illustrate math expression usage, fails in the sense that all expression
are shown literal
67 matches
Mail list logo