Displaying 20 results from an estimated 20 matches for "ans1".
Did you mean:
ans
2011 Dec 12
1
Detecting typo in function argument
...put it in my codes.
Cheers,
JN
rm(list=ls())
start<-rep(3,6)
lo<-rep(2,6)
up<-rep(4,6)
flb <- function(x)
{ p <- length(x); sum(c(1, rep(4, p-1)) * (x - c(1, x[-p])^2)^2) }
ans<-optim(start, flb, lower=lo, upper=up)
ans
ans<-optim(start, flb, lower<-lo, upper=up)
ans
ans1<-optim(start, flb, lower<-lo, upper=up)
ans1
require(optimx)
ans1x<-optimx(start, flb, lower<-lo, upper=up)
ans1x<-optimx(start, flb, gr="gfwd",lower<-lo, upper=up)
ans1<-optim(start, flb, gr=NULL,lower<-lo, upper=up)
2000 Sep 24
2
Folding ?
Hi,
I need to write a function that would look something like this:
S <- function(b=betas){
expression(b[1] * f(b[2] * x * f(b[3] * x * f(...b[n-1] * x * f(b[n] *
x)))...)
}
Where n is the number of element in b.
Further I need to be able to evaluate S at some x numerically of course and
I need to use "deriv" and produce dS/dx such that I can evaluate it also at
some x.
I
2010 Dec 15
3
Applying function to a TABLE and also "apply, tapply, sapply etc"
...20 and gives me desired result.
fun = function(X, Y)
{
X + Y #( I am just giving an example of process. Actual process is
quite different.)
}
result = fun(variable_1[1], variable_2[1]) # Thus, i should be getting answer 30 which I am storing in say 'ans1.csv'
# ____________________________________________________________________
# My problem
Suppose instead of having above dataframe having single data for variable 1 and variable 2, I have following data as
variable_1 variable_2
10 20
40 ...
2004 Jul 03
4
counting the occurrences of vectors
Hi:
I have two matrices, A and B, where A is n x k, and B is m x k, where n >> m >> k. Is there a computationally fast way to count the number of times each row (a k-vector) of B occurs in A? Thanks for any suggestions.
Best,
Ravi.
[[alternative HTML version deleted]]
2012 Aug 04
3
Head or Tails game
Hi,
Reading about a "Heads and Tails" game in
http://www.dartmouth.edu/~chance/teaching_aids/books_articles/probability_book/amsbook.mac.pdf
Introduction to Probability (Example 1.4, pp. 5-8).
You toss a coin 40 times. If heads, Peter wins $1, tails, he loses $1. I
think I can do that ok with:
winnings <- sum(sample(c(-1,1), 40, replace=TRUE))
But I have to do it 10,000 times
2009 Aug 25
0
analysis of categorical data
...actor, but how
can I mix these methods?
Also, I need to be able to do post-hoc comparisons in all dimensions.
Any ideas or references?
I'd be happy to share more details as needed.
Here is a sample from the data. All together, there are 366 subjects. There
are 4 levels of Test_no (1,2,3,4), Ans1 and Ans2 are the within subject
measures, and there are 8 levels of Ans* (cor, SE, CP, CPSE, FoM, FoMSE,
zero, other).
Thanks, again!
SID Test_No Ans1 Ans2
1 1 other other
2 1 CPSE CP
3 1 other other
4 1 SE SE
5 1 FoM CP
6 1 FoM CPSE
7 2 cor cor
8 2 cor cor
9 2 cor cor
10 2 CPSE CPSE
11 2 cor cor...
2010 Jun 29
1
Performance enhancement for ave
library(plyr)
n<-100000
grp1<-sample(1:750, n, replace=T)
grp2<-sample(1:750, n, replace=T)
d<-data.frame(x=rnorm(n), y=rnorm(n), grp1=grp1, grp2=grp2)
system.time({
d$avx1 <- ave(d$x, list(d$grp1, d$grp2))
d$avy1 <- ave(d$y, list(d$grp1, d$grp2))
})
# user system elapsed
# 39.300 0.279 40.809
system.time({
d$avx2 <- ave(d$x, interaction(d$grp1, d$grp2, drop =
2012 Sep 02
0
most efficient plyr solution
...### solution 1 using mapply
# proper answer, no input transform, output transform, no parallelization, no progress update
sol1 <- function() {
res1 <- mapply(
function(i,j,k,l) { fisher.test( matrix(c(i,j,k,l), ncol=2), conf.int=F)$p.value },
i=Ax, j=Ay, k=Bx, l=By,
SIMPLIFY=TRUE)
ans1 <- matrix(res1,ncol=4)
return(ans1)
}
s1 <- sol1()
### solution 2 using lapply
# proper answer, input transform, output transform, no parallelization, no progress update
sol2 <- function() {
tmp.list <- as.data.frame(rbind(as.numeric(Ax), as.numeric(Ay), as.numeric(Bx), as.numeric(By...
2004 Jul 01
3
list structure question
Hi,
I have a list in which element is a vector (all of the same length and
all numeric). I want to find the mean of the first elements of the
vectors, the mean of the second elements of the vectors and so on.
Currently I convert the list to a data.frame and apply rowMeans(). But
is there a way to to do this directly on the list? I seem to recall a
post in which there was such a function (or
2008 Aug 27
5
Integrate a 1-variable function with 1 parameter (Jose L. Romero)
Hey fellas:
I would like to integrate the following function:
integrand <- function (x,t) {
exp(-2*t)*(2*t)^x/(10*factorial(x))
}
with respect to the t variable, from 0 to 10.
The variable x here works as a parameter: I would like to integrate the said function for each value of x in 0,1,..,44.
I have tried Vectorize to no avail.
Thanks in advance,
jose romero
2004 Dec 16
8
counting numbers without replicates in a vector
Hi,
I am just wondering if there is an easy way to count
in a numeric vector how many numbers don't have
replicates.
For example,
a=c(1,1,2,2,3,4,5), how can I know there are three
numbers (3, 4 and 5) without replicates?
Thank you!
Jun
=====
2007 Feb 08
2
Timings of function execution in R [was Re: R in Industry]
On 2/8/07, Albrecht, Dr. Stefan (AZ Private Equity Partner)
<stefan.albrecht at apep.com> wrote:
> Dear all,
>
> Thanks a lot for your comments.
>
> I very well agree with you that writing efficient code is about optimisation. The most important rules I know would be:
> - vectorization
> - pre-definition of vectors, etc.
> - use matrix instead of data.frame
> - do
2009 Dec 08
4
lower.tail option in pnorm
Hi,
I would have thought that these two constructions would
produce the same result but they do not.
Resp <- rbinom(10, 1, 0.5)
Stim <- rep(0:1, 5)
mm <- model.matrix(~ Stim)
Xb <- mm %*% c(0, 1)
ifelse(Resp, log(pnorm(Xb)), log(1 - pnorm(Xb)))
pnorm(as.vector(Xb), lower.tail = Resp, log.p = TRUE)
> ifelse(Resp, log(pnorm(Xb)), log(1 - pnorm(Xb)))
[1] -0.6931472 -1.8410216
2011 Sep 02
5
Hessian Matrix Issue
Dear All,
I am running a simulation to obtain coverage probability of Wald type
confidence intervals for my parameter d in a function of two parameters
(mu,d).
I am optimizing it using "optim" method "L-BFGS-B" to obtain MLE. As, I
want to invert the Hessian matrix to get Standard errors of the two
parameter estimates. However, my Hessian matrix at times becomes
2010 Sep 17
0
question on OPTIMX with installing and using
...manual:
require(graphics)
fr <- function(x) { ## Rosenbrock Banana function
x1 <- x[1]
x2 <- x[2]
100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
grr <- function(x) { ## Gradient of 'fr'
x1 <- x[1]
x2 <- x[2]
c(-400 * x1 * (x2 - x1 * x1) - 2 * (1 - x1),
200 * (x2 - x1 * x1))
}
ans1<-optimx(c(-1.2,1), fr)
2009 Nov 02
2
a prolem with constrOptim
Hi,
I apologize for the long message but the problem I encountered can't be stated in a few lines.
I am having some problems with the function constrOptim. My goal is to maximize the likelihood of product of K multinomials, each with four catagories under linear constraints on the parameter values. I have found that the function does not work for many data configurations.
#The likelihood
2009 Jul 17
6
Solving two nonlinear equations with two knowns
Dear R users,
I have two nonlinear equations, f1(x1,x2)=0 and f2(x1,x2)=0. I try to use optim command by minimize f1^2+f2^2 to find x1 and x2. I found the optimal solution changes when I change initial values. How to solve this?
BTW, I also try to use grid searching. But I have no information on ranges of x1 and x2, respectively.
Any suggestion to solve this question?
Thanks,
Kate
2008 Jun 03
3
How to solve a non-linear system of equations using R
Dear R-list members,
I've had a hard time trying to solve a non-linear system (nls) of equations
which structure for the equation i, i=1,...,4, is as follows:
f_i(d_1,d_2,d_3,d_4)-k_i(l,m,s) = 0 (1)
In the expression above, both f_i and k_i are known functions and l, m and s
are known constants. I would like to estimate the vector d=(d_1,d_2,d_3,d_4)
which is solution
2003 Nov 11
1
Samba 3 Redhat 9 Openldap doc
...ls located in
samba-3.0.0/examples/LDAP/smbldap-tools
They can also be downloaded from http://www.idealx.org/prj/samba/dist/
Location of Perl Modules
###################
http://www.cpan.org/modules/01modules.index.html
##############################################
Install Perl LDAP and Convert ANS1
These are required for smbldap tools.
Install in the following order.
This can be copied and pasted in your terminal.
Convert-ASN1-0.17.tar.gz
tar -zxf Convert-ASN1-0.17.tar.gz
cd Convert-ASN1-0.17
perl Makefile.PL
make
make test
make install
cd ..
If you want to use TSL or SSL the following pac...
2010 Apr 15
4
Does "sink" stand for anything?
Hello Everyone,
Learning about R and its wonderful array of functions. If it's not obvious, I usually try to find out what a function stands for. I think this helps me remember better.
One function that has me stumped is "sink." Can anyone tell me if this stands for something?
Thanks,
Paul
__________________________________________________
[[alternative HTML