similar to: How to generate a distance matrix?

Displaying 20 results from an estimated 900 matches similar to: "How to generate a distance matrix?"

2006 Sep 18
1
Cochrans Q Test
Hi! I would like to conduct a Cochran`s Q Test in R, but have not found any suitable function. My first idea was: J <- as.table(matrix(c(6,16,2,4),ncol=2, dimnames = list("C" = c("Favorable","Unfavorable"),"Drug A Favorable"=c("B Favorable","B Unfavorable")))) L <- as.table(matrix(c(2,4,6,6),ncol=2, dimnames =
2011 Jan 11
1
glm specification where response is a 2col matrix
Hi, when I apply a glm() model in two ways, first with the response in a two column matrix specification with successes and failures y <- matrix(c( 5, 1, 3, 3, 2, 2, 0, 4), ncol=2, byrow=TRUE) X <- data.frame(x1 = factor(c(1,1,0,0)), x2 = factor(c(0,1,0,1))) glm(y ~ x1 + x2, data = X, family="binomial") second with a model matrix that
2011 Jun 07
2
Setting up a State Space Model in dlm
This question pertains to setting up a model in the package "dlm" (dynamic linear models, http://cran.r-project.org/web/packages/dlm/index.html I have read both the vignette and?"An R Package for Dynamic Linear Models" (http://www.jstatsoft.org/v36/i12/paper), both of which are very helpful. There is also some discussion at
2005 Nov 05
3
solve the quadratic equation ax^2+bx+c=0
If I have matrics as follows: > a <- c(1,1,0,0) > b <- c(4,4,0,0) > c <- c(3,5,5,6) How can I use R code to solve the equation ax^2+bx+c=0. thanks! yuying shi [[alternative HTML version deleted]]
2008 Jan 30
2
data.frame transformation
Dear all, maybe somebody can provide some help for this problem: Example: I've got the following dataframe "data": grid.id<-c(1:4) lat<-c(10,12,13,15) species1<-c(0,0,0,1) species2<-c(1,1,0,0) species3<-c(1,1,1,1) data<-data.frame(cbind(grid.id,lat,species1,species2,species3)) How can I, out of "data" make a new dataframe, where the cells of value
2009 Jun 10
1
how to get output from a nested loop
Dear all, I imagine that this is a trival question, but it has perplexed for most of the day. Any help would be greatly appreciated. Below is an example of what I'm trying to do. Essentially I want to produce all unique 1 x 1 combinations of certain columns from a dataframe, and join these to other columns from the same dataframe. I'm having problems with the nested loop as I can only
2008 Apr 15
2
glht with a glm using a Gamma distribution
Quick question about the usage of glht. I'm working with a data set from an experiment where the response is bounded at 0 whose variance increases with the mean, and is continuous. A Gamma error distribution with a log link seemed like the logical choice, and so I've modeled it as such. However, when I use glht to look for differences between groups, I get significant
2009 Dec 07
1
multiple plots using summary in rms package
Dear All, I wonder if someone can point me in the right direction here. I'm working with the rms library, R 2.9.2 under Windows XP. I'm trying to arrange two plots side by side for a colleague. mfrow or mfcol do not seem to work, however, so I am obviously missing something important. I know that there have been changes in the graphics from Design to rms, but am just not sure where to
2008 Aug 05
1
Fix for nls bug???
Hi All, I've hit a problem using nls. I think it may be a restriction in the applicability of nls and I may have found a fix, but I've been wrong before. This example is simplified to the essentials. My real application is much more complicated. Take a function of matrix 'x' with additional arguments: matrix 'aMat' whose values are _not_ to be determined by nls vector
2012 Mar 06
3
Label rows of table by factor level for groups of factors
Dear useRs, I am sure this is a fairly simple problem, but I just cannot get my head around it. I have a dataframe which contains several factor variables. I can use table() to tell me how many different combinations there are of these variables. What I should like to do is to add a column to my original dataframe which labels each row according to the unique combination of factors. E.g. in
2008 Jul 09
1
Question regarding lu in package Matrix
Dear R-helpers, I have a question regarding LU-decomposition with function lu in package Matrix. The following simple example confuses me: Why is as.matrix(elu$U) not an upper triangular matrix? u3 <- matrix(c(1,1,1,1,1,1,-1,1,0,0,0,0,0,-1,1,0,0,0,-1,0,1,0,0,0,0,0,-1,1,0,0),5,6,byrow=T) elu <- expand(lu(Matrix(u3,sparse=F))) as.matrix(elu$U) I only have very limited experience with the
2016 May 13
2
Division entre el numero de ocurrencias parciales y totalesdentro de un DataFrame de manera eficiente
Hola: Aplicaré lo que dices de usar data.table. Sobre hacer for, etc. Ya lo he hecho, pero pensaba que usar dplyr haría la tarea más rápida por estar este implementado en C (si no me equivoco). Siempre que puedo utilizo estas funciones, porque codificas menos y van más rápido. En este caso el problema es que no he encontrado la manera de hacer lo que quiero con dplyr o similar. La idea era al
2008 Sep 26
1
issue with varSel.svm.rfe in package MCRestimate
Hello all, I would like to perform SVM-RFE (Guyon et al. 2002) in R and have only found one implementation of this algorithm. The function belongs to the MCRestimate package but when I try to use it I encounter a problem - the function appears to be missing a required package or other function that I simply cannot find available anywhere. Here is my session info followed by a simple example
2016 May 12
2
Division entre el numero de ocurrencias parciales y totales dentro de un DataFrame de manera eficiente
Hola: A ver si me podéis ayudar que estoy atascado... Necesito contar los subcasos de la columna 2 de un dataframe respecto a los casos de la columna 1. Es decir, tengo un data.frame a<-c(rep(c('a','b','c','b','c'),3),'b') b<-c(rep(c('x','y','z','w'),4)) c<-c(rep(c(1,1,0,0),4))
2006 Aug 24
1
Optim question
This is a very basic question, but I am a bit confused with optim. I want to get the MLEs using optim which could replace the newton-raphson code I have below which also gives the MLEs. The function takes as input a vector x denoting whether a respondent answered an item correctly (x=1) or not (x=0). It also takes as input a vector b_vector, and these are parameters of test items (Rasch estimates
2007 Aug 23
0
weighted nls and confidence intervals
for unweighted fits using `nls' I compute confidence intervals for the fitted model function by using: #------------------- se.fit <- sqrt(apply(rr$m$gradient(), 1, function(x) sum(vcov(rr)*outer(x,x)))) luconf <- yfit + outer(se.fit, qnorm(c(probex, 1 - probex))) #------------------- where `rr' contains an `nls' object, `x' is the independent variable vector, `yfit'
2011 Mar 22
1
help need on working in subset within a dataframe
Dear R-experts Execuse me for an easy question, but I need help, sorry for that. >From days I have been working with a large dataset, where operations are needed within a component of dataset. Here is my question: I have big dataset where x1:.....x1000 or so. What I need to do is to work on 4 consequite variables to calculate a statistics and output. So far so good. There are more vector
2013 May 01
1
Combine multiple tables into one
Hi, May be this helps: dat1<- as.data.frame(table1) ?dat2<- as.data.frame(table2) names(dat2)<-c("V3","V4") library(plyr) res<-join(dat1,dat2,type="full") ?res[is.na(res)]<- 0 ?res #? V1 V2 V3 V4 #1? 1? 1? 0? 0 #2? 1? 2? 0? 0 #3? 0? 0? 0? 1 #4? 0? 0? 0? 4 ?combinedtable<-as.matrix(res) ?colnames(combinedtable)<- NULL ?combinedtable #???? [,1] [,2]
2007 Aug 31
0
non-linear fitting (nls) and confidence limits
dear list members, I apologize in advance for posting a second time, but probably after one week chances are, the first try went down the sink.. my question concerns computation of confidence intervals in nonlinear fits with `nls' when weigthing the fit. the seemingly correct procedure does not work as expected, as is detailed in my original post below. any remarks appreciated. greetings
2012 Jun 14
1
Question about sampling
Dear list I wish to extract from a population genotypized for 10 SNP a subsample of the same population of size n with similar allele frequencies. Essentially i have a matrix of 200 rows (df) like this Name,Condition,rs1385699_X,rs6625163_X,rs962458_X,Rs4658627_1, sample01,Case,1,1,1,-1 sample02,Control,1,1,1,1 sample06,Control,1,-1,1,0 sample10,Case,1,1,1,0 sample11,Control,1,1,1,1