search for: covar

Displaying 20 results from an estimated 76 matches for "covar".

2008 Feb 20
3
reshaping data frame
...a data frame. I tried with reshape{stats} and melt{reshape} but I was missing something. Any help is very welcome. Please find details below: ################################# # data in its original shape: indiv <- rep(c("A","B"),c(10,10)) level.1 <- rpois(20, lambda=3) covar.1 <- rlnorm(20, 3, 1) level.2 <- rpois(20, lambda=3) covar.2 <- rlnorm(20, 3, 1) my.dat <- data.frame(indiv,level.1,covar.1,level.2,covar.2) # the values of level.1 and level.2 represent the number of cases for the particular # combination of indiv*level*covar value # I would like to...
2010 Aug 11
4
Arbitrary number of covariates in a formula
...0,0,0,1,1,1)) and I can easily fit a cox model: library(survival) coxph(Surv(intx,status) ~ x1 + x2 + strata(sex),test1) However, I want to write my own function, fit the model inside this function and then do some further computations. f <- function(time, event, stratum, covar ) { fit <- coxph(Surv(time,event) ~ covar[[1]] + covar[[2]] + strata(stratum)) fit #... do some other stuff } attach(test1) f(intx, status, sex, list(x1,x2)) This works fine when I have exactly two covariates. However, I would like to have something that I can use with an arbitrary numb...
2010 May 24
2
Table to matrix
...[3,2] = A[3,3] = 0.5 otherwise, zero. Any suggestion will be greatly appreciated. Regrads, Kathryn Lord p.s. Here is R code. ------------------------------------------------------------------ > dat <- as.data.frame(matrix( c( 2, 1, 1, 3, 1, 1, 6, 1, 0, 5, 0, 0), 4, 3, byrow=T)) > covar <- apply(dat[,-1],1,paste,collapse='') > sp.dat <- split(dat,covar) > y.covar <- lapply(sp.dat, "[",1) > > prop <- function(prop) { table(prop)/sum(table(prop)) } > mass.func <- lapply(y.covar,prop) > mass.func $`00` prop 5 1 $`10` prop 6 1 $`11`...
2002 Jun 19
1
best selection of covariates (for each individual)
...ly R related (though I would implement the solution in R; besides, being this list so helpful for these kinds of stats questions...). I got a "strange" request from a colleage. He has a bunch (approx. 25000) subjects that belong to one of 12 possible classes. In addition, there are 8 covariates (factors) that can take as values either "absence" or "presence". Some of the subjects only have one covariate with value "presence" (the other covariates being absent), but many of the subjects have more than one covariate with a value of "presence"....
2006 Feb 20
1
var-covar matrices comparison:
Hi, Using package gclus in R, I have created some graphs that show the trends within subgroups of data and correlations among 9 variables (v1-v9). Being interested for more details on these data I have produced also the var-covar matrices. Question: From a pair of two subsets of data (with 9 variables each, I have two var-covar matrices for each subgroup, that differ for a treatment on one group (treatment A) vs (non-Treatment A). Is there a software that can compare if two var-covar matrices are statistically the same?...
2008 Dec 28
1
Random coefficients model with a covariate: coxme function
Dear R users: I'm new to R and am trying to fit a mixed model Cox regression model with coxme function. I have one two-level factor (treat) and one covariate (covar) and 32 different groups (centers). I'd like to fit a random coefficients model, with treat and covar as fixed factors and a random intercept, random treat effect and random covar slope per center. I haver a couple of doubts on how to use coxme function for this task: * Following...
2006 Feb 22
1
var-covar matrices comparison
...t; From: Aldi Kraja <aldi at wustl.edu> > > Hi, > Using package gclus in R, I have created some graphs that show the > trends within subgroups of data and correlations among 9 variables (v1-v9). > Being interested for more details on these data I have produced also the > var-covar matrices. > Question: From a pair of two subsets of data (with 9 variables each, I > have two var-covar matrices for each subgroup, that differ for a > treatment on one group (treatment A) vs (non-Treatment A). > > Is there a software that can compare if two var-covar matrices are &g...
2007 Apr 09
3
sem vs. LISREL: sem fails
...,.84,.82,.22,.22,.21, 0,0,0,0,1,.84,.19,.18,.19, 0,0,0,0,0,1,.18,.18,.18, 0,0,0,0,0,0,1,.84,.82, 0,0,0,0,0,0,0,1,.81, 0,0,0,0,0,0,0,0,1), 9, 9) ! Creating the ANXIETY, DEPRESSION, AND FEAR Standard Deviations vector (SD): SD<-c(1.5, 2.4, 3.2, 2.3, 2.3, 2.6, 4.5, 4.7, 5.6) ! Calculating the Var-Covar matrix based on correlations and SDs: library(MASS) COVAR<-outer(SD, SD) * KM ! Creating variable names rownames(COVAR)<-colnames(COVAR)<-c('a1','a2','a3','d1','d2','d3','f1','f2','f3') ! Specifying the measurement m...
2010 Jan 07
1
faster GLS code
Dear helpers, I wrote a code which estimates a multi-equation model with generalized least squares (GLS). I can use GLS because I know the covariance matrix of the residuals a priori. However, it is a bit slow and I wonder if anybody would be able to point out a way to make it faster (it is part of a bigger code and needs to run several times). Any suggestion would be greatly appreciated. Carlo *************************************** Ca...
2007 Apr 11
1
creating a path diagram in sem
...2,.2,.22, 0,0,0,1,.84,.82,.22,.22,.21, 0,0,0,0,1,.84,.19,.18,.19, 0,0,0,0,0,1,.18,.18,.18, 0,0,0,0,0,0,1,.84,.82, 0,0,0,0,0,0,0,1,.81, 0,0,0,0,0,0,0,0,1), 9, 9) # Creating the ANXIETY, DEPRESSION, AND FEAR SDs vector (SD) SD<-c(1.5, 2.4, 3.2, 2.3, 2.3, 2.6, 4.5, 4.7, 5.6) # Calculating the Var-Covar matrix based on correlations and SDs COVAR<-outer(SD, SD) * KM # Providing variable names rownames(COVAR)<-colnames(COVAR)<-c('a1','a2','a3','d1','d2','d3','f1','f2','f3') # Specifying the measurement model 1 model...
2005 Sep 27
1
Simulate phi-coefficient (correlation between dichotomous vars)
...creating two vectors of dichotomous variables with a known correlation (what I referred to as a phi-coefficient). My situation is a bit more complicated and I'm not sure it is easily solved. The problem is that I must assume one of the vectors is constant and generate one or more vectors that covary with the constant vector. In a continuous example I could use the following code that I got from the S-PLUS newsgroup year ago: sample.cor<-function (x, rho) { y <- (rho * (x - mean(x)))/sqrt(var(x)) + sqrt(1 - rho^2) * rnorm(length(x)) cat("Sample corr = ", cor...
2013 Mar 11
2
How to 'extend' a data.frame based on given variable combinations ?
Dear expeRts, I have a data.frame with certain covariate combinations ('group' and 'year') and corresponding values: set.seed(1) x <- data.frame(group = c(rep("A", 4), rep("B", 3)), year = c(2001, 2003, 2004, 2005, 2003, 2004, 2005), val...
2011 Aug 30
2
Error in evalauating a function
...But R returns a error `R Error in eval(expr, envir, enclos) : object 's' not found' when I run it. What am I doing wrong here? Here's what I got from the debug file. # Input data n <- 10 PHENO <- c( 1, 3, 2, 3, 1, 1, 1, 2, 1, 2 ) c <- c( 1, 1, 0, 0, 0, 0, 0, 1, 0, 0 ) COVAR <- matrix( c , nrow = n , byrow=T) CLUSTER <- c( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ) l <- 22 g <- c( 0, 1, 1, 0, 0, 0, 1, 0, 2, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 2, 0, 0, 0, 2, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, -1, -1, 1, 0, 0,...
2010 May 11
2
ANCOVA in R, single CoVar, two Variables
...o, either that or I am the only one doing something this simple. Could anyone please explain how to perform the analysis, I currently have the data in R in a data frame I have called anco. Thanks for any help. Tom -- View this message in context: http://r.789695.n4.nabble.com/ANCOVA-in-R-single-CoVar-two-Variables-tp2173850p2173850.html Sent from the R help mailing list archive at Nabble.com.
2011 Nov 23
0
Error using coeftest() with a heteroskedasticity-consistent estimation of the covar.
Hey I am trying to run /coeftest()/ using a heteroskedasticity-consistent estimation of the covariance matrix and i get this error: # packages >library(lmtest) >library(sandwich) #test > coeftest(*GSm_inc.pool*, vcov = vcovHC(*GSm_inc.pool*, method="arellano", > type="HC3")) /Fehler in 1 - diaghat : nicht-numerisches Argument f?r bin?ren Operator/ something lik...
2012 Mar 23
0
loops
...alculating the discriminant function. qda.res <- qda(type ~ npreg + glu + bp + skin + bmi + ped + age) ind_yes <- c(1:N)[type == "Yes"] > ind_no <- c(1:N)[type == "No"] > cov_yes <- cov(table[ind_yes, 1:7] ) > cov_no <- cov(table[ind_no, 1:7] ) > covar<-list(cov_no, cov_yes) qdf<- function(x, prior, mu, covar) + {x<- matrix(as.numeric(A[i,]), ncol=1) + log(prior) - (0.5%*%log(det(covar)))-0.5%*%(t(x-mu))%*%solve(covar)%*%(x-mu) } dfs<-rep(0,5) for (i in 1:N) { + {dfs[i]<-qdf(A[i,], qda.res$prior[1], qda.res$mean[1,], covar[[1]]...
2009 May 04
3
GEV para datos no estacionarios
Hola a todos, Soy nuevo en R y estoy intentando modelizar una serie de datos no estacionarios usand la distribucion Generalizada de Valores Extremos GEV. ¿Podriais indicarme como se modeliza una tendencia polinómica (cuadrática, por ejemplo) en alguno de los 3 parámetros (situación, escala o forma)? He encontrado documentación a cerca de modelización linear o exponencial, pero no acabo de
2012 Jul 26
2
coxph weirdness
Hi all, I cant' wrap my head around an error from the coxph function (package survival). Here's an example: library(survival) n = 100; set.seed(1); time = rexp(n); event = sample(c(0,1), n, replace = TRUE) covar = data.frame(z = rnorm(n)); model = coxph(Surv(time, event)~ . , data = covar) R gives the following error: > model = coxph(Surv(time, event)~ . , data = covar) Error in terms.formula(formula, specials = special) : '.' in formula and no 'data' argument I read through the he...
2012 Oct 04
1
geoRglm with factor variable as covariable
Dear R users. I'm trying to fit a generalised linear spatial mode using the geoRglm package. To do so, I'm preparing my data (geodata) as follow: geoData9093 = as.geodata(data9093, coords.col= 17:18, data.col=15,* covar.col=16*) where covar.col is a factor variable (years in this case 90-91-92-93)). Then I run the model as follow: / model.5 = list(cov.pars=c(1,1), cov.model='exponential', beta=1, family="poisson") mcmc.5 = mcmc.control(S.scale = 0.25, n.iter = 30000, burn.in=50000, thin = 100)...
2010 Jun 02
2
glmnet strange error message
Hello fellow R users, I have been getting a strange error message when using the cv.glmnet function in the glmnet package. I am attempting to fit a multinomial regression using the lasso. covars is a matrix with 80 rows and roughly 4000 columns, all the covariates are binary. resp is an eight level factor. I can fit the model with no errors but when I try to cross-validate after about 30 seconds I get the following: > glmnet.fit = glmnet(covars,resp,family="multinomial") &g...