[R] expand.grip for permutations

2012-10-31 Thread trekvana
if i were to have a block size of 4 people and i want to assign a treatment
combination to the entire block, there would be 16 different treatment
combinations (, TTTP, TTPP, PTTP, etc.)

i am trying to get all 16 permutations and i am able to use this code below.

drugs=c('P','T');
comb=expand.grid(drugs,drugs,drugs,drugs)

for a block size of 3 the code would be comb=expand.grid(drugs,drugs,drugs)
and for a block size of 2 it would be comb=expand.grid(drugs,drugs).

my question is whether there is a way to automatically create the comb
variable. i tried using expand.grid(rep(drugs, block.size) but that didn't
work.

any help on how i can proceed? thanks



--
View this message in context: 
http://r.789695.n4.nabble.com/expand-grip-for-permutations-tp4648067.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] expand.grip for permutations

2012-10-31 Thread trekvana
thank you both! that worked!



--
View this message in context: 
http://r.789695.n4.nabble.com/expand-grip-for-permutations-tp4648067p4648076.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How make a x,y dataset from a formula based entry

2011-09-22 Thread trekvana
Hello all, 

So I am using the (formula entry) method for randomForests:

randomForest(y~x1+x2+...+x39+x40,data=xxx,...) but the issue is that some of
the items in that package dont take a formula entry - you have to explicitly
state the y and x vector:

randomForest(x=xxx[,c('x1','x2',...,'x40')],y=xxx[,'y'],...)

Now my question is whether there is a function/way to tell R to take a
formula and make the two corresponding datasets [x,y] (that way I dont have
to create the x dataset manually with all 40 variables I have).

There must be a more elegant way to do this than
x=xxx[,c('x1','x2',...,'x40')] 

Thanks!
George

--
View this message in context: 
http://r.789695.n4.nabble.com/How-make-a-x-y-dataset-from-a-formula-based-entry-tp3834477p3834477.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Question about plot.mona {cluster}

2011-09-09 Thread trekvana
Hello all, I what to print the banner plot that is output from the mona
method in the cluster package but the problem is I dont want to print all
that red ink. Here is an example:

data(animals)
ma - mona(animals)
ma
## Plot similar to Figure 10 in Struyf et al (1996)
plot(ma)

I can change the bar color by using the argument col=c(0,0) -
plot(ma,col=c(0,0)) - but then the variable labels also get colored white.
Is there a way to remove the bar colors but leave the variables colored?

Thank you
George Skountrianos

--
View this message in context: 
http://r.789695.n4.nabble.com/Question-about-plot-mona-cluster-tp3802672p3802672.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to check conditional dependence

2010-09-18 Thread trekvana

Hello all-

Lets say I have my dependent variable Y_ij and a time varying covariate
X_ij. I want to formulate some regression model to check if X_ij is
dependent on X_i1,X_i2,,X_i(j-1) and Y_i1,Y_i2,,Y_i(j-1). I want to
test no dependence on the Y component.

I'm thinking a simple linear regression of X_i2,...,X_ij on
X_i1,...,X_i(j-1) and Y_i1,...,Y_i(j-1) with NO intercept term using the
lm() function should do it. Then I can look at the regression coefficient of
Y to test for no dependence on Y. Does this make sense or is there a
better/correct way to do this?

Thanks
George
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-check-conditional-dependence-tp2545533p2545533.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Pesky homemade function code

2010-09-16 Thread trekvana

Hi all-

this seems to be simple to figure out but since im new to writing functions
I dont know what is happening. Here is my code along with the error I am
receiving:

semivario=function(data,ids,times,resids){
id=unique(data$ids)
index=combinations(length(data$times[data$ids==id[1]]),2)
time=gamma=numeric(dim(index)[1])
for (j in 1:dim(index)[1]){

time[j]=abs(data$times[data$ids==id[1]][index[j,1]]-data$times[data$ids==id[1]][index[j,2]])

gamma[j]=.5*(data$resids[data$ids==id[1]][index[j,1]]-data$resids[data$ids==id[1]][index[j,2]])^2
}

for (i in id[-1]){
index=combinations(length(data$times[data$ids==i]),2)
time1=gamma1=numeric(dim(index)[1])
for (j in 1:dim(index)[1]){

time1[j]=abs(data$times[data$ids==i][index[j,1]]-data$times[data$ids==i][index[j,2]])

gamma1[j]=.5*(data$resids[data$ids==i][index[j,1]]-data$resids[data$ids==i][index[j,2]])^2
}
time=c(time,time1)
gamma=c(gamma,gamma1)
}
value=list(time=time,gamma=gamma)
return(value)
}

and I would run it as
semivario(data=hope,ids=id,times=sctime,resids=scResid)

What I want to do is everywhere we see the words data,ids,times,resids to be
replaced with, for example, hope,id,sctime,scResid. Think of macros in SAS
where we use the  before every macro input variable name. Im not sure if
this is how R handles function inputs.

Here is my error:
Error in combinations(length(data$times[data$ids == id[1]]), 2) : 
  bad value of n


Thanks

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Pesky-homemade-function-code-tp2541597p2541597.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Pesky homemade function code

2010-09-16 Thread trekvana

@Thierry-

I am writing my own semivariogram code since I could not find a pre-made
function that did what I need it do. The code in the function correctly
works but I not sure how to get the function itself to work. In other words
if I fill in the commands (hope,id,sctime,scResid) by hand then everything
is ok -- but I dont want to do that. 

Plus this will help be better understand how to program functions in R. 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Pesky-homemade-function-code-tp2541597p2541696.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] SAS to R

2010-07-12 Thread trekvana

Hi everyone I dont know how to code in SAS but I do know how to code in R.
Can someone please be kind enough to translate this into R code for me:

proc mixed data = small method = reml;
 class id day;
 model weight = day/ solution ddfm = bw;
 repeated day/ subject=id type = unstructured;
run;

===

so far i think it is
gls(weight~day,corr=corSymm(???),method=REML,data=small)

my main problem is I dont know how to get the unstructured covariance matrix
to work

Thank you
-- 
View this message in context: 
http://r.789695.n4.nabble.com/SAS-to-R-tp2286695p2286695.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] modify the make.link function GLM

2010-05-08 Thread trekvana

can someone please tell me how modify the make.link function

i want to update the function with this code but every time i save it R
never keeps my new version. i have tried to unbind first and then assign. i
also tried the fixInNamespace but that doesnt work either. can someone
please tell me how i can append this to the make.link file for good?

thank you

}, loglog = {
 linkfun - function(mu) -log(-log(mu))
 linkinv - function(eta) exp(-exp(-eta))
 mu.eta - function(eta) exp(-exp(-eta)-eta)
 valideta - function(eta) all(eta != 0)
 }, stop(sQuote(link),  link not recognised))
 structure(list(linkfun = linkfun, linkinv = linkinv, mu.eta = mu.eta,
 valideta = valideta, name = link), class = link-glm)
} 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/modify-the-make-link-function-GLM-tp2135906p2135906.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] glm binomial loglog (NOT cloglog) link

2010-05-08 Thread trekvana

can you please say specifically how to modify the make.link function
-- 
View this message in context: 
http://r.789695.n4.nabble.com/glm-binomial-loglog-NOT-cloglog-link-tp849370p2135909.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.