similar to: store variables in a for loop using get()

Displaying 20 results from an estimated 50000 matches similar to: "store variables in a for loop using get()"

2008 Nov 10
1
question about contrast in R for multi-factor linear regression models?
Hi all, I am using "lm" to fit some anova factor models with interactions. The default setting for my unordered factors is "treatment". I understand the resultant "lm" coefficients for one factors, but when it comes to the interaction term, I got confused. > options()$contrasts unordered ordered "contr.treatment"
2009 Sep 15
1
coefficients of aov results has less number of elements?
Hi, I run the following commands. 'A' has 3 levels and 'B' has 4 levels. Should there be totally 3+4 = 7 coefficients (A1, A2, A3, B1, B2, B3, B4)? > a=3 > b=4 > n=1000 > A = rep(sapply(1:a,function(x){rep(x,n)}),b) > B = as.vector(sapply(sapply(1:b, function(x){rep(x,n)}), function(x){rep(x,a)})) > Y = A + B + rnorm(a*b*n) > > fr =
2010 Jul 07
3
How do I test against a simple null that two regressions coefficients are equal?
Hi there, I run two regressions: y = a1 + b1 * x + e1 y = a2 + b2 * z + e2 I want to test against the null hypothesis: b1 = b2. How do I design the test? I think I can add two equations together and divide both sides by 2: y = 0.5*(a1+a2) + 0.5*b1 * x + 0.5*b2 * z + e3, where e3 = 0.5*(e1 + e2). or just y = a3 + 0.5*b1 * x + 0.5*b2 * z + e3 If I run this new regression, I can test against
2003 Apr 22
4
fisher exact vs. simulated chi-square
Dear All, I have a problem understanding the difference between the outcome of a fisher exact test and a chi-square test (with simulated p.value). For some sample data (see below), fisher reports p=.02337. The normal chi-square test complains about "approximation may be incorrect", because there is a column with cells with very small values. I therefore tried the chi-square with
2011 Jun 12
1
Linear model - coefficients
Dear R Users, Using lm() function with categorical variable R use contrasts. Let assume that I have one X independent variable with 3-levels. Because R estimate only 2 parameters ( e.g. a1, a2) the coef function returns only 2 estimators. Is there any function or trick to get another a3 values. I know that using contrast sum (?contr.sum) I could compute a3 = -(a1+a2). But I have many independent
2011 Apr 12
2
Testing equality of coefficients in coxph model
Dear all, I'm running a coxph model of the form: coxph(Surv(Start, End, Death.ID) ~ x1 + x2 + a1 + a2 + a3) Within this model, I would like to compare the influence of x1 and x2 on the hazard rate. Specifically I am interested in testing whether the estimated coefficient for x1 is equal (or not) to the estimated coefficient for x2. I was thinking of using a Chow-test for this but the Chow
2009 Oct 06
1
linear model with coefficient constraints
I would like to perform a regression like the one below: lm(x ~ 0 + a1 + a2 + a3 + b1 + b2 + b3 + c1 + c2 + c3, data=data) However, the data has the property that a1+a2+a3 = A, b1+b2+b3 = B, and c1+c2+c3 = C, where A, B, and C are positive constants. So there are two extra degrees of freedom, and R handles this by producing NA for two of the coefficients. Instead, I would prefer to remove the
2009 Jan 11
4
How to get solution of following polynomial?
Hi, I want find all roots for the following polynomial : a <- c(-0.07, 0.17); b <- c(1, -4); cc <- matrix(c(0.24, 0.00, -0.08, -0.31), 2); d <- matrix(c(0, 0, -0.13, -0.37), 2); e <- matrix(c(0.2, 0, -0.06, -0.34), 2) A1 <- diag(2) + a %*% t(b) + cc; A2 <- -cc + d; A3 <- -d + e; A4 <- -e fn <- function(z) { y <- diag(2) - A1*z - A2*z^2 - A3*z^3 - A4*z^4
2004 Mar 16
2
glm questions --- saturated model
> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of David Firth > Sent: Tuesday, March 16, 2004 1:12 PM > To: Paul Johnson > Cc: r-help at r-project.org > Subject: Re: [R] glm questions > > > Dear Paul > > Here are some attempts at your questions. I hope it's of some help.
2008 Dec 15
3
R2winbugs : vectorization
I'm new to bugs, so please bear with me. Can someone tell me if the following two models are doing the same thing? The reason I ask is that with the same data, the first (based on 4 separate coeffs a1--a4) takes about 50 secs, while the second (based on a vectorized form, a[]) takes about 300. The means are about the same, though R-hat's in the second version are quite a bit better.
2007 Mar 09
1
Applying some equations over all unique combinations of 4 variables
#I have a data set that looks like this. A bit more complicated actually with # three factor levels but these calculations need to be done on one factor at a #I then have a set of different rates that are applied #to it. #dataset cata <- c( 1,1,6,1,1,2) catb <- c( 1,2,3,4,5,6) doga <- c(3,5,3,6,4, 0) data1 <- data.frame(cata, catb, doga) rm(cata,catb,doga) data1 # start rates #
2010 Jan 19
1
change codes into loops
Hi, See example. for (i in 1:2) { for (j in 1:3) { b_1[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[1] b_2[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[2] b_3[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[3] } } The inner codes is really repeated, so i want to change the inner codes into loops. Take nn is from 1 to 3, something like, for (nn in 1:3) {
2003 Nov 18
1
aov with Error and lme
Hi I searched in the list and only found questions without answers e.g. http://finzi.psych.upenn.edu/R/Rhelp02a/archive/19955.html : Is there a way to get the same results with lme as with aov with Error()? Can anybody reproduce the following results with lme: id<-c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5)
2005 Sep 08
1
Tip: I() can designate constants in a regression
Just thought I would share a tip I learned: The function I() is useful for specifying constants to formulas and regressions. It will prevent nls (for example) from trying to treat the variable inside I() as something it needs to estimate. An example is below. -David P.S. This may be obvious to some, but it is not made clear to be by the documentation or common books that I reviewed.
2011 Mar 05
2
Repeating the same calculation across multiple pairs of variables
Hi all, I frequently encounter datasets that require me to repeat the same calculation across many variables. For example, given a dataset with total employment variables and manufacturing employment variables for the years 1990-2010, I might have to calculate manufacturing's share of total employment in each year. I find it cumbersome to have to manually define a share for each year and
2011 Jul 05
3
plotting survival curves (multiple curves on single graph)
Hello. This is a follow-up to a question I posted last week. With some previous suggestions from the R-help community, I have been able to plot survival (, hazard, and density) curves using published data for Siler hazard parameters from a number of ethnographic populations. Can the function below be modified, perhaps with a "for" statement, so that multiple curves (different line
2001 Mar 02
1
apply on data.frame does not work properly (PR#859)
Full_Name: Dr. Sergei Zuyev Version: 1.1.0 and 1.2.2 OS: Solaris Submission from: (NULL) (130.159.248.36) apply on data.frame with floats, factors and NA's does not work properly. Here is an example: I am searching for rows containig NA values. X1 <- c(1, NA) X2<-c("A","B") df<-data.frame(X1,X2) apply(df,1,function(x){any(is.na(x))}) # gives # 1 2 # FALSE
2009 Apr 22
1
Gee with nested desgin
Dear all, Is it possible to incorporate a nested design in GEE? I have measurements on trees that where measured in two years. The trees are nested in plots. Each plot contains 24 trees. The number of plots is 72. Hence we would expect 2 * 24 * 72 = 3456 data points. A few are missing, so we end up wih 3431 data points. This is what I have tried until now. #assuming independence between trees
2011 Jul 04
1
placing multiple rows in a single row
Dear people from the R help list, I have a question that I can't get my head around to start answering, that is why I am writing to the list. I have data in a format like this (tabs might look weird): John A1 1 0 1 John A2 1 1 1 John A3 1 0 0 Mary A1 1 0 1 Mary A2 0 0 1 Mary A3 1 1 0 Peter A1 1
2009 Oct 29
3
Removing & generating data by category
Dear R users, Basically, from the following arbitrary data set: a <- data.frame(id=c(c("A1","A2","A3","A4","A5"),c("A3","A2","A3","A4","A5")),loc=c("B1","B2","B3","B4","B5"),clm=c(rep(("General"),6),rep("Life",4))) > a