search for: 2x1

Displaying 20 results from an estimated 35 matches for "2x1".

Did you mean: 21
2004 Sep 25
2
making custom function compute/return multiple items
Hello, I'm relatively new to R. I've read the intro guide, but I can't quite figure out how to: I have a function: Jcost <- function (theta, in, out) { a <- output - input %*% theta 1/2 * t(a) %*% a } where "theta" is a 2x1 matrix "in" is a 20x2 matrix "out" is a 20x1 matrix return value is a scaler This works well when I only want to compute given 1 theta matrix. How do I compute several (say N) 2x1 theta matrices and get back N scaler values? Thanks! -- -david David Chu
2001 Nov 12
3
'subscript out of bounds' in matrices
Dear list Having read through all the archives of the mailing lists, I've had no luck finding the answer to my problem. I am running a for(i in 1:n) loop and am creating a matrix, p, for each of the n observations. This matrix p is a 2x1 matrix. I am then doing the following: diagp<-diag(c(p[1,1],p[2,1])) to create a matrix with the elements of P on the diagonal (i.e. a 4x4 matrix). This works fine when I have n=60, however when I increase the size of the data set to n=100, I get the error message: Error in diag(c(p[1, 1], p...
2009 Jun 23
1
How to exclude insignificant intercepts using "step" function
...rn y ~ -1 + x1 +x2 (or I guess y ~ 0 + x1 + x2). If I include -1 in the model designation then no intercept is returned for grps B and C. Am I not using step properly? Or perhaps there is an alternative methodology I could use. Any help appreciated. # y = x1 + x2 for grp A # y = 2 + 2x1 + 4x2 for grp B # y = 3 + 2x1 + 4x2 + 6x1x2 for grp C ind <- matrix(runif(200), ncol=2, dimnames=list(c(), c("x1","x2"))) d1 <- data.frame(ind, y=ind[,"x1"]+ind[,"x2"]+rnorm(100,0,0.05), grp=rep("A",100)) d2 <- data.frame(ind, y=2...
2013 Jan 04
2
a question about the computation of expression
Hi all: I have a question about the computation of expression: y = 1+(2x1+2)-3*(5x1-1)+(3x2+3)-2*(x2-1) The result of y is: y = 11-13x1+x2 How can I compute the result of y via R function? Many thanks! My best. [[alternative HTML version deleted]]
2009 Aug 21
2
"Special" LS estimation problem
Hi, I have following kind of model : Y = X1 * a1 + X2 * a2 + error Here sampled data for Y, X1, X2 are like that : Y <- replicate(10, matrix(rnorm(2),2), simplify = F) X1 <- replicate(10, matrix(rnorm(4),2), simplify = F) X2 <- replicate(10, matrix(rnorm(4),2), simplify = F) My goal is to calculate LS estimates of vectors "a1" and "a2". Can anyone please guide me
2009 Jun 17
2
Re gression by groups questions
...same idea for a multivariate data set. The code below shows a multivariate dataset which I hope to fit by group. # The code below creates a data.frame comprising three marginally noisy planes. I want to perform a # regression on each based on the grp factor. # y = x1 + x2 for grp A # y = 2 + 2x1 + 4x2 for grp B # y = 2 + 2x1 + 4x2 + 6x1x2 for grp C ind <- matrix(runif(100), ncol=2, dimnames=list(c(), c("x1","x2"))) d1 <- data.frame(ind, y=ind[,"x1"]+ind[,"x2"]+rnorm(100,0,0.1), grp=rep("A", 100)) d2 <- data.frame(ind, y=2+2*ind[...
2007 Mar 15
1
expm() within the Matrix package
...time values and I seem to be experiencing difficulty when I use the function expm(). Here's an example of what I am trying to do y<-c(5,10) #vector of 2 survival times p<-Matrix(c(1,0),1,2) #1x2 matrix Q<-Matrix(c(1,2,3,4),2,2) #2x2 matrix q<-Matrix(c(1,2),2,1) #2x1 matrix Loglik<-rep(0,length(y)) #creating empty vector of same length as y for(i in 1:length(y)){ Loglik[i]<-log((p %*% (expm(Q*y[i]))) %*% q) #calculating # Loglikelihood for each y[i] } The code works p...
2012 Sep 20
0
Plot to tiff, font size problem in multiple plot figures
...'t changed the tiff() resolution or pointsize specifications, I have increased the figure size according to how many plots it will ultimately have, and I have made sure the margins are equivalent for single and multiple plot figures... example code below (font size is consistent between 1x1 and 2x1 figure but decreases for 3x2 figure): tiff("1x1.tif", width=3,height=2.5,units="in",res=600,pointsize=8,compression="lzw",restoreConsole=T) par(mfrow=c(1,1),mar=c(4,4,.5,.5)+0.1) plot(x=rnorm(10),y=rnorm(10)) dev.off() tiff("2x1.tif", height=2.5*2,width=3,u...
2006 Sep 27
2
Urgent hardware help needed
...9;s apparently hard to find the appropriate type of memory (PC3200 ECC nonbuffered) quickly. Thus, if you happen to have available some of this type of memory that you could spare with and get to me quickly, I would really, *really* appreciate it. I would really like to have either 4x512 MB or 2x1 GB in this box. The new hardware is an Athlon 64 3000+ and an Asus A8N-VM CSN motherboard, in case someone is curious. -hpa P.S. The new case (cannibalized from another server donated to me by Penguin computing for RAID-6 testing) has additional slots, so I am also looking to add a couple...
2006 Feb 14
1
figs parameter for split.screen()
Dear all, I would be pleased if anyone could help me. The Rhelp description for the figs parameter is "a two-element vector describing the number of rows and colunns in a screen matrix". So, why does my code (below) produce a 2x1 screen matrix instead of a 1x2 one? Thanks in advance, rodrigo. ----------------------------------------------------------- plot.new() split.screen(figs=c(1,2)) screen(1) plot.new() plot(v16[vd==0], vdep[vd==0], bg="aliceblue", cex= 0.5, xlab="Age",ylab="AvWei"...
2010 Mar 09
1
error in a function
...Matrix x_tilde=X_ausgew-1/t*x_t #x_tilde ist auch eine Matrix ####X_aus=matrix(X_ausgew) V1=R%*%(S%*%y_aus-x_tilde%*%beta) V11=t(V1) V2=V11%*%J_n V_tilde=V2%*%V1 sumterm=sumterm+V_tilde a=b+1 } -((n*t)/2)*log(2*pi*sigm_sq)+t*(log(det_S)+log(det_R))-1/(2*sigm_sq)*sumterm } where beta is a matrix (2x1), X is a matrix (n*tx1) and y is numeric with length nt. My error message is: X_ausgew%*%beta - non-conformable arguments Can anybody help me? THANKS -- View this message in context: http://n4.nabble.com/error-in-a-function-tp1585792p1585792.html Sent from the R help mailing list archive at Na...
2015 Mar 23
2
UID and GID mapping throw DC and Member DC
What do you mean with different winbinds? I can destroy the member server, its on testing. It is for the version of windbind? I can get this from DC. But I can not do the same with DC. "Tonight 2X1 sledgehammers." :-) XD > Date: Mon, 23 Mar 2015 18:43:21 +0000 > From: rowlandpenny at googlemail.com > To: samba at lists.samba.org > Subject: Re: [Samba] UID and GID mapping throw DC and Member DC > > On 23/03/15 18:27, Jhon P wrote: > > After tried to solve the pro...
2009 Jun 22
1
Error when using step
...d as a unique ID. Q1. The code below creates a data.frame comprising three marginally noisy surfaces. The code below fails when I use step in a function but summary seems to show the model fits are legitimate. Any ideas on what I'm doing wrong? # y = x1 + x2 for grp A # y = 2 + 2x1 + 4x2 for grp B # y = 3 + 2x1 + 4x2 + 6x1x2 for grp C ind <- matrix(runif(200), ncol=2, dimnames=list(c(), c("x1","x2"))) d1 <- data.frame(ind, y=ind[,"x1"]+ind[,"x2"]+rnorm(100,0,0.05), grp=rep("A",100)) d2 <- data.frame(ind, y=2...
2006 Nov 18
1
Questions regarding "integrate" function
...l also call up "integrate" if the number of dimension equals one. I feed in the data x1 and x2 and bandwidths h1 and h2. These codes worked well when my final goal was to take double integrals. integrand <- function(x) { # x input is evaluation point for x1 and x2, a 2x1 vector x1.eval <- x[1] x2.eval <- x[2] # n is the number of observations n <- length(x1) # x1 and x2 are the vectors read from data.dat # Compute the marginal densities f.x1 <- sum(dnorm((x1.eval-x1)/h1))/(n*h1...
2012 Apr 30
1
Hmisc::pstamp, mfcol, and spacing
I am trying to make a nice 2x1 plot and add a timestamp with comment. The pstamp function from Hmisc works nicely when mfcol=c(1,1), but when mfcol=c(2,1), the stamp winds up in the wrong place: > require('Hmisc') > opar <- par(mfcol=c(2,1)) > plot(1:10) > title(main="MAIN Title") > plot(1:20...
2011 Mar 25
0
Bounding ellipse for any set of points
...r and speed up the matrix calculations, then reverse the shift ## to the center point of the resulting ellipoid. Default TRUE ## Output: A list containing the "center form" matrix equation of the ## ellipse. i.e. a 2x2 matrix "A" and a 2x1 vector "C" representing ## the center of the ellipse such that: ## (x - C)' A (x - C) <= 1 ## Also in the list is a 2x1 vector elps.axes.lngth whose elements ## are one-half the lengths of the major and minor axe...
2011 Jul 21
0
Bounding ellipse for any set of points
...atrix calculations, then reverse > the shift > ## to the center point of the resulting ellipoid. Default TRUE > ## Output: A list containing the "center form" matrix equation of the > ## ellipse. i.e. a 2x2 matrix "A" and a 2x1 vector "C" > representing > ## the center of the ellipse such that: > ## (x - C)' A (x - C) <= 1 > ## Also in the list is a 2x1 vector elps.axes.lngth whose > elements > ## are one-half the leng...
2006 Nov 17
0
Question regarding "integrate" function
...lso call up "integrate" if the number of dimension equals one. I feed in the data x1 and x2 and bandwidths h1 and h2. These codes worked well when my final goal was to take double integrals. integrand <- function(x) { # x input is evaluation point for x1 and x2, a 2x1 vector x1.eval <- x[1] x2.eval <- x[2] # n is the number of observations n <- length(x1) # x1 and x2 are the vectors read from data.dat # Compute the marginal densities f.x1 <- sum(dnorm((x1.eval-x1)/h1)...
2006 Nov 17
0
questions regarding "integrate" function in R
...also call up "integrate" if the number of dimension equals one. I feed in the data x1 and x2 and bandwidths h1 and h2. These codes worked well when my final goal was to take double integrals. integrand <- function(x) { # x input is evaluation point for x1 and x2, a 2x1 vector x1.eval <- x[1] x2.eval <- x[2] # n is the number of observations n <- length(x1) # x1 and x2 are the vectors read from data.dat # Compute the marginal densities f.x1 <- sum(dnorm((x1.eval-x1)/h1)...
2007 Mar 13
0
multiplying matrix by vector of times
...%*% expm(Q * y[i]) %*% q) > } > > Then you can sum(loglik) like you did before. > > Cheers, > Gad Hi Gad, Thanks for the tip about the empty vector, I ever knew you could do that. I just have one problem, Lets say Q is a 2x2 matrix p is a 1x2 matrix q is a 2x1 matrix y is vector of times, say y = c(5, 10) How do I multiply Q by each time y[i]? I would like to get the answer to the equation loglik[i] <- log(p %*% expm(Q * y[i]) %*% q) Where first y=5 and then y=10 so that the answers to loglik for each i are put into the empty vector. I...