search for: xvec

Displaying 16 results from an estimated 16 matches for "xvec".

Did you mean: vec
2007 Sep 04
3
how to do interpolation
Hello R Users, How to make a variable equidistance with time i.e. how to interpolate a variable if it is not sampled at equal time interval. Many thanks, Regards, Yogesh [[alternative HTML version deleted]]
2007 Dec 09
1
buglet in curve?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Symptoms: curve with log x axis gets the wrong x limits (in 2.6.1, I believe introduced in this version). Credit goes to Mike McCoy for detecting the problem. Demonstration: x = 1:5 plot(x,5*exp(-x),xlim=c(0.1,1000),log="x") xvec = 10^seq(-1,3,length=100) lines(xvec,5*exp(-xvec)) curve(5*exp(-x),add=TRUE,col=2,lwd=3) I believe the problem arises from this fix: o curve() with unspecified 'from', 'to' and 'xlim' now reuses the previous x limits, and not slightly larger ones. and I believe...
2007 May 12
1
Area() artefacts??
...ow me how to use integrate in this particular code? THanks in advance! #Computes the p.m.f. via (10.53) of the number of i.i.d. Ber(p) trials #required until m consecutive successes occur. #Requires MASS package #==========================================================# consecpmf <- function(xvec, m, p, eps=1e-05){ library(MASS) f<-numeric() for(j in seq(xvec)){ x <- xvec[j] f[j] <- area(fun, -pi, pi, limit=1000, eps=eps, x, m, p) } f<-Re(f) round(f,4) } fun <- function(t,x,m,p){ I <- exp(-1i*t*x)*cf(t,m,p)/(2*pi) I } cf <- function(t,m,p){ q <- 1-p if(m==1) {g &...
2009 Mar 25
1
Piecewise
Hi, I am a biologist (relatively new to R) analyzing data which we predict to fit a power function. I was wondering if anyone knew a way to model piecewise functions in R, where across a range of values (0-x) the data is modeled as a power function, and across another range (x-inf) it is a linear function. This would be predicted by one of our hypotheses, and we would like to find the AICs
2011 May 02
2
easy way to do a 2-D fit to an array of data?
...he row, column numbers). Is there an R function that lets me easily implement that? I've started down the path of something like zvec <- as.vector(Z), and creating applicable x,y vectors by something like (where for the sake of argument Z is 128x128) foo<-matrix(seq(1,128),128,128) xvec <- as.vector(foo) yvec <- as.vector(t(foo)) at which point I can feed zvec, xvec, yvec to lm() . I'm hopeful someone can point me to a much easier way to do the same thing. Oh, and if there's a 2-D splinefunction generator, that would work for me as well. thanks Carl
2006 Oct 27
2
Multivariate regression
...the covariance structure of Y within each unit - this would be represented by a specified matrix V (k x k), assumed to be the same across units. How do I use "lm" to do this? One approach that I was thinking of is as follows: Flatten Y to a vector, say, Yvec (n*k x 1). Create Xvec (n*k, p*k) such that it is made up of block matrices Bij (k x k), where Bij is a diagonal matrix with X_ij as the diagonal (i = 1,.n, and j = 1,.,p). Now I can use "lm" in a univariate mode to regress Yvec against Xvec, with covariance matrix Vvec (n*k x n*k). Vvec is a block-diagonal m...
2000 Jan 19
1
Segmentation fault using integrate()
Hi all, Running R 0.90.1 on a RH 6.1 system. Installation of the integrate_2.1-2 package went smoothly. My code contains a loop in which integrate() is called several times in each pass. I get a segmentation fault after what seems to be a random number of calls to integrate(). Debug output shows: Program received signal SIGSEGV, Segmentation fault. promiseArgs (el=0x40276414,
2007 Jul 24
1
How to add circular text for a graph with concentric circles
Dear R experts, I am plotting the population of students who live in a city, and in successive circular bands made of the contiguous districts that surround the city. This is a stylized figure, where I specify the area of each successive circle based on the cumulative population of students. I want to compare two sets of concentric circles across different populations - such as 'All
2012 Feb 09
2
Lattice 3d coordinate transformation
...(ll) ll$level)))) for (i in 2:length(clines)) { ll <- clines[[i]] ll0 <- clines[[i-1]] m <- ltransform3dto3d(rbind(ll$x-.5, ll$y-.5, zlim.scaled[1]), rot.mat, distance) m0 <- ltransform3dto3d(rbind(ll0$x-.5, ll0$y-.5, zlim.scaled[1]), rot.mat, distance) xvec <- c(m0[1,],m[1,ncol(m):1]) yvec <- c(m0[2,],m[2,ncol(m):1]) panel.polygon(xvec,yvec,col=colreg[ll$level],border='transparent') panel.lines(m[1,], m[2,], col = add.line$col, lty = add.line$lty, lwd = add.line$lwd) } panel.3dscatter(x, y, z,...
2008 Nov 20
1
binomial glm???
Hi everyone, newbee query! I've installed R 2.8.0 and tried to run this simple glm - x is no of cars in a given year, y is the number voted in an election that year while n is the population 18+: votes <- data.frame(x = c(0.62,0.77,0.71,0.74,0.77,0.86,1.13,1.44), + y=c(502,542,711,653,771,806,934,1123), n=
2004 Sep 14
0
overwriting a line in existing .csv file with new data
Dear R-users, I have a data matrix with 20 rows and 10 columns which is stored in the hard drive as .csv file called c:\DataFile.csv and a 10 elements vector called xVec. I would like to be able to copy and paste the information contained in xVec into (say) the 2nd row of DataFile.csv Obviously, one way of doing this would be to read the matrix using read.csv() command, implement the copy and paste manipulation and save the new matrix again using write.table(). H...
2012 Jun 09
0
-lgsl -lgslcblas fatal error no such file or directory
...value c:/R/GSL_test2/lib/ GSL_INC, value c:/R/GSL_test2/inc/ The source C code is #include <stdio.h> #include <math.h> #include <stdlib.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> #include <R.h> void gibbsGSL(int *Np,int *thinp,int *seedp,double *xvec,double *yvec) { int i,j; int N=*Np,thin=*thinp,seed=*seedp; gsl_rng *r = gsl_rng_alloc(gsl_rng_mt19937); gsl_rng_set(r,seed); double x=0; double y=0; for (i=0;i<N;i++) { for (j=0;j<thin;j++) { x=gsl_ran_gamma(r,3.0,1.0/(y*y+4)); y=1....
2012 Jun 16
0
R CMD -lgsl -lgslcblas *.c returns a fatal error: gsl/gsl_rng.h no such file or directory exists
.../GSL_test2/lib/ GSL_INC, value c:/R/GSL_test2/inc/ The failing C source code is #include <stdio.h> #include <math.h> #include <stdlib.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> #include <R.h> void gibbsGSL(int *Np,int *thinp,int *seedp,double *xvec,double *yvec) { int i,j; int N=*Np,thin=*thinp,seed=*seedp; gsl_rng *r = gsl_rng_alloc(gsl_rng_mt19937); gsl_rng_set(r,seed); double x=0; double y=0; for (i=0;i<N;i++) { for (j=0;j<thin;j++) { x=gsl_ran_gamma(r,3.0,1.0/(y*y+4));...
2009 Mar 29
4
Constrined dependent optimization.
I have an optimization question that I was hoping to get some suggestions on how best to go about sovling it. I would think there is probably a package that addresses this problem. This is an ordering optimzation problem. Best to describe it with a simple example. Say I have 100 "bins" each with a ball in it numbered from 1 to 100. Each bin can only hold one ball. This optimization is
2011 Feb 06
5
Help with integrating R and c/c++
Hi, I have been using R for close to two years now and have grown quite comfortable with the language. I am presently trying to implement an optimization routine in R (Newton Rhapson). I have some R functions that calculate the gradient and hessian (pre requisite matrices) fairly efficiently. Now, I have to call this function iteratively until some convergance criterion is reached. I think the
2009 Apr 01
0
回复: R-help Digest, Vol 73, Issue 32
...> Thank you. > > Kevin   If you look more closely at the docs for method="SANN" (and the examples), you'll see that SANN allows you to pass the "gradient" argument (gr) as a custom function to provide the candidate distribution.  Here's an example: N <- 10 xvec <- seq(0,1,length=N) target <- rank((xvec-0.2)^2) objfun <- function(x) {   sum((x-target)^2)/1e6 } objfun(1:100) swapfun <- function(x,N=10) {   loc <- sample(N,size=2,replace=FALSE)   tmp <- x[loc[1]]   x[loc[1]] <- x[loc[2]]   x[loc[2]] <- tmp   x } set.seed(1001) opt...