[R] Weighted regression in rms/Hmisc

2013-05-19 Thread Mullah Abu Shadeque
Hi all,  While using  the following package and code:    library(rms) library(Hmisc) test.trans-aregImpute( ~ NearestWeekGestation + MaternalBMI + MomAge_Years +      WtGain + ethnicity , n.impute=10 ,data=data.1)    test.mod-fit.mult.impute(BirthWeight_g ~

Re: [R] glmer.nb: function not in downloaded lme4 package?

2013-05-19 Thread Niklas Fischer
Thanks in advance! 2013/5/18 Ben Bolker bbol...@gmail.com Ross Marriott Ross.Marriott at fish.wa.gov.au writes: Dear R Help, I would like to use the glmer.nb function for mixed modelling using negative binomial distribution please. On the CRAN website apparently this function is

Re: [R] bar plot with non-zero starting level

2013-05-19 Thread Jim Lemon
On 05/19/2013 09:19 AM, Xianwen Chen wrote: Hi, I want to plot grouped bars to compare 95% confidence interval estimates from two models. Each bar represents a 95% confidence interval estimate of a coefficient from one of the two models. Each group represents confidence interval estimates of

[R] index of quantile variation (iqv)

2013-05-19 Thread Niklas Fischer
Dear all, I would like to compute index of quantile variation (iqv) for each observation in my survey data according to their responses on three categorical variable. Do you know iqv function for this purpose in a package? All the best, Niklas [[alternative HTML version deleted]]

Re: [R] Weighted regression in rms/Hmisc

2013-05-19 Thread Frank Harrell
You should be able to pass a weights argument through fit.mult.impute to ols. I assume that weights are with respect to variables that you, for some reason, do not want to have as predictors. Otherwise you are already conditioning on the weighting factors and no weights are needed. Frank Mullah

Re: [R] Empty clusters in k-means - possible solution

2013-05-19 Thread Luca Nanetti
Dear Simon, I respectfully disagree with you, when you say that it is NOT a bug. Empty clusters can only happen if one provides a set of centers; if one enters something like k=4, it cannot happen, so it must be a bug. Which one is your case? From the help: Except for the Lloyd-Forgy method, k

[R] apply and table

2013-05-19 Thread Jinsong Zhao
Hi there, I have the following code: z - matrix(c(A, A, B, B, C, C, A, B, C), ncol = 3) apply(z, 2, table, c(A, B, C)) which give correct results. However, the following code: apply(z[,1,drop=FALSE], 2, table, c(A, B, C)) which does not give what I expect. I have been thought it should give

[R] How to run lm for each subset of the data frame, and then aggreage the result?

2013-05-19 Thread CHEN, Cheng
Hi gurus, I have a big data frame df, with columns named as : age, income, country what I want to do is very simpe actually, do fitFunc-function(thisCountry){ subframe-df[which(country==thisCountry),]; fit-lm(income~0+age, data=subframe); return(coef(fit));} for each individual

[R] Extracting values from grid cells using for loops

2013-05-19 Thread Jess Baker
Dear list, I am very new to R and have been struggling with extracting data from a netcdf file. Basically I have read in a file containing vegetation height data organised in 0.5 degree grid cells spanning the whole globe. Each cell contains a histogram representing the height distribution and

[R] Generate positive definite matrix with constraints

2013-05-19 Thread mary
Hi, I have a question for my simulation problem: I would like to generate a positive (or semi def positive) covariance matrix, non singular, in wich the spectral decomposition returns me the same values for all dimensions but differs only in eigenvectors. Ex. sigma [,1] [,2] [1,]

[R] TODAY field in termstrc

2013-05-19 Thread Brijesh Gulati
Hi: I am using termstrc package and not sure if TODAY field (govbonds dataset) is today's date or the settlement date for the bonds. Although the name suggests that it should be today's date, but how the formula is setup indicates that it should be settlement date. Please help and thanks in

Re: [R] Generate positive definite matrix with constraints

2013-05-19 Thread mary
Sorry in the previuos message I've inverted: I would like generate ... same eigenvectors and different eigenvalues -- View this message in context: http://r.789695.n4.nabble.com/Generate-positive-definite-matrix-with-constraints-tp4667449p4667450.html Sent from the R help mailing list

Re: [R] Extracting values from grid cells using for loops

2013-05-19 Thread David Winsemius
On May 19, 2013, at 4:20 AM, Jess Baker wrote: Dear list, I am very new to R and have been struggling with extracting data from a netcdf file. Basically I have read in a file containing vegetation height data organised in 0.5 degree grid cells spanning the whole globe. Each cell

[R] strange behaviour with loops and lists

2013-05-19 Thread Liviu Andronic
Dear all, I encountered this strange behaviour with loops and lists. Consider this: xl - list() for(i in 5:7){##loop over numeric vector xl[[i]] - rnorm(i) } xl [[1]] NULL [[2]] [1] -0.4448192 -1.3395014 [[3]] [1] 1.3214195 -1.2968560 -0.6327795 The above lists contained a NULL element

Re: [R] How to run lm for each subset of the data frame, and then aggreage the result?

2013-05-19 Thread arun
HI, May be this helps: set.seed(24) dat1- data.frame(age=sample(30:70,120,replace=TRUE),income=sample(4:8,120,replace=FALSE),country=rep(c(USA,GB,France),each=40),stringsAsFactors=FALSE) library(plyr)  ldply(dlply(dat1,.(country),lm,formula=income~0+age),function(x) coef(x)) #  country   

Re: [R] Empty clusters in k-means - possible solution

2013-05-19 Thread Ranjan Maitra
There is a documented bug in R 2.15.2 and R 2.15.3. The developers decided not to fix this with an update, but it has been fixed with R 3.0.0 (perhaps also with R 3.0.1, which I have not tried myself). So, upgrading R should take care of this problem. HTH, Ranjan On Sun, 19 May 2013 16:17:30

Re: [R] How to run lm for each subset of the data frame, and then aggreage the result?

2013-05-19 Thread David Winsemius
On May 19, 2013, at 5:31 AM, CHEN, Cheng wrote: Hi gurus, I have a big data frame df, with columns named as : age, income, country what I want to do is very simpe actually, do fitFunc-function(thisCountry){ subframe-df[which(country==thisCountry),]; fit-lm(income~0+age,

Re: [R] strange behaviour with loops and lists

2013-05-19 Thread arun
Hi, xl- vector(list,7) for(i in 5:7){##loop over numeric vector xl[[i]] - rnorm(i)  }  xl #[[1]] #NULL # #[[2]] #NULL # #[[3]] #NULL # #[[4]] #NULL # #[[5]] #[1]  0.3266762  0.4316069  1.2290551 -0.6725783  1.6159861 # #[[6]] #[1] -2.8560618 -0.5694743 -0.7325862  1.6786160  0.3883842

Re: [R] strange behaviour with loops and lists

2013-05-19 Thread peter dalgaard
On May 19, 2013, at 18:08 , Liviu Andronic wrote: Dear all, I encountered this strange behaviour with loops and lists. Consider this: xl - list() for(i in 5:7){##loop over numeric vector xl[[i]] - rnorm(i) } xl [[1]] NULL [[2]] [1] -0.4448192 -1.3395014 [[3]] [1] 1.3214195

Re: [R] Extracting values from grid cells using for loops

2013-05-19 Thread Bert Gunter
Also ?tapply But if you are a beginner who has done no homework -- i.e. you have made no effort to learn basics with The Intro to R tutorial or other online tutorial -- then you probably won't be able figure it out. We expect some minimal effort by posters. If you have done such homework, then it

Re: [R] strange behaviour with loops and lists

2013-05-19 Thread Liviu Andronic
On Sun, May 19, 2013 at 7:02 PM, peter dalgaard pda...@gmail.com wrote: (The first example really had 2:3, not 5:7, right?) Indeed. I simplified the example mid-email. The essential bit is that to assign to the 2nd element of a list, it needs to have at least two elements: Thanks for the

Re: [R] apply and table

2013-05-19 Thread peter dalgaard
On May 19, 2013, at 16:22 , Jinsong Zhao wrote: Hi there, I have the following code: z - matrix(c(A, A, B, B, C, C, A, B, C), ncol = 3) apply(z, 2, table, c(A, B, C)) which give correct results. However, the following code: apply(z[,1,drop=FALSE], 2, table, c(A, B, C)) which

Re: [R] apply and table

2013-05-19 Thread arun
Hi, May be this helps: lev1- unique(as.vector(z)) lapply(lapply(as.data.frame(z),factor,levels=lev1),table,lev1) #$V1  #    #  A B C   #A 1 1 0   #B 0 0 1   #C 0 0 0 # #$V2  #    #  A B C   #A 0 0 0   #B 1 0 0   #C 0 1 1 # #$V3  #    #  A B C   #A 1 0 0   #B 0 1 0   #C 0 0 1 #or

Re: [R] Generate positive definite matrix with constraints

2013-05-19 Thread Gabor Grothendieck
On Sun, May 19, 2013 at 10:33 AM, mary mary.d...@libero.it wrote: Sorry in the previuos message I've inverted: I would like generate ... same eigenvectors and different eigenvalues Try this: m0 - 5 + matrix(c(.05, -.05, -.05, .05), 2) m0.values - eigen(m0)$values with(eigen(matrix(rnorm(4),

Re: [R] Generate positive definite matrix with constraints

2013-05-19 Thread Gabor Grothendieck
On Sun, May 19, 2013 at 4:57 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sun, May 19, 2013 at 10:33 AM, mary mary.d...@libero.it wrote: Sorry in the previuos message I've inverted: I would like generate ... same eigenvectors and different eigenvalues Try this: m0 - 5 +

[R] coping zeros from matrix to another

2013-05-19 Thread eliza botto
Dear useRs,i have two distance matrices A and B. The distances in A are linked with distances in B. What i want to do is the following...There are some points in A where distances are zero(those points are apart from usual diagonal of zero values).Whereas, in B the distances at those points are

Re: [R] coping zeros from matrix to another

2013-05-19 Thread Rui Barradas
Hello, Try the following. set.seed(27846) A - matrix(sample(0:2, 16, TRUE), ncol = 4) B - matrix(1:16, ncol = 4) zeros - which(A == 0, arr.ind = TRUE) B[zeros] - 0 Hope this helps, Rui Barradas Em 19-05-2013 22:05, eliza botto escreveu: Dear useRs,i have two distance matrices A and B. The

Re: [R] coping zeros from matrix to another

2013-05-19 Thread eliza botto
Thanks Rui,It worked.. Eliza Date: Sun, 19 May 2013 22:27:41 +0100 From: ruipbarra...@sapo.pt To: eliza_bo...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] coping zeros from matrix to another Hello, Try the following. set.seed(27846) A - matrix(sample(0:2, 16, TRUE), ncol =

Re: [R] Generate positive definite matrix with constraints

2013-05-19 Thread Gabor Grothendieck
On Sun, May 19, 2013 at 5:04 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sun, May 19, 2013 at 4:57 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sun, May 19, 2013 at 10:33 AM, mary mary.d...@libero.it wrote: Sorry in the previuos message I've inverted: I would like

Re: [R] coping zeros from matrix to another

2013-05-19 Thread arun
May be this helps:  set.seed(28)  mat1- matrix(sample(0:50,20,replace=TRUE),nrow=5) A- dist(mat1) A[2:4]- 0 set.seed(35)  mat2- matrix(sample(1:50,20,replace=TRUE),nrow=5) B- dist(mat2) B[which(A==0)]-0  B # 1    2    3    4 #2 49.07138   #3  0.0

Re: [R] coping zeros from matrix to another

2013-05-19 Thread eliza botto
Thankyou very much Arun,it has even been simplified.. Eliza Date: Sun, 19 May 2013 14:49:43 -0700 From: smartpink...@yahoo.com Subject: Re: [R] coping zeros from matrix to another To: eliza_bo...@hotmail.com #or just B[A==0]-0 - Original Message - From: arun

[R] Help needed

2013-05-19 Thread sleiman bou abdo
Hello, i can't find a test for elliptical symmetry In R, is there any package that can save me the trouble ?Thank you in advanceSincerely yoursSleiman [[alternative HTML version deleted]] __

[R] ANOVA Estimated effects may be unbalanced

2013-05-19 Thread Luis Fernando García Hernández
Dear All, This is a data relating leg shaking on differenntre treatments. I reused several individuals so I want to know 1) if there are significative differences on shaking per treatment and 2) if the reused individuals presented some effect or significative variation. Nevertehless when I make

Re: [R] ANOVA Estimated effects may be unbalanced

2013-05-19 Thread Jim Lemon
On 05/20/2013 10:52 AM, Luis Fernando García Hernández wrote: Dear All, This is a data relating leg shaking on differenntre treatments. I reused several individuals so I want to know 1) if there are significative differences on shaking per treatment and 2) if the reused individuals presented

Re: [R] ANOVA Estimated effects may be unbalanced

2013-05-19 Thread Bert Gunter
I would say that the OP should seek local statistical help, as he appears to be out of his statistical depth. This would appear to be a mixed effects models-type setup, but a local statistical expert would be much better able to judge what the goals of the study were and what sort of approach,

[R] How to create surface3d plot with surface data

2013-05-19 Thread Nguyen Hoang
I'm very new to R, and I'm having trouble figuring out a 3d surface plot of the data. I typically have something like this: 0.1 0.2 0.3 0.4 0.5 0.001 40960.16 40960.16 40960.16 40960.16 40960.16 0.0025 40960.16 40960.16 40960.16 40960.16 40960.16