similar to: Repeat a loop until...

Displaying 20 results from an estimated 700 matches similar to: "Repeat a loop until..."

2011 Feb 09
2
Generate multivariate normal data with a random correlation matrix
Hi All. I'd like to generate a sample of n observations from a k dimensional multivariate normal distribution with a random correlation matrix. My solution: The lower (or upper) triangle of the correlation matrix has n.tri=(d/2)(d+1)-d entries. Take a uniform sample of n.tri possible correlations (runi(n.tr,-.99,.99) Populate a triangle of the matrix with the sampled correlations Mirror the
2008 Sep 21
1
Calculating interval for conditional/unconditional correlation matrix
Hi there, Could anyone please help me to understand what should be done in order not to get this error message: Error: evaluation nested too deeply: infinite recursion / options(expressions=)? Here is my code: determinant<- function(x){det(matrix(c(1.0,0.2,0.5,0.8,0.2,1.0,0.5,0.6,0.5,0.5,0.5,1.0,x,0.8,0.6,x,1.0),ncol=4,byrow=T))} matrix<-
2011 Oct 25
1
regression using GMM for mulltiple groups
Inthe code below I was trying to to obtain the GMM estimates for CAPM (REGRESSION) for 36 stocks each have 180 observations,however it only gives me one output rather than 36. In SAS i would just put in a *By statement*. I have a variable TICKER that categorize them into 36 groups. *How can I obtain all 36 output instead of just one.* **
2010 Feb 16
1
Math.factor error message
Dear R-helpers, I am using a vrtest on time series data. My commands are as follows; read.table("B.txt",sep="\t",fill=TRUE, na.strings = "NA") require(vrtest) rm(list=ls(all=TRUE)) datamat <- read.table("B.txt",sep="\t",fill=TRUE, na.strings = "NA") column <- 1 nob <- nrow(datamat) y <-
2009 Aug 20
1
Understanding R code
What is 1. par.ests <- optimfit$par 2. fisher <- hessb(negloglik, par.ests, maxvalue=maxima); 3. varcov <- solve(fisher); 4. par.ses <- sqrt(diag(varcov)); Thanks a lot, fit.GEV <- function(maxima) { sigma0 <- sqrt((6. * var(maxima))/pi) mu0 <- mean(maxima) - 0.57722 * sigma0 xi0 <- 0.1 theta <- c(xi0, mu0, sigma0) #10/5/2007: removed assign() for maxima.nl
2003 Jan 29
3
multinomial conditional logit models
A multinomial logit model can be specified as a conditional logit model after restructuring the data. Doing so gives flexibility in imposing restrictions on the dependent variable. One application is to specify a loglinear model for square tables, e.g. quasi-symmetry or quasi-independence, as a multinomial logit model with covariates. Further details on this technique and examples with several
2011 May 05
1
matrix not positive definite (while it should be)
I do have some trouble with matrices. I want to build up a covariance matrix with a hierarchical structure). For instance, in dimension n=10, I have two subgroups (called REGION). NR=2; n=10 CORRELATION=matrix(c(0.4,-0.25, -0.25,0.3),NR,NR) REGION=sample(1:NR,size=n,replace=TRUE) R1=REGION%*%t(rep(1,n)) R2=rep(1,n)%*%t(REGION) SIGMA=matrix(NA,n,n) for(i in 1:NR){ for(j in
2009 Sep 14
2
Function "Varcov" in Design (Ver. 2.2-0) package
Hi, I'm running into an error message for the "anova"-function I never got before with the Design (Version 2.2-0) package. There seems to be a missing function "Varcov", please check my function calls (it's in german but I think you get the error): > library(Design) ## attaching Design package and dependent packages Lade n?tiges Paket: Hmisc ## loading
2009 May 09
2
Sweave \Sexpr{} advice please
Dear List, First off, my deepest gratitude to the Sweave developers: this tool has improved my quality greatly. A question in my work I use \Sexpr{} statements scalar values and the xtable package for all manner of tables. What I'd like to do is to use a vector inline, rather than a whole separate table. Something like: %%%%%%%%%%%%%%%% begin code % Latex junk % Sweave block:
2003 Jul 27
1
multiple imputation with fit.mult.impute in Hmisc
I have always avoided missing data by keeping my distance from the real world. But I have a student who is doing a study of real patients. We're trying to test regression models using multiple imputation. We did the following (roughly): f <- aregImpute(~ [list of 32 variables, separated by + signs], n.impute=20, defaultLinear=T, data=t1) # I read that 20 is better than the default of
2007 Feb 06
3
How-To construct a cov list to use a covariance matrix in factanal?
Hi, I have a set of covariance matrices but not the original data. I want to carry out some exploratory factor analysis. So, I am trying to construct a covariance matrix list as the input for factanal. I can construct a list which includes the cov, the centers, and the n.obs. But it doesn't work. I get an error that says "Error in sqrt(diag(cv)) : Non-numeric argument to mathematical
2011 Jun 27
1
Hardy Weinberg Simulation
Hello, I am trying to simulate 10 relicates of 100-tables. Each table is a 2 x 3 and 80% pf the tables are true nulls and 20% are non-nulls. The nulls follow the Hardy Weinberg distribution (ratio) 1:2:1. I have the code below but the p-values are not what I am expecting. I want to use the Cochran Armitage trend test to get the p-values. num.reps=10 num.vars=1000 pi0 = 80 num.subjects = 100
2008 Oct 09
2
vectorization instead of using loop
Dear all, I've sent this question 2 days ago and got response from Sarah. Thanks for that. But unfortunately, it did not really solve our problem. The main issue is that we want to use our own (manipulated) covariance matrix in the calculation of the mahalanobis distance. Does anyone know how to vectorize the below code instead of using a loop (which slows it down)? I'd really appreciate
2009 Oct 14
1
using mapply to avoid loops
Hello, I would like to use mapply to avoid using a loop but for some reason, I can't seem to get it to work. I've included copies of my code below. The first set of code uses a loop (and it works fine), and the second set of code attempts to use mapply but I get a "subscript out of bounds" error. Any guidance would be greatly appreciated. Xj, Yj, and Wj are also lists, and s2,
2008 Oct 02
3
Adding plane in a 3D scatterplot
I have drawn a 3D scatter plot : library(mnormt) library(scatterplot3d) dat = cbind(rmnorm(3, rep(0,2), diag(2)), 1:3) scatterplot3d(dat) Now I want to do 2 things : 1 : In the Z-axis (i.e. height), I want to see only numbers 1,2,3, etc NOT, 1,1.5,2,2.5............. 2. I want to add two Horizontal planes at hight z=2 and z=3. Those two planes should look like "bottom" of that 3D plot
2003 Aug 08
1
covmat argument in princomp() (PR#3682)
R version: 1.7.1 OS: Red Hat Linux 7.2 When "covmat" is supplied in princomp(), the output value "center" is all NA's, even though the input matrix was indeed centered. I haven't read anything about this in the help file for princomp(). See code below for an example: pc2$center is all NA's. Jerome Asselin x <- rnorm(6) y <- rnorm(6) X <- cbind(x,y)
2010 May 10
2
Warning message
Hello, I want to draw a histogram of the mean of sample observations drawn from multivariate t distribution. I am getting the following error corresponding to the code I used. Though I am getting the graph, but I am curious to know the warning message. Warning messages: 1: In if (freq) x$counts else { : the condition has length > 1 and only the first element will be used 2: In if (!freq)
2008 Sep 09
1
Addendum to wishlist bug report #10931 (factanal) (PR#12754)
--=-hiYzUeWcRJ/+kx41aPIZ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Hi, on March 10 I filed a wishlist bug report asking for the inclusion of some changes to factanal() and the associated print method. The changes were originally proposed by John Fox in 2005; they make print.factanal() display factor correlations if factanal() is called with rotation =
2002 Jun 21
1
naming things in functions
Hello, I'm working with R version 1.5.0 in Windows. I've written a function (SummaryMat, segment below) which uses a loop to repeatedly call another function (PercentsMat, segment below). PercentsMat creates a matrix and adds rows to it each time it is called. I use deparse(substitute(...)) to get the names of the lists sent to PercentsMat to use them as row names in the generated
2009 Jan 30
1
Factor Analysis-factanal function
Dear friends, I'm using R to produce the following Factor Analysis: > matriz.cor<-hetcor(matrix(as.factor(data), ncol=variables, byrow=T))$correlations > factanal(x=data, factors=2, covmat=matriz.cor, scores='regression') Then the screen output shows the following message: Error en factanal(x = data, factors = 2, covmat = matrix, : requested scores without