Displaying 20 results from an estimated 917 matches for "n1".
2013 Mar 29
3
if clause in data frame
Hi,
final<-data.frame()
?? for (m1 in 4:10) {
?????? for (n1 in 4:10){?
?????????? for (x1 in 0: m1) {
????????????? for (y1 in 0: n1) {
final<- rbind(final,c(m1,n1,x1,y1))
res}}}}
?final1<-within(final,{flag<-ifelse(x1/m1>y1/n1, 1,0)})
?head(final1)
#? m1 n1 x1 y1 flag
#1? 4? 4? 0? 0??? 0
#2? 4? 4? 0? 1??? 0
#3? 4? 4? 0? 2??? 0
#4? 4? 4? 0? 3?...
2017 Jan 24
3
Convertir programa Matlab a R sacado de Threshold Models of Collective Behavior de Michèle Lai & Yann Poltera
...puter exercises: Modelling and simulating social systems with matlab. Tech. rep., Swiss Federal Institute of Technology (December 2009). 27.
Ahora estoy convirtiendo la siguiente funcin:
function sizes = gridsizes(N,varargin)
% gridsizes(N) calculates the best factorization of N into two integers N1 and
% N2 such that : N1xN2 == N and N2-N1 -> min (optimal grid)
% gridsizes(N,C1,C2) calculates the best factorization of N into two integers N1 and
% N2 such that : N1xN2 == N and N2-N1 -> min, under the condition that N1
% divides C1 and N2 divides C2 (optimal subgrids for an already existi...
2012 Dec 04
1
Solve system of equations (nleqslv) only returns origin
...rs/Alicia/Documents/R.Codes/R.Packages/")
require(nleqslv)
###### Global Parameters ############
beeta=0.8
pq=10000
L=12600
theta=0.6
psale=0.6
mu=psale*(1-theta)
alphah=0.15
Cg=6240
Cs=2820
A= 100
D=0.0001
greekp=0.43
K=100000
##### Species Parameters ##########
b1=0.38
p1=16654
v1 = 0.28
N1=6000
g1=1
delta1=1
b2=0.4
p2=2797
v2 = 0.31
N2=10000
g2=1
delta2=1
### Define functions with vector x = c(Lg, Ls, gamma1, gamma2, lamda)
firstordercond <- function (x) {
y=numeric(4)
y[1]=(alphah/x[3])-(x[5]*((p1-(((theta+mu)*(((N1/A)*g1^greekp*x[1]^b1)+K))+((theta+mu)*(((1-exp(-2*D*v1...
2013 Feb 01
2
How does this function print, why is n1 which equals 1 printed as 2?
Windows 7, R 2.12.1
Colleagues,
I am trying to understand the n.for.2means function. The code below is a copy of the function (renamed to n.for.2means.js). I have inserted a single line of code towards the bottom of the function which uses the cat function to print the value of n1. You will note the value (preceded by stars) is printed as 1.
The function (1) prints a lot of output without any instructions in the function to print anything (other than the cat statement I added), and when it prints (2) reports the value of n1 to be 2!.
I have two questions, (i) how is the func...
2012 Dec 17
1
seeking a help on if function
...of gw1=gw2 (which mean equal trimming), the result will come out as "a" not the value of ssdw when equal trimming is done. I f anyone could with this, I really appreciate it. I need the value of ssdw so that I can proceed with computing the F test. Thanks.
Regards,
Hyo Min
UPM Malaysia
n1<-15
miu<-0
sd1<-1
data1<-rnorm(n1,miu,sd1)
## data transformation as G=0.5 and h=0.5 (data is normal)
G<-0.5
h<-0.5
w<-((exp(G*data1)-1)/G)*(exp((h*data1^2)/2))
group1<-sort(w)
g<-0.15 ## proportion of trimming
## group 1
uw<-floor(0.2*n1)
low1<-mean(group...
2013 Mar 10
0
max row
HI,
Using
c11<- 0.01
c12<- 0.01
c1<- 0.10
c2<- 0.10
One possible problem is that:
dim(res5)
#[1] 513? 20
res6<-aggregate(.~m1+n1+m+n,data=res5[,c(1:6,9:12,21:24)] ,max)
#Error in `[.data.frame`(res5, , c(1:6, 9:12, 21:24)) :
?# undefined columns selected
A.K.
________________________________
From: Joanna Zhang <zjoanna2013 at gmail.com>
To: arun <smartpink111 at yahoo.com>
Sent: Saturday, March 9, 2013 10:...
2013 Feb 01
29
cumulative sum by group and under some criteria
...Error in split.default(x = seq_len(nrow(x)), f = f, drop = drop, ...) :
Group length is 0 but data length > 0
On Thu, Jan 31, 2013 at 12:21 PM, arun kirshna [via R] <
ml-node+s789695n4657196h87@n4.nabble.com> wrote:
> Hi,
> Try this:
> colnames(d)<-c("m1","n1","x1","y1","p11","p12")
> library(zoo)
> res1<- do.call(rbind,lapply(lapply(split(d,list(d$m1,d$n1)),function(x)
> {x$cp11[x$x1>1]<- cumsum(x$p11[x$x1>1]);x$cp12[x$y1>1]<-
> cumsum(x$p12[x$y1>1]);x}),function(x)
> {x$c...
2004 Oct 01
3
same test statistic for t-test with and without equal variance assumption
...RUE and var.equal=FALSE in t.test ?
set.seed(1066)
x1 <- rnorm(50)
x2 <- rnorm(50)
t.test(x1, x2, var.equal=FALSE)$statistic # 0.5989774
t.test(x1, x2, var.equal=TRUE)$statistic # 0.5989774 ???
Here are my own calculations that shows that perhaps the result when
var.equal=TRUE is wrong.
n1 <- length(x1); n2 <- length(x2)
m1 <- mean(x1) ; m2 <- mean(x2) ; num <- (m1 - m2)
v1 <- var(x1) ; v2 <- var(x2)
# t-test with UNequal variance
denom1 <- sqrt( v1/n1 + v2/n2 )
num / denom1 # gives 0.5989774
# t-test with equal variance
sp <- ( (n1-1)*v1 + (n2-1...
2013 Jan 03
0
help with NLOPTR
...stall.packages ("mosaic")
library(mosaic)
###### Global Parameters ############
beeta=0.8
pq=10000
pf=10000
F=20
L=12600
theta=0.6
psale=0.6
mu=psale*(1-theta)
alphah=0.15
Cg=6240
Cs=2820
A= 100
D=0.0001
greekp=0.43
K=100000
##### Species Parameters##########
b1=0.38
p1=16654
v1 = 0.28
N1=6000
g1=1
delta1=1
b2=0.4
p2=2797
v2 = 0.31
N2=10000
g2=1
delta2=1
####################################### Objective function
############################################
eval_f = function (x) {
return(-1 * ( ( (1-alphah) *log(F) ) + ( alphah* (
(x[1]*(((N1/A)*(g1^greekp)*(x[3]^b1))+((1-exp(...
2006 Jul 03
2
help a newbie with a loop
...p around it (for different values of p) ,
R stays in a loop?
Can't it take more then 2 loops in one program?
powerb<-function(x,sp2,a,b,b1,m)
{ sx<-(sum(x^2)-(sum(x)^2)/length(x))/length(x)
n0<-ceiling((((qnorm(1-(a/2))+qnorm(1-b))/b1)^2)*(((m+1)/m)*sp2/sx))
repeat
{
n1<-ceiling((((qt(1-(a/2),n0-4)+qt(1-b,n0-4))/b1)^2)*(((m+1)/m)*sp2/sx))
if(n0==n1) break
n0<-n1
}
return(c(sx,n1))
}
x<-rnorm(1000,0,1)
x<-x[order(x)]
res<-matrix(0,1000,2)
#use the function and plot for different values of ind and p
for ( p in c(0.05,0....
2010 Jul 24
1
Doubt about a population competition function
Hi,
I'm doing a function that describe two populations in competition.
that's the function that i wrote:
exclusao<-function(n10, n20, k1, k2, alfa, beta, t){
n1<-k1-(alfa*n20)
n2<-k2-(beta*n10)
if(t==0){plot(t, n10, type='b', xlim=range(c(1:t),c
(1:t)), ylim=range(n10, n20), xlab='tempo',
ylab='tamanho populacional')
points(t, n20, type='b', col="red")
points(t,n10,type=&q...
2009 Jun 17
2
cumulative sum in data frame
Dear R-Help List,
I have a question about data manipulation. I tried to make code myself but too much for me. I would greatly appreciate your help.
I have data set consisting of site (from 1 to N1) and distance and there are several variables (1 to N2) collected from each sampling site. I am interested in looking at cumulative sums of each variable based on site and distance like below.
Can anyone help create function to do the task? The cumulative sum outputs may not be necessarily combin...
2003 Mar 04
4
writing several command line in R console
...the continuity of my code
more clearly : if for example I write a function, so far i have to write the
all code inside on the same line wich may become obscure as the function is
more and more complex.
I would like to do like in the example of the manuels:
>twosam <- function(y1, y2) {
n1 <- length(y1); n2 <- length(y2)
yb1 <- mean(y1); yb2 <- mean(y2) s1 <- var(y1); s2 <- var(y2)
s <- ((n1-1)*s1 + (n2-1)*s2)/(n1+n2-2)
tst <- (yb1 - yb2)/sqrt(s2*(1/n1 + 1/n2)) tst }
all I can do is something like that:
>twosam <- function(...
2008 Jul 26
4
parametric bootstrap
Hi
I am trying to find a parametric bootstrap confidence interval and when I used the boot function I get zero bias and zero st.error? What could be my mistake?
Thank you and take care.
Laila
[[alternative HTML version deleted]]
1998 Mar 03
1
":" (seq) bug -- should not always coerce to integer!
The problem seems that ":" always coerces to integer, but should not..
9.9:12
## R: [1] 9 10 11
## S-plus 3.4: [1] 9.9 10.9 11.9
## and many more examples....
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or
2003 Nov 24
1
[PATCH] library functions
...-Nru a/klibc/strcasecmp.c b/klibc/strcasecmp.c
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/klibc/strcasecmp.c Mon Nov 24 11:33:52 2003
@@ -0,0 +1,25 @@
+/*
+ * strcasecmp.c
+ *
+ */
+
+#include <string.h>
+#include <ctype.h>
+
+int strcasecmp(const char *s1, const char *s2)
+{
+ char *n1, *n2;
+ int i, retval;
+
+ n1 = strdup(s1);
+ n2 = strdup(s2);
+
+ for (i = 0; i < strlen(n1); i++)
+ n1[i] = toupper(n1[i]);
+ for (i = 0; i < strlen(n2); i++)
+ n2[i] = toupper(n2[i]);
+ retval = strcmp(n1, n2);
+ free(n1);
+ free(n2);
+ return retval;
+}
diff -Nru a/klibc/strncasecmp.c b...
2009 Nov 02
1
need help in using Hessian matrix
...for a complicated function from a certain
kind of data but i keep getting this error
Error in f1 - f2 : non-numeric argument to binary operator
the data is given by
U<-runif(n)
Us<-sort(U)
tau1<- 2
F1tau<- pgamma((tau1/theta1),shape,1)
N1<-sum(Us<F1tau)
X1<- Us[1:N1]
Ti<- theta1*qgamma(Us[1:N1],shape,1)
w=N1+1
V<- Us[w:r]
N2<- length(V)
V1<-theta2*qgamma(V,shape,1)
Tj<-V1+tau1-(theta2/theta1)*tau1
c1<-matrix(Ti,ncol=1)...
2009 Mar 09
5
Help
...if we can improve the interconnettivity among free software.
> > thanks again..
> > livio
> >
> > NEW FILE.
> > FILE TYPE NESTED RECORD=1(A).
> > - RECORD TYPE 'A'.
> > - DATA LIST LIST / i0(A1) d1(N3) d2(DATETIME20.0) d3(A15) d4(N2)
> > d5(N1) d6(N1) d7(N1) d8(N1) d9(N1) d10(N1) d11(N1) d12(N1) d13(N1)
> > d14(N1) d15(N1) d16(N1) d17(N2) d18(N1) d19(N1) d20(N1) .
> >
> > - RECORD TYPE 'B'.
> > - DATA LIST LIST / i1(A1) d21(N1) d22(N1) d23(N1) d24(N1) d25(N1)
> > d26(N1) d27(N1) d28(N1) d29(N1) d30(N...
2017 Jun 06
4
integrating 2 lists and a data frame in R
Dear Bert,
thank you for your response. here it is the piece of R code : given 3 data
frames below ---
N <- data.frame(N=c("n1","n2","n3","n4"))
M <- data.frame(M=c("m1","m2","m3","m4","m5"))
C <- data.frame(n=c("n1","n2","n3"), m=c("m1","m1","m3"), I=c(100,300,400))
how...
2011 Jul 27
3
Reorganize(stack data) a dataframe inducing names
Dear Contributors,
thanks for collaboration.
I am trying to reorganize data frame, that looks like this:
n1.Index Date PX_LAST n2.Index Date.1 PX_LAST.1
n3.Index Date.2 PX_LAST.2
1 NA 04/02/07 1.34 NA 04/02/07 1.36
NA 04/02/07 1.33
2 NA 04/09/07 1.34 NA 04/09/07
1.36...