similar to: Basic Dummy Variable Creation

Displaying 20 results from an estimated 3000 matches similar to: "Basic Dummy Variable Creation"

2003 Aug 29
3
Creating a new table from a set of constraints
Hi Everyone, Here's a silly newbie question. How do I remove unwanted rows from an R table? Say that I read my data as: X <- read.table("mydata.txt") and say that there are columns for age and gender. Call these X[5] and X[10], respectively. Here, X[5] is a column of positive integers and X[10] is binary valued i.e., zero (for male) and one (for female) Now, say that I
2005 Jul 12
4
Calculation of group summaries
I know R has a steep learning curve, but from where I stand the slope looks like a sheer cliff. I'm pawing through the available docs and have come across examples which come close to what I want but are proving difficult for me to modify for my use. Calculating simple group means is fairly straight forward: data(PlantGrowth) attach(PlantGrowth) stack(mean(unstack(PlantGrowth)))
2008 Oct 22
3
coalesce columns within a data frame
Dear all, I searched the mail archives and the R site and found no guidance (tried "merge", "cbind" and terms like "coalesce" with no success). There surely is a way to coalesce (like in SQL) columns in a dataframe, right? For example, I would like to go from a dataframe with two columns to one with only one as follows: From Name.x Name.y nx1 ny1 nx2 NA
2010 Feb 09
2
Model matrix using dummy regressors or deviation regressors
The model matrix for the code at the end the email is shown below. Since the model matrix doesn't have -1, I think that it is made of dummy regressors rather than deviation regressors. I'm wondering how to make a model matrix using deviation regressors. Could somebody let me know? > model.matrix(aaov) (Intercept) A2 B2 B3 A2:B2 A2:B3 1 1 0 0 0 0 0 2
2003 Aug 27
4
Newbie graphing questions
Hi everyone. R is new to me and I'm very impressed with its capabilities but still cannot figure out how to do some basic things. There seems to be no lack of documentation but finding what I need has proven difficult. Perhaps you can help. Here's what I'm after: 1. How do I create a new plot without erasing the prior one i.e., have a new window pop up with the new graph?
2012 Feb 26
1
strucchange breakpoints (Bai and Perron, 1998, 2003)
If I try the breakpoints() function (strucchange package) with a minimum segment size = the number of regressors, there appears the following error message: "minimum segment size must be greater than the number of regressors" According to the documentation: "breakpoints implements the algorithm described in Bai & Perron (2003) for simultaneous estimation of multiple
2013 Mar 25
1
From Java to R OOP
Hi, I'm new to OOP in R so please forgive the naiveness of some of the questions. Here are a couple of them. It would be great if you can contrast to OOP in Java. 1. R's S4 appears to centered around a dispatch mechanism which in my understanding is just a way to implement polymorphism. Now, here's the snag, I thought polymorphism was an aspect of OOP not by itself the definition of
2012 Mar 08
3
Calculating length of consecutive sequences within a vector
Hi all, I have a nx1 logical array of zeros and ones and I want to calculate the individual lengths of all 1-consecutive sequences contained in it. Is there an easy quick way to do this in R? So, if I have a vector such as 111001101000011111110 I would like to get (1) 3, (2) 2, (3) 1, (4) 7 Any help would be appreciated! thanks! Jorge [[alternative HTML version deleted]]
2005 May 01
1
opimization problem
hi, i want to execute the following opimization problem: max r*w s.t.: w*z=1 # sum of w is 1 r, w are [nx1] vectors, z is a [nx1] vector consisting of 1 so far so good, works fine with lp the problem arises with the additional restriction w' * V * w where V is a [nxn] matrix how can i include this restriction since w arises twice? thanks, gg --
2006 Jul 22
1
Why the contrain does not work for selecting a particular range of data?
Dear: Continuing the issue of 'ifelse'! I selecting the data whose 'x2'=1 for maximizing likelihood. I used two way to do this but the results are different. 1.Way one I use the data for x2=1 and run the program. It works for me. Tthe program is described as below: function (parameters,y1,x11) { p<-parameters[1] alpha1<-parameters[2] beta1<-parameters[3]
2009 Jul 07
3
Error due to non-conformable arrays
Hello, Consider this function for generalized ridge regression: gre <- function (X,y,D){ n <- dim(X)[1] p <- dim(X)[2] intercept <- rep(1, n) X <- cbind(intercept, X) X2D <- crossprod(X,X)+ D Xy <- crossprod(X,y) bth <- qr.solve(X2D, Xy) } # suppose X is an (nxp) design matrix and y is an (nx1) response vector p <- dim(x)[2] D<- diag(rep(1.5,p)) bt
2003 Aug 04
1
Novice question
Hello. I am new R user, so this question is probably quite stupid, but for the life of me I cannot figure out how to get predications using multivariate linear regression analysis. Single variable predictions work fine. I am trying the following: -- Known y's for known x's1 and x's2 ys <- c(133890, 135000, 135790, 137300, 138130, 139100, 139900, 141120, 141890, 143230, 144000,
2024 Feb 28
2
converting MATLAB -> R | element-wise operation
On Tue, 27 Feb 2024 13:51:25 -0800 Jeff Newmiller via R-help <r-help at r-project.org> wrote: > The fundamental data type in Matlab is a matrix... they don't have > vectors, they have Nx1 matrices and 1xM matrices. Also known as column vectors and row vectors. :) > Vectors don't have any concept of "row" vs. "column". They do in (numerical) linear
1997 Sep 05
2
R-beta: help with R simulation
[[this bounced first, because it has 'help' in the Subject line ... -- Martin Maechler ]] I am a complete novice R programmer. (Though I know C quite well) I am trying to write some R code to do the following simulation. There is a 2-frame "movie" of noise and signal dots. the noise dots have random positions in each frame. The signal dots are placed randomly in frame 1,
2007 Sep 03
2
The quadprog package
Hi everybody, I'm using Windows XP Prof, R 2.5.1 and a Pentium 4 Processor. Now, I want to solve a quadratic optimization program (Portfolio Selection) with the quadprog package I want to minimize (\omega'%*%\Sigma%*%\omega) Subject to (1) \iota' %*% \omega = 1 (full investment) (2) R'%*%\omega = \mu (predefined expectation value) (3) \omega \ge 0 (no short sales). Where
2012 Jul 31
2
Creation of a vector of time series from a data frame
Hello, I am a new user of R. I am trying to create a vector of time series called "LTot" from a data frame. The purpose is to call LTot element from a loop to make multiple regressions over a large number of regressors. Here a piece of R code OGData <- read.table("heartatk4R.txt", header=TRUE) OGCol <- ncol(OGData) OGRow <- nrow(OGData) S1.ts=ts(OGData[,1]) #
2011 Sep 14
1
Strucchange generating breakpoints
Hi, I am new to R. I am using strucchange to get the breakpoints in time series dataset. So the problem I am facing is: I want to link the result generated by the breakpoints to further analysis (for eg. generating volatility for each group). The result is in following form: --------------------------------------- > res <- gbreakpoints(GDP.new ~ 1,data=a,h=2,breaks=6) > res
2011 Sep 20
2
Multivariate spline regression and predicted values
Hello, I am trying to estimate a multivariate regression of Y on X with regression splines. Y is (nx1), and X is (nxd), with d>1. I assume the data is generated by some unknown regression function f(X), as in Y = f(X) + u, where u is some well-behaved regression error. I want to estimate f(X) via regression splines (tensor product splines). Then, I want to get the predicted values for some new
2024 Feb 27
2
converting MATLAB -> R | element-wise operation
Why anything but sweep? The fundamental data type in Matlab is a matrix... they don't have vectors, they have Nx1 matrices and 1xM matrices. Vectors don't have any concept of "row" vs. "column". Straight division is always elementwise with recycling as needed, and matrices are really vectors in row-major order: 1 2 3 4 5 6 is really 1 4 2 5 3 6 and when you do
2012 Oct 26
3
summation sign
Hi all, I have a very quick question on how to use the summation sign in R for the function. Here?s a basic example: the function is sum(i=1 to 5)log(1-xi^2) Id be grateful if someone knows how to do this without writing it out 5 times - I am looking sth along the lines of the following: computeR <- function(x) { return (-sum(log(1-x^2)) }^ thank you vm in advance! -- View this