Displaying 20 results from an estimated 4000 matches similar to: "Simplify formula for heterogeneity"
2005 Jun 03
2
Simplify formula for iterative programming
Dear R-ians,
I am looking for the simplification of a formula to improve the
calculation speed of my program. Therefore I want to simplify the
following formula:
H = Si (Sj ( sqrt [ (Ai - Aj)?? + (Bi - Bj)?? ] ) )
where:
A, B = two vectors (with numerical data) of length n
sqrt = square root
Si = summation over i (= 0 to n)
Sj = summation over j (= 0 to n)
Ai = element of A with index i
Aj
2005 Nov 04
2
Simplify iterative programming
Dear,
I am looking for the simplification of a formula to improve the
calculation speed of my program. Therefore I want to simplify the
following formula:
H = sum{i=0..n-1 , [ sum {j=0..m-1 , sqrt ( (Ai - Bj)^2 + (Ci -
Dj)^2) } ] }
where:
A, C = two vectors (with numerical data) of length n
B, D = two vectors (with numerical data) of length m
sqrt = square root
Ai = element of A with index
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,
2008 Jul 01
1
[.data.frame speedup
Below is a version of [.data.frame that is faster
for subscripting rows of large data frames; it avoids calling
duplicated(rows)
if there is no need to check for duplicate row names, when:
i is logical
attr(x, "dup.row.names") is not NULL (S+ compatibility)
i is numeric and negative
i is strictly increasing
"[.data.frame" <-
function (x, i, j,
2004 May 24
1
as.matrix.data.frame() in R 1.9.0 converts to character when it should (?) convert to numeric
Conversion of a data frame to a matrix using as.matrix() when a
column of the data frame is POSIXt and all other columns are numeric
has changed in R 1.9.0 from R 1.8.1. The new behavior issues a
warning message and converts to a character matrix. In R 1.8.1, such
an object was converted to a numeric matrix.
Here is an example.
#### R 1.9.0 ####
> foo <- data.frame(
2017 Dec 01
1
Bug is as.matrix.data.frame with nested data.frame
Converting a data.frame with a nested data.frame to a matrix fails:
x <- structure(list(a = data.frame(letters)),
class = "data.frame",
row.names = .set_row_names(26))
as.matrix(x)
#> Error in ncol(xj) : object 'xj' not found
The offending code is here, in the definition of as.matrix.data.frame
(source/base/all.R):
for (j in pseq) {
2009 Oct 29
3
Weird error: Error in xj[i] : invalid subscript type 'list'
I got the error. I haven't been able to get a stand along case so that
I can show it here. But could somebody give some clue on what could
cause this error? Since I never defined xj[i], I don't understand
where this error come from.
Error in xj[i] : invalid subscript type 'list'
2003 Jun 18
1
suggestion for make.names
I would like to suggest a modification to the make.names() function.
The current implementation has two problems:
1. It doesn't check if a name matches an R keyword (like "function").
2. The uniqueness algorithm is not invariant to concatenation.
In other words,
make.names(c("a","a","a"),unique=T) !=
2003 Jun 18
1
suggestion for make.names
I would like to suggest a modification to the make.names() function.
The current implementation has two problems:
1. It doesn't check if a name matches an R keyword (like "function").
2. The uniqueness algorithm is not invariant to concatenation.
In other words,
make.names(c("a","a","a"),unique=T) !=
2009 Nov 04
4
unexpected results in comparison (x == y)
Dear readers of the list,
I have a problem a comparison of two data from a vector. The comparison
yields FALSE but should be TRUE. I have checked for mode(), length() and
attributes(). See the following code (R2.10.0):
-----------------------------------------------
# data vector of 66 double data
X =
2017 Oct 09
1
Using response variable in interaction as explanatory variable in glm crashes R
>>>>> Jan van der Laan <rhelp at eoos.dds.nl>
>>>>> on Fri, 6 Oct 2017 12:13:39 +0200 writes:
> It is actually model.matrix that crashes, not glm. Same
> crash occurs with e.g. lm.
> model.matrix(dob_mon ~ dob_day*dob_mon, data = tab)
> also crashes R.
Yes, segmentation fault.
It only happens when these are *logical*
2010 Mar 26
2
R loop help
Hi,
I am tring to write a loop to compute this,
==========================
x1=c(
rep(-1,4),
rep(1,4)
)
x2=c(
rep(c(-1,-1,1,1),2)
)
x3=c(
rep(c(-1,1),4)
)
x1*x2
x1*x3
x2*x3
========================
suppose i have x1,x2,x3
i want to compute their ' two factor interactions', x1x2,x1x3 and x2x3,
I wrote
========================
for(i in 1:2){
for( j in i+1:3){
xij=c()
2003 Oct 02
3
Query: weighting cells in histogram
I have the 'breaks' for the histogram ('hist') but I want weight the cells instead of using actual observations. I thought that using freq=FALSE implied that the numbers in 'x' were weights but this turned out to be wrong.
Any help and/or comment is very much appreciated.
Regards,
M?rten
M?rten Bjellerup
Doctoral Student in Economics
School of Management and Economics
2008 Oct 25
1
pairwise.wilcox.test for paired samples
Dear R Core,
pairwise.wilcox.test does not handle "paired = TRUE" correctly; e.g.
set.seed(13)
x <- rnorm(20)
g <- c(rep(1, 10), rep(2, 10))
wilcox.test(x ~ g)$p.value # 0.075
pairwise.wilcox.test(x, g)$p.value # 0.075, o.k
wilcox.test(x ~ g, paired = TRUE)$p.value # 0.105
pairwise.wilcox.test(x, g, paired = TRUE)$p.value # 0.075, wrong
The line
wilcox.test(xi, xj,
2003 Nov 05
1
Fitting a 3-parameter gammadistribution
I have 'grouped' data, that is in the form of:
Interval Median
0-9.9%: -25
10-19.9%: 0
20-29.9%: 3
30-39.9%: 10
40-49.9%: 50
50-59.9%: 200
et cetera
and want to fit a three parameter gamma distribution. Does anyone know of an existing routine for doing this (or something similar)? Any help or comment is much appreciated.
Regards,
M?rten
M?rten
2009 May 29
1
error message in plm
Hi everyone,
Could anyone tell me what means the follow error message
Error in xj[i] : invalid subscript type 'closure'
It happens when I run the function plm, like this:
>ff<-totaccz~lactivoz+varvolnegz
>ss<-plm(ff,data=regaccdis,na.omit)
Error in xj[i] : invalid subscript type 'closure'
> coef(ss)
(Intercept) lactivoz varvolnegz
0.02571212 6.94227541
2003 Oct 02
2
Query: What is 'Trellis'?
I'm an R-beginner and have found the function 'panel.mathdensity' in the full manual. R can't find the function and under 'Description' in the manual it says that they "are available in Trellis". What is it and where can I find the function?
Regards,
M?rten
M?rten Bjellerup
Doctoral Student in Economics
School of Management and Economics
V?xj? University
1999 Aug 05
1
pairwise scatterplot matrix
Dear Friends:
I like so much to work with R program. Congratulations for your work.
I need R for work with multivariate data.
My question is:
With the pairs(X) command my output is a pairwise scatterplot symmetric matrix. Like:
| X1 |X1 vs X2|X1 vs X3|X1 vs X4|
|X2 vs X1| X2 |X2 vs X3|X2 vs X4|
|X3 vs X1|X3 vs X2| X3 |X3 vs X4|
|X4 vs X1|X4 vs X2|X4 vs X3| X4 |
It is
2008 Jan 13
1
Hmisc latex() does not want to work
I seem to have a problem getting latex (Hmisc) to
work.
Any suggestions as to what I am doing wrong?
Thanks
library(Hmisc)
aa <- data.frame(aa=1:10, bb=rnorm(10, 5, 2),
cc=rnorm(10, 20, 4))
rr <- lm(cc~aa+bb, data=aa); rr
latex(rr)
> latex(rr)
'latex' is not recognized as an internal or external
command,
operable program or batch file.
Warning messages:
1: In cbind(cx, cxk) :
2008 Mar 03
7
help for the first poster- a simple question
Hi, there,
I cannot get accurate value for calculation.
for example:
ld<-sqrt(1*0.05*0.95*0.05*0.95)
0.05*0.95-ld=-6.938894e-18
0.05*0.95-ld==0 is False.
I met this problem in my program, how can I handle it. Thanks.
xj.