I can run one-sample t-test on an array, for example a matrix myData1,
with the following
apply(myData1, 2, t.test)
Is there a similar fashion using apply() or something else to run
2-sample t-test with datasets from two groups, myData1 and myData2,
without looping?
TIA,
Gang
__
-sample
t-test. Is there a way I can achieve the same with mapply()?
Thanks again,
Gang
On Tue, Jan 6, 2009 at 12:34 PM, Henrique Dallazuanna wrote:
> I think that you can use mapply for this.
>
> On Tue, Jan 6, 2009 at 3:24 PM, Gang Chen wrote:
>>
>> I can run one-sample t-
; to test by column and
>
> mapply(t.test,as.data.frame(t(myData1)),as.data.frame(t(myData2)))
>
>
> to test by row?
>
>
> - Original Message
> From: Gang Chen
> To: Henrique Dallazuanna
> Cc: r-h...@stat.math.ethz.ch
> Sent: Tuesday, January 6, 2009 10
With the following example using contr.sum for both factors,
> dd <- data.frame(a = gl(3,4), b = gl(4,1,12)) # balanced 2-way
> model.matrix(~ a * b, dd, contrasts = list(a="contr.sum", b="contr.sum"))
(Intercept) a1 a2 b1 b2 b3 a1:b1 a2:b1 a1:b2 a2:b2 a1:b3 a2:b3
11 1 0 1
. Model validation is very important,
but interpreting those coefficients, at least in the case of balanced
designs, also provides some insights about various effects for the
people working in the field.
Gang
On Sun, Jan 25, 2009 at 11:25 AM, John Fox wrote:
> Dear Doug and Gang Chen,
>
Hi, I'm trying to set up AR(1) as a correlation structure in modeling some
data (attached file data.txt in text format) with lme, but have trouble
getting it to work.
Incent, Correctness, and Oppor are 3 categorical variables, Beta is a
response variable, and Time is an equally-spaced variable wit
Hi, I'm trying to set up AR(1) as a correlation structure in modeling some
data (attached file data.txt in text format) with lme, but have trouble
getting it to work.
Incent, Correctness, and Oppor are 3 categorical variables, Beta is a
response variable, and Time is an equally-spaced variable wit
Normally I can run an R script in batch mode with a command like this
R CMD BATCH MyScript.R MyOutput &
However I prefer to write another script containing something like
R --no-restore --save --no-readline < $1 >$2
so that I could run the original script simply on the prompt as
MyScript.R MyO
Suppose I have a 4-D array X with dimensions (dx, dy, dz, dp). I want
to collapse the first 3 dimensions of X to make a 2-D array Y with
dimensions (dx*dy*dz, dp). Instead of awkward looping, what is a good
way to do this? Is there a similar function like reshape in Matlab?
Thanks,
Gang
___
Thanks a lot for all the suggestions!
Gang
On Feb 28, 2008, at 3:20 PM, Henrique Dallazuanna wrote:
> Try this also:
>
> apply(x, 4, rbind)
>
> On 28/02/2008, Gang Chen <[EMAIL PROTECTED]> wrote:
>> Suppose I have a 4-D array X with dimensions (dx, dy, dz, dp). I wan
I have two arrays A and B with dimensions of (L, M, N, P) and (L, M,
N), and I want to do
for (i in 1:L) {
for (j in 1:M) {
for (k in 1:N) {
if (abs(B[i, j, k]) > 10e-5) C[i, j, k,] <- A[i, j, k,]/B[i, j, k]
else C[i, j, k,] <- 0
}
}
}
How can I get C more efficiently than looping?
Thanks
lazuanna wrote:
>>
>>> I think this should work:
>>>
>>> array(A[abs(B) > 10e-5]/B[abs(B) > 10e-5], dim=c(L, M, N, P))
>>>
>>> On 06/03/2008, Gang Chen <[EMAIL PROTECTED]> wrote:
>>>> I have two arrays A and B with dimensions o
I want to pass a predefined string ww ("fa*fb+fc") to function lme so
that I can run
> lme(y ~ fa*fb+fc, random = ~1|subj, model)
I've tried something like
> lme(y ~ paste(ww), random = ~1|subj, model)
and
> lme(y ~ sprintf(ww), random = ~1|subj, model)
but both give me the following
Yes, as.formula is the magic tool! Thanks a lot...
Gang
On Sep 19, 2007, at 2:00 PM, Vladimir Eremeev wrote:
>
> lme(as.formula(paste("y~",ww)),random=~1|subj,model)
>
>
> Gang Chen-3 wrote:
>>
>> I want to pass a predefined string ww ("fa*fb+fc")
Why does R CMD INSTALL work for some packages (e.g., lme4) but not
others (e.g., nlme)?
Thanks,
Gang
__
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-gu
fine:
> R CMD INSTALL lme4
Gang
On Oct 17, 2007, at 1:29 PM, Liviu Andronic wrote:
> On 10/17/07, Gang Chen <[EMAIL PROTECTED]> wrote:
>> Why does R CMD INSTALL work for some packages (e.g., lme4) but not
>> others (e.g., nlme)?
>
> If you don't provide any co
Hi Liviu,
Thank you very much for the response! I knew that would work within
R, but was just wondering why
> R CMD INSTALL nlme
does not work on the shell terminal. Any clue?
Thanks,
Gang
On Oct 17, 2007, at 6:27 PM, Liviu Andronic wrote:
> On 10/17/07, Gang Chen <[EMAIL
This is the command I want to execute with function contrast in
contrast package:
> contrast(MyObject, list(Trust="T"), list(Trust="U"));
As the two arguments with 'list' are defined as a string of
characters, contr:
> str(contr)
chr "list(Trust=\"T\"),list(Trust=\"U\")"
I would like to
Suppose I have a mixed-effects model where yij is the jth sample for
the ith subject:
yij= beta0 + beta1(age) + beta2(age^2) + beta3(age^3) + beta4(IQ) +
beta5(IQ^2) + beta6(age*IQ) + beta7(age^2*IQ) + beta8(age^3 *IQ)
+random intercepti + eij
In R how can I get an F test against the nu
This must be very simple, but I'm stuck. I have a command line in R
defined as a variable of a string of characters. How can I convert
the variable so that I can execute it in R?
Really appreciate any help,
Gang
__
R-help@r-project.org mailing list
into MyFunc to make it
executable?
Gang
On Oct 29, 2007, at 5:42 PM, jim holtman wrote:
> Can you provide an example of your input and what you expect the
> output to be. You can always use 'as.numeric'.
>
> On 10/29/07, Gang Chen <[EMAIL PROTECTED]> wrote:
>> This
>
> Of course this is yet another case where Lumley's principle (at
> least I
> think it's his) holds: if you have to use eval(parse(...)) rethink --
> there's a better way.
>
>
> Bert Gunter
> Genentech Nonclinical Statistics
>
>
> -Original
0', 'IQ:I
(age^3) = 0'))
Error in FUN(newX[, i], ...) :
`param' has no names and does not match number of coefficients of
model. Unable to construct coefficient vector
Thanks,
Gang
On Oct 30, 2007, at 9:08 AM, Dieter Menne wrote:
> Gang Chen mail.nih.gov> write
actly a partial F test. So does
it mean that this only tests the average effect of those 3 terms? If
so, that would be slightly different from the partial F test I was
looking for, no?
Gang
> -G
>
>
>
> On Oct 30, 2007, at 5:26PM , Gang Chen wrote:
>
>> Dieter,
>>
>
I want to create a list based on the information from a data.frame,
Model. So I tried the following:
MyList <- list(colnames(Model)[2] = levels(Model$(colnames(Model)[2])))
but it failed with an error:
Error: unexpected '=' in "list(colnames(Model)[2] ="
I have the following problems with th
I have trouble creating an array of lists? For example, I want to do
something like this
clist <- array(data=NA, dim=c(7, 2, 3));
for (n in 1:7) {
for (ii in 1:2) {
for (jj in 1:3) {
if (cc[n, ii, jj] == "0") { clist[n, ii, ][[jj]] <- list(levels
(MyModel[,colnames(M
eplacement, so to see what the alternatives are, can you give an
> explicit example of what you would like as an outcome and then how you
> intend to use it.
>
> On Nov 8, 2007 5:19 PM, Gang Chen <[EMAIL PROTECTED]> wrote:
>> Thanks for the response!
>>
>> I want to create
gt;
> On Nov 8, 2007 4:51 PM, Gang Chen <[EMAIL PROTECTED]> wrote:
>> I have trouble creating an array of lists? For example, I want to do
>> something like this
>>
>> clist <- array(data=NA, dim=c(7, 2, 3));
>> for (n in 1:7) {
>>for (ii in 1:2) {
>
cc[n, ii, jj]
> }
> names(sublist) <- names(MyModel)
> result[[n]][[ii]] <- sublist
> }
> }
> str(result) # see what it looks like
>
>
>
> On Nov 8, 2007 6:31 PM, Gang Chen <[EMAIL PROTECTED]> wrote:
>> Thanks again for th
Sorry to hijack this thread. I have a similar but slightly different
situation. Using the original poster's example, how to elegantly get
the mean of column V2 when column V1 is either A or C and F1 is 0?
Thanks,
Gang
On Nov 13, 2007, at 5:30 AM, Petr PIKAL wrote:
> Hi
>
> [EMAIL PROTECTED]
101 - 130 of 130 matches
Mail list logo