Re: [R] Definition of t-value

2007-01-13 Thread Dimitrios Rizopoulos
try this Out - lm(A ~ data$B + data$C + data$D) summary(Out) moreover, by typing 'summary.lm' in your R console you may see how the t-values are computed; check also ?summary.lm. Another way, though less efficient, to obtain the standard errors is the following summ.Out - summary(Out) X -

Re: [R] The most common row in a matrix?

2006-11-19 Thread Dimitrios Rizopoulos
try this: mat - array(1:3, dim = c(4, 5)) # ind - table(apply(mat, 1, paste, collapse = /)) ind - which.max(ind) as.numeric(strsplit(names(ind), /)[[1]]) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic

Re: [R] Nominal Respose Model in R

2006-11-13 Thread Dimitrios Rizopoulos
AFAIK there exist functions to fit IRT models only for ordinal data. In particular, look at function grm() that fits the Graded Response Model in the 'ltm' package (using Marginal Maximum Likelihood), function PCM() in the 'eRm' package (using Condtional Maximum Likelihood), and function

Re: [R] Selective subsetting

2006-11-10 Thread Dimitrios Rizopoulos
try this: cor.mat - cor(iris[1:4]) cor.mat[lower.tri(cor.mat)] I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax:

Re: [R] Defining factors in GLM

2006-11-05 Thread Dimitrios Rizopoulos
look at ?factor ?formula ?data.frame I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web:

Re: [R] Recursive decreasing sequences

2006-10-20 Thread Dimitrios Rizopoulos
try this: start.val - 2 end.val - 6500 system.time(res - unlist(lapply(start.val:end.val, :, to = end.val))) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven,

Re: [R] multiline string continuation

2006-10-18 Thread Dimitrios Rizopoulos
maybe you're looking for: cat(datadir) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web:

Re: [R] Generating bivariate or multivariate data with known parameter values

2006-10-08 Thread Dimitrios Rizopoulos
you can do that using the copula package, e.g., library(copula) bivGamma - mvdc(claytonCopula(2), c(gamma, gamma), list(list(shape = 1, rate = 2), list(shape = 2, rate = 1))) dat - rmvdc(bivGamma, 1000) regarding correlation, the Clayton copula with alpha = 2 gives Kendall's tau =

Re: [R] GLM information matrix

2006-09-29 Thread Dimitrios Rizopoulos
look at summary.glm(), probably you're looking for fit - glm(..., family = binomial) # the inverse Fisher Information matrix summary(fit)$cov.scaled I hope it helps. Best, Dimitris -- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of

Re: [R] Exponentiate a matrix

2006-09-21 Thread Dimitrios Rizopoulos
Quoting Duncan Murdoch [EMAIL PROTECTED]: On 9/21/2006 10:40 AM, Doran, Harold wrote: Suppose I have a square matrix P P - matrix(c(.3,.7, .7, .3), ncol=2) I know that P * P Returns the element by element product, whereas P%*%P Returns the matrix product. Now, P^2 also returns

Re: [R] Exponentiate a matrix

2006-09-21 Thread Dimitrios Rizopoulos
Quoting Douglas Bates [EMAIL PROTECTED]: On 9/21/06, Dimitrios Rizopoulos [EMAIL PROTECTED] wrote: Quoting Duncan Murdoch [EMAIL PROTECTED]: On 9/21/2006 10:40 AM, Doran, Harold wrote: Suppose I have a square matrix P P - matrix(c(.3,.7, .7, .3), ncol=2) I know that P * P

Re: [R] help on data frame and matrix

2006-09-17 Thread Dimitrios Rizopoulos
look at ?data.matrix() Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/

Re: [R] variables in object names

2006-09-12 Thread Dimitrios Rizopoulos
you need something like the following, fit.lis - list(model1, model2, model3, model4, model5) # or if you have many models fit.lis - lapply(paste(model, 1:5, sep = ), get) sapply(fit.lis, function(x) summary(x)$r.squared) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student

Re: [R] rownumber

2006-09-10 Thread Dimitrios Rizopoulos
maybe the following is what you're looking for: lead.dat[!duplicate(rownames(lead.dat)), ] lead.dat[duplicate(rownames(lead.dat)), ] I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address:

Re: [R] Running wilcox.test function on two lists

