search for: cov1

Displaying 20 results from an estimated 39 matches for "cov1".

Did you mean: com1
2012 Oct 13
4
Problems with coxph and survfit in a stratified model with interactions
I?m trying to set up proportional hazard model that is stratified with respect to covariate 1 and has an interaction between covariate 1 and another variable, covariate 2. Both variables are categorical. In the following, I try to illustrate the two problems that I?ve encountered, using the lung dataset. The first problem is the warning: To me, it seems that there are too many dummies
2003 Apr 28
2
stepAIC/lme problem (1.7.0 only)
I can use stepAIC on an lme object in 1.6.2, but I get the following error if I try to do the same in 1.7.0: Error in lme(fixed = resp ~ cov1 + cov2, data = a, random = structure(list( : unused argument(s) (formula ...) Does anybody know why? Here's an example: library(nlme) library(MASS) a <- data.frame( resp=rnorm(250), cov1=rnorm(250), cov2=rnorm(250), group=rep(letters[1:10],25) ) mod1 <- lme(re...
2012 Oct 14
1
Problems with coxph and survfit in a stratified model, with interactions
...Please try to fix this in the future (Nabble issue?) As to the problems: handling strata by covariate interactions turns out to be a bit of a pain in the posteriorin the survival code. It would have worked, however, if you had done the following: fit <- coxph(Surv(time, status) ~ strata(cov1) * cov2, data=...) or ~ strata(cov1):cov2 or ~ strata(cov1):cov2 + cov2 But by using ~ strata(cov1) + cov1:cov2 you fooled the program into thinking that there was no strata by covariate interaction, and so it did not follow the special logic necessary for that case. Second is...
2013 Oct 18
1
crr question‏ in library(cmprsk)
Hi all I do not understand why I am getting the following error message. Can anybody help me with this? Thanks in advance. install.packages("cmprsk") library(cmprsk) result1 <-crr(ftime, fstatus, cov1, failcode=1, cencode=0 ) one.pout1 = predict(result1,cov1,X=cbind(1,one.z1,one.z2)) predict.crr(result1,cov1,X=cbind(1,one.z1,one.z2)) Error: could not find function "predict.crr" [[alternative HTML version deleted]]
2003 Jun 04
3
Slow ttests in R-devel
...drastically slower under current R-devel vs. current R-patched - one example is below using a ttest. I have the following snippet of code that demonstrates the problem while avoiding "real" code that takes an extremely long time to finish on R-devel: library(genefilter) data(eset) eset$cov1 z <- ttest(eset$cov1, p=0.01) gf <- filterfun(z) system.time(genefilter(eset, gf)) (this requires the genefilter & Biobase packages from Bioconductor) Using R-1.7.0p I had the following output: > data(eset) > eset$cov1 [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 >...
2005 Oct 05
1
Analyses of covariation with lme() or lm()
...better than m2. So far so good. Now I have one (1) measure from each Trial, of soil factors weather and such, that I want to evaluate. Remember: only one value of the covariate for each Trial. The suggestion I have got from my local guru is to base this in m1 like: m3 <- lme(Yield ~ Treat + Cov1 + Treat:Cov1, data=data, random =~1| Trial/Block) thus giving a model where the major random factor (Trial) is represented both as a (1) measure of Cov1 in the fixed part and by itself in the random part. Trying the simpler call: m4 <- lm(Yield ~ Treat + Cov1 + Treat:Cov1, data=...
2012 Jul 06
2
Anova Type II and Contrasts
the study design of the data I have to analyse is simple. There is 1 control group (CTRL) and 2 different treatment groups (TREAT_1 and TREAT_2). The data also includes 2 covariates COV1 and COV2. I have been asked to check if there is a linear or quadratic treatment effect in the data. I created a dummy data set to explain my situation: df1 <- data.frame( Observation = c(rep("CTRL",15), rep("TREAT_1",13), rep("TREAT_2", 12)), COV1 = c(rep(&...
2012 Apr 08
1
Avoid loop with the integrate function
...n 1:length(ed$ID)) { ed$base[k]<-100*exp(rnorm(1,0,0.05)) ed$drop[k]<-0.2*exp(rnorm(1,0,0.01)) ed$frac[k]<-0.5*exp(rnorm(1,0,0.1)) } comb1<-merge(data1[, c("ID","TIME")], ed) comb2<-comb1 comb2$score<-comb2$base*exp(-comb2$drop*comb2$TIME) func1<-function(t,cov1,beta1, change,other) { ifelse(t==0,cov1, cov1*exp(beta1*change+other)) } comb3<-comb2 comb3$cmhz=0 comb3<-comb3[order(comb3$ID, comb3$TIME), ] for (q in 1:length(comb3$ID)) { comb3$cmhz[q]<-integrate(func1, lower=0, upper=comb3$TIME[q], cov1=0.001,beta1=0.02, change=comb...
2008 Aug 18
1
lmer syntax, matrix of (grouped) covariates?
...covariates need to be nested hierarchically within a grouping "class", of which there are 8. I have an accessory vector, " cov2class" that specifies the mapping between covariates and the 8 classes. Now, I understand I can break all this information up into individual vectors (cov1, cov2, ..., cov211, class1, class2, ..., class8), and do something like this: model <- lmer(Y ~ 1 + cov1 + cov2 + ... + cov211 + (cov1 + cov2 + ... | class1) + (...) + (... + cov210 + cov211 | class8) But I'd like keep things syntactica...
2024 Oct 04
3
apply
Homework questions are not answered on this list. Best, Uwe Ligges On 04.10.2024 10:32, Steven Yen wrote: > The following line calculates standard deviations of a column vector: > > se<-apply(dd,1,sd) > > How can I calculate the covariance matrix using apply? Thanks. > > ______________________________________________ > R-help at r-project.org mailing list -- To
2005 Feb 23
1
How to conctruct an inner grouping for nlme random statement?
Hello. Im hoping someone can help with a grouping question related to the "random=" statement within the nlme function. How do you specify that some grouping levels are inner to others? I tried several things, given below. Lets say I have a data frame with five variables, resp, cov1, ran1, ran2, group1, and group 2. The formula is resp~cov1 + ran1 + ran2, where the ran are random variables. The data is of length 80, and there are 4 unique factors in group1 and 20 unique factors in group2. These are factors related to ran1 and ran2, respectively. The difficult part is tha...
2010 Jan 30
2
Questions on Mahalanobis Distance
...matrix (the third argument supplied to the mahalanobis funtion). Any help or guidance would be greatly appreciated. Thank you! RL CODE fit<-lda(pop~v1 + v2 + v3 +...+vn, data=my.data) x1<-subset(my.data, pop==1) x2<-subset(my.data, pop==2) #Save Covariance Matices for each group cov1<-cov(x1) cov2<-cov(x2) #Determine number of rows in each matrix n1<-nrow(x1); n2<-nrow(x2); n.rows<-c(n1,n2) #store mean vectors from lda object mu1<-fit$means[1,] mu2<-fit$means[2,] #Calculate the common Covariance Matrix S<-(((n.rows[1]-1)*cov1)+((n.rows[2]-1)*cov2...
2006 Jul 11
2
Multiple tests on 2 way-ANOVA
Dear r-helpers, I have a question about multiple testing. Here an example that puzzles me: All matrixes and contrast vectors are presented in treatment contrasts. 1. example: library(multcomp) n<-60; sigma<-20 # n = sample size per group # sigma standard deviation of the residuals cov1 <- matrix(c(3/4,-1/2,-1/2,-1/2,1,0,-1/2,0,1), nrow = 3, ncol=3, byrow=TRUE, dimnames = list(c("A", "B", "C"), c("C.1", "C.2", "C.3"))) # cov1 = variance covariance matrix of the beta coefficients of a # 2x2 factorial design (see Pian...
2024 Oct 04
1
apply
...te a covariance matrix but > wonder how I might replicate the results with "apply". I am not too > comfortable with the online documentation of "apply". > > > set.seed(122345671) > n<-3 > x<-rnorm(n); x [1] 0.92098449 0.80940115 > 0.60374785 > cov1<-outer(x-mean(x),x-mean(x))/(n-1); cov1 [,1] [,2] > [,3] [1,] 0.0102159207 0.00224105983 -0.0124569805 [2,] 0.0022410598 > 0.00049161983 -0.0027326797 [3,] -0.0124569805 -0.00273267965 > 0.0151896601 > cov2<-(x-mean(x))%*%t((x-mean(x)))/(n-1); cov2 [,1] > [,2] [,3] [1,] 0.0...
2024 Oct 04
1
apply
...you. I did the following: two ways to calculate a covariance matrix but wonder how I might replicate the results with "apply". I am not too comfortable with the online do of apply. > set.seed(122345671) > n<-3 > x<-rnorm(n); x [1] 0.92098449 0.80940115 0.60374785 > cov1<-outer(x-mean(x),x-mean(x))/(n-1); cov1 [,1] [,2] [,3] [1,] 0.0102159207 0.00224105983 -0.0124569805 [2,] 0.0022410598 0.00049161983 -0.0027326797 [3,] -0.0124569805 -0.00273267965 0.0151896601 > cov2<-(x-mean(x))%*%t((x-mean(x)))/(n-1); cov2 [,1] [,2] [,3] [1,] 0.0102159207 0.00224105...
2024 Oct 04
1
apply
...lowing: two ways to calculate a covariance matrix but >wonder how I might replicate the results with "apply". I am not too >comfortable with the online do of apply. > >> set.seed(122345671) > n<-3 > x<-rnorm(n); x [1] 0.92098449 0.80940115 >0.60374785 > cov1<-outer(x-mean(x),x-mean(x))/(n-1); cov1 [,1] [,2] [,3] >[1,] 0.0102159207 0.00224105983 -0.0124569805 [2,] 0.0022410598 >0.00049161983 -0.0027326797 [3,] -0.0124569805 -0.00273267965 >0.0151896601 > cov2<-(x-mean(x))%*%t((x-mean(x)))/(n-1); cov2 [,1] [,2] >[,3] [1,] 0.01021...
2006 Mar 11
2
Draw level lines on the surface of a bivariate function
...of them are, of course, visible even if they are drawn on a non visible "face". Any suggestion to avoid this problem ? Thank you Etienne Example : trans3d <- function(x,y,z, pmat) { tr <- cbind(x,y,z,1) %*% pmat list(x = tr[,1]/tr[,4], y= tr[,2]/tr[,4]) } mean1 = c(2,4) cov1 = matrix(c(0.7, 0.2,0.2,0.7), ncol=2) x = seq(0, 5, by = 0.1) y = seq(0,10, by= 0.1) z = matrix(nrow = length(x), ncol=length(y)) for(i in 1:length(x)) for(j in 1:length(y)) { z[i,j]=dmvnorm(c(x[i],y[j]),mean1,cov1) } pmat1 = persp(x, y, z, col= "red",shade = 0.25, border=NA)...
2009 May 22
0
EM algorithm mixture of multivariate
...s="blue", col.grid="lightblue",angle=120, pch=20) em2mn<- function(y) { n<-length(y[,1]) p<-matrix(0,n,1) f1<-matrix(0,n,1) f2<-matrix(0,n,1) tau<-matrix(0,n,2) eps<-0.0001 mu01<-c(0,0) mu02<-c(0,0) sd01<-matrix(0,2,2) sd02<-matrix(0,2,2) cov1<-matrix(0,2,2) cov2<-matrix(0,2,2) # 1 inizializzare i valori alpha0= runif(1,0,1) for (j in 1:2) { mu01[j] <- runif(1,min=quantile(y[,j], probs =0.25), max=quantile(y[,j], probs =0.75)) mu02[j] <- runif(1,min=quantile(y[,j], probs =0.25), max=quantile(y[,j], probs =0.75)) } sd01<-...
2009 May 22
0
EM algorithm mixture of multivariate gaussian
...s="blue", col.grid="lightblue",angle=120, pch=20) em2mn<- function(y) { n<-length(y[,1]) p<-matrix(0,n,1) f1<-matrix(0,n,1) f2<-matrix(0,n,1) tau<-matrix(0,n,2) eps<-0.0001 mu01<-c(0,0) mu02<-c(0,0) sd01<-matrix(0,2,2) sd02<-matrix(0,2,2) cov1<-matrix(0,2,2) cov2<-matrix(0,2,2) # 1 inizializzare i valori alpha0= runif(1,0,1) for (j in 1:2) { mu01[j] <- runif(1,min=quantile(y[,j], probs =0.25), max=quantile(y[,j], probs =0.75)) mu02[j] <- runif(1,min=quantile(y[,j], probs =0.25), max=quantile(y[,j], probs =0.75)) } sd01<-...
2024 Oct 04
1
apply
...matrix but >> wonder how I might replicate the results with "apply". I am not too >> comfortable with the online documentation of "apply". >> >>> set.seed(122345671) > n<-3 > x<-rnorm(n); x [1] 0.92098449 0.80940115 >> 0.60374785 > cov1<-outer(x-mean(x),x-mean(x))/(n-1); cov1 [,1] [,2] >> [,3] [1,] 0.0102159207 0.00224105983 -0.0124569805 [2,] 0.0022410598 >> 0.00049161983 -0.0027326797 [3,] -0.0124569805 -0.00273267965 >> 0.0151896601 > cov2<-(x-mean(x))%*%t((x-mean(x)))/(n-1); cov2 [,1] >> [,2] [...