Displaying 20 results from an estimated 3000 matches similar to: "sum of functions"
2009 Oct 14
1
using mapply to avoid loops
Hello, I would like to use mapply to avoid using a loop but for some reason, I can't seem to get it to work. I've included copies of my code below. The first set of code uses a loop (and it works fine), and the second set of code attempts to use mapply but I get a "subscript out of bounds" error. Any guidance would be greatly appreciated. Xj, Yj, and Wj are also lists, and s2,
2010 Sep 06
1
calculating area between plot lines
Hi everyone. I have these data:
probClass<-seq(0,0.9,0.1)
prob1<-c(0.0070,0.0911,0.1973,0.2949,0.3936,0.5030,0.5985,0.6869,0.7820,0.8822)
prob2<-c(0.0066,0.0791,0.2358,0.3478,0.3714,0.3860,0.6667,0.6400,0.7000,1.0000)
# which I'm plotting as follows:
plot(probClass,prob1,xlim=c(0,1),ylim=c(0,1),xaxs='i',yaxs='i',type="n")
lines(probClass,prob1)
2010 Mar 06
1
Plotting Comparisons with Missing Data
Hi,
I'm new to R and I've run into a problem that I'm not really sure how to
express properly in the language. I've got a data table that I've read from
a file containing some simple information about the performance of 4
algorithms. The columns are the name of the algorithm, the problem instance
and the resulting score on that problem (if it wasn't solved I mark that
2008 Apr 22
2
Multidimensional contingency tables
How does one ideally handle and display multidimenstional contingency
tables in R v. 2.6.2?
E.g.:
> prob1<- data.frame(victim=c(rep('white',4),rep('black',4)),
+ perp=c(rep('white',2),rep('black',2),rep('white',2),rep('black',2)),
+ death=rep(c('yes','no'),4), count=c(19,132,11,52,0,9,6,97))
> prob1
victim perp
2011 Dec 02
1
1.6x speedup for requal() function (in R/src/main/unique.c)
Hi,
FWIW:
/* Taken from R/src/main/unique.c */
static int requal(SEXP x, int i, SEXP y, int j)
{
if (i < 0 || j < 0) return 0;
if (!ISNAN(REAL(x)[i]) && !ISNAN(REAL(y)[j]))
return (REAL(x)[i] == REAL(y)[j]);
else if (R_IsNA(REAL(x)[i]) && R_IsNA(REAL(y)[j])) return 1;
else if (R_IsNaN(REAL(x)[i]) && R_IsNaN(REAL(y)[j])) return 1;
2007 Jan 19
1
naive bayes help
Hello
I have a rather simple code and for some reason it produces an error
message. If someone can tell me why and how to fix it, I would be very
greatful. Thank you in advance.
##### create data
set.seed(10)
n <- 200 # number of training points
n.test <- 200 # number of test points
p<-2 # dimension of input space
z <-
2000 Apr 05
2
My first R-program
Sorry, I pasted the wrong file in earlier... this is the correct one:
pValCalculator(b, n=20, m=20)
{
ind <- 1:min(c(n,m))
prob <- (1-pnorm(b,sd=std*sqrt(ind)))
prob1 <- sum((n-ind+1)*(m-ind+1)*prob)
prob1
}
inputData <-
scan("/users/lvssso/projects/LAMA/output/pValLamaScore.tmp", list(block1
= "",block2 = "",width1 = 0,width2 = 0,alignment = 0,score
2010 May 10
2
Robust SE & Heteroskedasticity-consistent estimation
Hi,
I'm using maxlik with functions specified (L, his gradient & hessian).
Now I would like determine some robust standard errors of my estimators.
So I 'm try to use vcovHC, or hccm or robcov for example
but in use one of them with my result of maxlik, I've a the following
error message :
Erreur dans terms.default(object) : no terms component
Is there some attributes
2010 Mar 12
2
Question regarding to maxNR
Hi R-users,
Recently, I use maxNR function to find maximizer. I have error appears as follows
Error in maxNRCompute(fn = fn, grad = grad, hess = hess, start = start, :
NA in the initial gradient
My code is
mu=2
s=1
n=300
library(maxLik)
set.seed(1004)
x<-rcauchy(n,mu,s)
loglik<-function(mu)
{
log(prod(dcauchy(x,mu,s)))
}
maxNR(loglik,start=median(x))$estimate
Does anyone know how
2004 Aug 30
3
Multiple lapply get-around
I am faced with a situation wherein I have to use multiple lapply's. The
pseudo-code could be approximated to something as below:
For each X from i=1 to n
For each Y based on j=1 to m
For each F from 1 to f
Do some calculation based on Fij
Store Xi,Yj = Fij
End For F
End for Y
End for X
Is there anyway to optimize the processing logic further? I *guess*
using the multiple lapply
2002 Aug 06
3
hard to believe speed difference
First, I love R and am grateful to be using this free and extremely
high quality software.
Recently I have been comparing two algorithms and naturally I
programmed in R first. It is so slow that I can almost feel its pain.
So I decided to do a comparison with Java. To draw 500,0000 truncated
normal, Java program takes 2 second and R takes 72 seconds. Not a
computer science major, I find it hard
2013 Jan 07
3
During startup - Warning messages:
Dear Sir/Madam,
After installing R, I saw this warning message in red when I open the R...
During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_COLLATE failed, using "C"
3: Setting LC_TIME failed, using "C"
4: Setting LC_MESSAGES failed, using "C"
5: Setting LC_PAPER failed, using "C"
how shall I solve this ?
2009 Mar 02
1
initial gradient and vmmin not finite
Dear Rhelpers
I have the problem with initial values, could you please tell me how to solve it?
Thank you
June
> p = summary(maxLik(fr,start=c(0,0,0,1,0,-25,-0.2)))
Error in maxRoutine(fn = logLik, grad = grad, hess = hess, start = start, :
NA in the initial gradient
> p = summary(maxLik(fr,start=c(0,0,0,1,0,-25,-0.2),method="BFGS"))
Error in optim(start, func, gr =
2010 Oct 01
1
Place constrictions on parameters when using Optim and MaxLik
Hi R users,
I am trying to restrct the range of two of the parameters in a maximization
problem. Both parameters should be between -1 and 1. As far as I know, if
I choose the estimation method ="L-BFGS-B" under Optim, I can restrict the
parameter space. However, the "L-BFGS-B" always require finite values of
the loglik function and cannot get around of the problem if an
2011 Jul 25
0
error in optimization when I include constant term in Klein and Spady (np package)
Dear all,
I am trying to use the np package for the estimation of a model with Klein
and Spady's semiparametric estimator. When though, I include a constant term
( a column with 1s in X) then the following message appear:
Multistart 1 of 3...Error in optim(c(beta, h), fn = optim.fn, gr = NULL,
method = optim.method, :
non-finite value supplied by optim
So, how can I include a constant
2011 Jul 11
1
plot means ?
Hi,
I need this plot:
given: x,y - numerical vectors of length N
plot xi vs mean(yj such that |xj - xi|<epsilon)
(running mean?)
alternatively, discretize X as if for histogram plotting and plot mean y
over the center of the histogram group.
is there a simple way?
thanks!
--
Sam Steingold (http://sds.podval.org/) on CentOS release 5.6 (Final) X 11.0.60900031
http://thereligionofpeace.com
2009 Apr 21
4
My surprising experience in trying out REvolution's R
I care a lot about R's speed. So I decided to give REvolution's R
(http://revolution-computing.com/) a try, which bills itself as an
optimized R. Note that I used the free version.
My machine is a Intel core 2 duo under Windows XP professional. The code
I run is in the end of this post.
First, the regular R 1.9. It takes 2 minutes and 6 seconds, CPU usage
50%
Next, REvolution's R.
2003 Dec 19
1
iterative proportional fitting
Dear all,
I wonder if there are some function or package in R which can do the
iterative proportional fitting.
In the exponential model
f(y1,...yn)=exp(a'yi+b'(yi*yj)+.....+c'(y1*...*yn)+constance),
instead of the canonical parameters, I use maginal probability instead of a
and log odds ratio instead of b. and for the order higher than 3, I use the
canonical way or even assume
2009 Dec 04
1
Saving predict
Hi all,,Im using function arima()
I.e
series is my data
model<-arima(series,c(1,0,0))
forecast<-predict(model,80)
I want to create a variable:
b1<-forecast$pred - 1.96*forecast$se
and save in a txt file
but using this:
save(b1, file= "b1.txt")
creates afile butwith this inside:
]{HQ ~|LJIiW*-l)% )m#),
RIiSfdbGur9p94; H"L#Rez
1y3pN8{,I6W!6=
{6l?OMw_5KZ+
=
2008 Aug 27
2
r function for calculating extreme spread in group
I'm trying to figure out how to write a r function that will calculate
the extreme spread of a group of points given their (x,y)
coordinates. Extreme Spread is the maximal Euclidean distance between
two points in a group
ex.spread = max{ sqrt [ (xi-xj)^2 - (yi-yj)^2 ] } for i not equal to j
I have 60 levels to apply this to.
There is the combination function in the dprep package but