2006-09-07 Thread Dimitrios Rizopoulos
try something like the following: lis1 - c(lapply(1:10, rnorm, n = 10)) lis2 - c(lapply(1:10, rnorm, n = 10)) lis1[[5]] - lis2[[8]] - numeric(0) ind - sapply(lis1, length) 0 sapply(lis2, length) 0 lis1 - lis1[ind] lis2 - lis2[ind]

Re: [R] get ylim of current plot()

2006-08-31 Thread Dimitrios Rizopoulos
I don't think you can obtain these values directly since plot.default() does not return something. 'ylim' is in fact calculated from xy.coords() as the range of the finite 'y' abscissa values; check the code of plot.default() for more info. I hope it helps. Best, Dimitris Dimitris

Re: [R] horizontal direct product

2006-08-25 Thread Dimitrios Rizopoulos
maybe something like: %*~% - function(x, y){ n - nrow(x) out - matrix(0, n, ncol(x) * ncol(y)) for(i in 1:n) out[i, ] - c(y[i, ] %o% x[i, ]) out } x - matrix(1:4, 2, 2, TRUE) y - matrix(5:8, 2, 2, TRUE) x %*~% y I hope it helps. Best, Dimitris Dimitris

Re: [R] how to the p-values or t-values from the lm's results

2006-08-20 Thread Dimitrios Rizopoulos
try the following: data - data.frame(matrix(rnorm(900), ncol = 9)) names(data) - c(y, paste(x, 1:8, sep = )) logr - lm(y ~ . - 1, data) a - summary(logr) coef(a) coef(a)[, 3:4] coef(a)[, t value] coef(a)[, Pr(|t|)] I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student

Re: [R] How to order or sort a data.frame

2006-08-14 Thread Dimitrios Rizopoulos
Quoting John Kane [EMAIL PROTECTED]: --- Dimitrios Rizopoulos [EMAIL PROTECTED] wrote: try the following: mdf - data.frame(us.state, count, year, month) mdf[order(mdf$year, mdf$month), ] Thansk to Dimitris and Dieter. This has helped since seems to have shown me a way around

Re: [R] How to order or sort a data.frame

2006-08-13 Thread Dimitrios Rizopoulos
try the following: mdf - data.frame(us.state, count, year, month) mdf[order(mdf$year, mdf$month), ] I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium

Re: [R] Unique rows

2006-08-09 Thread Dimitrios Rizopoulos
if you want the first row for the unique 'aa' entries, try the following: cc[!duplicated(cc$aa), ] I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium

Re: [R] locating intervals (corrected version)

2006-08-08 Thread Dimitrios Rizopoulos
?findInterval() could be of help in this case. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web:

Re: [R] workaround for numeric problems

2006-07-02 Thread Dimitrios Rizopoulos
I'd compute this in the log-scale (taking also advantage of the 'log' and 'log.p' arguments of dnorm() and pnorm(), respectively), and then transform back, e.g., fn1 - function(B){ -(pnorm(B) * dnorm(B) * B + dnorm(B)^2)/pnorm(B)^2 } fn2 - function(B){ p1 - dnorm(B, log = TRUE) +

Re: [R] how to recode in my dataset?

2006-07-02 Thread Dimitrios Rizopoulos
probably ?cut() is what you're looking for, e.g., something like: ind - cut(mydata$soiltem, seq(0, 60, 0.2), labels = FALSE) seq(0.1, 60, 0.2)[ind] I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of

Re: [R] Interpreting as.factor

2006-06-23 Thread Dimitrios Rizopoulos
probably you want to look at the help page of ?contr.treatment I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax:

Re: [R] about the analysis of strings, thanks

2006-06-18 Thread Dimitrios Rizopoulos
I'm not aware of package for amino acid sequence analysis, but it'd better to search yourself using, e.g., RSiteSearch() and help.search(). Regarding your question consider the following: strg1 - c(AAA, AA, ) strg2 - c(BBB, , BBB) strg - paste(strg1, strg2, sep = ) nA - nchar(gsub(B, ,

Re: [R] Vector Manipulation

2006-06-16 Thread Dimitrios Rizopoulos
try the following: x - c(B, F, N, Y) y - numeric(length(x)) y[x != N] - 1 y I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel:

Re: [R] select the last row by id group

2006-06-12 Thread Dimitrios Rizopoulos
one approach is the following: math - c(80, 75, 70, 65, 65, 70) reading - c(65, 70, 88, NA, 90, NA) id - c('001', '001', '001', '002', '003', '003') score - data.frame(id, reading, math) # ind - cumsum(tapply(score$id, score$id, length)) score[ind, ] I hope it helps. Best, Dimitris

Re: [R] How to call a value labels attribute?

2006-06-04 Thread Dimitrios Rizopoulos
maybe you could consider something like the following: varlabs - function(x){ if (is.null(names(x))) NULL else x[!duplicated(x)] } varlabs- - function(x, value){ names(x) - names(value[x]) x } ### x - c(1, 2, 3, 3, 2, 3, 1) x varlabs(x) varlabs(x) - c(apple=1, banana=2,

Re: [R] slanted ends of horizontal lines for certain line widths

2006-06-04 Thread Dimitrios Rizopoulos
probably you want to look at the `lend' argument of ?par, e.g., op - par(lend = 2) plot(c(1,2), c(1,1), xlim = c(0,3), lwd = 20, type = l) par(op) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven

Re: [R] evaluation of the alternative expression in ifelse

2006-06-04 Thread Dimitrios Rizopoulos
Quoting Renaud Lancelot [EMAIL PROTECTED]: Dear all, I am trying to avoid the warnings produced by: x - -2:2 log(x) [1] NaN NaN -Inf 0.000 0.6931472 Warning message: production de NaN in: log(x) I thought that using ifelse would be a solution, but it is not

Re: [R] Random number generation

2006-06-01 Thread Dimitrios Rizopoulos
according to ?.Random.seed, `Note' section, different R sessions give differen simulation results; maybe each time you start R you load a previously saved workspace, with an existing .Random.seed, i.e., check if the .Random.seed value is the same each time you start R. I hope it helps. Best,

Re: [R] Joining variables

2006-05-24 Thread Dimitrios Rizopoulos
look at ?paste(). Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/

Re: [R] conditional replacement

2006-05-23 Thread Dimitrios Rizopoulos
you could try something like: ifelse(df 30, 30, ifelse(df 60, 60, df)) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax:

Re: [R] intervals from cut() as numerics?

2006-05-20 Thread Dimitrios Rizopoulos
as an alternative, you can have a look inside cut.default and use the part that produces the breaks, i.e., breaks - 10 groups - cut(x, breaks = breaks) max.bias - as.vector(tapply(error, groups, mean)) # from cut.default() nb - as.integer(breaks + 1) dx - diff(rx - range(x, na.rm = TRUE))

Re: [R] extracting values from data.frame given arbitrary keys

2006-05-18 Thread Dimitrios Rizopoulos
maybe merge() is what you're looking for, e.g., dat - data.frame(x = rnorm(10), v1 = gl(5, 2), v2 = rep(1:2, 5)) ids - data.frame(v1 = c(2, 3, 4), v2 = c(1, 2, 1)) # dat merge(dat, ids) I hope it helps. Best, Dimitris -- Dimitris Rizopoulos Ph.D. Student

Re: [R] matrix transformation into 3 columns

2006-05-18 Thread Dimitrios Rizopoulos
probably ?reshape() could be used in this case; I hope it helps. Best, Dimitris -- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web:

Re: [R] Converting character strings to numeric

2006-05-18 Thread Dimitrios Rizopoulos
your code works for me, e.g., x1 - 1159 1129 1124 -5 -0.44 -1.52 x2 - c(1159, 1129, 1124, -5, -0.44, -1.52) x3 - unlist(strsplit(x1, )) all.equal(x2, x3) [1] TRUE as.numeric(x2) [1] 1159.00 1129.00 1124.00 -5.00 -0.44 -1.52 as.numeric(x3) [1] 1159.00 1129.00 1124.00

Re: [R] What does it mean to be masked from data when attaching? (Newbie question)

2006-05-13 Thread Dimitrios Rizopoulos
the problem you get comes from the fact that you attach the data.frame, e.g., it can be re-produced by: x1 - rnorm(30) dat - data.frame(x1 = rnorm(30)) attach(dat) look at ?attach for more details; you could consider with() as an alternative. I hope it helps. Best, Dimitris -- Dimitris

Re: [R] integer vector to a string

2006-05-10 Thread Dimitrios Rizopoulos
probably you need ?paste, e.g., paste(1:500, collapse = ,) I hope it helps. Best, Dimitris Quoting Søren Merser [EMAIL PROTECTED]: hi there is there a way that i can coerce a vector of integers to ONE string with the numbers comma separated like: 1:500 -1,2,3, ..., 500 i've